[Minor] Don't restart activities in error

This commit is contained in:
Robert von Burg 2021-08-12 09:20:08 +02:00
parent bca8b16184
commit 9c11f4502e
1 changed files with 11 additions and 12 deletions

View File

@ -176,24 +176,23 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
// iterate all activities
tx.streamActivities().forEach(activity -> {
if (activity.isReadOnly())
activity = activity.getClone(true);
// we only want to restart activities which were in execution
State state = activity.getState();
if (!state.inExecutionPhase())
return;
logger.info("Starting Execution of " + activity.getLocator() + " on realm " + realmName);
if (activity.isReadOnly())
activity = activity.getClone(true);
logger.info("Restarting Execution of " + activity.getLocator() + " on realm " + realmName);
// in execution actions need to be in state STOPPED to restart
activity.findActionsDeep(a -> a.getState().inExecutionPhase()).forEach(a -> {
// but not if is in error:
if (state != State.ERROR)
a.setState(State.STOPPED);
});
// Activities need to be in state STOPPED to restart
if (state == State.ERROR) {
activity.getActionsWithState(State.ERROR).forEach(a -> a.setState(State.STOPPED));
} else if (state == State.WARNING) {
activity.getActionsWithState(State.WARNING).forEach(a -> a.setState(State.STOPPED));
} else if (state == State.EXECUTION) {
activity.getActionsWithState(State.EXECUTION).forEach(a -> a.setState(State.STOPPED));
}
tx.update(activity);
// register for execution