/** * We group the tasks by the root command id, so that we can identify the commands that were * partially submitted to vdsm */ private Map<Guid, List<AsyncTask>> groupTasksByRootCommandId(List<AsyncTask> tasksInDB) { Map<Guid, List<AsyncTask>> rootCommandIdToCommandsMap = new HashMap<>(); for (AsyncTask task : tasksInDB) { MultiValueMapUtils.addToMap(task.getRootCommandId(), task, rootCommandIdToCommandsMap); } return rootCommandIdToCommandsMap; }
/** * 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 coco Handle to command coordinator * @param creationInfo The Asyc Task Creation info */ public static SPMAsyncTask construct( CommandCoordinator coco, AsyncTaskCreationInfo creationInfo) { 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(coco, creationInfo.getTaskType(), asyncTaskParams, true); }