YARN-5286. Add RPC port info in RM web service's response when getting app status. (Jun Gong via Varun Saxena).

This commit is contained in:
Varun Saxena 2016-07-05 23:10:08 +05:30
parent 0401adcaca
commit 516aa58c1b
3 changed files with 43 additions and 6 deletions

View File

@ -82,6 +82,7 @@ public class AppInfo {
protected long elapsedTime; protected long elapsedTime;
protected String amContainerLogs; protected String amContainerLogs;
protected String amHostHttpAddress; protected String amHostHttpAddress;
private String amRPCAddress;
protected long allocatedMB; protected long allocatedMB;
protected long allocatedVCores; protected long allocatedVCores;
protected int runningContainers; protected int runningContainers;
@ -169,6 +170,8 @@ public class AppInfo {
this.amHostHttpAddress = masterContainer.getNodeHttpAddress(); this.amHostHttpAddress = masterContainer.getNodeHttpAddress();
} }
this.amRPCAddress = getAmRPCAddressFromRMAppAttempt(attempt);
ApplicationResourceUsageReport resourceReport = attempt ApplicationResourceUsageReport resourceReport = attempt
.getApplicationResourceUsageReport(); .getApplicationResourceUsageReport();
if (resourceReport != null) { if (resourceReport != null) {
@ -281,6 +284,22 @@ public class AppInfo {
return this.amHostHttpAddress; 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() { public boolean amContainerLogsExist() {
return this.amContainerLogsExist; return this.amContainerLogsExist;
} }

View File

@ -45,6 +45,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState; 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.ResourceScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler; 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.GenericExceptionHandler;
import org.apache.hadoop.yarn.webapp.JerseyTestBase; import org.apache.hadoop.yarn.webapp.JerseyTestBase;
import org.apache.hadoop.yarn.webapp.WebServicesTestUtils; import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
@ -1316,7 +1317,8 @@ public class TestRMWebServicesApps extends JerseyTestBase {
WebServicesTestUtils.getXmlString(element, "logAggregationStatus"), WebServicesTestUtils.getXmlString(element, "logAggregationStatus"),
WebServicesTestUtils.getXmlBoolean(element, "unmanagedApplication"), WebServicesTestUtils.getXmlBoolean(element, "unmanagedApplication"),
WebServicesTestUtils.getXmlString(element, "appNodeLabelExpression"), WebServicesTestUtils.getXmlString(element, "appNodeLabelExpression"),
WebServicesTestUtils.getXmlString(element, "amNodeLabelExpression")); WebServicesTestUtils.getXmlString(element, "amNodeLabelExpression"),
WebServicesTestUtils.getXmlString(element, "amRPCAddress"));
} }
} }
@ -1335,6 +1337,12 @@ public class TestRMWebServicesApps extends JerseyTestBase {
expectedNumberOfElements++; expectedNumberOfElements++;
amNodeLabelExpression = info.getString("amNodeLabelExpression"); amNodeLabelExpression = info.getString("amNodeLabelExpression");
} }
String amRPCAddress = null;
if (AppInfo.getAmRPCAddressFromRMAppAttempt(app.getCurrentAppAttempt())
!= null) {
expectedNumberOfElements++;
amRPCAddress = info.getString("amRPCAddress");
}
assertEquals("incorrect number of elements", expectedNumberOfElements, assertEquals("incorrect number of elements", expectedNumberOfElements,
info.length()); info.length());
@ -1357,7 +1365,8 @@ public class TestRMWebServicesApps extends JerseyTestBase {
info.getString("logAggregationStatus"), info.getString("logAggregationStatus"),
info.getBoolean("unmanagedApplication"), info.getBoolean("unmanagedApplication"),
appNodeLabelExpression, appNodeLabelExpression,
amNodeLabelExpression); amNodeLabelExpression,
amRPCAddress);
} }
public void verifyAppInfoGeneric(RMApp app, String id, String user, public void verifyAppInfoGeneric(RMApp app, String id, String user,
@ -1370,9 +1379,8 @@ public class TestRMWebServicesApps extends JerseyTestBase {
int preemptedResourceMB, int preemptedResourceVCores, int preemptedResourceMB, int preemptedResourceVCores,
int numNonAMContainerPreempted, int numAMContainerPreempted, int numNonAMContainerPreempted, int numAMContainerPreempted,
String logAggregationStatus, boolean unmanagedApplication, String logAggregationStatus, boolean unmanagedApplication,
String appNodeLabelExpression, String amNodeLabelExpression) String appNodeLabelExpression, String amNodeLabelExpression,
throws JSONException, String amRPCAddress) throws JSONException, Exception {
Exception {
WebServicesTestUtils.checkStringMatch("id", app.getApplicationId() WebServicesTestUtils.checkStringMatch("id", app.getApplicationId()
.toString(), id); .toString(), id);
@ -1433,6 +1441,9 @@ public class TestRMWebServicesApps extends JerseyTestBase {
assertEquals("unmanagedApplication doesn't match", assertEquals("unmanagedApplication doesn't match",
app.getAMResourceRequest().getNodeLabelExpression(), app.getAMResourceRequest().getNodeLabelExpression(),
amNodeLabelExpression); amNodeLabelExpression);
assertEquals("amRPCAddress",
AppInfo.getAmRPCAddressFromRMAppAttempt(app.getCurrentAppAttempt()),
amRPCAddress);
} }
@Test @Test

View File

@ -1381,6 +1381,7 @@ Response Body:
"clusterId" : 1326815542473, "clusterId" : 1326815542473,
"finalStatus" : "SUCCEEDED", "finalStatus" : "SUCCEEDED",
"amHostHttpAddress" : "host.domain.com:8042", "amHostHttpAddress" : "host.domain.com:8042",
"amRPCAddress" : "host.domain.com:4201",
"progress" : 100, "progress" : 100,
"name" : "word count", "name" : "word count",
"startedTime" : 1326815573334, "startedTime" : 1326815573334,
@ -1410,6 +1411,7 @@ Response Body:
"clusterId" : 1326815542473, "clusterId" : 1326815542473,
"finalStatus" : "SUCCEEDED", "finalStatus" : "SUCCEEDED",
"amHostHttpAddress" : "host.domain.com:8042", "amHostHttpAddress" : "host.domain.com:8042",
"amRPCAddress" : "host.domain.com:4202",
"progress" : 100, "progress" : 100,
"name" : "Sleep job", "name" : "Sleep job",
"startedTime" : 1326815641380, "startedTime" : 1326815641380,
@ -1472,6 +1474,7 @@ Response Body:
<elapsedTime>25196</elapsedTime> <elapsedTime>25196</elapsedTime>
<amContainerLogs>http://host.domain.com:8042/node/containerlogs/container_1326815542473_0001_01_000001</amContainerLogs> <amContainerLogs>http://host.domain.com:8042/node/containerlogs/container_1326815542473_0001_01_000001</amContainerLogs>
<amHostHttpAddress>host.domain.com:8042</amHostHttpAddress> <amHostHttpAddress>host.domain.com:8042</amHostHttpAddress>
<amRPCAddress>host.domain.com:4201</amRPCAddress>
<allocatedMB>0</allocatedMB> <allocatedMB>0</allocatedMB>
<allocatedVCores>0</allocatedVCores> <allocatedVCores>0</allocatedVCores>
<runningContainers>0</runningContainers> <runningContainers>0</runningContainers>
@ -1501,6 +1504,7 @@ Response Body:
<elapsedTime>148166</elapsedTime> <elapsedTime>148166</elapsedTime>
<amContainerLogs>http://host.domain.com:8042/node/containerlogs/container_1326815542473_0002_01_000001</amContainerLogs> <amContainerLogs>http://host.domain.com:8042/node/containerlogs/container_1326815542473_0002_01_000001</amContainerLogs>
<amHostHttpAddress>host.domain.com:8042</amHostHttpAddress> <amHostHttpAddress>host.domain.com:8042</amHostHttpAddress>
<amRPCAddress>host.domain.com:4202</amRPCAddress>
<allocatedMB>0</allocatedMB> <allocatedMB>0</allocatedMB>
<allocatedVCores>0</allocatedVCores> <allocatedVCores>0</allocatedVCores>
<runningContainers>0</runningContainers> <runningContainers>0</runningContainers>
@ -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) | | elapsedTime | long | The elapsed time since the application started (in ms) |
| amContainerLogs | string | The URL of the application master container logs | | amContainerLogs | string | The URL of the application master container logs |
| amHostHttpAddress | string | The nodes http address of the application master | | 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 | | 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 | | 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 | | runningContainers | int | The number of containers currently running for the application |
@ -1703,6 +1708,7 @@ Response Body:
"clusterId" : 1326821518301, "clusterId" : 1326821518301,
"finalStatus" : "SUCCEEDED", "finalStatus" : "SUCCEEDED",
"amHostHttpAddress" : "host.domain.com:8042", "amHostHttpAddress" : "host.domain.com:8042",
"amRPCAddress" : "host.domain.com:4201",
"progress" : 100, "progress" : 100,
"name" : "Sleep job", "name" : "Sleep job",
"applicationType" : "Yarn", "applicationType" : "Yarn",
@ -1756,6 +1762,7 @@ Response Body:
<elapsedTime>446748</elapsedTime> <elapsedTime>446748</elapsedTime>
<amContainerLogs>http://host.domain.com:8042/node/containerlogs/container_1326821518301_0005_01_000001</amContainerLogs> <amContainerLogs>http://host.domain.com:8042/node/containerlogs/container_1326821518301_0005_01_000001</amContainerLogs>
<amHostHttpAddress>host.domain.com:8042</amHostHttpAddress> <amHostHttpAddress>host.domain.com:8042</amHostHttpAddress>
<amRPCAddress>host.domain.com:4201</amRPCAddress>
<memorySeconds>151730</memorySeconds> <memorySeconds>151730</memorySeconds>
<vcoreSeconds>103</vcoreSeconds> <vcoreSeconds>103</vcoreSeconds>
<unmanagedApplication>false</unmanagedApplication> <unmanagedApplication>false</unmanagedApplication>