Commit 56840b00 authored by Daniel Seybold's avatar Daniel Seybold

PS-167 fixed application state machine for stopping states

parent eb17a260
......@@ -116,11 +116,15 @@ public final class LifecycleController {
public synchronized void blockingStop() {
//throw new UnsupportedOperationException(
// "not calling stop handler; this is not part of the state machine (yet).");
machine.transit(LifecycleHandlerType.PRE_STOP);
//run(LifecycleHandlerType.PRE_STOP);
//machine.transit(LifecycleHandlerType.PRE_STOP);
getLogger().warn("running POST_START state!");
run(LifecycleHandlerType.POST_START);
getLogger().warn("running PRE_STOP state!");
run(LifecycleHandlerType.PRE_STOP);
//FIXME: is a stop detector action required at this point?
getLogger().warn("Stopping instance, running PRE_STOP state!");
//run(LifecycleHandlerType.STOP);
run(LifecycleHandlerType.STOP);
//machine.transit(LifecycleHandlerType.STOP);
}
......
package de.uniulm.omi.cloudiator.lance.lifecycle;
import de.uniulm.omi.cloudiator.lance.lifecycle.handlers.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.uniulm.omi.cloudiator.lance.lifecycle.handlers.InitHandler;
import de.uniulm.omi.cloudiator.lance.lifecycle.handlers.InstallHandler;
import de.uniulm.omi.cloudiator.lance.lifecycle.handlers.PostInstallHandler;
import de.uniulm.omi.cloudiator.lance.lifecycle.handlers.PostStartHandler;
import de.uniulm.omi.cloudiator.lance.lifecycle.handlers.PreInstallHandler;
import de.uniulm.omi.cloudiator.lance.lifecycle.handlers.PreStartHandler;
import de.uniulm.omi.cloudiator.lance.lifecycle.handlers.StartHandler;
import de.uniulm.omi.cloudiator.lance.util.state.StateMachine;
import de.uniulm.omi.cloudiator.lance.util.state.StateMachineBuilder;
import de.uniulm.omi.cloudiator.lance.util.state.TransitionAction;
......@@ -35,9 +29,11 @@ public class LifecycleControllerTransitions {
return transitions.addInitTransition(
transitions.addInstallTransitions(
transitions.addStartTransitions(
transitions.addStopTransitions(
new StateMachineBuilder<>(LifecycleHandlerType.NEW).
addAllState(LifecycleHandlerType.values())
))).build();
)))).build();
}
private StateMachineBuilder<LifecycleHandlerType> addInitTransition(StateMachineBuilder<LifecycleHandlerType> b) {
......@@ -97,4 +93,28 @@ public class LifecycleControllerTransitions {
}
});
}
private StateMachineBuilder<LifecycleHandlerType> addStopTransitions(StateMachineBuilder<LifecycleHandlerType> b) {
return b.addSynchronousTransition(LifecycleHandlerType.POST_START, LifecycleHandlerType.PRE_STOP,
new TransitionAction() {
@Override public void transit(Object[] params) {
PreStopHandler h = store.getHandler(LifecycleHandlerType.PRE_STOP, PreStopHandler.class);
h.execute(ec);
}
}).
addSynchronousTransition(LifecycleHandlerType.PRE_STOP, LifecycleHandlerType.STOP,
new TransitionAction() {
@Override public void transit(Object[] params) {
StopHandler h = store.getHandler(LifecycleHandlerType.STOP, StopHandler.class);
h.execute(ec);
}
}).
addSynchronousTransition(LifecycleHandlerType.STOP, LifecycleHandlerType.POST_STOP,
new TransitionAction() {
@Override public void transit(Object[] params) {
PostStopHandler h = store.getHandler(LifecycleHandlerType.POST_STOP, PostStopHandler.class);
h.execute(ec);
}
});
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment