Search in sources :

Example 1 with TransactionScopeOption

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

AsyncTaskCreationInfo (org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo)1 AsyncTask (org.ovirt.engine.core.common.businessentities.AsyncTask)1 Guid (org.ovirt.engine.core.compat.Guid)1 TransactionScopeOption (org.ovirt.engine.core.compat.TransactionScopeOption)1