use of org.ovirt.engine.core.common.job.Step in project ovirt-engine by oVirt.
the class CoCoAsyncTaskHelper method createTask.
/**
* Use this method in order to create task in the AsyncTaskManager in a safe way. If you use
* this method within a certain command, make sure that the command implemented the
* ConcreteCreateTask method.
*
* @param asyncTaskCreationInfo
* info to send to AsyncTaskManager when creating the task.
* @param parentCommand
* ActionType of the command that its EndAction we want to invoke when tasks are finished.
* @param entitiesMap
* Map of entities that are associated with the task
* @return Guid of the created task.
*/
public Guid createTask(Guid taskId, CommandBase<?> command, AsyncTaskCreationInfo asyncTaskCreationInfo, ActionType parentCommand, String description, Map<Guid, VdcObjectType> entitiesMap) {
Step taskStep = ExecutionHandler.getInstance().addTaskStep(command.getExecutionContext(), StepEnum.getStepNameByTaskType(asyncTaskCreationInfo.getTaskType()), description, command.getCommandStepSubjectEntities());
command.getExecutionContext().setStep(taskStep);
if (taskStep != null) {
asyncTaskCreationInfo.setStepId(taskStep.getId());
}
SPMAsyncTask task = concreteCreateTask(taskId, command, asyncTaskCreationInfo, parentCommand);
task.setEntitiesMap(entitiesMap);
AsyncTaskUtils.addOrUpdateTaskInDB(coco.get(), task);
asyncTaskManager.get().lockAndAddTaskToManager(task);
Guid vdsmTaskId = task.getVdsmTaskId();
ExecutionHandler.getInstance().updateStepExternalId(taskStep, vdsmTaskId, ExternalSystemType.VDSM);
return vdsmTaskId;
}
use of org.ovirt.engine.core.common.job.Step in project ovirt-engine by oVirt.
the class StepDaoTest method updateStepProgress.
@Test
public void updateStepProgress() {
Integer newProgress = 74;
Step s = dao.get(FixturesTool.STEP_ID);
assertNotEquals("New progress should be different than the current", newProgress, s.getProgress());
updateStepProgress(FixturesTool.STEP_ID, newProgress);
s = dao.get(FixturesTool.STEP_ID);
assertEquals("New progress should be the same as the current", newProgress, s.getProgress());
}
use of org.ovirt.engine.core.common.job.Step in project ovirt-engine by oVirt.
the class StepDaoTest method diskNullFinishedStepProgress.
@Test
public void diskNullFinishedStepProgress() {
Guid entityId = FixturesTool.FLOATING_DISK_ID;
prepareProgressTest(entityId);
List<Guid> stepIds = Arrays.asList(FixturesTool.STEP_ID, FixturesTool.STEP_ID_2);
stepIds.forEach(x -> {
Step s = dao.get(x);
s.setProgress(null);
s.setStatus(JobExecutionStatus.FINISHED);
dao.update(s);
});
BaseDisk diskImage = getDiskDao().get(entityId);
assertProgress(80, diskImage);
}
use of org.ovirt.engine.core.common.job.Step in project ovirt-engine by oVirt.
the class StepDaoTest method startedStepsByStepSubjectEntityNoStepsHaveStep.
@Test
public void startedStepsByStepSubjectEntityNoStepsHaveStep() {
StepSubjectEntity subjectEntity = prepareStartedStepsByStepSubjectEntityTest();
List<Step> steps = dao.getStartedStepsByStepSubjectEntity(subjectEntity);
assertEquals(1, steps.size());
assertEquals(subjectEntity.getStepId(), steps.get(0).getId());
}
use of org.ovirt.engine.core.common.job.Step in project ovirt-engine by oVirt.
the class StepDaoTest method prepareStartedStepsByStepSubjectEntityTest.
private StepSubjectEntity prepareStartedStepsByStepSubjectEntityTest() {
Guid entityId = Guid.newGuid();
VdcObjectType entityType = VdcObjectType.EXECUTION_HOST;
StepSubjectEntity subjectEntity = new StepSubjectEntity(FixturesTool.STEP_ID, entityType, entityId);
getStepSubjectEntityDao().saveAll(Arrays.asList(subjectEntity));
Step s = dao.get(FixturesTool.STEP_ID);
s.setStatus(JobExecutionStatus.STARTED);
dao.update(s);
return subjectEntity;
}
Aggregations