This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/master by this push:
new ffe4956 [#2398]in safe mode , before merge Instances should ping
instance (#2406)
ffe4956 is described below
commit ffe4956bcedd3702f8723f54992b7eb34cee1b47
Author: fanjiang-2021 <[email protected]>
AuthorDate: Tue Jun 8 11:10:11 2021 +0800
[#2398]in safe mode , before merge Instances should ping instance (#2406)
Co-authored-by: f30000430 <[email protected]>
---
.../apache/servicecomb/registry/consumer/MicroserviceVersions.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/consumer/MicroserviceVersions.java
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/consumer/MicroserviceVersions.java
index 3ea0d7b..47b9523 100644
---
a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/consumer/MicroserviceVersions.java
+++
b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/consumer/MicroserviceVersions.java
@@ -254,12 +254,15 @@ public class MicroserviceVersions {
Collection<MicroserviceInstance> inUseInstances) {
MergedInstances mergedInstances = new MergedInstances();
pulledInstances.stream().forEach(mergedInstances::addInstance);
+ MicroserviceInstancePing ping =
SPIServiceUtils.getPriorityHighestService(MicroserviceInstancePing.class);
if (safeMode) {
// in safe mode, instances will never be deleted
inUseInstances.forEach(instance -> {
if
(!mergedInstances.instanceIdMap.containsKey(instance.getInstanceId())) {
- mergedInstances.addInstance(instance);
+ if (ping.ping(instance)) {
+ mergedInstances.addInstance(instance);
+ }
}
});
return mergedInstances;
@@ -267,7 +270,7 @@ public class MicroserviceVersions {
if (pulledInstances.isEmpty() && inUseInstances != null &&
ServiceRegistryCommonConfig
.isEmptyInstanceProtectionEnabled()) {
- MicroserviceInstancePing ping =
SPIServiceUtils.getPriorityHighestService(MicroserviceInstancePing.class);
+
inUseInstances.stream().forEach(instance -> {
if
(!mergedInstances.instanceIdMap.containsKey(instance.getInstanceId())) {
if (ping.ping(instance)) {