Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cluster id from etcd key #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions pkg/etcd/etcdkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ type CDCKey struct {

// BaseKey is the common prefix of the keys with cluster id in CDC
func BaseKey(clusterID string) string {
return fmt.Sprintf("/tidb/cdc/%s", clusterID)
return "/tidb/cdc"
}

// NamespacedPrefix returns the etcd prefix of changefeed data
func NamespacedPrefix(clusterID, namespace string) string {
return BaseKey(clusterID) + "/" + namespace
return "/tidb/cdc"
}

// Parse parses the given etcd key
Expand All @@ -115,9 +115,9 @@ func (k *CDCKey) Parse(clusterID, key string) error {
return cerror.ErrInvalidEtcdKey.GenWithStackByArgs(key)
}
key = key[len("/tidb/cdc"):]
parts := strings.Split(key, "/")
k.ClusterID = parts[1]
key = key[len(k.ClusterID)+1:]
//parts := strings.Split(key, "/")
k.ClusterID = "defauult"
//key = key[len(k.ClusterID)+1:]
if strings.HasPrefix(key, metaPrefix) {
key = key[len(metaPrefix):]
switch {
Expand All @@ -139,15 +139,15 @@ func (k *CDCKey) Parse(clusterID, key string) error {
return cerror.ErrInvalidEtcdKey.GenWithStackByArgs(key)
}
} else {
namespace := parts[2]
key = key[len(namespace)+1:]
k.Namespace = namespace
//namespace := parts[2]
//key = key[len(namespace)+1:]
k.Namespace = "default"
switch {
case strings.HasPrefix(key, ChangefeedInfoKey):
k.Tp = CDCKeyTypeChangefeedInfo
k.CaptureID = ""
k.ChangefeedID = model.ChangeFeedID{
Namespace: namespace,
Namespace: "default",
ID: key[len(ChangefeedInfoKey)+1:],
}
k.OwnerLeaseID = ""
Expand All @@ -163,7 +163,7 @@ func (k *CDCKey) Parse(clusterID, key string) error {
k.Tp = CDCKeyTypeChangeFeedStatus
k.CaptureID = ""
k.ChangefeedID = model.ChangeFeedID{
Namespace: namespace,
Namespace: "default",
ID: key[len(ChangefeedStatusKey)+1:],
}
k.OwnerLeaseID = ""
Expand All @@ -175,7 +175,7 @@ func (k *CDCKey) Parse(clusterID, key string) error {
k.Tp = CDCKeyTypeTaskPosition
k.CaptureID = splitKey[0]
k.ChangefeedID = model.ChangeFeedID{
Namespace: namespace,
Namespace: "default",
ID: splitKey[1],
}
k.OwnerLeaseID = ""
Expand Down