You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ze...@apache.org on 2019/06/21 01:51:54 UTC
[servicecomb-service-center] 02/02: Change nodeName to clusterName
in storage
This is an automated email from the ASF dual-hosted git repository.
zenlin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
commit 71b9cca812c8a5ef94e3b15924d1fa589d09afc7
Author: chinx <c5...@126.com>
AuthorDate: Thu Jun 20 18:40:11 2019 +0800
Change nodeName to clusterName in storage
---
syncer/etcd/storage.go | 10 +++++-----
syncer/pkg/mock/mocksotrage/storage.go | 8 ++++----
syncer/servicecenter/servicecenter.go | 10 +++++-----
syncer/servicecenter/servicecenter_test.go | 2 +-
4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/syncer/etcd/storage.go b/syncer/etcd/storage.go
index b1e4f7f..36995a3 100644
--- a/syncer/etcd/storage.go
+++ b/syncer/etcd/storage.go
@@ -94,8 +94,8 @@ next:
}
}
-// UpdateMapByNode update map to storage by clusterName of other node
-func (s *storage) UpdateMapByNode(clusterName string, mapping pb.SyncMapping) {
+// UpdateMapByCluster update map to storage by clusterName of other cluster
+func (s *storage) UpdateMapByCluster(clusterName string, mapping pb.SyncMapping) {
newMaps := make(pb.SyncMapping, 0, len(mapping))
for _, val := range mapping {
key := mappingsKey + "/" + clusterName + "/" + val.OrgInstanceID
@@ -110,11 +110,11 @@ func (s *storage) UpdateMapByNode(clusterName string, mapping pb.SyncMapping) {
}
newMaps = append(newMaps, val)
}
- s.cleanExpired(s.GetMapByNode(clusterName), newMaps)
+ s.cleanExpired(s.GetMapByCluster(clusterName), newMaps)
}
-// GetMapByNode get map by clusterName of other node
-func (s *storage) GetMapByNode(clusterName string) (mapping pb.SyncMapping) {
+// GetMapByCluster get map by clusterName of other cluster
+func (s *storage) GetMapByCluster(clusterName string) (mapping pb.SyncMapping) {
maps := make(pb.SyncMapping, 0, 10)
s.getPrefixKey(mappingsKey+"/"+clusterName, func(key, val []byte) (next bool) {
next = true
diff --git a/syncer/pkg/mock/mocksotrage/storage.go b/syncer/pkg/mock/mocksotrage/storage.go
index 36a1685..11b7284 100644
--- a/syncer/pkg/mock/mocksotrage/storage.go
+++ b/syncer/pkg/mock/mocksotrage/storage.go
@@ -57,15 +57,15 @@ func (s *Storage) GetData() (data *pb.SyncData) {
return
}
-// UpdateMapByNode update map to storage by clusterName of other node
-func (s *Storage) UpdateMapByNode(clusterName string, mapping pb.SyncMapping) {
+// UpdateMapByCluster update map to storage by clusterName of other cluster
+func (s *Storage) UpdateMapByCluster(clusterName string, mapping pb.SyncMapping) {
s.lock.Lock()
s.maps[clusterName] = mapping
s.lock.Unlock()
}
-// GetMapByNode get map by clusterName of other node
-func (s *Storage) GetMapByNode(clusterName string) (mapping pb.SyncMapping) {
+// GetMapByCluster get map by clusterName of other cluster
+func (s *Storage) GetMapByCluster(clusterName string) (mapping pb.SyncMapping) {
s.lock.RLock()
data, ok := s.maps[clusterName]
if !ok {
diff --git a/syncer/servicecenter/servicecenter.go b/syncer/servicecenter/servicecenter.go
index b6f5446..a2da4ad 100644
--- a/syncer/servicecenter/servicecenter.go
+++ b/syncer/servicecenter/servicecenter.go
@@ -42,8 +42,8 @@ type Storage interface {
UpdateData(data *pb.SyncData)
GetMaps() (maps pb.SyncMapping)
UpdateMaps(maps pb.SyncMapping)
- GetMapByNode(clusterName string) (mapping pb.SyncMapping)
- UpdateMapByNode(clusterName string, mapping pb.SyncMapping)
+ GetMapByCluster(clusterName string) (mapping pb.SyncMapping)
+ UpdateMapByCluster(clusterName string, mapping pb.SyncMapping)
}
// NewServicecenter new store with endpoints
@@ -79,7 +79,7 @@ func (s *servicecenter) FlushData() {
// Registry registry data to the servicecenter, update mapping data
func (s *servicecenter) Registry(clusterName string, data *pb.SyncData) {
- mapping := s.storage.GetMapByNode(clusterName)
+ mapping := s.storage.GetMapByCluster(clusterName)
for _, svc := range data.Services {
log.Debugf("trying to do registration of service, serviceID = %s", svc.Service.ServiceId)
// If the svc is in the mapping, just do nothing, if not, created it in servicecenter and get the new serviceID
@@ -110,8 +110,8 @@ func (s *servicecenter) Registry(clusterName string, data *pb.SyncData) {
}
// UnRegistry instances that is not in the data which means the instance in the mapping is no longer actived
mapping = s.unRegistryInstances(data, mapping)
- // Update mapping data of the node to the storage of the servicecenter
- s.storage.UpdateMapByNode(clusterName, mapping)
+ // Update mapping data of the cluster to the storage of the servicecenter
+ s.storage.UpdateMapByCluster(clusterName, mapping)
}
// Discovery discovery data from storage
diff --git a/syncer/servicecenter/servicecenter_test.go b/syncer/servicecenter/servicecenter_test.go
index 7036b9d..d12d874 100644
--- a/syncer/servicecenter/servicecenter_test.go
+++ b/syncer/servicecenter/servicecenter_test.go
@@ -79,7 +79,7 @@ func TestOnEvent(t *testing.T) {
return
}
- clusterName := "test_node"
+ clusterName := "test_cluster"
dc.Registry(clusterName, data)
mockplugin.SetGetAll(mockplugin.NewGetAll)