use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendCreationResourceTest method getTaskStatus.
protected AsyncTaskStatus getTaskStatus() {
AsyncTaskStatus status = new AsyncTaskStatus();
status.setStatus(AsyncTaskStatusEnum.finished);
status.setResult(AsyncTaskResultEnum.success);
return status;
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class SpmStopVDSCommand method executeVdsBrokerCommand.
@Override
protected void executeVdsBrokerCommand() {
boolean lockAcquired = false;
try {
if (canVdsBeReached()) {
lockAcquired = lockManager.acquireLock(retrieveVdsExecutionLock()).getFirst();
if (!lockAcquired) {
getVDSReturnValue().setVdsError(new VDSError(EngineError.ENGINE, "Failed to acquire vds execution lock - related operation is under execution"));
getVDSReturnValue().setSucceeded(false);
return;
}
boolean performSpmStop = true;
Map<Guid, AsyncTaskStatus> unclearedTasks = null;
try {
VDSReturnValue vdsReturnValue = resourceManager.runVdsCommand(VDSCommandType.HSMGetAllTasksStatuses, new VdsIdVDSCommandParametersBase(getVds().getId()));
if (isNotSPM(vdsReturnValue)) {
return;
}
getVDSReturnValue().setSucceeded(vdsReturnValue.getSucceeded());
getVDSReturnValue().setVdsError(vdsReturnValue.getVdsError());
if (vdsReturnValue.getReturnValue() != null) {
unclearedTasks = (HashMap<Guid, AsyncTaskStatus>) vdsReturnValue.getReturnValue();
performSpmStop = unclearedTasks.isEmpty();
}
} catch (Exception e) {
performSpmStop = false;
log.info("SpmStopVDSCommand::Could not get tasks on vds '{}': {}", getVds().getName(), e.getMessage());
log.debug("Exception", e);
}
if (performSpmStop) {
log.info("SpmStopVDSCommand::Stopping SPM on vds '{}', pool id '{}'", getVds().getName(), getParameters().getStoragePoolId());
status = getBroker().spmStop(getParameters().getStoragePoolId().toString());
proceedProxyReturnValue();
} else {
getVDSReturnValue().setSucceeded(false);
if (getVDSReturnValue().getVdsError() == null) {
String unclearedTasksDetails = unclearedTasks.entrySet().stream().map(entry -> String.format("Task '%s', status '%s'", entry.getKey(), entry.getValue().getStatus())).collect(Collectors.joining("\n"));
log.error("SpmStopVDSCommand::Not stopping SPM on vds '{}', pool id '{}' as there are uncleared tasks '{}'", getVds().getName(), getParameters().getStoragePoolId(), unclearedTasksDetails);
VDSError error = new VDSError(EngineError.TaskInProgress, unclearedTasksDetails);
getVDSReturnValue().setVdsError(error);
} else if (getVDSReturnValue().getVdsError().getCode() == EngineError.VDS_NETWORK_ERROR) {
log.info("SpmStopVDSCommand::Could not get tasks on vds '{}' - network exception, not stopping spm! pool id '{}'", getVds().getName(), getParameters().getStoragePoolId());
}
}
} else {
log.info("SpmStopVDSCommand:: vds '{}' is in '{}' status - not performing spm stop, pool id '{}'", getVds().getName(), getVds().getStatus(), getParameters().getStoragePoolId());
getVDSReturnValue().setVdsError(new VDSError(EngineError.VDS_NETWORK_ERROR, "Vds is in incorrect status"));
getVDSReturnValue().setSucceeded(false);
}
} catch (RuntimeException exp) {
log.warn("Could not stop spm of pool '{}' on vds '{}': {}", getParameters().getStoragePoolId(), getParameters().getVdsId(), exp.getMessage());
log.debug("Exception", exp);
getVDSReturnValue().setExceptionObject(exp);
getVDSReturnValue().setSucceeded(false);
} finally {
if (lockAcquired) {
lockManager.releaseLock(retrieveVdsExecutionLock());
}
}
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendHostResourceTest method doTestActivateAsync.
private void doTestActivateAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus actionStatus) throws Exception {
setUriInfo(setUpActionExpectations(ActionType.ActivateVds, VdsActionParameters.class, new String[] { "VdsId" }, new Object[] { GUIDS[0] }, asList(GUIDS[1]), asList(new AsyncTaskStatus(asyncStatus))));
Response response = resource.activate(new Action());
verifyActionResponse(response, "hosts/" + GUIDS[0], true, null);
Action action = (Action) response.getEntity();
assertTrue(action.isSetStatus());
assertEquals(actionStatus.value(), action.getStatus());
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class AsyncTaskManager method updateTaskStatuses.
/**
* Update task status based on asyncTaskMap.
*
* @param poolsAllTasksMap Task statuses Map fetched from VDSM.
*/
private void updateTaskStatuses(Map<Guid, Map<Guid, AsyncTaskStatus>> poolsAllTasksMap) {
for (SPMTask task : tasks.values()) {
if (task.getShouldPoll()) {
Map<Guid, AsyncTaskStatus> asyncTasksForPoolMap = poolsAllTasksMap.get(task.getStoragePoolID());
// If the storage pool id exists
if (asyncTasksForPoolMap != null) {
AsyncTaskStatus cachedAsyncTaskStatus = asyncTasksForPoolMap.get(task.getVdsmTaskId());
log.debug("Updating task of command {} with id '{}' to status '{}'.", task.getParameters().getDbAsyncTask().getActionType(), task.getCommandId(), cachedAsyncTaskStatus);
// task found in VDSM.
task.updateTask(cachedAsyncTaskStatus);
}
} else {
log.debug("Not updating task of command {} with id '{}' and status '{}'.", task.getParameters().getDbAsyncTask().getActionType(), task.getCommandId(), task.getLastTaskStatus());
}
}
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class AsyncTaskManager method logAndFailPartiallySubmittedTaskOfCommand.
public void logAndFailPartiallySubmittedTaskOfCommand(final AsyncTask task, String message) {
log.info("Failing partially submitted task AsyncTaskType '{}': Task '{}' Parent Command '{}'", task.getTaskType(), task.getTaskId(), task.getActionType());
task.getTaskParameters().setTaskGroupSuccess(false);
if (task.getActionType() == ActionType.Unknown) {
removeTaskFromDbByTaskId(task.getTaskId());
log.info("Not calling endAction for partially submitted task and AsyncTaskType '{}': Task '{}' Parent Command '{}'", task.getTaskType(), task.getTaskId(), task.getActionType());
return;
}
log.info("Calling updateTask for partially submitted task and AsyncTaskType '{}': Task '{}' Parent Command" + " '{}' Parameters class '{}'", task.getTaskType(), task.getTaskId(), task.getActionType());
AsyncTaskCreationInfo creationInfo = new AsyncTaskCreationInfo(Guid.Empty, task.getTaskType(), task.getStoragePoolId());
SPMTask spmTask = coco.construct(creationInfo, task);
AsyncTaskStatus failureStatus = new AsyncTaskStatus();
failureStatus.setStatus(AsyncTaskStatusEnum.finished);
failureStatus.setResult(AsyncTaskResultEnum.failure);
failureStatus.setMessage(message);
spmTask.setState(AsyncTaskState.Ended);
spmTask.setLastTaskStatus(failureStatus);
spmTask.updateTask(failureStatus);
}
Aggregations