use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class GlusterTasksSyncJob method createJobToMonitor.
private void createJobToMonitor(Cluster cluster, GlusterAsyncTask task) {
if (!isTaskToBeMonitored(task)) {
// there's no need to monitor jobs that are failed or completed
return;
}
StepEnum step = task.getType().getStep();
ActionType actionType;
switch(step) {
case REBALANCING_VOLUME:
actionType = ActionType.StartRebalanceGlusterVolume;
break;
case REMOVING_BRICKS:
actionType = ActionType.StartRemoveGlusterVolumeBricks;
break;
default:
actionType = ActionType.Unknown;
}
String volumeName = task.getTaskParameters().getVolumeName();
GlusterVolumeEntity vol = volumeDao.getByName(cluster.getId(), volumeName);
if (vol == null) {
log.info("Volume '{}' does not exist yet for task detected from CLI '{}', not adding to engine", volumeName, task);
return;
}
Guid jobId = addJob(cluster, task, actionType, vol);
Guid execStepId = addExecutingStep(jobId);
Guid asyncStepId = addAsyncTaskStep(cluster, task, step, execStepId);
Step asyncStep = stepDao.get(asyncStepId);
executionHandler.updateStepExternalId(asyncStep, task.getTaskId(), ExternalSystemType.GLUSTER);
updateVolumeBricksAndLock(cluster, task, vol);
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class CommandBase method withRootCommandInfo.
protected <P extends ActionParametersBase> P withRootCommandInfo(P params, ActionType actionType) {
ActionType parentCommand = isExecutedAsChildCommand() ? getParameters().getParentCommand() : actionType;
params.setParentParameters(getParametersForTask(parentCommand, getParameters()));
params.setParentCommand(parentCommand);
return params;
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class CoCoAsyncTaskHelper method endAction.
public ActionReturnValue endAction(SPMTask task) {
AsyncTask dbAsyncTask = task.getParameters().getDbAsyncTask();
ActionType actionType = getEndActionType(dbAsyncTask);
ActionParametersBase parameters = dbAsyncTask.getActionParameters();
CommandBase<?> command = CommandHelper.buildCommand(actionType, parameters, coco.get().retrieveCommandContext(dbAsyncTask.getRootCommandId()).getExecutionContext(), coco.get().getCommandStatus(dbAsyncTask.getCommandId()));
return new DecoratedCommand<>(command).endAction();
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class CommandAsyncTask method handleEndActionRuntimeException.
private void handleEndActionRuntimeException(CommandMultiAsyncTasks commandInfo, AsyncTask dbAsyncTask) {
try {
ActionType actionType = getParameters().getDbAsyncTask().getActionType();
log.info("CommandAsyncTask::HandleEndActionResult: endAction for action type '{}' threw an" + " unrecoverable RuntimeException the task will be cleared.", actionType);
commandInfo.clearTaskByVdsmTaskId(dbAsyncTask.getVdsmTaskId());
removeTaskFromDB();
if (commandInfo.getAllCleared()) {
log.info("CommandAsyncTask::HandleEndActionRuntimeException: Removing CommandMultiAsyncTasks" + " object for entity '{}'", commandInfo.getCommandId());
synchronized (_lockObject) {
_multiTasksByCommandIds.remove(commandInfo.getCommandId());
}
}
} catch (RuntimeException ex) {
log.error("CommandAsyncTask::HandleEndActionResult [within thread]: an exception has been thrown", ex);
}
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class MoveDiskCommand method executeCommand.
@Override
protected void executeCommand() {
List<DiskVmElement> diskVmElements = diskVmElementDao.getAllDiskVmElementsByDiskId(getParameters().getImageGroupID());
ActionType actionType = getMoveActionType(diskVmElements);
if (actionType == ActionType.MoveOrCopyDisk) {
MoveDiskParameters moveDiskParameters = getParameters();
// This is required to make MoveDiskCommand and MoveOrCopyDiskCommand have
// different a commandId. Having the same commandId will make CommandsCache
// return the wrong command and lead to unexpected results
moveDiskParameters.setCommandId(null);
setReturnValue(runInternalAction(actionType, moveDiskParameters, ExecutionHandler.createInternalJobContext(getContext(), getLock())));
} else {
Guid vmId = diskVmElements.get(0).getVmId();
engineLock = lockVmWithWait(vmId);
setReturnValue(runInternalAction(actionType, createLiveMigrateDiskParameters(getParameters(), vmId), ExecutionHandler.createInternalJobContext(getContext(), engineLock)));
}
setSucceeded(true);
}
Aggregations