public synchronized ArrayList<AsyncTaskStatus> pollTasks(ArrayList<Guid> vdsmTaskIdList) { ArrayList<AsyncTaskStatus> returnValue = new ArrayList<>(); if (vdsmTaskIdList != null && vdsmTaskIdList.size() > 0) { for (Guid vdsmTaskId : vdsmTaskIdList) { if (_tasks.containsKey(vdsmTaskId)) { // task is still running or is still in the cache: _tasks.get(vdsmTaskId).setLastStatusAccessTime(); returnValue.add(_tasks.get(vdsmTaskId).getLastTaskStatus()); } else { // task doesn't exist in the manager (shouldn't happen) -> // assume it has been ended successfully. log.warn( "Polling tasks. Task ID '{}' doesn't exist in the manager -> assuming 'finished'.", vdsmTaskId); AsyncTaskStatus tempVar = new AsyncTaskStatus(); tempVar.setStatus(AsyncTaskStatusEnum.finished); tempVar.setResult(AsyncTaskResultEnum.success); returnValue.add(tempVar); } } } return returnValue; }
public void logAndFailPartiallySubmittedTaskOfCommand(final AsyncTask task, String message) { log.info( "Failing partially submitted task AsyncTaskType '{}': Task '{}' Parent Command '{}'", task.getTaskType(), task.getTaskId(), task.getActionType()); task.getTaskParameters().setTaskGroupSuccess(false); if (task.getActionType() == VdcActionType.Unknown) { removeTaskFromDbByTaskId(task.getTaskId()); log.info( "Not calling endAction for partially submitted task and AsyncTaskType '{}': Task '{}' Parent Command '{}'", task.getTaskType(), task.getTaskId(), task.getActionType()); return; } log.info( "Calling updateTask for partially submitted task and AsyncTaskType '{}': Task '{}' Parent Command" + " '{}' Parameters class '{}'", task.getTaskType(), task.getTaskId(), task.getActionType()); AsyncTaskCreationInfo creationInfo = new AsyncTaskCreationInfo(Guid.Empty, task.getTaskType(), task.getStoragePoolId()); SPMTask spmTask = coco.construct(creationInfo, task); AsyncTaskStatus failureStatus = new AsyncTaskStatus(); failureStatus.setStatus(AsyncTaskStatusEnum.finished); failureStatus.setResult(AsyncTaskResultEnum.failure); failureStatus.setMessage(message); spmTask.setState(AsyncTaskState.Ended); spmTask.setLastTaskStatus(failureStatus); spmTask.updateTask(failureStatus); }