liubao68 commented on a change in pull request #704: [SCB-582]Provide a way to 
protect instance removal
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/704#discussion_r189175400
 
 

 ##########
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/consumer/MicroserviceVersions.java
 ##########
 @@ -169,6 +166,28 @@ private void setInstances(List<MicroserviceInstance> 
pulledInstances, String rev
     }
   }
 
+  private List<MicroserviceInstance> mergeInstances(List<MicroserviceInstance> 
pulledInstances,
+      List<MicroserviceInstance> inUseInstances) {
+    List<MicroserviceInstance> upInstances = pulledInstances
+        .stream()
+        .filter(instance -> {
+          return MicroserviceInstanceStatus.UP.equals(instance.getStatus());
+        })
+        .collect(Collectors.toList());
+    if (upInstances.isEmpty() && inUseInstances != null && 
ServiceRegistryConfig.INSTANCE.isEmptyInstanceProtectionEnabled()) {
+      MicroserviceInstancePing ping = 
SPIServiceUtils.getPriorityHighestService(MicroserviceInstancePing.class);
+      inUseInstances.stream()
+          .forEach(instance -> {
+            if (!upInstances.contains(instance)) {
+              if (ping.ping(instance)) {
 
 Review comment:
   This scenario is rarely as I explained above, mostly because of service 
center bugs. And this health check run a separate background thread, will not 
influence normal performance.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to