caimo commented on code in PR #5019:
URL:
https://github.com/apache/servicecomb-java-chassis/pull/5019#discussion_r2546649721
##########
service-registry/registry-service-center/src/main/java/org/apache/servicecomb/registry/sc/SCAddressManager.java:
##########
@@ -79,19 +76,30 @@ public void onHeartBeatEvent(HeartBeatEvent event) {
}
private void initEndPort(String key) {
- List<MicroserviceInstance> instances = findServiceInstance("default",
- key, "0+");
- if ("SERVICECENTER".equals(key) && !instances.isEmpty()) {
- initialized = true;
- }
- Map<String, List<String>> zoneAndRegion =
generateZoneAndRegionAddress(instances);
+ List<MicroserviceInstance> instances = findServiceInstance("default", key,
"0+");
+ HashSet<String> currentEngineEndpoints = new HashSet<>();
+ Map<String, List<String>> zoneAndRegion =
generateZoneAndRegionAddress(instances, currentEngineEndpoints);
if (zoneAndRegion == null) {
return;
}
- EventManager.post(new RefreshEndpointEvent(zoneAndRegion, key));
+ if (isEngineEndpointsChanged(lastEngineEndpointsCache.get(key),
currentEngineEndpoints)) {
+ LOGGER.info("auto discovery service [{}] addresses: [{}]", key,
zoneAndRegion);
+ lastEngineEndpointsCache.put(key, currentEngineEndpoints);
+ EventManager.post(new RefreshEndpointEvent(zoneAndRegion, key));
+ }
+ }
+
+ private boolean isEngineEndpointsChanged(Set<String> lastEngineEndpoints,
Set<String> currentEngineEndpoints) {
+ if (lastEngineEndpoints == null || lastEngineEndpoints.isEmpty()) {
Review Comment:
currentEngineEndpoints will null?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]