use of org.ovirt.engine.core.compat.TransactionScopeOption 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