@Async public Future<Boolean> stop(String nsr_id, String vnfr_id) { log.debug("Stopping ExecutionTask/CooldownTask for VNFR with id: " + vnfr_id); int i = 60; while (!actionMonitor.isTerminated(vnfr_id) && actionMonitor.getAction(vnfr_id) != Action.INACTIVE && i >= 0) { actionMonitor.terminate(vnfr_id); log.debug( "Waiting for finishing ExecutionTask/Cooldown for VNFR with id: " + vnfr_id + " (" + i + "s)"); log.debug(actionMonitor.toString()); try { Thread.sleep(1_000); } catch (InterruptedException e) { log.error(e.getMessage(), e); } i--; if (i <= 0) { actionMonitor.removeId(vnfr_id); log.error( "Were not able to wait until ExecutionTask finished for VNFR with id: " + vnfr_id); return new AsyncResult<>(false); } } actionMonitor.removeId(vnfr_id); log.info("Stopped ExecutionTask for VNFR with id: " + vnfr_id); return new AsyncResult<>(true); }