Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 359E2200BB4 for ; Mon, 17 Oct 2016 20:31:00 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 34444160AF0; Mon, 17 Oct 2016 18:31:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5D4DF160AE2 for ; Mon, 17 Oct 2016 20:30:59 +0200 (CEST) Received: (qmail 37538 invoked by uid 500); 17 Oct 2016 18:30:57 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 37080 invoked by uid 99); 17 Oct 2016 18:30:57 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Oct 2016 18:30:57 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6DD90F0BEA; Mon, 17 Oct 2016 18:30:57 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: wangda@apache.org To: common-commits@hadoop.apache.org Date: Mon, 17 Oct 2016 18:31:03 -0000 Message-Id: <4d0e5102e35e4584a502e3f3235ed635@git.apache.org> In-Reply-To: <737beaf8901c42efb71f3eb45535cb6e@git.apache.org> References: <737beaf8901c42efb71f3eb45535cb6e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [07/50] [abbrv] hadoop git commit: HDFS-11008. Change unit test for testing parsing "-source" parameter in Balancer CLI. Contributed by Mingliang Liu archived-at: Mon, 17 Oct 2016 18:31:00 -0000 HDFS-11008. Change unit test for testing parsing "-source" parameter in Balancer CLI. Contributed by Mingliang Liu Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/76cc84e6 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/76cc84e6 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/76cc84e6 Branch: refs/heads/YARN-3368 Commit: 76cc84e6d41c2b02218c2c98d60481cd565e067c Parents: aee538b Author: Mingliang Liu Authored: Thu Oct 13 17:51:38 2016 -0700 Committer: Mingliang Liu Committed: Fri Oct 14 14:29:02 2016 -0700 ---------------------------------------------------------------------- .../hdfs/server/balancer/TestBalancer.java | 61 ++++++++++++-------- 1 file changed, 38 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/76cc84e6/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancer.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancer.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancer.java index 73a4cbc..f58a3ad 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancer.java @@ -1282,6 +1282,14 @@ public class TestBalancer { } catch (IllegalArgumentException e) { } + + parameters = new String[] {"-source"}; + try { + Balancer.Cli.parse(parameters); + fail(reason + " for -source parameter"); + } catch (IllegalArgumentException ignored) { + // expected + } } @Test @@ -1800,11 +1808,12 @@ public class TestBalancer { final Collection namenodes = DFSUtil.getInternalNsRpcUris(conf); { // run Balancer with min-block-size=50 - BalancerParameters.Builder b = - new BalancerParameters.Builder(); - b.setBalancingPolicy(BalancingPolicy.Node.INSTANCE); - b.setThreshold(1); - final BalancerParameters p = b.build(); + final BalancerParameters p = Balancer.Cli.parse(new String[] { + "-policy", BalancingPolicy.Node.INSTANCE.getName(), + "-threshold", "1" + }); + assertEquals(p.getBalancingPolicy(), BalancingPolicy.Node.INSTANCE); + assertEquals(p.getThreshold(), 1.0, 0.001); conf.setLong(DFSConfigKeys.DFS_BALANCER_GETBLOCKS_MIN_BLOCK_SIZE_KEY, 50); final int r = Balancer.run(namenodes, p, conf); @@ -1819,12 +1828,14 @@ public class TestBalancer { for(int i = capacities.length; i < datanodes.size(); i++) { sourceNodes.add(datanodes.get(i).getDisplayName()); } - BalancerParameters.Builder b = - new BalancerParameters.Builder(); - b.setBalancingPolicy(BalancingPolicy.Node.INSTANCE); - b.setThreshold(1); - b.setSourceNodes(sourceNodes); - final BalancerParameters p = b.build(); + final BalancerParameters p = Balancer.Cli.parse(new String[] { + "-policy", BalancingPolicy.Node.INSTANCE.getName(), + "-threshold", "1", + "-source", StringUtils.join(sourceNodes, ',') + }); + assertEquals(p.getBalancingPolicy(), BalancingPolicy.Node.INSTANCE); + assertEquals(p.getThreshold(), 1.0, 0.001); + assertEquals(p.getSourceNodes(), sourceNodes); conf.setLong(DFSConfigKeys.DFS_BALANCER_GETBLOCKS_MIN_BLOCK_SIZE_KEY, 50); final int r = Balancer.run(namenodes, p, conf); @@ -1835,12 +1846,14 @@ public class TestBalancer { final Set sourceNodes = new HashSet<>(); final List datanodes = cluster.getDataNodes(); sourceNodes.add(datanodes.get(0).getDisplayName()); - BalancerParameters.Builder b = - new BalancerParameters.Builder(); - b.setBalancingPolicy(BalancingPolicy.Node.INSTANCE); - b.setThreshold(1); - b.setSourceNodes(sourceNodes); - final BalancerParameters p = b.build(); + final BalancerParameters p = Balancer.Cli.parse(new String[] { + "-policy", BalancingPolicy.Node.INSTANCE.getName(), + "-threshold", "1", + "-source", StringUtils.join(sourceNodes, ',') + }); + assertEquals(p.getBalancingPolicy(), BalancingPolicy.Node.INSTANCE); + assertEquals(p.getThreshold(), 1.0, 0.001); + assertEquals(p.getSourceNodes(), sourceNodes); conf.setLong(DFSConfigKeys.DFS_BALANCER_GETBLOCKS_MIN_BLOCK_SIZE_KEY, 1); final int r = Balancer.run(namenodes, p, conf); @@ -1853,12 +1866,14 @@ public class TestBalancer { for(int i = 0; i < capacities.length; i++) { sourceNodes.add(datanodes.get(i).getDisplayName()); } - BalancerParameters.Builder b = - new BalancerParameters.Builder(); - b.setBalancingPolicy(BalancingPolicy.Node.INSTANCE); - b.setThreshold(1); - b.setSourceNodes(sourceNodes); - final BalancerParameters p = b.build(); + final BalancerParameters p = Balancer.Cli.parse(new String[] { + "-policy", BalancingPolicy.Node.INSTANCE.getName(), + "-threshold", "1", + "-source", StringUtils.join(sourceNodes, ',') + }); + assertEquals(p.getBalancingPolicy(), BalancingPolicy.Node.INSTANCE); + assertEquals(p.getThreshold(), 1.0, 0.001); + assertEquals(p.getSourceNodes(), sourceNodes); conf.setLong(DFSConfigKeys.DFS_BALANCER_GETBLOCKS_MIN_BLOCK_SIZE_KEY, 1); final int r = Balancer.run(namenodes, p, conf); --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org