[Major] Renamed ExecutionHandler.getState() to getExecutionState()

This commit is contained in:
Robert von Burg 2023-02-16 09:59:26 +01:00
parent 7085c18893
commit ec3db2ade0
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
6 changed files with 56 additions and 12 deletions

View File

@ -211,7 +211,7 @@ public class Controller {
return false;
}
ExecutionHandlerState state = this.executionHandler.getState(this.realm);
ExecutionHandlerState state = this.executionHandler.getExecutionState(this.realm);
if (state == ExecutionHandlerState.Paused) {
logger.warn("Ignoring trigger for paused realm " + this.realm);
return false;

View File

@ -552,12 +552,22 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
}
@Override
public ExecutionHandlerState getState(String realm) {
public ExecutionHandlerState getExecutionState() {
return getExecutionState(getDefaultRealm());
}
@Override
public ExecutionHandlerState getExecutionState(String realm) {
return this.statesByRealm.getOrDefault(realm, ExecutionHandlerState.Running);
}
@Override
public void setState(Certificate cert, String realm, ExecutionHandlerState state) {
public void getExecutionState(Certificate cert, ExecutionHandlerState state) {
getExecutionState(cert, getDefaultRealm(), state);
}
@Override
public void getExecutionState(Certificate cert, String realm, ExecutionHandlerState state) {
try (StrolchTransaction tx = openTx(realm, cert, false)) {
Resource executionHandlerConfig = tx.getResourceBy(TYPE_CONFIGURATION,
ExecutionHandler.class.getSimpleName());

View File

@ -363,14 +363,37 @@ public abstract class ExecutionHandler extends StrolchComponent {
public abstract void triggerExecution(String realm);
/**
* Get the sate of the execution handler
* Get the state of the execution handler for the default realm
*
* @return the state of the execution handler
*
* @throws IllegalStateException
* if the default realm is not set!
*/
public abstract ExecutionHandlerState getExecutionState();
/**
* Get the state of the execution handler for the given realm
*
* @param realm
* the realm for which to get the state
*
* @return the state of the execution handler
*/
public abstract ExecutionHandlerState getState(String realm);
public abstract ExecutionHandlerState getExecutionState(String realm);
/**
* Set the state for the default realm
*
* @param cert
* certificate to use
* @param state
* the state to set
*
* @throws IllegalStateException
* if the default realm is not set!
*/
public abstract void getExecutionState(Certificate cert, ExecutionHandlerState state);
/**
* Set the state for the given realm
@ -382,7 +405,18 @@ public abstract class ExecutionHandler extends StrolchComponent {
* @param state
* the state to set
*/
public abstract void setState(Certificate cert, String realm, ExecutionHandlerState state);
public abstract void getExecutionState(Certificate cert, String realm, ExecutionHandlerState state);
/**
* Archives the given {@link Activity} on the default realm
*
* @param activityLoc
* the {@link Locator} of the {@link Activity} to archive
*
* @throws IllegalStateException
* if the default realm is not set!
*/
public abstract void archiveActivity(Locator activityLoc);
/**
* Archives the given {@link Activity}

View File

@ -34,16 +34,16 @@ public class SetExecutionHandlerStateService extends AbstractService<StringMapAr
switch (state) {
case "Running" -> {
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
executionHandler.setState(getCertificate(), realm, ExecutionHandlerState.Running);
executionHandler.getExecutionState(getCertificate(), realm, ExecutionHandlerState.Running);
executionHandler.triggerExecution(realm);
}
case "HaltNew" -> {
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
executionHandler.setState(getCertificate(), realm, ExecutionHandlerState.HaltNew);
executionHandler.getExecutionState(getCertificate(), realm, ExecutionHandlerState.HaltNew);
}
case "Paused" -> {
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
executionHandler.setState(getCertificate(), realm, ExecutionHandlerState.Paused);
executionHandler.getExecutionState(getCertificate(), realm, ExecutionHandlerState.Paused);
}
case "Trigger" -> {
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);

View File

@ -32,7 +32,7 @@ public class StartActivityExecutionService extends AbstractService<LocatorArgume
String realm = StringHelper.isEmpty(arg.realm) ? StrolchConstants.DEFAULT_REALM : arg.realm;
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
ExecutionHandlerState executionHandlerState = executionHandler.getState(getRealmName());
ExecutionHandlerState executionHandlerState = executionHandler.getExecutionState(getRealmName());
if (executionHandlerState != ExecutionHandlerState.Running)
return new StrolchRootElementResult(ServiceResultState.WARNING,
"ExecutionHandler is not running, can not start new jobs!")

View File

@ -58,7 +58,7 @@ public class ControlResource {
.map(activity -> activity.accept(inExecutionActivityToJson(tx.getRealmName(), executionHandler))) //
.collect(JsonArray::new, JsonArray::add, JsonArray::addAll);
ExecutionHandlerState state = executionHandler.getState(tx.getRealmName());
ExecutionHandlerState state = executionHandler.getExecutionState(tx.getRealmName());
return ResponseUtil.toResponse(PARAM_STATE, state.name(), activitiesJ);
}
}
@ -83,7 +83,7 @@ public class ControlResource {
public Response getExecutionHandlerState(@Context HttpServletRequest request, @QueryParam("realm") String realm) {
ExecutionHandler executionHandler = RestfulStrolchComponent.getInstance().getComponent(ExecutionHandler.class);
String state = executionHandler.getState(realm).name();
String state = executionHandler.getExecutionState(realm).name();
return ResponseUtil.toResponse(PARAM_STATE, state);
}