liubao68 commented on a change in pull request #2691:
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/2691#discussion_r790091526



##########
File path: 
clients/config-center-client/src/main/java/org/apache/servicecomb/config/center/client/AddressManager.java
##########
@@ -47,16 +54,29 @@ private String formatAddress(String address) {
   }
 
   public String address() {
-    synchronized (this) {
-      this.index++;
-      if (this.index >= addresses.size()) {
-        this.index = 0;
-      }
-      return addresses.get(index);
-    }
+    return endpointAddress.getAvailableZoneAddress();
   }
 
   public boolean sslEnabled() {
-    return address().startsWith("https://";);
+    isSSLEnable = address().startsWith("https://";);
+    return isSSLEnable;
+  }
+
+  public EndpointAddress getEndpointAddress() {
+    return endpointAddress;
+  }
+
+  public void setEndpointAddress(EndpointAddress endpointAddress) {
+    this.endpointAddress = endpointAddress;
+  }
+
+  @Subscribe
+  public void onRefreshEndpointEvent(RefreshEndpointEvent event) {
+    if (null == event || event.getName() != "CseConfigCenter") {
+      return;
+    }
+    endpointAddress.setAvailableZone(event.getSameZone());
+    endpointAddress.setAvailableRegion(event.getSameRegion());
+    endpointAddress.refreshCache();

Review comment:
       Encapsulation. Maybe calcute address groups can encapsulte in 
AddressManager. Events only send the server list. e.g. List<AddressInfo> where 
AddresInfo has address, zone, az information. 




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


Reply via email to