From 036cbd745313598a8867d7fff11d110c90c2961a Mon Sep 17 00:00:00 2001 From: Jian He Date: Tue, 29 Aug 2017 20:35:53 -0700 Subject: [PATCH] YARN-6756. ContainerRequest#executionTypeRequest causes NPE. Contributed by Jian He --- .../java/org/apache/hadoop/yarn/client/api/AMRMClient.java | 5 +++-- .../client/api/impl/TestAMRMClientContainerRequest.java | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/AMRMClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/AMRMClient.java index bc4173f6daa..1c3ac1c7bff 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/AMRMClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/AMRMClient.java @@ -111,9 +111,10 @@ public abstract class AMRMClient extends private List racks; private Priority priority; private long allocationRequestId; - private boolean relaxLocality; + private boolean relaxLocality = true; private String nodeLabelsExpression; - private ExecutionTypeRequest executionTypeRequest; + private ExecutionTypeRequest executionTypeRequest = + ExecutionTypeRequest.newInstance(); /** * Instantiates a {@link ContainerRequest} with the given constraints and diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClientContainerRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClientContainerRequest.java index ad18da3c53f..96035394ec7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClientContainerRequest.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClientContainerRequest.java @@ -51,8 +51,10 @@ public class TestAMRMClientContainerRequest { Resource capability = Resource.newInstance(1024, 1); ContainerRequest request = - new ContainerRequest(capability, new String[] {"host1", "host2"}, - new String[] {"/rack2"}, Priority.newInstance(1)); + ContainerRequest.newBuilder().capability(capability) + .nodes(new String[] { "host1", "host2" }) + .racks(new String[] { "/rack2" }).priority(Priority.newInstance(1)) + .build(); client.addContainerRequest(request); verifyResourceRequest(client, request, "host1", true); verifyResourceRequest(client, request, "host2", true);