smengcl commented on code in PR #6285:
URL: https://github.com/apache/ozone/pull/6285#discussion_r1508120661


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/pipeline/Pipeline.java:
##########
@@ -72,14 +72,63 @@ public static Codec<Pipeline> getCodec() {
   }
 
   private static final Logger LOG = LoggerFactory.getLogger(Pipeline.class);
+
+  /**
+   * Inner class that provides thread-safe access to DN list.
+   */
+  static class NodesInOrder {
+    private final List<DatanodeDetails> nodes = new ArrayList<>();
+
+    synchronized DatanodeDetails getClosest(PipelineID id, 
Set<DatanodeDetails> excluded) throws IOException {
+      if (nodes.isEmpty()) {
+        LOG.debug("Nodes in order is empty, delegate to getFirstNode");

Review Comment:
   I've added the logging in `getClosestNode`.
   
   But I kept the `isEmpty()` check inside `getClosest` as well to facilitate 
debugging (because there is still a none-zero chance of `nodes` becoming empty 
between the locks, TOCTOU).



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

Reply via email to