From 8e672e3c717bb6f02ae9f93747f78ca3ab5d74a6 Mon Sep 17 00:00:00 2001 From: Varun Saxena Date: Tue, 5 Jul 2016 22:56:07 +0530 Subject: [PATCH] YARN-5286. Add RPC port info in RM web service's response when getting app status. (Jun Gong via Varun Saxena). --- .../resourcemanager/webapp/dao/AppInfo.java | 21 ++++++++++++++++++- .../webapp/TestRMWebServicesApps.java | 21 ++++++++++++++----- .../src/site/markdown/ResourceManagerRest.md | 7 +++++++ 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java index c5c02a806d..be0b87f261 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java @@ -82,6 +82,7 @@ public class AppInfo { protected long elapsedTime; protected String amContainerLogs; protected String amHostHttpAddress; + private String amRPCAddress; protected long allocatedMB; protected long allocatedVCores; protected int runningContainers; @@ -168,7 +169,9 @@ public AppInfo(ResourceManager rm, RMApp app, Boolean hasAccess, masterContainer.getId().toString(), app.getUser()); this.amHostHttpAddress = masterContainer.getNodeHttpAddress(); } - + + this.amRPCAddress = getAmRPCAddressFromRMAppAttempt(attempt); + ApplicationResourceUsageReport resourceReport = attempt .getApplicationResourceUsageReport(); if (resourceReport != null) { @@ -281,6 +284,22 @@ public String getAMHostHttpAddress() { return this.amHostHttpAddress; } + public String getAmRPCAddress() { + return amRPCAddress; + } + + static public String getAmRPCAddressFromRMAppAttempt(RMAppAttempt attempt) { + String amRPCAddress = null; + if (attempt != null) { + String amHost = attempt.getHost(); + int amRpcPort = attempt.getRpcPort(); + if (!"N/A".equals(amHost) && amRpcPort != -1) { + amRPCAddress = amHost + ":" + amRpcPort; + } + } + return amRPCAddress; + } + public boolean amContainerLogsExist() { return this.amContainerLogsExist; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesApps.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesApps.java index 4f99c5cad4..2d20a82726 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesApps.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesApps.java @@ -46,6 +46,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler; +import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo; import org.apache.hadoop.yarn.webapp.GenericExceptionHandler; import org.apache.hadoop.yarn.webapp.GuiceServletConfig; import org.apache.hadoop.yarn.webapp.JerseyTestBase; @@ -1319,7 +1320,8 @@ public void verifyAppsXML(NodeList nodes, RMApp app) throws JSONException, WebServicesTestUtils.getXmlString(element, "logAggregationStatus"), WebServicesTestUtils.getXmlBoolean(element, "unmanagedApplication"), WebServicesTestUtils.getXmlString(element, "appNodeLabelExpression"), - WebServicesTestUtils.getXmlString(element, "amNodeLabelExpression")); + WebServicesTestUtils.getXmlString(element, "amNodeLabelExpression"), + WebServicesTestUtils.getXmlString(element, "amRPCAddress")); } } @@ -1338,6 +1340,12 @@ public void verifyAppInfo(JSONObject info, RMApp app) throws JSONException, expectedNumberOfElements++; amNodeLabelExpression = info.getString("amNodeLabelExpression"); } + String amRPCAddress = null; + if (AppInfo.getAmRPCAddressFromRMAppAttempt(app.getCurrentAppAttempt()) + != null) { + expectedNumberOfElements++; + amRPCAddress = info.getString("amRPCAddress"); + } assertEquals("incorrect number of elements", expectedNumberOfElements, info.length()); @@ -1360,7 +1368,8 @@ public void verifyAppInfo(JSONObject info, RMApp app) throws JSONException, info.getString("logAggregationStatus"), info.getBoolean("unmanagedApplication"), appNodeLabelExpression, - amNodeLabelExpression); + amNodeLabelExpression, + amRPCAddress); } public void verifyAppInfoGeneric(RMApp app, String id, String user, @@ -1373,9 +1382,8 @@ public void verifyAppInfoGeneric(RMApp app, String id, String user, int preemptedResourceMB, int preemptedResourceVCores, int numNonAMContainerPreempted, int numAMContainerPreempted, String logAggregationStatus, boolean unmanagedApplication, - String appNodeLabelExpression, String amNodeLabelExpression) - throws JSONException, - Exception { + String appNodeLabelExpression, String amNodeLabelExpression, + String amRPCAddress) throws JSONException, Exception { WebServicesTestUtils.checkStringMatch("id", app.getApplicationId() .toString(), id); @@ -1436,6 +1444,9 @@ public void verifyAppInfoGeneric(RMApp app, String id, String user, assertEquals("unmanagedApplication doesn't match", app.getAMResourceRequest().getNodeLabelExpression(), amNodeLabelExpression); + assertEquals("amRPCAddress", + AppInfo.getAmRPCAddressFromRMAppAttempt(app.getCurrentAppAttempt()), + amRPCAddress); } @Test diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/ResourceManagerRest.md b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/ResourceManagerRest.md index 1b77127519..5862506755 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/ResourceManagerRest.md +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/ResourceManagerRest.md @@ -1381,6 +1381,7 @@ Response Body: "clusterId" : 1326815542473, "finalStatus" : "SUCCEEDED", "amHostHttpAddress" : "host.domain.com:8042", + "amRPCAddress" : "host.domain.com:4201", "progress" : 100, "name" : "word count", "startedTime" : 1326815573334, @@ -1410,6 +1411,7 @@ Response Body: "clusterId" : 1326815542473, "finalStatus" : "SUCCEEDED", "amHostHttpAddress" : "host.domain.com:8042", + "amRPCAddress" : "host.domain.com:4202", "progress" : 100, "name" : "Sleep job", "startedTime" : 1326815641380, @@ -1472,6 +1474,7 @@ Response Body: 25196 http://host.domain.com:8042/node/containerlogs/container_1326815542473_0001_01_000001 host.domain.com:8042 + host.domain.com:4201 0 0 0 @@ -1501,6 +1504,7 @@ Response Body: 148166 http://host.domain.com:8042/node/containerlogs/container_1326815542473_0002_01_000001 host.domain.com:8042 + host.domain.com:4202 0 0 0 @@ -1664,6 +1668,7 @@ Note that depending on security settings a user might not be able to see all the | elapsedTime | long | The elapsed time since the application started (in ms) | | amContainerLogs | string | The URL of the application master container logs | | amHostHttpAddress | string | The nodes http address of the application master | +| amRPCAddress | string | The RPC address of the application master | | allocatedMB | int | The sum of memory in MB allocated to the application's running containers | | allocatedVCores | int | The sum of virtual cores allocated to the application's running containers | | runningContainers | int | The number of containers currently running for the application | @@ -1703,6 +1708,7 @@ Response Body: "clusterId" : 1326821518301, "finalStatus" : "SUCCEEDED", "amHostHttpAddress" : "host.domain.com:8042", + "amRPCAddress" : "host.domain.com:4201", "progress" : 100, "name" : "Sleep job", "applicationType" : "Yarn", @@ -1756,6 +1762,7 @@ Response Body: 446748 http://host.domain.com:8042/node/containerlogs/container_1326821518301_0005_01_000001 host.domain.com:8042 + host.domain.com:4201 151730 103 false