pkuwm commented on a change in pull request #542: Use a copy of the new best 
possible assignment for measuring baseline divergence
URL: https://github.com/apache/helix/pull/542#discussion_r340125828
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedRebalancer.java
 ##########
 @@ -401,11 +401,17 @@ private void 
refreshBaseline(ResourceControllerDataProvider clusterData,
 
     // Asynchronously report baseline divergence metric before persisting to 
metadata store,
     // just in case if persisting fails, we still have the metric.
+    // To avoid changes of the new assignment and make it safe when being used 
to measure baseline
+    // divergence, use a deep copy of the new assignment.
+    Map<String, ResourceAssignment> newAssignmentCopy = new HashMap<>();
+    for (Map.Entry<String, ResourceAssignment> entry : 
newAssignment.entrySet()) {
+      newAssignmentCopy.put(entry.getKey(), new 
ResourceAssignment(entry.getValue().getRecord()));
 
 Review comment:
   ZNRecord has mapFields which is a nested map: Map<String, Map<String, 
String>>. Caling putAll doesn't do deep copy. Still have to do deep copy 
manually.
   If we can do deep copy for #549, we can keep this code. 

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

Reply via email to