YARN-4925. ContainerRequest in AMRMClient, application should be able to specify nodes/racks together with nodeLabelExpression. Contributed by Bibin A Chundatt
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f04c81c9 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f04c81c9 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f04c81c9 Branch: refs/heads/HDFS-7240 Commit: f04c81c9ce93512bc714531a7731debbe6b794ce Parents: ef17577 Author: Naganarasimha <naganarasimha...@apache.org> Authored: Thu May 19 01:30:12 2016 +0800 Committer: Naganarasimha <naganarasimha...@apache.org> Committed: Thu May 19 01:30:48 2016 +0800 ---------------------------------------------------------------------- .../hadoop/yarn/client/api/impl/AMRMClientImpl.java | 10 ---------- .../hadoop/yarn/client/api/impl/TestAMRMClient.java | 13 ++++++++++++- 2 files changed, 12 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/f04c81c9/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java index 37a1fb6..46ddc4d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java @@ -712,16 +712,6 @@ public class AMRMClientImpl<T extends ContainerRequest> extends AMRMClient<T> { "Cannot specify more than two node labels" + " in a single node label expression"); } - - // Don't allow specify node label against ANY request - if ((containerRequest.getRacks() != null && - (!containerRequest.getRacks().isEmpty())) - || - (containerRequest.getNodes() != null && - (!containerRequest.getNodes().isEmpty()))) { - throw new InvalidContainerRequestException( - "Cannot specify node label with rack and node"); - } } private void validateContainerResourceChangeRequest( http://git-wip-us.apache.org/repos/asf/hadoop/blob/f04c81c9/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClient.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClient.java index 3b3c0ed..75b49d0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClient.java @@ -35,11 +35,11 @@ import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Set; import java.util.TreeSet; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.CommonConfigurationKeys; import org.apache.hadoop.io.DataOutputBuffer; import org.apache.hadoop.io.Text; import org.apache.hadoop.security.Credentials; @@ -713,6 +713,17 @@ public class TestAMRMClient { Assert.assertNull(req.getNodeLabelExpression()); } } + // set container with nodes and racks with labels + client.addContainerRequest(new ContainerRequest( + Resource.newInstance(1024, 1), new String[] { "rack1" }, + new String[] { "node1", "node2" }, Priority.UNDEFINED, true, "y")); + for (ResourceRequest req : client.ask) { + if (ResourceRequest.ANY.equals(req.getResourceName())) { + Assert.assertEquals("y", req.getNodeLabelExpression()); + } else { + Assert.assertNull(req.getNodeLabelExpression()); + } + } } private void verifyAddRequestFailed(AMRMClient<ContainerRequest> client, --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org