qqu0127 commented on code in PR #2447:
URL: https://github.com/apache/helix/pull/2447#discussion_r1173872450
##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/util/DelayedRebalanceUtil.java:
##########
@@ -335,6 +335,42 @@ public static Set<AssignableReplica>
findToBeAssignedReplicasForMinActiveReplica
return toBeAssignedReplicas;
}
+ /**
+ * Merge entries from currentResourceAssignment to newAssignment.
+ * To handle minActiveReplica for delayed rebalance, new assignment is
computed based on enabled live instances, but
+ * could miss out current partition allocation still on offline instances
(within delayed window).
+ * The merge process is independent for each resource; for each
resource-partition, it adds the <instance, state> pair
+ * to newAssignment if it's not there yet; in other word, the entries in
newAssignment won't be override.
+ * @param newAssignment newAssignment to merge, this map is getting updated
during this method.
+ * @param currentResourceAssignment the current resource assignment
+ * @param enabledLiveInstances the set of enabled live instance
+ */
+ public static void mergeAssignments(Map<String, ResourceAssignment>
newAssignment,
+ Map<String, ResourceAssignment> currentResourceAssignment,
+ Set<String> enabledLiveInstances) {
+ // merge with current assignment for partitions assigned on rest of the
instances (not immediately live)
+ currentResourceAssignment.entrySet().parallelStream().forEach(entry -> {
+ String resourceName = entry.getKey();
+ ResourceAssignment currentAssignment = entry.getValue();
+ for (Partition partition : currentAssignment.getMappedPartitions()) {
+ currentAssignment.getReplicaMap(partition).entrySet().stream() //
<instance, state>
+ // the existing partitions on the enabledLiveInstances are
pre-allocated, only process for the rest
+ .filter(e -> !enabledLiveInstances.contains(e.getKey()) ||
+ !newAssignment.containsKey(resourceName) ||
+
!newAssignment.get(resourceName).getReplicaMap(partition).containsKey(e.getKey()))
Review Comment:
I see your point. I thought about similar approach too, unfortunately the
current logic in ClusterModel requires we pre-allocate existing partitions,
otherwise the new assignment calculations won't honor the constraints. And the
current logic is to pass on existing assignment.
--
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]