jiajunwang commented on a change in pull request #941: Fix unexpceted partition
movements in the CrushEd strategy.
URL: https://github.com/apache/helix/pull/941#discussion_r407647004
##########
File path:
helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java
##########
@@ -294,4 +312,33 @@ public void clearMonitoringRecords() {
_missingTopStateMap.clear();
_lastTopStateLocationMap.clear();
}
+
+ /**
+ * Return the cached stable partition list of the specified resource. If no
such cached item,
+ * return empty list.
+ * This is for a backward compatible workaround to fix
https://github.com/apache/helix/issues/940.
+ *
+ * @param resourceName
+ */
+ public List<String> getStablePartitionList(String resourceName) {
+ return _stablePartitionListCache.getOrDefault(resourceName,
Collections.EMPTY_LIST);
+ }
+
+ /**
+ * Refresh the stable partition list cache items and remove the non-exist
resources' cache.
+ * This is for a backward compatible workaround to fix
https://github.com/apache/helix/issues/940.
+ *
+ * @param idealStateMap
+ */
+ final void refreshStablePartitionList(Map<String, IdealState> idealStateMap)
{
+ _stablePartitionListCache.keySet().retainAll(idealStateMap.keySet());
+ for (String resourceName : idealStateMap.keySet()) {
+ Set<String> newPartitionSet =
idealStateMap.get(resourceName).getPartitionSet();
+ List<String> cachedPartitionList = getStablePartitionList(resourceName);
+ if (cachedPartitionList.size() != newPartitionSet.size() ||
!newPartitionSet
+ .containsAll(cachedPartitionList)) {
Review comment:
Why it is O(N^2)? The containsAll of the set is looping on the input list
and then call contains() to check. So it should be O(N). Note that we are
copying the input set to a list anyway. So this won't change the latency
dramatically. The O() calculation has the same result.
But I agree that this might still cause an additional delay. Since this is
related to the later 2 comments, let's keep in the same threads. I will resolve
this one.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]