diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/ServiceScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/ServiceScheduler.java index dfe9808a022..15df49473af 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/ServiceScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/ServiceScheduler.java @@ -96,6 +96,7 @@ import static org.apache.hadoop.fs.FileSystem.FS_DEFAULT_NAME_KEY; import static org.apache.hadoop.registry.client.api.RegistryConstants.*; +import static org.apache.hadoop.yarn.api.records.ContainerExitStatus.KILLED_AFTER_APP_COMPLETION; import static org.apache.hadoop.yarn.service.api.ServiceApiConstants.*; import static org.apache.hadoop.yarn.service.component.ComponentEventType.*; @@ -253,6 +254,13 @@ public void serviceInit(Configuration conf) throws Exception { public void serviceStop() throws Exception { LOG.info("Stopping service scheduler"); + // Mark component-instances/containers as STOPPED + if (YarnConfiguration.timelineServiceV2Enabled(getConfig())) { + for (ContainerId containerId : getLiveInstances().keySet()) { + serviceTimelinePublisher.componentInstanceFinished(containerId, + KILLED_AFTER_APP_COMPLETION, diagnostics.toString()); + } + } if (executorService != null) { executorService.shutdownNow(); } @@ -598,6 +606,7 @@ public void onContainersReceivedFromPreviousAttempts( public void onContainersCompleted(List statuses) { for (ContainerStatus status : statuses) { ContainerId containerId = status.getContainerId(); + LOG.info("GOUR: container completed {}", containerId); ComponentInstance instance = liveInstances.get(status.getContainerId()); if (instance == null) { LOG.warn( @@ -609,6 +618,10 @@ public void onContainersCompleted(List statuses) { new ComponentEvent(instance.getCompName(), CONTAINER_COMPLETED) .setStatus(status).setInstance(instance); dispatcher.getEventHandler().handle(event); + if (YarnConfiguration.timelineServiceV2Enabled(getConfig())) { + serviceTimelinePublisher.componentInstanceFinished(containerId, + KILLED_AFTER_APP_COMPLETION, diagnostics.toString()); + } } }