Ejemplo n.º 1
0
 public void executeCooldown(String nsr_id, String vnfr_id, long cooldown) {
   log.info("[EXECUTOR] START_COOLDOWN " + new Date().getTime());
   if (actionMonitor.isTerminating(vnfr_id)) {
     actionMonitor.finishedAction(vnfr_id, Action.TERMINATED);
     return;
   }
   log.info("Starting CooldownTask for VNFR with id: " + vnfr_id);
   if (actionMonitor.requestAction(vnfr_id, Action.COOLDOWN)) {
     log.debug("Creating new CooldownTask for VNFR with id: " + vnfr_id);
     CooldownTask cooldownTask =
         new CooldownTask(nsr_id, vnfr_id, cooldown, executionEngine, actionMonitor);
     taskScheduler.execute(cooldownTask);
   } else {
     if (actionMonitor.getAction(vnfr_id) == Action.COOLDOWN) {
       log.debug(
           "Waiting already for Cooldown for VNFR with id: "
               + vnfr_id
               + ". Cannot create another ExecutionTask for VNFR with id: "
               + vnfr_id);
     } else if (actionMonitor.getAction(vnfr_id) == Action.SCALE) {
       log.debug("VNFR with id: " + vnfr_id + " is still in Scaling.");
     } else {
       log.debug(actionMonitor.toString());
     }
   }
 }
Ejemplo n.º 2
0
 @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);
 }
Ejemplo n.º 3
0
 public void executeActions(
     String nsr_id, String vnfr_id, Set<ScalingAction> actions, long cooldown) {
   log.info("[EXECUTOR] RECEIVED_ACTION " + new Date().getTime());
   log.info(
       "Processing execution request of ScalingActions: "
           + actions
           + " for VNFR with id: "
           + vnfr_id);
   if (actionMonitor.requestAction(vnfr_id, Action.SCALE)) {
     log.debug(
         "Creating new ExecutionTask of ScalingActions: "
             + actions
             + " for VNFR with id: "
             + vnfr_id);
     ExecutionTask executionTask =
         new ExecutionTask(nsr_id, vnfr_id, actions, cooldown, executionEngine, actionMonitor);
     taskScheduler.execute(executionTask);
   } else {
     if (actionMonitor.getAction(vnfr_id) == Action.SCALE) {
       log.debug(
           "Processing already an execution request for VNFR with id: "
               + vnfr_id
               + ". Cannot create another ExecutionTask for VNFR with id: "
               + vnfr_id);
     } else if (actionMonitor.getAction(vnfr_id) == Action.COOLDOWN) {
       log.debug(
           "Waiting for Cooldown for VNFR with id: "
               + vnfr_id
               + ". Cannot create another ExecutionTask for VNFR with id: "
               + vnfr_id);
     } else {
       log.warn(
           "Problem while starting ExecutionThread. Internal Status is: "
               + actionMonitor.getAction(vnfr_id));
     }
   }
 }