Commit de1606f1 authored by Joerg Domaschka's avatar Joerg Domaschka

implemented an error aware state machine including test scripts

parent 1f27c0a1
......@@ -57,6 +57,11 @@ public enum ContainerStatus implements State {
READY,
SHUTTING_DOWN,
DESTROYED,
ERROR,
CREATION_FAILED,
BOOTSTRAPPING_FAILED,
INITIALISATION_FAILED,
UNKNOWN,
;
}
......@@ -20,4 +20,5 @@ package de.uniulm.omi.cloudiator.lance.util.state;
public interface State {
// a simple marker interface //
// boolean isErrorState();
}
......@@ -44,7 +44,8 @@ import static de.uniulm.omi.cloudiator.lance.container.standard.StandardContaine
// FIXME: update component instance status each time a state has been reached
// FIXME: introduce error states to life cycle handling
// FIXME: introduce error states to life cycle handling
@Deprecated
public final class StandardContainer<T extends ContainerLogic> implements ContainerController {
private static final Logger LOGGER = LoggerFactory.getLogger(ContainerController.class);
......
......@@ -20,6 +20,7 @@ package de.uniulm.omi.cloudiator.lance.util;
import java.util.concurrent.FutureTask;
@Deprecated
public class AsyncRunner implements Runnable {
public interface Setter {
......
......@@ -28,6 +28,7 @@ import java.util.concurrent.Future;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated
public final class StateMachine<T extends Enum<?> & State > {
private final static Logger LOGGER = LoggerFactory.getLogger(StateMachine.class);
......
......@@ -23,7 +23,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Deprecated
public final class StateMachineBuilder<T extends Enum<?> & State > {
private final T init;
......
......@@ -20,6 +20,7 @@ package de.uniulm.omi.cloudiator.lance.util.state;
import java.util.concurrent.Future;
@Deprecated
public interface StateSetter<T extends Enum<?> & State >{
public void setIntermediateState(T state, Future<?> future);
......
......@@ -66,13 +66,21 @@ public final class StateTransition<T extends Enum<?> & State > {
void execute(final StateSetter<T> setter, final Object[] params) {
if(isSynchronous()) {
action.transit(params);
try {
action.transit(params);
} catch (TransitionException te) {
throw new RuntimeException(te);
}
setter.setFinalState(to);
} else {
Thread t = AsyncRunner.createWrappedStateRunner(
new Setter() {
@Override public void set() {
action.transit(params);
@Override public void set() {
try {
action.transit(params);
} catch (TransitionException te) {
throw new RuntimeException(te);
}
setter.setFinalState(to);
}
},
......
......@@ -20,5 +20,13 @@ package de.uniulm.omi.cloudiator.lance.util.state;
public interface TransitionAction {
public void transit(Object[] params);
/**
*
* @param params the parameters passed on to the action
* @throws TransitionException thrown when an unrecoverable error has happened
* that prevents the transition from being completed. This will trigger the
* execution of the exception handler if available and pass on to the error
* state (if available).
*/
public void transit(Object[] params) throws TransitionException ;
}
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