Skip to content

Commit aa5afa7

Browse files
Prabhu JosephPrabhu Joseph
authored andcommitted
YARN-10381. Add application attempt state in AppAttempts RM REST API
Contributed by Siddharth Ahuja. Reviewed by Bilwa ST.
1 parent 2986058 commit aa5afa7

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppAttemptInfo.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.hadoop.yarn.api.records.Container;
2727
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
2828
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
29+
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
2930
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler;
3031
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
3132
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
@@ -45,6 +46,7 @@ public class AppAttemptInfo {
4546
private String nodesBlacklistedBySystem;
4647
protected String appAttemptId;
4748
private String exportPorts;
49+
private RMAppAttemptState appAttemptState;
4850

4951
public AppAttemptInfo() {
5052
}
@@ -89,6 +91,7 @@ public AppAttemptInfo(ResourceManager rm, RMAppAttempt attempt, String user,
8991
}
9092
}
9193
this.appAttemptId = attempt.getAppAttemptId().toString();
94+
this.appAttemptState = attempt.getAppAttemptState();
9295
}
9396
}
9497

@@ -115,4 +118,8 @@ public String getLogsLink() {
115118
public String getAppAttemptId() {
116119
return this.appAttemptId;
117120
}
121+
122+
public RMAppAttemptState getAppAttemptState() {
123+
return this.appAttemptState;
124+
}
118125
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesAppAttempts.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,25 +381,28 @@ private void verifyAppAttemptsXML(NodeList nodes, RMAppAttempt appAttempt,
381381
WebServicesTestUtils.getXmlString(element, "nodeHttpAddress"),
382382
WebServicesTestUtils.getXmlString(element, "nodeId"),
383383
WebServicesTestUtils.getXmlString(element, "logsLink"), user,
384-
WebServicesTestUtils.getXmlString(element, "exportPorts"));
384+
WebServicesTestUtils.getXmlString(element, "exportPorts"),
385+
WebServicesTestUtils.getXmlString(element, "appAttemptState"));
385386
}
386387
}
387388

388389
private void verifyAppAttemptsInfo(JSONObject info, RMAppAttempt appAttempt,
389390
String user)
390391
throws Exception {
391392

392-
assertEquals("incorrect number of elements", 11, info.length());
393+
assertEquals("incorrect number of elements", 12, info.length());
393394

394395
verifyAppAttemptInfoGeneric(appAttempt, info.getInt("id"),
395396
info.getLong("startTime"), info.getString("containerId"),
396397
info.getString("nodeHttpAddress"), info.getString("nodeId"),
397-
info.getString("logsLink"), user, info.getString("exportPorts"));
398+
info.getString("logsLink"), user, info.getString("exportPorts"),
399+
info.getString("appAttemptState"));
398400
}
399401

400402
private void verifyAppAttemptInfoGeneric(RMAppAttempt appAttempt, int id,
401403
long startTime, String containerId, String nodeHttpAddress, String
402-
nodeId, String logsLink, String user, String exportPorts) {
404+
nodeId, String logsLink, String user, String exportPorts,
405+
String appAttemptState) {
403406

404407
assertEquals("id doesn't match", appAttempt.getAppAttemptId()
405408
.getAttemptId(), id);
@@ -415,5 +418,7 @@ private void verifyAppAttemptInfoGeneric(RMAppAttempt appAttempt, int id,
415418
assertTrue(
416419
"logsLink doesn't contain user info", logsLink.endsWith("/"
417420
+ user));
421+
assertEquals("appAttemptState doesn't match", appAttemptState, appAttempt
422+
.getAppAttemptState().toString());
418423
}
419424
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/ResourceManagerRest.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2265,6 +2265,7 @@ appAttempts:
22652265
| logsLink | string | The http link to the app attempt logs |
22662266
| containerId | string | The id of the container for the app attempt |
22672267
| startTime | long | The start time of the attempt (in ms since epoch) |
2268+
| appAttemptState | string | The state of the application attempt - valid values are members of the RMAppAttemptState enum: NEW, SUBMITTED, SCHEDULED, ALLOCATED, LAUNCHED, FAILED, RUNNING, FINISHING, FINISHED, KILLED, ALLOCATED_SAVING, LAUNCHED_UNMANAGED_SAVING, FINAL_SAVING |
22682269

22692270
### Response Examples
22702271

@@ -2293,7 +2294,8 @@ Response Body:
22932294
"startTime" : 1326381444693,
22942295
"id" : 1,
22952296
"logsLink" : "http://host.domain.com:8042/node/containerlogs/container_1326821518301_0005_01_000001/user1",
2296-
"containerId" : "container_1326821518301_0005_01_000001"
2297+
"containerId" : "container_1326821518301_0005_01_000001",
2298+
"appAttemptState" : "RUNNING"
22972299
}
22982300
]
22992301
}
@@ -2326,6 +2328,7 @@ Response Body:
23262328
<startTime>1326381444693</startTime>
23272329
<containerId>container_1326821518301_0005_01_000001</containerId>
23282330
<logsLink>http://host.domain.com:8042/node/containerlogs/container_1326821518301_0005_01_000001/user1</logsLink>
2331+
<appAttemptState>RUNNING</appAttemptState>
23292332
</appAttempt>
23302333
</appAttempts>
23312334
```

0 commit comments

Comments
 (0)