use of org.ovirt.engine.core.common.businessentities.CommandEntity in project ovirt-engine by oVirt.
the class CommandsCacheImpl method initializeCache.
private void initializeCache() {
if (!cacheInitialized) {
synchronized (LOCK) {
if (!cacheInitialized) {
List<CommandEntity> cmdEntities = commandEntityDao.getAll();
for (CommandEntity cmdEntity : cmdEntities) {
commandMap.put(cmdEntity.getId(), cmdEntity);
}
cacheInitialized = true;
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.CommandEntity in project ovirt-engine by oVirt.
the class CommandsCacheImpl method updateCallbackNotified.
@Override
public void updateCallbackNotified(final Guid commandId) {
CommandEntity cmdEntity = get(commandId);
if (cmdEntity != null) {
cmdEntity.setCallbackNotified(true);
commandEntityDao.updateNotified(commandId);
}
}
use of org.ovirt.engine.core.common.businessentities.CommandEntity in project ovirt-engine by oVirt.
the class CommandsRepository method markExpiredCommandAsFailure.
private void markExpiredCommandAsFailure(Guid cmdId) {
CommandEntity cmdEntity = getCommandEntity(cmdId);
if (cmdEntity != null && cmdEntity.getCommandStatus() == CommandStatus.ACTIVE) {
Calendar cal = Calendar.getInstance();
Integer cmdLifeTimeInMin = cmdEntity.getCommandParameters().getLifeInMinutes();
cal.add(Calendar.MINUTE, -1 * (cmdLifeTimeInMin == null ? Config.<Integer>getValue(ConfigValues.CoCoLifeInMinutes) : cmdLifeTimeInMin));
if (cmdEntity.getCreatedAt().getTime() < cal.getTime().getTime()) {
log.warn("Marking expired command as Failed: command '{} ({})' that started at '{}' has been marked as Failed.", cmdEntity.getCommandType(), cmdEntity.getId(), cmdEntity.getCreatedAt());
updateCommandStatus(cmdId, CommandStatus.FAILED);
}
}
}
use of org.ovirt.engine.core.common.businessentities.CommandEntity in project ovirt-engine by oVirt.
the class CommandsRepository method getCommandIdsBySessionSeqId.
public List<Guid> getCommandIdsBySessionSeqId(long engineSessionSeqId) {
List<Guid> cmdIds = new ArrayList<>();
CommandEntity cmdEntity;
for (Guid cmdId : commandsCache.keySet()) {
cmdEntity = commandsCache.get(cmdId);
if (cmdEntity != null && cmdEntity.getEngineSessionSeqId() != SsoSessionUtils.EMPTY_SESSION_SEQ_ID && cmdEntity.getEngineSessionSeqId() == engineSessionSeqId) {
cmdIds.add(cmdId);
}
}
return cmdIds;
}
use of org.ovirt.engine.core.common.businessentities.CommandEntity in project ovirt-engine by oVirt.
the class SPMAsyncTask method handleEndedTask.
/**
* Handle ended task operation. Change task state to Ended ,Cleared or
* Cleared Failed , and log appropriate message.
*/
private void handleEndedTask() {
AsyncTask asyncTask = getParameters().getDbAsyncTask();
log.debug("Task of command {} with id '{}' has ended.", asyncTask.getActionType(), getCommandId());
// last access time to now.
if (getState() != AsyncTaskState.Ended) {
setState(AsyncTaskState.Ended);
setLastStatusAccessTime();
}
CommandEntity rootCmdEntity = coco.getCommandEntity(asyncTask.getRootCommandId());
// if the task's root command has failed
if (rootCmdEntity != null && !rootCmdEntity.isExecuted()) {
// mark it as a task of a partially completed command
// Will result in failure of the command
setPartiallyCompletedCommandTask(true);
log.debug("Marking task of command {} with id '{}' as partially completed.", asyncTask.getActionType(), getCommandId());
}
// Fail zombie task and task that belongs to a partially submitted command
if (isZombieTask() || isPartiallyCompletedCommandTask()) {
log.debug("Task of command {} with id '{}' is a zombie or is partially completed, executing failure logic.", asyncTask.getActionType(), getCommandId());
getParameters().getDbAsyncTask().getTaskParameters().setTaskGroupSuccess(false);
ExecutionHandler.getInstance().endTaskStep(parameters.getDbAsyncTask().getStepId(), JobExecutionStatus.FAILED);
onTaskEndFailure();
}
if (hasTaskEndedSuccessfully()) {
log.debug("Task of command {} with id '{}' has succeeded, executing success logic.", asyncTask.getActionType(), getCommandId());
ExecutionHandler.getInstance().endTaskStep(parameters.getDbAsyncTask().getStepId(), JobExecutionStatus.FINISHED);
onTaskEndSuccess();
} else if (hasTaskEndedInFailure()) {
log.debug("Task of command {} with id '{}' has failed, executing failure logic.", asyncTask.getActionType(), getCommandId());
ExecutionHandler.getInstance().endTaskStep(parameters.getDbAsyncTask().getStepId(), JobExecutionStatus.FAILED);
onTaskEndFailure();
} else if (!doesTaskExist()) {
log.debug("Task of command {} with id '{}' does not exist, executing cleanup logic.", asyncTask.getActionType(), getCommandId());
ExecutionHandler.getInstance().endTaskStep(parameters.getDbAsyncTask().getStepId(), JobExecutionStatus.UNKNOWN);
onTaskDoesNotExist();
}
}
Aggregations