use of org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState in project hadoop by apache.
the class ApplicationHistoryManagerOnTimelineStore method convertToApplicationAttemptReport.
private static ApplicationAttemptReport convertToApplicationAttemptReport(TimelineEntity entity) {
String host = null;
int rpcPort = -1;
ContainerId amContainerId = null;
String trackingUrl = null;
String originalTrackingUrl = null;
String diagnosticsInfo = null;
YarnApplicationAttemptState state = null;
List<TimelineEvent> events = entity.getEvents();
if (events != null) {
for (TimelineEvent event : events) {
if (event.getEventType().equals(AppAttemptMetricsConstants.REGISTERED_EVENT_TYPE)) {
Map<String, Object> eventInfo = event.getEventInfo();
if (eventInfo == null) {
continue;
}
if (eventInfo.containsKey(AppAttemptMetricsConstants.HOST_INFO)) {
host = eventInfo.get(AppAttemptMetricsConstants.HOST_INFO).toString();
}
if (eventInfo.containsKey(AppAttemptMetricsConstants.RPC_PORT_INFO)) {
rpcPort = (Integer) eventInfo.get(AppAttemptMetricsConstants.RPC_PORT_INFO);
}
if (eventInfo.containsKey(AppAttemptMetricsConstants.MASTER_CONTAINER_INFO)) {
amContainerId = ContainerId.fromString(eventInfo.get(AppAttemptMetricsConstants.MASTER_CONTAINER_INFO).toString());
}
} else if (event.getEventType().equals(AppAttemptMetricsConstants.FINISHED_EVENT_TYPE)) {
Map<String, Object> eventInfo = event.getEventInfo();
if (eventInfo == null) {
continue;
}
if (eventInfo.containsKey(AppAttemptMetricsConstants.TRACKING_URL_INFO)) {
trackingUrl = eventInfo.get(AppAttemptMetricsConstants.TRACKING_URL_INFO).toString();
}
if (eventInfo.containsKey(AppAttemptMetricsConstants.ORIGINAL_TRACKING_URL_INFO)) {
originalTrackingUrl = eventInfo.get(AppAttemptMetricsConstants.ORIGINAL_TRACKING_URL_INFO).toString();
}
if (eventInfo.containsKey(AppAttemptMetricsConstants.DIAGNOSTICS_INFO)) {
diagnosticsInfo = eventInfo.get(AppAttemptMetricsConstants.DIAGNOSTICS_INFO).toString();
}
if (eventInfo.containsKey(AppAttemptMetricsConstants.STATE_INFO)) {
state = YarnApplicationAttemptState.valueOf(eventInfo.get(AppAttemptMetricsConstants.STATE_INFO).toString());
}
if (eventInfo.containsKey(AppAttemptMetricsConstants.MASTER_CONTAINER_INFO)) {
amContainerId = ContainerId.fromString(eventInfo.get(AppAttemptMetricsConstants.MASTER_CONTAINER_INFO).toString());
}
}
}
}
return ApplicationAttemptReport.newInstance(ApplicationAttemptId.fromString(entity.getEntityId()), host, rpcPort, trackingUrl, originalTrackingUrl, diagnosticsInfo, state, amContainerId);
}
use of org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState in project hadoop by apache.
the class TestUnmanagedAMLauncher method testUMALauncher.
@Test(timeout = 30000)
public void testUMALauncher() throws Exception {
String classpath = getTestRuntimeClasspath();
String javaHome = System.getenv("JAVA_HOME");
if (javaHome == null) {
LOG.fatal("JAVA_HOME not defined. Test not running.");
return;
}
String[] args = { "--classpath", classpath, "--queue", "default", "--cmd", javaHome + "/bin/java -Xmx512m " + TestUnmanagedAMLauncher.class.getCanonicalName() + " success" };
LOG.info("Initializing Launcher");
UnmanagedAMLauncher launcher = new UnmanagedAMLauncher(new Configuration(yarnCluster.getConfig())) {
public void launchAM(ApplicationAttemptId attemptId) throws IOException, YarnException {
YarnApplicationAttemptState attemptState = rmClient.getApplicationAttemptReport(attemptId).getYarnApplicationAttemptState();
Assert.assertTrue(attemptState.equals(YarnApplicationAttemptState.LAUNCHED));
super.launchAM(attemptId);
}
};
boolean initSuccess = launcher.init(args);
Assert.assertTrue(initSuccess);
LOG.info("Running Launcher");
boolean result = launcher.run();
LOG.info("Launcher run completed. Result=" + result);
Assert.assertTrue(result);
}
Aggregations