Github user poornachandra commented on a diff in the pull request: https://github.com/apache/twill/pull/2#discussion_r75439711 --- Diff: twill-core/src/main/java/org/apache/twill/internal/TwillContainerLauncher.java --- @@ -153,21 +155,29 @@ public TwillContainerController start(RunId runId, int instanceId, Class<?> main .addCommand(firstCommand, command.toArray(new String[command.size()])) .launch(); - TwillContainerControllerImpl controller = new TwillContainerControllerImpl(zkClient, runId, processController); + TwillContainerControllerImpl controller = + new TwillContainerControllerImpl(zkClient, runId, runtimeSpec.getName(), instanceId, processController); controller.start(); return controller; } private static final class TwillContainerControllerImpl extends AbstractZKServiceController implements TwillContainerController { + private final String runnable; + private final int instanceId; private final ProcessController<Void> processController; + // This latch can be used to wait for container shutdown + private final CountDownLatch shutdownLatch; private volatile ContainerLiveNodeData liveData; - protected TwillContainerControllerImpl(ZKClient zkClient, RunId runId, + protected TwillContainerControllerImpl(ZKClient zkClient, RunId runId, String runnable, int instanceId, ProcessController<Void> processController) { super(runId, zkClient); + this.runnable = runnable; + this.instanceId = instanceId; this.processController = processController; + this.shutdownLatch = new CountDownLatch(1); --- End diff -- The thread that stops the container needs to wait until the container stops. The only good way to know whether the container has stopped or not is to get a notification from RM during the heartbeat (that happens in a separate thread). Hence we wait on a `CountDownLatch` until the heartbeat thread calls `completed()` method where the latch get count down.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---