// use latch if container wants to be long running
if (container instanceof LongRunningYarnContainer && ((LongRunningYarnContainer)container).isWaitCompleteState()) {
log.info("Container requested that we wait state, setting up latch");
latch = new CountDownLatch(1);
((LongRunningYarnContainer)container).addContainerStateListener(new ContainerStateListener() {
@Override
public void state(ContainerState state, Object exit) {
if (log.isDebugEnabled()) {
log.debug("Got state ContainerState=" + state + " and exit=" + exit);
}