homatthew commented on code in PR #3586:
URL: https://github.com/apache/gobblin/pull/3586#discussion_r1001148782


##########
gobblin-yarn/src/main/java/org/apache/gobblin/yarn/YarnService.java:
##########
@@ -845,8 +877,6 @@ public void onContainersAllocated(List<Container> 
containers) {
               instanceName = null;
             }
           }
-          allocatedContainerCountMap.put(containerHelixTag,

Review Comment:
   Turns out it is thread safe to iterate over concurrent hash set. 
https://stackoverflow.com/questions/56099744/java-concurrenthashset-iterating-over-it-in-a-multi-threaded-environment
   
   And the reason for the lock / synchronized block is because if multiple 
threads are iterating over the same concurrent hashset and one of the threads 
calls remove, then since the iterator is essentially a snapshot they could each 
re-use the same helix instance.
   
   The sync block makes the removal process completely thread safe



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

Reply via email to