From e37aaa412f5022aa4c2378c83fbc0854afd8bce7 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Tue, 18 Feb 2020 20:05:50 +0100 Subject: [PATCH] [Fix] Fixed some execution issues --- .../execution/EventBasedExecutionHandler.java | 4 +++- .../execution/command/ArchiveActivityCommand.java | 2 ++ .../execution/policy/ReservationExecution.java | 14 +++----------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/li.strolch.service/src/main/java/li/strolch/execution/EventBasedExecutionHandler.java b/li.strolch.service/src/main/java/li/strolch/execution/EventBasedExecutionHandler.java index 4c4718f79..2780788d1 100644 --- a/li.strolch.service/src/main/java/li/strolch/execution/EventBasedExecutionHandler.java +++ b/li.strolch.service/src/main/java/li/strolch/execution/EventBasedExecutionHandler.java @@ -118,10 +118,12 @@ public class EventBasedExecutionHandler extends ExecutionHandler { @Override public void removeFromExecution(Controller controller) { - logger.info("Removing controller " + controller.getLocator() + " from execution..."); if (this.controllers.removeElement(controller.getRealm(), controller.getLocator()) != null) { logger.info("Removed controller " + controller.getLocator() + " from execution."); getExecutor().submit(() -> notifyObserverRemove(controller)); + } else { + logger.error( + "Controller " + controller.getRealm() + " " + controller.getLocator() + " was already removed."); } } diff --git a/li.strolch.service/src/main/java/li/strolch/execution/command/ArchiveActivityCommand.java b/li.strolch.service/src/main/java/li/strolch/execution/command/ArchiveActivityCommand.java index 6bc8dfd9d..d8a98fe51 100644 --- a/li.strolch.service/src/main/java/li/strolch/execution/command/ArchiveActivityCommand.java +++ b/li.strolch.service/src/main/java/li/strolch/execution/command/ArchiveActivityCommand.java @@ -29,6 +29,8 @@ public class ArchiveActivityCommand extends Command { @Override public void doCommand() { + tx().lock(this.activityLoc); + Activity activity = tx().getActivityBy(this.activityLoc.get(1), this.activityLoc.get(2)); if (activity == null) { logger.error("Activity " + this.activityLoc + " does not exist anymore, can not archive!"); diff --git a/li.strolch.service/src/main/java/li/strolch/execution/policy/ReservationExecution.java b/li.strolch.service/src/main/java/li/strolch/execution/policy/ReservationExecution.java index da19a91ac..ef6a96559 100644 --- a/li.strolch.service/src/main/java/li/strolch/execution/policy/ReservationExecution.java +++ b/li.strolch.service/src/main/java/li/strolch/execution/policy/ReservationExecution.java @@ -4,7 +4,6 @@ import static li.strolch.model.StrolchModelConstants.BAG_PARAMETERS; import static li.strolch.runtime.StrolchConstants.PolicyConstants.*; import li.strolch.exception.StrolchModelException; -import li.strolch.model.Locator; import li.strolch.model.Resource; import li.strolch.model.State; import li.strolch.model.activity.Action; @@ -24,8 +23,7 @@ import li.strolch.runtime.StrolchConstants; * *

* Note: the reservation is done for {@link Action} of type {@link StrolchConstants.PolicyConstants#TYPE_RESERVE} - * and releasing is done for - * {@link Action} of type {@link StrolchConstants.PolicyConstants#TYPE_RELEASE} + * and releasing is done for {@link Action} of type {@link StrolchConstants.PolicyConstants#TYPE_RELEASE} *

* * @author Robert von Burg @@ -72,14 +70,8 @@ public class ReservationExecution extends DurationExecution { case TYPE_RESERVE: case TYPE_RELEASE: - boolean isReserve = action.getType().equals(TYPE_RESERVE); - setReservation(action, isReserve); - - String realmName = tx().getRealmName(); - Locator locator = action.getLocator(); - getDelayedExecutionTimer().execute(realmName, getContainer(), locator, 0L); - - setActionState(action, State.EXECUTION); + // async to executed only causes trouble =)) + toExecuted(action); break; default: