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 ta...@apache.org on 2020/05/23 08:32:40 UTC

[hadoop] branch branch-3.2 updated: HDFS-15363. BlockPlacementPolicyWithNodeGroup should validate if it is initialized by NetworkTopologyWithNodeGroup. Contributed by hemanthboyina.

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

tasanuma pushed a commit to branch branch-3.2
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.2 by this push:
     new d6de530  HDFS-15363. BlockPlacementPolicyWithNodeGroup should validate if it is initialized by NetworkTopologyWithNodeGroup. Contributed by hemanthboyina.
d6de530 is described below

commit d6de530bbbf9720b05e4a91202fd2ccbf176d438
Author: Takanobu Asanuma <ta...@apache.org>
AuthorDate: Sat May 23 17:28:38 2020 +0900

    HDFS-15363. BlockPlacementPolicyWithNodeGroup should validate if it is initialized by NetworkTopologyWithNodeGroup. Contributed by hemanthboyina.
    
    (cherry picked from commit 4d22d1c58f0eb093775f0fe4f39ef4be639ad752)
---
 .../BlockPlacementPolicyWithNodeGroup.java         |  5 ++++
 .../server/balancer/TestBalancerWithNodeGroup.java | 27 ++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyWithNodeGroup.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyWithNodeGroup.java
index 194f6ba..39f1519 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyWithNodeGroup.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyWithNodeGroup.java
@@ -46,6 +46,11 @@ public class BlockPlacementPolicyWithNodeGroup extends BlockPlacementPolicyDefau
   public void initialize(Configuration conf,  FSClusterStats stats,
           NetworkTopology clusterMap, 
           Host2NodesMap host2datanodeMap) {
+    if (!(clusterMap instanceof NetworkTopologyWithNodeGroup)) {
+      throw new IllegalArgumentException(
+          "Configured cluster topology should be "
+              + NetworkTopologyWithNodeGroup.class.getName());
+    }
     super.initialize(conf, stats, clusterMap, host2datanodeMap);
   }
 
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerWithNodeGroup.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerWithNodeGroup.java
index caac02c..6088722 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerWithNodeGroup.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerWithNodeGroup.java
@@ -47,6 +47,7 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
 import org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicyWithNodeGroup;
 import org.apache.hadoop.net.NetworkTopology;
 import org.apache.hadoop.net.NetworkTopologyWithNodeGroup;
+import org.apache.hadoop.test.LambdaTestUtils;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -361,4 +362,30 @@ public class TestBalancerWithNodeGroup {
       cluster.shutdown();
     }
   }
+
+  /**
+   * verify BlockPlacementPolicyNodeGroup uses NetworkTopologyWithNodeGroup.
+   */
+
+  @Test
+  public void testBPPNodeGroup() throws Exception {
+    Configuration conf = createConf();
+    conf.setBoolean(DFSConfigKeys.DFS_USE_DFS_NETWORK_TOPOLOGY_KEY, true);
+    long[] capacities = new long[] {CAPACITY, CAPACITY, CAPACITY, CAPACITY};
+    String[] racks = new String[] {RACK0, RACK0, RACK1, RACK1};
+    String[] nodeGroups =
+        new String[] {NODEGROUP0, NODEGROUP0, NODEGROUP1, NODEGROUP2};
+
+    int numOfDatanodes = capacities.length;
+    assertEquals(numOfDatanodes, racks.length);
+    assertEquals(numOfDatanodes, nodeGroups.length);
+    MiniDFSCluster.Builder builder =
+        new MiniDFSCluster.Builder(conf).numDataNodes(capacities.length)
+            .racks(racks).simulatedCapacities(capacities);
+    MiniDFSClusterWithNodeGroup.setNodeGroups(nodeGroups);
+    LambdaTestUtils.intercept(IllegalArgumentException.class,
+        "Configured cluster topology should be "
+            + "org.apache.hadoop.net.NetworkTopologyWithNodeGroup",
+        () -> new MiniDFSClusterWithNodeGroup(builder));
+  }
 }


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