hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aajis...@apache.org
Subject hadoop git commit: YARN-5753. fix NPE in AMRMClientImpl.getMatchingRequests() (haibochen via rkanter)
Date Wed, 13 Sep 2017 07:57:50 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 0a8ed025e -> 055bde980


YARN-5753. fix NPE in AMRMClientImpl.getMatchingRequests() (haibochen via rkanter)

(cherry picked from commit 44fdf009642ae4e99b15f89ec0ca43834f991ef3)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/055bde98
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/055bde98
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/055bde98

Branch: refs/heads/branch-2
Commit: 055bde980691a0853c8d1429a2b46696b9afe85d
Parents: 0a8ed02
Author: Robert Kanter <rkanter@apache.org>
Authored: Tue Oct 25 23:59:39 2016 -0700
Committer: Akira Ajisaka <aajisaka@apache.org>
Committed: Wed Sep 13 16:48:43 2017 +0900

----------------------------------------------------------------------
 .../yarn/client/api/impl/AMRMClientImpl.java    | 23 ++++++++++++--------
 .../yarn/client/api/impl/TestAMRMClient.java    | 14 ++++++++++++
 2 files changed, 28 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/055bde98/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 748e7f5..caeaa7d 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
@@ -694,15 +694,20 @@ public class AMRMClientImpl<T extends ContainerRequest> extends
AMRMClient<T> {
     List<LinkedHashSet<T>> list = new LinkedList<LinkedHashSet<T>>();
 
     RemoteRequestsTable remoteRequestsTable = getTable(0);
-    List<ResourceRequestInfo<T>> matchingRequests =
-        remoteRequestsTable.getMatchingRequests(priority, resourceName,
-            executionType, capability);
-    // If no exact match. Container may be larger than what was requested.
-    // get all resources <= capability. map is reverse sorted.
-    for (ResourceRequestInfo<T> resReqInfo : matchingRequests) {
-      if (canFit(resReqInfo.remoteRequest.getCapability(), capability) &&
-        !resReqInfo.containerRequests.isEmpty()) {
-        list.add(resReqInfo.containerRequests);
+
+    if (null != remoteRequestsTable) {
+      List<ResourceRequestInfo<T>> matchingRequests =
+          remoteRequestsTable.getMatchingRequests(priority, resourceName,
+              executionType, capability);
+      if (null != matchingRequests) {
+        // If no exact match. Container may be larger than what was requested.
+        // get all resources <= capability. map is reverse sorted.
+        for (ResourceRequestInfo<T> resReqInfo : matchingRequests) {
+          if (canFit(resReqInfo.remoteRequest.getCapability(), capability) &&
+              !resReqInfo.containerRequests.isEmpty()) {
+            list.add(resReqInfo.containerRequests);
+          }
+        }
       }
     }
     // no match found

http://git-wip-us.apache.org/repos/asf/hadoop/blob/055bde98/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 88d646f..ffe9ce3 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
@@ -242,6 +242,20 @@ public class TestAMRMClient {
       yarnCluster.stop();
     }
   }
+
+  @Test (timeout = 60000)
+  public void testAMRMClientNoMatchingRequests()
+      throws IOException, YarnException {
+    AMRMClient<ContainerRequest> amClient =  AMRMClient.createAMRMClient();
+    amClient.init(conf);
+    amClient.start();
+    amClient.registerApplicationMaster("Host", 10000, "");
+
+    Resource testCapability1 = Resource.newInstance(1024,  2);
+    List<? extends Collection<ContainerRequest>> matches =
+        amClient.getMatchingRequests(priority, node, testCapability1);
+    assertEquals("Expected no macthing requests.", matches.size(), 0);
+  }
   
   @Test (timeout=60000)
   public void testAMRMClientMatchingFit() throws YarnException, IOException {


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


Mime
View raw message