Search in sources :

Example 1 with CommandMultiAsyncTasks

use of org.ovirt.engine.core.bll.CommandMultiAsyncTasks in project ovirt-engine by oVirt.

the class CommandAsyncTask method concreteStartPollingTask.

@Override
public void concreteStartPollingTask() {
    CommandMultiAsyncTasks entityInfo = getCommandMultiAsyncTasks();
    entityInfo.startPollingTask(getVdsmTaskId());
}
Also used : CommandMultiAsyncTasks(org.ovirt.engine.core.bll.CommandMultiAsyncTasks)

Example 2 with CommandMultiAsyncTasks

use of org.ovirt.engine.core.bll.CommandMultiAsyncTasks 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)

Example 3 with CommandMultiAsyncTasks

use of org.ovirt.engine.core.bll.CommandMultiAsyncTasks in project ovirt-engine by oVirt.

the class CommandAsyncTask method endActionIfNecessary.

private void endActionIfNecessary() {
    CommandMultiAsyncTasks entityInfo = getCommandMultiAsyncTasks();
    if (entityInfo == null) {
        log.warn("CommandAsyncTask::endActionIfNecessary: No info is available for entity '{}', current" + " task ('{}') was probably created while other tasks were in progress, clearing task.", getCommandId(), getVdsmTaskId());
        clearAsyncTask();
    } else if (entityInfo.shouldEndAction() && !hasRunningChildCommands()) {
        log.info("CommandAsyncTask::endActionIfNecessary: All tasks of command '{}' has ended -> executing 'endAction'", getCommandId());
        log.info("CommandAsyncTask::endAction: Ending action for '{}' tasks (command ID: '{}'): calling endAction '.", entityInfo.getTasksCountCurrentActionType(), entityInfo.getCommandId());
        entityInfo.markAllWithAttemptingEndAction();
        ThreadPoolUtil.execute(() -> endCommandAction());
    }
}
Also used : CommandMultiAsyncTasks(org.ovirt.engine.core.bll.CommandMultiAsyncTasks)

Aggregations

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