Search in sources :

Example 1 with EndedTaskInfo

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;
}
Also used : CommandAsyncTask(org.ovirt.engine.core.bll.tasks.CommandAsyncTask) EndedTasksInfo(org.ovirt.engine.core.common.asynctasks.EndedTasksInfo) ArrayList(java.util.ArrayList) EndedTaskInfo(org.ovirt.engine.core.common.asynctasks.EndedTaskInfo)

Example 2 with EndedTaskInfo

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);
        }
    }
}
Also used : CommandMultiAsyncTasks(org.ovirt.engine.core.bll.CommandMultiAsyncTasks) ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) AsyncTask(org.ovirt.engine.core.common.businessentities.AsyncTask) ArrayList(java.util.ArrayList) EngineException(org.ovirt.engine.core.common.errors.EngineException) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) EndedTaskInfo(org.ovirt.engine.core.common.asynctasks.EndedTaskInfo)

Aggregations

ArrayList (java.util.ArrayList)2 EndedTaskInfo (org.ovirt.engine.core.common.asynctasks.EndedTaskInfo)2 CommandMultiAsyncTasks (org.ovirt.engine.core.bll.CommandMultiAsyncTasks)1 ExecutionContext (org.ovirt.engine.core.bll.job.ExecutionContext)1 CommandAsyncTask (org.ovirt.engine.core.bll.tasks.CommandAsyncTask)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 EndedTasksInfo (org.ovirt.engine.core.common.asynctasks.EndedTasksInfo)1 AsyncTask (org.ovirt.engine.core.common.businessentities.AsyncTask)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1