hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject [42/50] [abbrv] hadoop git commit: YARN-5753. fix NPE in AMRMClientImpl.getMatchingRequests() (haibochen via rkanter)
Date Wed, 26 Oct 2016 18:31:08 GMT
YARN-5753. fix NPE in AMRMClientImpl.getMatchingRequests() (haibochen via rkanter)


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

Branch: refs/heads/YARN-4752
Commit: 44fdf009642ae4e99b15f89ec0ca43834f991ef3
Parents: d3bb69a
Author: Robert Kanter <rkanter@apache.org>
Authored: Tue Oct 25 23:59:39 2016 -0700
Committer: Robert Kanter <rkanter@apache.org>
Committed: Tue Oct 25 23:59:39 2016 -0700

----------------------------------------------------------------------
 .../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/44fdf009/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 3221661..3ed43b0 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
@@ -664,15 +664,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/44fdf009/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 239189a..c4bb3ce 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
@@ -235,6 +235,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