Explorar o código

YARN-4925. ContainerRequest in AMRMClient, application should be able to specify nodes/racks together with nodeLabelExpression. Contributed by Bibin A Chundatt

(cherry picked from commit f04c81c9ce93512bc714531a7731debbe6b794ce)
Naganarasimha %!s(int64=9) %!d(string=hai) anos
pai
achega
4f2ff8540b

+ 3 - 0
hadoop-yarn-project/CHANGES.txt

@@ -102,6 +102,9 @@ Release 2.7.4 - UNRELEASED
     YARN-6304. Skip rm.transitionToActive call to RM if RM is already active.
     (Rohith Sharma K S via junping_du)
 
+    YARN-4925. ContainerRequest in AMRMClient, application should be able to
+    specify nodes/racks together with nodeLabelExpression. Bibin A Chundatt
+
 Release 2.7.3 - 2016-08-25
 
   INCOMPATIBLE CHANGES

+ 0 - 10
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java

@@ -607,16 +607,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 addResourceRequestToAsk(ResourceRequest remoteRequest) {

+ 12 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClient.java

@@ -39,6 +39,7 @@ 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.Text;
 import org.apache.hadoop.security.Credentials;
 import org.apache.hadoop.security.SecurityUtil;
@@ -708,6 +709,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,