[Major] Renamed ExecutionHandler.getState() to getExecutionState()
This commit is contained in:
parent
7085c18893
commit
ec3db2ade0
|
@ -211,7 +211,7 @@ public class Controller {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutionHandlerState state = this.executionHandler.getState(this.realm);
|
ExecutionHandlerState state = this.executionHandler.getExecutionState(this.realm);
|
||||||
if (state == ExecutionHandlerState.Paused) {
|
if (state == ExecutionHandlerState.Paused) {
|
||||||
logger.warn("Ignoring trigger for paused realm " + this.realm);
|
logger.warn("Ignoring trigger for paused realm " + this.realm);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -552,12 +552,22 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
return this.statesByRealm.getOrDefault(realm, ExecutionHandlerState.Running);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)) {
|
try (StrolchTransaction tx = openTx(realm, cert, false)) {
|
||||||
Resource executionHandlerConfig = tx.getResourceBy(TYPE_CONFIGURATION,
|
Resource executionHandlerConfig = tx.getResourceBy(TYPE_CONFIGURATION,
|
||||||
ExecutionHandler.class.getSimpleName());
|
ExecutionHandler.class.getSimpleName());
|
||||||
|
|
|
@ -363,14 +363,37 @@ public abstract class ExecutionHandler extends StrolchComponent {
|
||||||
public abstract void triggerExecution(String realm);
|
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
|
* @param realm
|
||||||
* the realm for which to get the state
|
* the realm for which to get the state
|
||||||
*
|
*
|
||||||
* @return the state of the execution handler
|
* @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
|
* Set the state for the given realm
|
||||||
|
@ -382,7 +405,18 @@ public abstract class ExecutionHandler extends StrolchComponent {
|
||||||
* @param state
|
* @param state
|
||||||
* the state to set
|
* 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}
|
* Archives the given {@link Activity}
|
||||||
|
|
|
@ -34,16 +34,16 @@ public class SetExecutionHandlerStateService extends AbstractService<StringMapAr
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case "Running" -> {
|
case "Running" -> {
|
||||||
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
|
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
|
||||||
executionHandler.setState(getCertificate(), realm, ExecutionHandlerState.Running);
|
executionHandler.getExecutionState(getCertificate(), realm, ExecutionHandlerState.Running);
|
||||||
executionHandler.triggerExecution(realm);
|
executionHandler.triggerExecution(realm);
|
||||||
}
|
}
|
||||||
case "HaltNew" -> {
|
case "HaltNew" -> {
|
||||||
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
|
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
|
||||||
executionHandler.setState(getCertificate(), realm, ExecutionHandlerState.HaltNew);
|
executionHandler.getExecutionState(getCertificate(), realm, ExecutionHandlerState.HaltNew);
|
||||||
}
|
}
|
||||||
case "Paused" -> {
|
case "Paused" -> {
|
||||||
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
|
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
|
||||||
executionHandler.setState(getCertificate(), realm, ExecutionHandlerState.Paused);
|
executionHandler.getExecutionState(getCertificate(), realm, ExecutionHandlerState.Paused);
|
||||||
}
|
}
|
||||||
case "Trigger" -> {
|
case "Trigger" -> {
|
||||||
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
|
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class StartActivityExecutionService extends AbstractService<LocatorArgume
|
||||||
String realm = StringHelper.isEmpty(arg.realm) ? StrolchConstants.DEFAULT_REALM : arg.realm;
|
String realm = StringHelper.isEmpty(arg.realm) ? StrolchConstants.DEFAULT_REALM : arg.realm;
|
||||||
|
|
||||||
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
|
ExecutionHandler executionHandler = getContainer().getComponent(ExecutionHandler.class);
|
||||||
ExecutionHandlerState executionHandlerState = executionHandler.getState(getRealmName());
|
ExecutionHandlerState executionHandlerState = executionHandler.getExecutionState(getRealmName());
|
||||||
if (executionHandlerState != ExecutionHandlerState.Running)
|
if (executionHandlerState != ExecutionHandlerState.Running)
|
||||||
return new StrolchRootElementResult(ServiceResultState.WARNING,
|
return new StrolchRootElementResult(ServiceResultState.WARNING,
|
||||||
"ExecutionHandler is not running, can not start new jobs!")
|
"ExecutionHandler is not running, can not start new jobs!")
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class ControlResource {
|
||||||
.map(activity -> activity.accept(inExecutionActivityToJson(tx.getRealmName(), executionHandler))) //
|
.map(activity -> activity.accept(inExecutionActivityToJson(tx.getRealmName(), executionHandler))) //
|
||||||
.collect(JsonArray::new, JsonArray::add, JsonArray::addAll);
|
.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);
|
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) {
|
public Response getExecutionHandlerState(@Context HttpServletRequest request, @QueryParam("realm") String realm) {
|
||||||
|
|
||||||
ExecutionHandler executionHandler = RestfulStrolchComponent.getInstance().getComponent(ExecutionHandler.class);
|
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);
|
return ResponseUtil.toResponse(PARAM_STATE, state);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue