use of org.ovirt.engine.core.common.asynctasks.AsyncTaskParameters in project ovirt-engine by oVirt.
the class AsyncTaskFactory method construct.
/**
* Constructs a task based on creation info (task type and task parameters
* as retrieved from the vdsm). Use in order to construct tasks when service
* is initializing.
* @param creationInfo
* The Asyc Task Creation info
*/
public SPMAsyncTask construct(AsyncTaskCreationInfo creationInfo) {
CommandCoordinator coco = cocoInstance.get();
AsyncTask asyncTask = coco.getByVdsmTaskId(creationInfo.getVdsmTaskId());
if (asyncTask == null || asyncTask.getActionParameters() == null) {
asyncTask = new AsyncTask(AsyncTaskResultEnum.success, AsyncTaskStatusEnum.running, Guid.Empty, creationInfo.getVdsmTaskId(), creationInfo.getStepId(), creationInfo.getStoragePoolID(), creationInfo.getTaskType(), getCommandEntity(coco, asyncTask == null ? Guid.newGuid() : asyncTask.getRootCommandId()), getCommandEntity(coco, asyncTask == null ? Guid.newGuid() : asyncTask.getCommandId()));
creationInfo.setTaskType(AsyncTaskType.unknown);
}
AsyncTaskParameters asyncTaskParams = new AsyncTaskParameters(creationInfo, asyncTask);
return construct(creationInfo.getTaskType(), asyncTaskParams, true);
}
use of org.ovirt.engine.core.common.asynctasks.AsyncTaskParameters in project ovirt-engine by oVirt.
the class CoCoAsyncTaskHelper method concreteCreateTask.
/**
* Create the {@link SPMAsyncTask} object to be run
* @param taskId the id of the async task place holder in the database
* @param asyncTaskCreationInfo Info on how to create the task
* @param parentCommand The type of command issuing the task
* @return An {@link SPMAsyncTask} object representing the task to be run
*/
public SPMAsyncTask concreteCreateTask(Guid taskId, CommandBase<?> command, AsyncTaskCreationInfo asyncTaskCreationInfo, ActionType parentCommand) {
AsyncTaskParameters p = new AsyncTaskParameters(asyncTaskCreationInfo, getAsyncTask(taskId, command, asyncTaskCreationInfo, parentCommand));
p.setEntityInfo(command.getParameters().getEntityInfo());
return createTask(internalGetTaskType(command), p);
}
use of org.ovirt.engine.core.common.asynctasks.AsyncTaskParameters in project ovirt-engine by oVirt.
the class SPMAsyncTask method isTaskOverPrePollingLapse.
/**
* Use this to hold unknown tasks from polling, to overcome bz673695 without a complete re-haul to the
* AsyncTaskManager and CommandBase.
* TODO remove this and re-factor {@link org.ovirt.engine.core.bll.tasks.AsyncTaskManager}
* @return true when the time passed after creating the task is bigger than
* <code>ConfigValues.UnknownTaskPrePollingLapse</code>
* @see org.ovirt.engine.core.bll.tasks.AsyncTaskManager
* @see org.ovirt.engine.core.bll.CommandBase
* @since 3.0
*/
boolean isTaskOverPrePollingLapse() {
AsyncTaskParameters parameters = getParameters();
long taskStartTime = parameters.getDbAsyncTask().getStartTime().getTime();
Integer prePollingPeriod = Config.<Integer>getValue(UnknownTaskPrePollingLapse);
boolean idlePeriodPassed = System.currentTimeMillis() - taskStartTime > prePollingPeriod;
log.info("Task id '{}' {}. Pre-polling period is {} millis. ", parameters.getVdsmTaskId(), idlePeriodPassed ? "has passed pre-polling period time and should be polled" : "is in pre-polling period and should not be polled", prePollingPeriod);
return idlePeriodPassed;
}
Aggregations