You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/01/05 08:23:13 UTC

[GitHub] little-cui closed pull request #243: SCB-181 Unused instance index key is stored in backend.

little-cui closed pull request #243: SCB-181 Unused instance index key is stored in backend.
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/243
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/server/core/key_generator.go b/server/core/key_generator.go
index 73775e89..41613435 100644
--- a/server/core/key_generator.go
+++ b/server/core/key_generator.go
@@ -115,15 +115,6 @@ func GetServiceSchemaRootKey(domainProject string) string {
 	}, "/")
 }
 
-func GetInstanceIndexRootKey(domainProject string) string {
-	return util.StringJoin([]string{
-		GetRootKey(),
-		REGISTRY_INSTANCE_KEY,
-		REGISTRY_INDEX,
-		domainProject,
-	}, "/")
-}
-
 func GetInstanceRootKey(domainProject string) string {
 	return util.StringJoin([]string{
 		GetRootKey(),
@@ -234,13 +225,6 @@ func GetServiceSchemaSummaryRootKey(domainProject string) string {
 	}, "/")
 }
 
-func GenerateInstanceIndexKey(domainProject string, instanceId string) string {
-	return util.StringJoin([]string{
-		GetInstanceIndexRootKey(domainProject),
-		instanceId,
-	}, "/")
-}
-
 func GenerateInstanceKey(domainProject string, serviceId string, instanceId string) string {
 	return util.StringJoin([]string{
 		GetInstanceRootKey(domainProject),
diff --git a/server/service/instances.go b/server/service/instances.go
index 6a526258..8fdbd6a2 100644
--- a/server/service/instances.go
+++ b/server/service/instances.go
@@ -183,7 +183,6 @@ func (s *InstanceService) Register(ctx context.Context, in *pb.RegisterInstanceR
 		}, err
 	}
 
-	index := apt.GenerateInstanceIndexKey(domainProject, instanceId)
 	key := apt.GenerateInstanceKey(domainProject, instance.ServiceId, instanceId)
 	hbKey := apt.GenerateInstanceLeaseKey(domainProject, instance.ServiceId, instanceId)
 
@@ -192,8 +191,6 @@ func (s *InstanceService) Register(ctx context.Context, in *pb.RegisterInstanceR
 	opts := []registry.PluginOp{
 		registry.OpPut(registry.WithStrKey(key), registry.WithValue(data),
 			registry.WithLease(leaseID), registry.WithIgnoreLease()),
-		registry.OpPut(registry.WithStrKey(index), registry.WithStrValue(instance.ServiceId),
-			registry.WithLease(leaseID), registry.WithIgnoreLease()),
 	}
 	if leaseID != 0 {
 		opts = append(opts,
diff --git a/server/service/util/microservice_util.go b/server/service/util/microservice_util.go
index 8cb7816c..433458ce 100644
--- a/server/service/util/microservice_util.go
+++ b/server/service/util/microservice_util.go
@@ -268,7 +268,7 @@ func GetOneDomainProjectServiceCount(ctx context.Context, domainProject string)
 }
 
 func GetOneDomainProjectInstanceCount(ctx context.Context, domainProject string) (int64, error) {
-	key := apt.GenerateInstanceIndexKey(domainProject, "")
+	key := apt.GetInstanceRootKey(domainProject) + "/"
 	opts := append(FromContext(ctx),
 		registry.WithStrKey(key),
 		registry.WithCountOnly(),


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services