Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7E469200BAC for ; Wed, 26 Oct 2016 08:59:51 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7CD12160AEE; Wed, 26 Oct 2016 06:59:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C0A06160ACA for ; Wed, 26 Oct 2016 08:59:50 +0200 (CEST) Received: (qmail 98789 invoked by uid 500); 26 Oct 2016 06:59:49 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 98778 invoked by uid 99); 26 Oct 2016 06:59:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Oct 2016 06:59:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B90A9E05E1; Wed, 26 Oct 2016 06:59:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rkanter@apache.org To: common-commits@hadoop.apache.org Message-Id: <1159de5787e742629d77694c1ef6eb4a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: YARN-5753. fix NPE in AMRMClientImpl.getMatchingRequests() (haibochen via rkanter) Date: Wed, 26 Oct 2016 06:59:49 +0000 (UTC) archived-at: Wed, 26 Oct 2016 06:59:51 -0000 Repository: hadoop Updated Branches: refs/heads/trunk d3bb69a66 -> 44fdf0096 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/trunk Commit: 44fdf009642ae4e99b15f89ec0ca43834f991ef3 Parents: d3bb69a Author: Robert Kanter Authored: Tue Oct 25 23:59:39 2016 -0700 Committer: Robert Kanter 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 extends AMRMClient { List> list = new LinkedList>(); RemoteRequestsTable remoteRequestsTable = getTable(0); - List> 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 resReqInfo : matchingRequests) { - if (canFit(resReqInfo.remoteRequest.getCapability(), capability) && - !resReqInfo.containerRequests.isEmpty()) { - list.add(resReqInfo.containerRequests); + + if (null != remoteRequestsTable) { + List> 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 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 amClient = AMRMClient.createAMRMClient(); + amClient.init(conf); + amClient.start(); + amClient.registerApplicationMaster("Host", 10000, ""); + + Resource testCapability1 = Resource.newInstance(1024, 2); + List> 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