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


##########
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:
   i don't get this. you assigned liveInstace = getLiveInstances() on line: 
227. and on line: 233 - you are again checking - which is just few cpu cycles 
after the first call
   
   



##########
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();

Review Comment:
   requireFullRefresh - shouldn't it be boolean, indicating if you need 
full-refresh?



##########
helix-view-aggregator/src/main/java/org/apache/helix/view/aggregator/HelixViewAggregator.java:
##########
@@ -191,14 +191,19 @@ private void handleSourceClusterEvent(ClusterViewEvent 
event) {
         _refreshViewCluster.set(true);
         break;
       case PeriodicViewRefresh:
-        if (!_refreshViewCluster.get()) {
+        // refresh local view cluster data cache

Review Comment:
   is there a way to throttle view-cluster refresh?
   
   I am sure that when you aggregate across multiple clusters, things can be 
very dynamic. 
   
   is there a way to mark that cache is dirty and only periodically refresh the 
cache for clusters which are dirty?
   
   



##########
helix-view-aggregator/src/main/java/org/apache/helix/view/aggregator/HelixViewAggregator.java:
##########
@@ -75,7 +75,7 @@ public HelixViewAggregator(String viewClusterName, String 
zkAddr) {
     _viewClusterManager = HelixManagerFactory
         .getZKHelixManager(_viewClusterName, 
generateHelixManagerInstanceName(_viewClusterName),
             InstanceType.SPECTATOR, zkAddr);
-    _refreshViewCluster = new AtomicBoolean(false);
+    _refreshViewCluster = new AtomicBoolean(true);

Review Comment:
   why change default from 'false' to 'true'



##########
helix-view-aggregator/src/main/java/org/apache/helix/view/aggregator/HelixViewAggregator.java:
##########
@@ -191,14 +191,19 @@ private void handleSourceClusterEvent(ClusterViewEvent 
event) {
         _refreshViewCluster.set(true);
         break;
       case PeriodicViewRefresh:
-        if (!_refreshViewCluster.get()) {
+        // refresh local view cluster data cache
+        boolean cacheChanged = 
_viewClusterRefresher.refreshViewClusterDataCache();
+        if (cacheChanged) {
+          logger.info("Detected change in view cluster data, trigger a 
refresh");
+        } else if (!_refreshViewCluster.get()) {

Review Comment:
   is refreshViewCluster ever getting set to FALSE ?? 



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