예제 #1
0
  private AsyncTaskManager(CommandCoordinator coco) {
    this.coco = coco;
    _tasks = new ConcurrentHashMap<>();

    SchedulerUtil scheduler = Injector.get(SchedulerUtilQuartzImpl.class);
    scheduler.scheduleAFixedDelayJob(
        this,
        "timerElapsed",
        new Class[] {},
        new Object[] {},
        Config.<Integer>getValue(ConfigValues.AsyncTaskPollingRate),
        Config.<Integer>getValue(ConfigValues.AsyncTaskPollingRate),
        TimeUnit.SECONDS);

    scheduler.scheduleAFixedDelayJob(
        this,
        "cacheTimerElapsed",
        new Class[] {},
        new Object[] {},
        Config.<Integer>getValue(ConfigValues.AsyncTaskStatusCacheRefreshRateInSeconds),
        Config.<Integer>getValue(ConfigValues.AsyncTaskStatusCacheRefreshRateInSeconds),
        TimeUnit.SECONDS);
    _cacheTimeInMinutes =
        Config.<Integer>getValue(ConfigValues.AsyncTaskStatusCachingTimeInMinutes);
  }
예제 #2
0
  private void processOnVmStopInternal(final Collection<Guid> vmIds, final Guid hostId) {
    for (Guid vmId : vmIds) {
      backend.runInternalAction(
          VdcActionType.ProcessDownVm, new ProcessDownVmParameters(vmId, true));
    }

    HostDeviceManager hostDeviceManager = Injector.get(HostDeviceManager.class);
    hostDeviceManager.refreshHostIfAnyVmHasHostDevices(vmIds, hostId);
  }
예제 #3
0
  private void cleanZombieTasks() {
    long maxTime =
        DateTime.getNow()
            .addMinutes(
                -1 * Config.<Integer>getValue(ConfigValues.AsyncTaskZombieTaskLifeInMinutes))
            .getTime();
    for (SPMTask task : _tasks.values()) {

      if (task.getParameters().getDbAsyncTask().getStartTime().getTime() < maxTime) {
        AuditLogableBase logable = Injector.injectMembers(new AuditLogableBase());
        logable.addCustomValue(
            "CommandName", task.getParameters().getDbAsyncTask().getActionType().toString());
        logable.addCustomValue(
            "Date", task.getParameters().getDbAsyncTask().getStartTime().toString());

        // if task is not finish and not unknown then it's in running
        // status
        if (task.getLastTaskStatus().getStatus() != AsyncTaskStatusEnum.finished
            && task.getLastTaskStatus().getStatus() != AsyncTaskStatusEnum.unknown) {
          // mark it as a zombie task, Will result in failure of the command
          task.setZombieTask(true);
          auditLogDirector.log(logable, AuditLogType.TASK_STOPPING_ASYNC_TASK);

          log.info(
              "Cleaning zombie tasks: Stopping async task '{}' that started at '{}'",
              task.getParameters().getDbAsyncTask().getActionType(),
              task.getParameters().getDbAsyncTask().getStartTime());

          task.stopTask(true);
        } else {
          auditLogDirector.log(logable, AuditLogType.TASK_CLEARING_ASYNC_TASK);

          log.info(
              "Cleaning zombie tasks: Clearing async task '{}' that started at '{}'",
              task.getParameters().getDbAsyncTask().getActionType(),
              task.getParameters().getDbAsyncTask().getStartTime());

          task.clearAsyncTask(true);
        }
      }
    }
  }