Search in sources :

Example 21 with AsyncTask

use of org.ovirt.engine.core.common.businessentities.AsyncTask in project ovirt-engine by oVirt.

the class CoCoAsyncTaskHelper method getByVdsmTaskId.

public AsyncTask getByVdsmTaskId(Guid vdsmTaskId) {
    AsyncTask asyncTask = DbFacade.getInstance().getAsyncTaskDao().getByVdsmTaskId(vdsmTaskId);
    if (asyncTask != null) {
        asyncTask.setRootCmdEntity(getCommandEntity(asyncTask.getRootCommandId()));
        asyncTask.setChildCmdEntity(getCommandEntity(asyncTask.getCommandId()));
    }
    return asyncTask;
}
Also used : AsyncTask(org.ovirt.engine.core.common.businessentities.AsyncTask)

Example 22 with AsyncTask

use of org.ovirt.engine.core.common.businessentities.AsyncTask in project ovirt-engine by oVirt.

the class CoCoAsyncTaskHelper method getAsyncTaskFromDb.

public AsyncTask getAsyncTaskFromDb(Guid asyncTaskId) {
    AsyncTask asyncTask = DbFacade.getInstance().getAsyncTaskDao().get(asyncTaskId);
    if (asyncTask != null) {
        asyncTask.setRootCmdEntity(getCommandEntity(asyncTask.getRootCommandId()));
        asyncTask.setChildCmdEntity(getCommandEntity(asyncTask.getCommandId()));
    }
    return asyncTask;
}
Also used : AsyncTask(org.ovirt.engine.core.common.businessentities.AsyncTask)

Example 23 with AsyncTask

use of org.ovirt.engine.core.common.businessentities.AsyncTask in project ovirt-engine by oVirt.

the class CoCoAsyncTaskHelper method createAsyncTask.

public AsyncTask createAsyncTask(CommandBase<?> command, AsyncTaskCreationInfo asyncTaskCreationInfo, ActionType parentCommand) {
    ActionParametersBase parentParameters = command.getParentParameters() == null ? command.getParentParameters(parentCommand) : command.getParentParameters();
    Guid parentCommandId = parentParameters == null ? Guid.Empty : parentParameters.getCommandId();
    if (ActionType.Unknown.equals(command.getParameters().getCommandType())) {
        command.getParameters().setCommandType(command.getActionType());
    }
    AsyncTask asyncTask = new AsyncTask(AsyncTaskResultEnum.success, AsyncTaskStatusEnum.running, command.getUserId(), asyncTaskCreationInfo.getVdsmTaskId(), asyncTaskCreationInfo.getStepId(), asyncTaskCreationInfo.getStoragePoolID(), asyncTaskCreationInfo.getTaskType(), getParentCommandEntity(parentCommandId, parentCommand, parentParameters), getChildCommandEntity(command, parentCommand));
    return asyncTask;
}
Also used : AsyncTask(org.ovirt.engine.core.common.businessentities.AsyncTask) Guid(org.ovirt.engine.core.compat.Guid) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 24 with AsyncTask

use of org.ovirt.engine.core.common.businessentities.AsyncTask in project ovirt-engine by oVirt.

the class CommandBase method persistAsyncTaskPlaceHolder.

public Guid persistAsyncTaskPlaceHolder(ActionType parentCommand, final String taskKey) {
    Guid taskId = Guid.Empty;
    try {
        AsyncTaskCreationInfo creationInfo = new AsyncTaskCreationInfo();
        creationInfo.setTaskType(getTaskType());
        final AsyncTask task = createAsyncTask(creationInfo, parentCommand);
        taskId = task.getTaskId();
        TransactionScopeOption scopeOption = getTransactive() ? TransactionScopeOption.RequiresNew : TransactionScopeOption.Required;
        TransactionSupport.executeInScope(scopeOption, () -> {
            saveTaskAndPutInMap(taskKey, task);
            return null;
        });
        addToReturnValueTaskPlaceHolderIdList(taskId);
    } catch (RuntimeException ex) {
        log.error("Error during persistAsyncTaskPlaceHolder for command '{}': {}", getClass().getName(), ex.getMessage());
        log.error("Exception", ex);
    }
    return taskId;
}
Also used : TransactionScopeOption(org.ovirt.engine.core.compat.TransactionScopeOption) AsyncTaskCreationInfo(org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo) AsyncTask(org.ovirt.engine.core.common.businessentities.AsyncTask) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

AsyncTask (org.ovirt.engine.core.common.businessentities.AsyncTask)24 Test (org.junit.Test)8 Guid (org.ovirt.engine.core.compat.Guid)7 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)5 ArrayList (java.util.ArrayList)4 AsyncTaskCreationInfo (org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Before (org.junit.Before)1 CommandMultiAsyncTasks (org.ovirt.engine.core.bll.CommandMultiAsyncTasks)1 ExecutionContext (org.ovirt.engine.core.bll.job.ExecutionContext)1 CommandCoordinator (org.ovirt.engine.core.bll.tasks.interfaces.CommandCoordinator)1 SPMTask (org.ovirt.engine.core.bll.tasks.interfaces.SPMTask)1 MultipleVmsValidator (org.ovirt.engine.core.bll.validator.MultipleVmsValidator)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1