use of org.ovirt.engine.core.common.asynctasks.EndedTaskInfo in project ovirt-engine by oVirt.
the class CommandMultiAsyncTasks method getEndedTasksInfo.
public EndedTasksInfo getEndedTasksInfo() {
EndedTasksInfo endedTasksInfo = new EndedTasksInfo();
ArrayList<EndedTaskInfo> endedTaskInfoList = new ArrayList<>();
synchronized (_listTasks) {
ArrayList<CommandAsyncTask> CurrentActionTypeTasks = getCurrentTasks();
for (CommandAsyncTask task : CurrentActionTypeTasks) {
task.setLastStatusAccessTime();
EndedTaskInfo tempVar = new EndedTaskInfo();
tempVar.setTaskStatus(task.getLastTaskStatus());
tempVar.setTaskParameters(task.getParameters());
endedTaskInfoList.add(tempVar);
}
endedTasksInfo.setTasksInfo(endedTaskInfoList);
}
return endedTasksInfo;
}
use of org.ovirt.engine.core.common.asynctasks.EndedTaskInfo in project ovirt-engine by oVirt.
the class CommandAsyncTask method endCommandAction.
private void endCommandAction() {
CommandMultiAsyncTasks entityInfo = getCommandMultiAsyncTasks();
ActionReturnValue actionReturnValue = null;
ExecutionContext context = null;
boolean endActionRuntimeException = false;
AsyncTask dbAsyncTask = getParameters().getDbAsyncTask();
ArrayList<ActionParametersBase> imagesParameters = new ArrayList<>();
for (EndedTaskInfo taskInfo : entityInfo.getEndedTasksInfo().getTasksInfo()) {
ActionParametersBase childTaskParameters = taskInfo.getTaskParameters().getDbAsyncTask().getTaskParameters();
boolean childTaskGroupSuccess = childTaskParameters.getTaskGroupSuccess() && taskInfo.getTaskStatus().getTaskEndedSuccessfully();
childTaskParameters.setTaskGroupSuccess(childTaskGroupSuccess);
if (!childTaskParameters.equals(dbAsyncTask.getActionParameters())) {
imagesParameters.add(childTaskParameters);
}
}
dbAsyncTask.getActionParameters().setImagesParameters(imagesParameters);
try {
log.info("CommandAsyncTask::endCommandAction [within thread] context: Attempting to endAction '{}',", dbAsyncTask.getActionParameters().getCommandType());
try {
actionReturnValue = coco.endAction(this);
} catch (EngineException ex) {
log.error("{}: {}", getErrorMessage(), ex.getMessage());
log.debug("Exception", ex);
} catch (RuntimeException ex) {
log.error(getErrorMessage(), ex);
endActionRuntimeException = true;
}
} catch (RuntimeException Ex2) {
log.error("CommandAsyncTask::endCommandAction [within thread]: An exception has been thrown (not" + " related to 'endAction' itself)", Ex2);
endActionRuntimeException = true;
} finally {
// if a RuntimeExcpetion occurs we clear the task from db and perform no other action
if (endActionRuntimeException) {
handleEndActionRuntimeException(entityInfo, dbAsyncTask);
} else {
boolean isTaskGroupSuccess = dbAsyncTask.getActionParameters().getTaskGroupSuccess();
handleEndActionResult(entityInfo, actionReturnValue, context, isTaskGroupSuccess);
}
}
}
Aggregations