You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/08/09 14:25:30 UTC

[GitHub] wujimin commented on a change in pull request #857: [SCB-802]in rollback scenario, old versions meta is used and invocation is fail

wujimin commented on a change in pull request #857: [SCB-802]in rollback scenario, old versions meta is used and invocation is fail
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/857#discussion_r208949639
 
 

 ##########
 File path: service-registry/src/main/java/org/apache/servicecomb/serviceregistry/consumer/MicroserviceVersions.java
 ##########
 @@ -191,9 +193,30 @@ private void setInstances(List<MicroserviceInstance> pulledInstances, String rev
         microserviceVersionRule.setInstances(instances);
       }
       revision = rev;
+      // Clean up down versions in case of rollback and other interface not compatible scenarios. Users should ensure running versions are compatible.
+      pack();
     }
   }
 
+  private void pack() {
+    Set<String> microservices = new HashSet<>(instances.size());
+    instances.forEach(item -> {
+      microservices.add(item.getServiceId());
+    });
+    Set<String> downSet = new HashSet<>(instances.size());
+    versions.keySet().forEach(item -> {
+      if (!microservices.contains(item)) {
+        downSet.add(item);
+      }
+    });
+    downSet.forEach(item -> {
+      MicroserviceVersion version = versions.remove(item);
+      for (MicroserviceVersionRule microserviceVersionRule : versionRules.values()) {
+        microserviceVersionRule.deleteMicroserviceVersion(version);
 
 Review comment:
   maybe we just need to update latestVersion?

----------------------------------------------------------------
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