@Override
public void restart() {
String mode = getConfig(RESTART_MODE);
if (mode==null) {
throw new UnsupportedOperationException("Restart not supported for this cluster: "+RESTART_MODE.getName()+" is not configured.");
}
if ("off".equalsIgnoreCase(mode)) {
throw new UnsupportedOperationException("Restart not supported for this cluster.");
}
if ("sequential".equalsIgnoreCase(mode)) {
ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
DynamicTasks.queue(Effectors.invocationSequential(Startable.RESTART, null,
Iterables.filter(getChildren(), Predicates.and(Predicates.instanceOf(Startable.class), EntityPredicates.isManaged()))));
} else if ("parallel".equalsIgnoreCase(mode)) {
ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
for (Entity member : Iterables.filter(getChildren(), Predicates.and(Predicates.instanceOf(Startable.class), EntityPredicates.isManaged()))) {
DynamicTasks.queue(newThrottledEffectorTask(member, Startable.RESTART, Collections.emptyMap()));
}
} else {
throw new IllegalArgumentException("Unknown "+RESTART_MODE.getName()+" '"+mode+"'");
}
DynamicTasks.waitForLast();
ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
}