qqu0127 commented on code in PR #2199:
URL: https://github.com/apache/helix/pull/2199#discussion_r951805612


##########
helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java:
##########
@@ -217,6 +218,23 @@ public void requireFullRefresh() {
     }
   }
 
+  /**
+   * Update cache and return true if any local data is changed compared to 
before refresh.
+   * @param dataAccessor the data accessor used to fetch data.
+   * @return true if there is a change to local cache.
+   */
+  public boolean updateCache(HelixDataAccessor dataAccessor) {
+    Map<String, LiveInstance> liveInstance = new HashMap<>(getLiveInstances());
+    Map<String, ExternalView> externalView = new HashMap<>(getExternalViews());
+    Map<String, InstanceConfig> instanceConfig = new 
HashMap<>(getInstanceConfigMap());
+    requireFullRefresh();
+    refresh(dataAccessor);
+
+    return !(liveInstance.equals(getLiveInstances())

Review Comment:
   refresh() happen and update the cache data in the middle of two 
`getLiveInstances()`, the data may be changed.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to