[HELIX-765] TASK: Build quota profile from scratch every rebalance

It has been reported that instances have a full quota despite no tasks existing 
in their CURRENTSTATES. The cause of this is not clear, so making 
ClusterDataCache trigger a refresh of all AssignableInstances will ensure that 
there aren't situations where it looks like there has been a thread leak. 
Optimizations will be implemented if necessary.
Changelist:
1. Make AssignableInstanceManager build all AssignableInstances from scratch 
every rebalance


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/930a4b7a
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/930a4b7a
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/930a4b7a

Branch: refs/heads/master
Commit: 930a4b7ae7eb63be0a751a593ba630ae55fb2cfb
Parents: d33d9ef
Author: Hunter Lee <[email protected]>
Authored: Fri Oct 26 19:06:42 2018 -0700
Committer: Hunter Lee <[email protected]>
Committed: Fri Oct 26 19:06:42 2018 -0700

----------------------------------------------------------------------
 .../controller/stages/ClusterDataCache.java     | 29 ++++++++++++--------
 1 file changed, 17 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/930a4b7a/helix-core/src/main/java/org/apache/helix/controller/stages/ClusterDataCache.java
----------------------------------------------------------------------
diff --git 
a/helix-core/src/main/java/org/apache/helix/controller/stages/ClusterDataCache.java
 
b/helix-core/src/main/java/org/apache/helix/controller/stages/ClusterDataCache.java
index 67b59a8..93aea4f 100644
--- 
a/helix-core/src/main/java/org/apache/helix/controller/stages/ClusterDataCache.java
+++ 
b/helix-core/src/main/java/org/apache/helix/controller/stages/ClusterDataCache.java
@@ -209,7 +209,6 @@ public class ClusterDataCache extends AbstractDataCache {
     }
 
     _liveInstanceMap = new HashMap<>(_liveInstanceCacheMap);
-    _liveInstanceMap = new HashMap<>(_liveInstanceCacheMap);
     _instanceConfigMap = new ConcurrentHashMap<>(_instanceConfigCacheMap);
     _resourceConfigMap = new HashMap<>(_resourceConfigCacheMap);
 
@@ -230,17 +229,23 @@ public class ClusterDataCache extends AbstractDataCache {
       // Refresh AssignableInstanceManager
       AssignableInstanceManager assignableInstanceManager =
           _taskDataCache.getAssignableInstanceManager();
-      if (_existsClusterConfigChange) {
-        // Update both flags since buildAssignableInstances includes 
updateAssignableInstances
-        _existsClusterConfigChange = false;
-        _existsInstanceChange = false;
-        assignableInstanceManager.buildAssignableInstances(_clusterConfig, 
_taskDataCache,
-            _liveInstanceMap, _instanceConfigMap);
-      } else if (_existsInstanceChange) {
-        _existsInstanceChange = false;
-        assignableInstanceManager.updateAssignableInstances(_clusterConfig, 
_liveInstanceMap,
-            _instanceConfigMap);
-      }
+      // Build from scratch every time
+      assignableInstanceManager.buildAssignableInstances(_clusterConfig, 
_taskDataCache,
+          _liveInstanceMap, _instanceConfigMap);
+      /**
+       * TODO: Consider this for optimization after sufficient testing
+       * if (_existsClusterConfigChange) {
+       * // Update both flags since buildAssignableInstances includes 
updateAssignableInstances
+       * _existsClusterConfigChange = false;
+       * _existsInstanceChange = false;
+       * assignableInstanceManager.buildAssignableInstances(_clusterConfig, 
_taskDataCache,
+       * _liveInstanceMap, _instanceConfigMap);
+       * } else if (_existsInstanceChange) {
+       * _existsInstanceChange = false;
+       * assignableInstanceManager.updateAssignableInstances(_clusterConfig, 
_liveInstanceMap,
+       * _instanceConfigMap);
+       * }
+       **/
     }
 
     _instanceMessagesCache.refresh(accessor, _liveInstanceMap);

Reply via email to