|
@@ -211,6 +211,9 @@ public class ApplicationImpl implements Application {
|
|
private static final ContainerDoneTransition CONTAINER_DONE_TRANSITION =
|
|
private static final ContainerDoneTransition CONTAINER_DONE_TRANSITION =
|
|
new ContainerDoneTransition();
|
|
new ContainerDoneTransition();
|
|
|
|
|
|
|
|
+ private static final InitContainerTransition INIT_CONTAINER_TRANSITION =
|
|
|
|
+ new InitContainerTransition();
|
|
|
|
+
|
|
private static StateMachineFactory<ApplicationImpl, ApplicationState,
|
|
private static StateMachineFactory<ApplicationImpl, ApplicationState,
|
|
ApplicationEventType, ApplicationEvent> stateMachineFactory =
|
|
ApplicationEventType, ApplicationEvent> stateMachineFactory =
|
|
new StateMachineFactory<ApplicationImpl, ApplicationState,
|
|
new StateMachineFactory<ApplicationImpl, ApplicationState,
|
|
@@ -221,12 +224,12 @@ public class ApplicationImpl implements Application {
|
|
ApplicationEventType.INIT_APPLICATION, new AppInitTransition())
|
|
ApplicationEventType.INIT_APPLICATION, new AppInitTransition())
|
|
.addTransition(ApplicationState.NEW, ApplicationState.NEW,
|
|
.addTransition(ApplicationState.NEW, ApplicationState.NEW,
|
|
ApplicationEventType.INIT_CONTAINER,
|
|
ApplicationEventType.INIT_CONTAINER,
|
|
- new InitContainerTransition())
|
|
|
|
|
|
+ INIT_CONTAINER_TRANSITION)
|
|
|
|
|
|
// Transitions from INITING state
|
|
// Transitions from INITING state
|
|
.addTransition(ApplicationState.INITING, ApplicationState.INITING,
|
|
.addTransition(ApplicationState.INITING, ApplicationState.INITING,
|
|
ApplicationEventType.INIT_CONTAINER,
|
|
ApplicationEventType.INIT_CONTAINER,
|
|
- new InitContainerTransition())
|
|
|
|
|
|
+ INIT_CONTAINER_TRANSITION)
|
|
.addTransition(ApplicationState.INITING,
|
|
.addTransition(ApplicationState.INITING,
|
|
EnumSet.of(ApplicationState.FINISHING_CONTAINERS_WAIT,
|
|
EnumSet.of(ApplicationState.FINISHING_CONTAINERS_WAIT,
|
|
ApplicationState.APPLICATION_RESOURCES_CLEANINGUP),
|
|
ApplicationState.APPLICATION_RESOURCES_CLEANINGUP),
|
|
@@ -249,7 +252,7 @@ public class ApplicationImpl implements Application {
|
|
.addTransition(ApplicationState.RUNNING,
|
|
.addTransition(ApplicationState.RUNNING,
|
|
ApplicationState.RUNNING,
|
|
ApplicationState.RUNNING,
|
|
ApplicationEventType.INIT_CONTAINER,
|
|
ApplicationEventType.INIT_CONTAINER,
|
|
- new InitContainerTransition())
|
|
|
|
|
|
+ INIT_CONTAINER_TRANSITION)
|
|
.addTransition(ApplicationState.RUNNING,
|
|
.addTransition(ApplicationState.RUNNING,
|
|
ApplicationState.RUNNING,
|
|
ApplicationState.RUNNING,
|
|
ApplicationEventType.APPLICATION_CONTAINER_FINISHED,
|
|
ApplicationEventType.APPLICATION_CONTAINER_FINISHED,
|
|
@@ -268,6 +271,10 @@ public class ApplicationImpl implements Application {
|
|
ApplicationState.APPLICATION_RESOURCES_CLEANINGUP),
|
|
ApplicationState.APPLICATION_RESOURCES_CLEANINGUP),
|
|
ApplicationEventType.APPLICATION_CONTAINER_FINISHED,
|
|
ApplicationEventType.APPLICATION_CONTAINER_FINISHED,
|
|
new AppFinishTransition())
|
|
new AppFinishTransition())
|
|
|
|
+ .addTransition(ApplicationState.FINISHING_CONTAINERS_WAIT,
|
|
|
|
+ ApplicationState.FINISHING_CONTAINERS_WAIT,
|
|
|
|
+ ApplicationEventType.INIT_CONTAINER,
|
|
|
|
+ INIT_CONTAINER_TRANSITION)
|
|
.addTransition(ApplicationState.FINISHING_CONTAINERS_WAIT,
|
|
.addTransition(ApplicationState.FINISHING_CONTAINERS_WAIT,
|
|
ApplicationState.FINISHING_CONTAINERS_WAIT,
|
|
ApplicationState.FINISHING_CONTAINERS_WAIT,
|
|
EnumSet.of(
|
|
EnumSet.of(
|
|
@@ -284,6 +291,10 @@ public class ApplicationImpl implements Application {
|
|
ApplicationState.FINISHED,
|
|
ApplicationState.FINISHED,
|
|
ApplicationEventType.APPLICATION_RESOURCES_CLEANEDUP,
|
|
ApplicationEventType.APPLICATION_RESOURCES_CLEANEDUP,
|
|
new AppCompletelyDoneTransition())
|
|
new AppCompletelyDoneTransition())
|
|
|
|
+ .addTransition(ApplicationState.APPLICATION_RESOURCES_CLEANINGUP,
|
|
|
|
+ ApplicationState.APPLICATION_RESOURCES_CLEANINGUP,
|
|
|
|
+ ApplicationEventType.INIT_CONTAINER,
|
|
|
|
+ INIT_CONTAINER_TRANSITION)
|
|
.addTransition(ApplicationState.APPLICATION_RESOURCES_CLEANINGUP,
|
|
.addTransition(ApplicationState.APPLICATION_RESOURCES_CLEANINGUP,
|
|
ApplicationState.APPLICATION_RESOURCES_CLEANINGUP,
|
|
ApplicationState.APPLICATION_RESOURCES_CLEANINGUP,
|
|
EnumSet.of(
|
|
EnumSet.of(
|
|
@@ -300,9 +311,14 @@ public class ApplicationImpl implements Application {
|
|
ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED,
|
|
ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED,
|
|
ApplicationEventType.APPLICATION_LOG_HANDLING_FAILED),
|
|
ApplicationEventType.APPLICATION_LOG_HANDLING_FAILED),
|
|
new AppLogsAggregatedTransition())
|
|
new AppLogsAggregatedTransition())
|
|
|
|
+ .addTransition(ApplicationState.FINISHED,
|
|
|
|
+ ApplicationState.FINISHED,
|
|
|
|
+ ApplicationEventType.INIT_CONTAINER,
|
|
|
|
+ INIT_CONTAINER_TRANSITION)
|
|
.addTransition(ApplicationState.FINISHED, ApplicationState.FINISHED,
|
|
.addTransition(ApplicationState.FINISHED, ApplicationState.FINISHED,
|
|
EnumSet.of(
|
|
EnumSet.of(
|
|
ApplicationEventType.APPLICATION_LOG_HANDLING_INITED,
|
|
ApplicationEventType.APPLICATION_LOG_HANDLING_INITED,
|
|
|
|
+ ApplicationEventType.APPLICATION_CONTAINER_FINISHED,
|
|
ApplicationEventType.FINISH_APPLICATION))
|
|
ApplicationEventType.FINISH_APPLICATION))
|
|
// create the topology tables
|
|
// create the topology tables
|
|
.installTopology();
|
|
.installTopology();
|
|
@@ -445,8 +461,9 @@ public class ApplicationImpl implements Application {
|
|
app.containers.put(container.getContainerId(), container);
|
|
app.containers.put(container.getContainerId(), container);
|
|
LOG.info("Adding " + container.getContainerId()
|
|
LOG.info("Adding " + container.getContainerId()
|
|
+ " to application " + app.toString());
|
|
+ " to application " + app.toString());
|
|
-
|
|
|
|
- switch (app.getApplicationState()) {
|
|
|
|
|
|
+
|
|
|
|
+ ApplicationState appState = app.getApplicationState();
|
|
|
|
+ switch (appState) {
|
|
case RUNNING:
|
|
case RUNNING:
|
|
app.dispatcher.getEventHandler().handle(new ContainerInitEvent(
|
|
app.dispatcher.getEventHandler().handle(new ContainerInitEvent(
|
|
container.getContainerId()));
|
|
container.getContainerId()));
|
|
@@ -456,8 +473,13 @@ public class ApplicationImpl implements Application {
|
|
// these get queued up and sent out in AppInitDoneTransition
|
|
// these get queued up and sent out in AppInitDoneTransition
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- assert false : "Invalid state for InitContainerTransition: " +
|
|
|
|
- app.getApplicationState();
|
|
|
|
|
|
+ LOG.warn("Killing {} because {} is in state {}",
|
|
|
|
+ container.getContainerId(), app, appState);
|
|
|
|
+ app.dispatcher.getEventHandler().handle(new ContainerKillEvent(
|
|
|
|
+ container.getContainerId(),
|
|
|
|
+ ContainerExitStatus.KILLED_AFTER_APP_COMPLETION,
|
|
|
|
+ "Application no longer running.\n"));
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|