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;
}
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;
}
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;
}
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;
}
Aggregations