Commit eb17a260 authored by Daniel Seybold's avatar Daniel Seybold

PS-167 first fixes for stopping component instance

parent 7a3b2def
......@@ -29,10 +29,7 @@ import de.uniulm.omi.cloudiator.lance.lifecycle.LifecycleHandlerType;
import de.uniulm.omi.cloudiator.lance.lifecycle.detector.DetectorState;
import de.uniulm.omi.cloudiator.lance.lifecycle.detector.PortUpdateHandler;
import de.uniulm.omi.cloudiator.lance.lifecycle.detector.StartDetector;
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.PreInstallHandler;
import de.uniulm.omi.cloudiator.lance.lifecycle.handlers.StartHandler;
import de.uniulm.omi.cloudiator.lance.lifecycle.handlers.*;
public final class BashBasedHandlerBuilder {
......@@ -66,6 +63,12 @@ public final class BashBasedHandlerBuilder {
case START:
retVal = new BashStartHandler(os, commands);
break;
case PRE_STOP:
retVal = new BashPreStopHandler(os, commands);
break;
case STOP:
retVal = new BashStopHandler(os, commands);
break;
case INIT:
default:
throw new UnsupportedOperationException();
......@@ -139,12 +142,46 @@ final class BashStartHandler implements StartHandler {
private static final long serialVersionUID = -5666019177853948866L;
private final OperatingSystem os;
private final List<String[]> commands;
BashStartHandler(OperatingSystem osParam, List<String[]> commandsParam) {
os = osParam;
commands = commandsParam;
}
@Override
public void execute(ExecutionContext ec) {
BashExecutionHelper.executeBlockingCommands(os, ec, commands);
}
}
final class BashStopHandler implements StopHandler {
private static final long serialVersionUID = -5666019177853948866L;
private final OperatingSystem os;
private final List<String[]> commands;
BashStopHandler(OperatingSystem osParam, List<String[]> commandsParam) {
os = osParam;
commands = commandsParam;
}
@Override
public void execute(ExecutionContext ec) {
BashExecutionHelper.executeBlockingCommands(os, ec, commands);
}
}
final class BashPreStopHandler implements PreStopHandler {
private static final long serialVersionUID = -5666019177853948866L;
private final OperatingSystem os;
private final List<String[]> commands;
BashPreStopHandler(OperatingSystem osParam, List<String[]> commandsParam) {
os = osParam;
commands = commandsParam;
}
@Override
public void execute(ExecutionContext ec) {
BashExecutionHelper.executeBlockingCommands(os, ec, commands);
......
......@@ -106,6 +106,7 @@ public class PlainContainerLogic implements ContainerLogic, LifecycleActionInter
if(forceShutdown) {
throw new ContainerException("cannot force shutdown in plain container. shutdown will fail.");
}
throw new UnsupportedOperationException("graceful shutdown not implemented.");
}
......
......@@ -114,8 +114,14 @@ public final class LifecycleController {
}
public synchronized void blockingStop() {
throw new UnsupportedOperationException(
"not calling stop handler; this is not part of the state machine (yet).");
//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);
//FIXME: is a stop detector action required at this point?
getLogger().warn("Stopping instance, running PRE_STOP state!");
//run(LifecycleHandlerType.STOP);
//machine.transit(LifecycleHandlerType.STOP);
}
......
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