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 A380F200D01 for ; Fri, 22 Sep 2017 22:56:40 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A220B1609D0; Fri, 22 Sep 2017 20:56:40 +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 BFF961609BE for ; Fri, 22 Sep 2017 22:56:39 +0200 (CEST) Received: (qmail 86596 invoked by uid 500); 22 Sep 2017 20:56:38 -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 86587 invoked by uid 99); 22 Sep 2017 20:56:38 -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; Fri, 22 Sep 2017 20:56:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BEF2AE08A1; Fri, 22 Sep 2017 20:56:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: junping_du@apache.org To: common-commits@hadoop.apache.org Message-Id: <7cfe7196739041a58a3fee55e9142ed3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: YARN-7118. AHS REST API can return NullPointerException. Contributed by Billie Rinaldi. Date: Fri, 22 Sep 2017 20:56:38 +0000 (UTC) archived-at: Fri, 22 Sep 2017 20:56:40 -0000 Repository: hadoop Updated Branches: refs/heads/branch-3.0 0eb029802 -> b58cc1617 YARN-7118. AHS REST API can return NullPointerException. Contributed by Billie Rinaldi. (cherry picked from commit 4002bf0a9e7e3619a3bdcff071f0369cbf2873ad) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b58cc161 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b58cc161 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b58cc161 Branch: refs/heads/branch-3.0 Commit: b58cc16171b5ecc5feaa3ae529e9901654b0911a Parents: 0eb0298 Author: Junping Du Authored: Fri Sep 22 13:58:09 2017 -0700 Committer: Junping Du Committed: Fri Sep 22 14:00:40 2017 -0700 ---------------------------------------------------------------------- ...pplicationHistoryManagerOnTimelineStore.java | 16 ++++++++--- .../webapp/TestAHSWebServices.java | 28 +++++++++++++++++--- .../hadoop/yarn/server/webapp/WebServices.java | 3 ++- 3 files changed, 38 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/b58cc161/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryManagerOnTimelineStore.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryManagerOnTimelineStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryManagerOnTimelineStore.java index 9600251..ecaaf1e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryManagerOnTimelineStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryManagerOnTimelineStore.java @@ -146,7 +146,11 @@ public class TestApplicationHistoryManagerOnTimelineStore { } else if (i == 3) { entities.addEntity(createApplicationTimelineEntity( appId, false, false, false, false, YarnApplicationState.FINISHED, - true)); + true, false)); + } else if (i == SCALE + 1) { + entities.addEntity(createApplicationTimelineEntity( + appId, false, false, false, false, YarnApplicationState.FINISHED, + false, true)); } else { entities.addEntity(createApplicationTimelineEntity( appId, false, false, false, false, YarnApplicationState.FINISHED)); @@ -497,13 +501,14 @@ public class TestApplicationHistoryManagerOnTimelineStore { boolean wrongAppId, boolean enableUpdateEvent, YarnApplicationState state) { return createApplicationTimelineEntity(appId, emptyACLs, noAttemptId, - wrongAppId, enableUpdateEvent, state, false); + wrongAppId, enableUpdateEvent, state, false, false); } private static TimelineEntity createApplicationTimelineEntity( ApplicationId appId, boolean emptyACLs, boolean noAttemptId, boolean wrongAppId, boolean enableUpdateEvent, - YarnApplicationState state, boolean missingPreemptMetrics) { + YarnApplicationState state, boolean missingPreemptMetrics, + boolean missingQueue) { TimelineEntity entity = new TimelineEntity(); entity.setEntityType(ApplicationMetricsConstants.ENTITY_TYPE); if (wrongAppId) { @@ -519,7 +524,10 @@ public class TestApplicationHistoryManagerOnTimelineStore { entityInfo.put(ApplicationMetricsConstants.TYPE_ENTITY_INFO, "test app type"); entityInfo.put(ApplicationMetricsConstants.USER_ENTITY_INFO, "user1"); - entityInfo.put(ApplicationMetricsConstants.QUEUE_ENTITY_INFO, "test queue"); + if (!missingQueue) { + entityInfo.put(ApplicationMetricsConstants.QUEUE_ENTITY_INFO, + "test queue"); + } entityInfo.put( ApplicationMetricsConstants.UNMANAGED_APPLICATION_ENTITY_INFO, "false"); entityInfo.put(ApplicationMetricsConstants.APPLICATION_PRIORITY_INFO, http://git-wip-us.apache.org/repos/asf/hadoop/blob/b58cc161/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java index dc692a5..a850c3e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java @@ -100,7 +100,7 @@ public class TestAHSWebServices extends JerseyTestBase { private static ApplicationHistoryClientService historyClientService; private static AHSWebServices ahsWebservice; private static final String[] USERS = new String[] { "foo" , "bar" }; - private static final int MAX_APPS = 5; + private static final int MAX_APPS = 6; private static Configuration conf; private static FileSystem fs; private static final String remoteLogRootDir = "target/logs/"; @@ -364,7 +364,27 @@ public class TestAHSWebServices extends JerseyTestBase { JSONObject apps = json.getJSONObject("apps"); assertEquals("incorrect number of elements", 1, apps.length()); JSONArray array = apps.getJSONArray("app"); - assertEquals("incorrect number of elements", 5, array.length()); + assertEquals("incorrect number of elements", MAX_APPS, array.length()); + } + + @Test + public void testQueueQuery() throws Exception { + WebResource r = resource(); + ClientResponse response = + r.path("ws").path("v1").path("applicationhistory").path("apps") + .queryParam("queue", "test queue") + .queryParam("user.name", USERS[round]) + .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); + assertResponseStatusCode(Status.OK, response.getStatusInfo()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); + JSONObject json = response.getEntity(JSONObject.class); + assertEquals("incorrect number of elements", 1, json.length()); + JSONObject apps = json.getJSONObject("apps"); + assertEquals("incorrect number of elements", 1, apps.length()); + JSONArray array = apps.getJSONArray("app"); + assertEquals("incorrect number of elements", MAX_APPS - 1, + array.length()); } @Test @@ -414,7 +434,7 @@ public class TestAHSWebServices extends JerseyTestBase { JSONObject appAttempts = json.getJSONObject("appAttempts"); assertEquals("incorrect number of elements", 1, appAttempts.length()); JSONArray array = appAttempts.getJSONArray("appAttempt"); - assertEquals("incorrect number of elements", 5, array.length()); + assertEquals("incorrect number of elements", MAX_APPS, array.length()); } @Test @@ -471,7 +491,7 @@ public class TestAHSWebServices extends JerseyTestBase { JSONObject containers = json.getJSONObject("containers"); assertEquals("incorrect number of elements", 1, containers.length()); JSONArray array = containers.getJSONArray("container"); - assertEquals("incorrect number of elements", 5, array.length()); + assertEquals("incorrect number of elements", MAX_APPS, array.length()); } @Test http://git-wip-us.apache.org/repos/asf/hadoop/blob/b58cc161/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebServices.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebServices.java index 6bb6c98..1399099 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebServices.java @@ -192,7 +192,8 @@ public class WebServices { } } if (queueQuery != null && !queueQuery.isEmpty()) { - if (!appReport.getQueue().equals(queueQuery)) { + if (appReport.getQueue() == null || !appReport.getQueue() + .equals(queueQuery)) { continue; } } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org