You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ne...@apache.org on 2021/11/12 04:27:06 UTC

[ozone] branch master updated: HDDS-5820. Intermittent failure in TestPipelinePlacementPolicy#testPickLowestLoadAnchor (#2757)

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

neoyang 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 9384bd7  HDDS-5820. Intermittent failure in TestPipelinePlacementPolicy#testPickLowestLoadAnchor (#2757)
9384bd7 is described below

commit 9384bd737d8123a585afc71a64d207311f04b2b6
Author: Ke-Yi Sung <72...@users.noreply.github.com>
AuthorDate: Fri Nov 12 12:26:54 2021 +0800

    HDDS-5820. Intermittent failure in TestPipelinePlacementPolicy#testPickLowestLoadAnchor (#2757)
---
 .../hdds/scm/pipeline/PipelinePlacementPolicy.java | 24 +++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelinePlacementPolicy.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelinePlacementPolicy.java
index 5782fbe..9f1edd6 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelinePlacementPolicy.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelinePlacementPolicy.java
@@ -287,7 +287,7 @@ public final class PipelinePlacementPolicy extends SCMCommonPlacementPolicy {
     // base on distance in topology, rack awareness and load balancing.
     List<DatanodeDetails> exclude = new ArrayList<>();
     // First choose an anchor node.
-    DatanodeDetails anchor = chooseNode(healthyNodes);
+    DatanodeDetails anchor = chooseFirstNode(healthyNodes);
     if (anchor != null) {
       results.add(anchor);
       removePeers(anchor, healthyNodes);
@@ -367,6 +367,7 @@ public final class PipelinePlacementPolicy extends SCMCommonPlacementPolicy {
   /**
    * Find a node from the healthy list and return it after removing it from the
    * list that we are operating on.
+   * Return random node in the list.
    *
    * @param healthyNodes - Set of healthy nodes we can choose from.
    * @return chosen datanodeDetails
@@ -386,6 +387,27 @@ public final class PipelinePlacementPolicy extends SCMCommonPlacementPolicy {
   }
 
   /**
+   * Find a node from the healthy list and return it after removing it from the
+   * list that we are operating on.
+   * Return the first node in the list.
+   *
+   * @param healthyNodes - Set of healthy nodes we can choose from.
+   * @return chosen datanodeDetails
+   */
+  private DatanodeDetails chooseFirstNode(
+      final List<DatanodeDetails> healthyNodes) {
+    if (healthyNodes == null || healthyNodes.isEmpty()) {
+      return null;
+    }
+    DatanodeDetails selectedNode = healthyNodes.get(0);
+    healthyNodes.remove(selectedNode);
+    if (selectedNode != null) {
+      removePeers(selectedNode, healthyNodes);
+    }
+    return selectedNode;
+  }
+
+  /**
    * Choose node on different racks as anchor is on based on rack awareness.
    * If a node on different racks cannot be found, then return a random node.
    * @param healthyNodes healthy nodes

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org