This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new e1d123149e HDDS-9848. Pipeline.nodesInOrder should not be ThreadLocal 
(#5944)
e1d123149e is described below

commit e1d123149ecd7d6817f09a43707570513a71fbda
Author: Sumit Agrawal <[email protected]>
AuthorDate: Tue Jan 9 22:54:00 2024 +0530

    HDDS-9848. Pipeline.nodesInOrder should not be ThreadLocal (#5944)
---
 .../apache/hadoop/hdds/scm/pipeline/Pipeline.java  | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/pipeline/Pipeline.java
 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/pipeline/Pipeline.java
index 2a117de35b..9d95cee483 100644
--- 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/pipeline/Pipeline.java
+++ 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/pipeline/Pipeline.java
@@ -79,7 +79,7 @@ public final class Pipeline {
   private Map<DatanodeDetails, Long> nodeStatus;
   private Map<DatanodeDetails, Integer> replicaIndexes;
   // nodes with ordered distance to client
-  private ThreadLocal<List<DatanodeDetails>> nodesInOrder = new 
ThreadLocal<>();
+  private List<DatanodeDetails> nodesInOrder = new ArrayList<>();
   // Current reported Leader for the pipeline
   private UUID leaderId;
   // Timestamp for pipeline upon creation
@@ -287,11 +287,11 @@ public final class Pipeline {
     if (excluded == null) {
       excluded = Collections.emptySet();
     }
-    if (nodesInOrder.get() == null || nodesInOrder.get().isEmpty()) {
+    if (nodesInOrder.isEmpty()) {
       LOG.debug("Nodes in order is empty, delegate to getFirstNode");
       return getFirstNode(excluded);
     }
-    for (DatanodeDetails d : nodesInOrder.get()) {
+    for (DatanodeDetails d : nodesInOrder) {
       if (!excluded.contains(d)) {
         return d;
       }
@@ -316,15 +316,19 @@ public final class Pipeline {
   }
 
   public void setNodesInOrder(List<DatanodeDetails> nodes) {
-    nodesInOrder.set(nodes);
+    nodesInOrder.clear();
+    if (null == nodes) {
+      return;
+    }
+    nodesInOrder.addAll(nodes);
   }
 
   public List<DatanodeDetails> getNodesInOrder() {
-    if (nodesInOrder.get() == null || nodesInOrder.get().isEmpty()) {
+    if (nodesInOrder.isEmpty()) {
       LOG.debug("Nodes in order is empty, delegate to getNodes");
       return getNodes();
     }
-    return nodesInOrder.get();
+    return nodesInOrder;
   }
 
   void reportDatanode(DatanodeDetails dn) throws IOException {
@@ -402,8 +406,8 @@ public final class Pipeline {
 
     // To save the message size on wire, only transfer the node order based on
     // network topology
-    List<DatanodeDetails> nodes = nodesInOrder.get();
-    if (nodes != null && !nodes.isEmpty()) {
+    List<DatanodeDetails> nodes = nodesInOrder;
+    if (!nodes.isEmpty()) {
       for (int i = 0; i < nodes.size(); i++) {
         Iterator<DatanodeDetails> it = nodeStatus.keySet().iterator();
         for (int j = 0; j < nodeStatus.keySet().size(); j++) {
@@ -551,7 +555,7 @@ public final class Pipeline {
       this.replicationConfig = pipeline.replicationConfig;
       this.state = pipeline.state;
       this.nodeStatus = pipeline.nodeStatus;
-      this.nodesInOrder = pipeline.nodesInOrder.get();
+      this.nodesInOrder = pipeline.nodesInOrder;
       this.leaderId = pipeline.getLeaderId();
       this.creationTimestamp = pipeline.getCreationTimestamp();
       this.suggestedLeaderId = pipeline.getSuggestedLeaderId();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to