YARN-8218 Add application launch time to ATSV1. Contributed by Abhishek Modi
This commit is contained in:
parent
09a9938db7
commit
491313ab84
|
@ -250,6 +250,7 @@ public class ApplicationHistoryManagerOnTimelineStore extends AbstractService
|
||||||
String type = null;
|
String type = null;
|
||||||
boolean unmanagedApplication = false;
|
boolean unmanagedApplication = false;
|
||||||
long createdTime = 0;
|
long createdTime = 0;
|
||||||
|
long launchTime = 0;
|
||||||
long submittedTime = 0;
|
long submittedTime = 0;
|
||||||
long finishedTime = 0;
|
long finishedTime = 0;
|
||||||
float progress = 0.0f;
|
float progress = 0.0f;
|
||||||
|
@ -378,6 +379,9 @@ public class ApplicationHistoryManagerOnTimelineStore extends AbstractService
|
||||||
if (event.getEventType().equals(
|
if (event.getEventType().equals(
|
||||||
ApplicationMetricsConstants.CREATED_EVENT_TYPE)) {
|
ApplicationMetricsConstants.CREATED_EVENT_TYPE)) {
|
||||||
createdTime = event.getTimestamp();
|
createdTime = event.getTimestamp();
|
||||||
|
} else if (event.getEventType().equals(
|
||||||
|
ApplicationMetricsConstants.LAUNCHED_EVENT_TYPE)) {
|
||||||
|
launchTime = event.getTimestamp();
|
||||||
} else if (event.getEventType().equals(
|
} else if (event.getEventType().equals(
|
||||||
ApplicationMetricsConstants.UPDATED_EVENT_TYPE)) {
|
ApplicationMetricsConstants.UPDATED_EVENT_TYPE)) {
|
||||||
// This type of events are parsed in time-stamp descending order
|
// This type of events are parsed in time-stamp descending order
|
||||||
|
@ -454,7 +458,8 @@ public class ApplicationHistoryManagerOnTimelineStore extends AbstractService
|
||||||
return new ApplicationReportExt(ApplicationReport.newInstance(
|
return new ApplicationReportExt(ApplicationReport.newInstance(
|
||||||
ApplicationId.fromString(entity.getEntityId()),
|
ApplicationId.fromString(entity.getEntityId()),
|
||||||
latestApplicationAttemptId, user, queue, name, null, -1, null, state,
|
latestApplicationAttemptId, user, queue, name, null, -1, null, state,
|
||||||
diagnosticsInfo, null, createdTime, submittedTime, 0, finishedTime,
|
diagnosticsInfo, null, createdTime,
|
||||||
|
submittedTime, launchTime, finishedTime,
|
||||||
finalStatus, appResources, null, progress, type, null, appTags,
|
finalStatus, appResources, null, progress, type, null, appTags,
|
||||||
unmanagedApplication, Priority.newInstance(applicationPriority),
|
unmanagedApplication, Priority.newInstance(applicationPriority),
|
||||||
appNodeLabelExpression, amNodeLabelExpression), appViewACLs);
|
appNodeLabelExpression, amNodeLabelExpression), appViewACLs);
|
||||||
|
|
|
@ -121,6 +121,19 @@ public class TimelineServiceV1Publisher extends AbstractSystemMetricsPublisher {
|
||||||
SystemMetricsEventType.PUBLISH_ENTITY, entity, app.getApplicationId()));
|
SystemMetricsEventType.PUBLISH_ENTITY, entity, app.getApplicationId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void appLaunched(RMApp app, long launchTime) {
|
||||||
|
TimelineEntity entity = createApplicationEntity(app.getApplicationId());
|
||||||
|
|
||||||
|
TimelineEvent tEvent = new TimelineEvent();
|
||||||
|
tEvent.setEventType(ApplicationMetricsConstants.LAUNCHED_EVENT_TYPE);
|
||||||
|
tEvent.setTimestamp(launchTime);
|
||||||
|
entity.addEvent(tEvent);
|
||||||
|
|
||||||
|
getDispatcher().getEventHandler().handle(new TimelineV1PublishEvent(
|
||||||
|
SystemMetricsEventType.PUBLISH_ENTITY, entity, app.getApplicationId()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appFinished(RMApp app, RMAppState state, long finishedTime) {
|
public void appFinished(RMApp app, RMAppState state, long finishedTime) {
|
||||||
TimelineEntity entity = createApplicationEntity(app.getApplicationId());
|
TimelineEntity entity = createApplicationEntity(app.getApplicationId());
|
||||||
|
|
|
@ -115,6 +115,7 @@ public class TestSystemMetricsPublisher {
|
||||||
ApplicationId appId = ApplicationId.newInstance(0, i);
|
ApplicationId appId = ApplicationId.newInstance(0, i);
|
||||||
RMApp app = createRMApp(appId);
|
RMApp app = createRMApp(appId);
|
||||||
metricsPublisher.appCreated(app, app.getStartTime());
|
metricsPublisher.appCreated(app, app.getStartTime());
|
||||||
|
metricsPublisher.appLaunched(app, app.getLaunchTime());
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
when(app.getQueue()).thenReturn("new test queue");
|
when(app.getQueue()).thenReturn("new test queue");
|
||||||
ApplicationSubmissionContext asc = mock(
|
ApplicationSubmissionContext asc = mock(
|
||||||
|
@ -150,7 +151,7 @@ public class TestSystemMetricsPublisher {
|
||||||
ApplicationMetricsConstants.ENTITY_TYPE,
|
ApplicationMetricsConstants.ENTITY_TYPE,
|
||||||
EnumSet.allOf(Field.class));
|
EnumSet.allOf(Field.class));
|
||||||
// ensure Five events are both published before leaving the loop
|
// ensure Five events are both published before leaving the loop
|
||||||
} while (entity == null || entity.getEvents().size() < 5);
|
} while (entity == null || entity.getEvents().size() < 6);
|
||||||
// verify all the fields
|
// verify all the fields
|
||||||
Assert.assertEquals(ApplicationMetricsConstants.ENTITY_TYPE,
|
Assert.assertEquals(ApplicationMetricsConstants.ENTITY_TYPE,
|
||||||
entity.getEntityType());
|
entity.getEntityType());
|
||||||
|
@ -240,6 +241,7 @@ public class TestSystemMetricsPublisher {
|
||||||
Assert.assertEquals("context", entity.getOtherInfo()
|
Assert.assertEquals("context", entity.getOtherInfo()
|
||||||
.get(ApplicationMetricsConstants.YARN_APP_CALLER_CONTEXT));
|
.get(ApplicationMetricsConstants.YARN_APP_CALLER_CONTEXT));
|
||||||
boolean hasCreatedEvent = false;
|
boolean hasCreatedEvent = false;
|
||||||
|
boolean hasLaunchedEvent = false;
|
||||||
boolean hasUpdatedEvent = false;
|
boolean hasUpdatedEvent = false;
|
||||||
boolean hasFinishedEvent = false;
|
boolean hasFinishedEvent = false;
|
||||||
boolean hasACLsUpdatedEvent = false;
|
boolean hasACLsUpdatedEvent = false;
|
||||||
|
@ -249,6 +251,10 @@ public class TestSystemMetricsPublisher {
|
||||||
ApplicationMetricsConstants.CREATED_EVENT_TYPE)) {
|
ApplicationMetricsConstants.CREATED_EVENT_TYPE)) {
|
||||||
hasCreatedEvent = true;
|
hasCreatedEvent = true;
|
||||||
Assert.assertEquals(app.getStartTime(), event.getTimestamp());
|
Assert.assertEquals(app.getStartTime(), event.getTimestamp());
|
||||||
|
} else if (event.getEventType().equals(
|
||||||
|
ApplicationMetricsConstants.LAUNCHED_EVENT_TYPE)) {
|
||||||
|
hasLaunchedEvent = true;
|
||||||
|
Assert.assertEquals(app.getLaunchTime(), event.getTimestamp());
|
||||||
} else if (event.getEventType().equals(
|
} else if (event.getEventType().equals(
|
||||||
ApplicationMetricsConstants.FINISHED_EVENT_TYPE)) {
|
ApplicationMetricsConstants.FINISHED_EVENT_TYPE)) {
|
||||||
hasFinishedEvent = true;
|
hasFinishedEvent = true;
|
||||||
|
@ -292,6 +298,7 @@ public class TestSystemMetricsPublisher {
|
||||||
}
|
}
|
||||||
// Do assertTrue verification separately for easier debug
|
// Do assertTrue verification separately for easier debug
|
||||||
Assert.assertTrue(hasCreatedEvent);
|
Assert.assertTrue(hasCreatedEvent);
|
||||||
|
Assert.assertTrue(hasLaunchedEvent);
|
||||||
Assert.assertTrue(hasFinishedEvent);
|
Assert.assertTrue(hasFinishedEvent);
|
||||||
Assert.assertTrue(hasACLsUpdatedEvent);
|
Assert.assertTrue(hasACLsUpdatedEvent);
|
||||||
Assert.assertTrue(hasUpdatedEvent);
|
Assert.assertTrue(hasUpdatedEvent);
|
||||||
|
@ -499,6 +506,7 @@ public class TestSystemMetricsPublisher {
|
||||||
when(app.getQueue()).thenReturn("test queue");
|
when(app.getQueue()).thenReturn("test queue");
|
||||||
when(app.getSubmitTime()).thenReturn(Integer.MAX_VALUE + 1L);
|
when(app.getSubmitTime()).thenReturn(Integer.MAX_VALUE + 1L);
|
||||||
when(app.getStartTime()).thenReturn(Integer.MAX_VALUE + 2L);
|
when(app.getStartTime()).thenReturn(Integer.MAX_VALUE + 2L);
|
||||||
|
when(app.getLaunchTime()).thenReturn(Integer.MAX_VALUE + 2L);
|
||||||
when(app.getFinishTime()).thenReturn(Integer.MAX_VALUE + 3L);
|
when(app.getFinishTime()).thenReturn(Integer.MAX_VALUE + 3L);
|
||||||
when(app.getDiagnostics()).thenReturn(
|
when(app.getDiagnostics()).thenReturn(
|
||||||
new StringBuilder("test diagnostics info"));
|
new StringBuilder("test diagnostics info"));
|
||||||
|
|
Loading…
Reference in New Issue