You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by xy...@apache.org on 2019/06/05 16:10:08 UTC

[hadoop] branch trunk updated: HDDS-1637. Fix random test failure TestSCMContainerPlacementRackAware. Contributed by Sammi Chen. (#904)

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

xyao pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 0b1e288  HDDS-1637. Fix random test failure TestSCMContainerPlacementRackAware. Contributed by Sammi Chen. (#904)
0b1e288 is described below

commit 0b1e288deb2c330521b9bb1d1803481afe49168b
Author: ChenSammi <sa...@apache.org>
AuthorDate: Thu Jun 6 00:09:36 2019 +0800

    HDDS-1637. Fix random test failure TestSCMContainerPlacementRackAware. Contributed by Sammi Chen. (#904)
---
 .../algorithms/SCMContainerPlacementRackAware.java          | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/algorithms/SCMContainerPlacementRackAware.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/algorithms/SCMContainerPlacementRackAware.java
index ffebb84..e126f27 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/algorithms/SCMContainerPlacementRackAware.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/algorithms/SCMContainerPlacementRackAware.java
@@ -237,6 +237,7 @@ public final class SCMContainerPlacementRackAware extends SCMCommonPolicy {
       long sizeRequired) throws SCMException {
     int ancestorGen = RACK_LEVEL;
     int maxRetry = MAX_RETRY;
+    List<Node> excludedNodesForCapacity = null;
     while(true) {
       Node node = networkTopology.chooseRandom(NetConstants.ROOT, null,
           excludedNodes, affinityNode, ancestorGen);
@@ -265,6 +266,9 @@ public final class SCMContainerPlacementRackAware extends SCMCommonPolicy {
       if (hasEnoughSpace((DatanodeDetails)node, sizeRequired)) {
         LOG.debug("Datanode {} is chosen. Required size is {}",
             node.toString(), sizeRequired);
+        if (excludedNodes != null && excludedNodesForCapacity != null) {
+          excludedNodes.removeAll(excludedNodesForCapacity);
+        }
         return node;
       } else {
         maxRetry--;
@@ -275,6 +279,15 @@ public final class SCMContainerPlacementRackAware extends SCMCommonPolicy {
           LOG.info(errMsg);
           throw new SCMException(errMsg, null);
         }
+        if (excludedNodesForCapacity == null) {
+          excludedNodesForCapacity = new ArrayList<>();
+        }
+        excludedNodesForCapacity.add(node);
+        if (excludedNodes == null) {
+          excludedNodes = excludedNodesForCapacity;
+        } else {
+          excludedNodes.add(node);
+        }
       }
     }
   }


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