use of org.ovirt.engine.core.common.businessentities.CommandEntity in project ovirt-engine by oVirt.
the class CoCoAsyncTaskHelper method shouldRemoveCommand.
private boolean shouldRemoveCommand(AsyncTask asyncTask) {
if (asyncTask == null || Guid.isNullOrEmpty(asyncTask.getCommandId())) {
return false;
}
CommandEntity cmdEntity = coco.get().getCommandEntity(asyncTask.getCommandId());
CommandEntity parentEntity = null;
if (cmdEntity != null) {
parentEntity = coco.get().getCommandEntity(cmdEntity.getParentCommandId());
}
return cmdEntity != null && !cmdEntity.isCallbackEnabled() && (parentEntity == null || !parentEntity.isCallbackEnabled());
}
use of org.ovirt.engine.core.common.businessentities.CommandEntity in project ovirt-engine by oVirt.
the class CoCoEventSubscriber method processEvent.
/**
* Processes the event of the current subscription by invoking the {@code CommandCallback.onEvent} of the associated
* command. After the event is processed, the callback can be terminated from the {@code CommandCallback.onEvent} or
* continue to the rest of command's callback execution.
*
* @param eventData
* the requested data for the event processing
*/
private void processEvent(Map<String, Object> eventData) {
Guid cmdId = commandEntity.getId();
CallbackTiming callbackTiming = commandsRepository.getCallbackTiming(cmdId);
if (callbackTiming == null) {
return;
}
try {
// TODO there is a race condition between processing the callback here and by the polling, in case of an
// event which has arrived during its timeout treatment by CommandCallbacksPoller.
// Once Bug 1334926 is implemented, this code will be changed to mark the callback to be processed, and
// the actual processing will be done by the CommandCallbacksPoller which will be the responsible to invoke
// the CommandCallback.onEvent() on thread from a dedicated thread pool
callbackTiming.getCallback().onEvent(cmdId, commandsRepository.getChildCommandIds(cmdId), eventData);
} finally {
subscription.cancel();
commandsRepository.removeEventSubscription(cmdId);
CommandEntity commandEntityFromCache = commandsRepository.getCommandEntity(cmdId);
if (commandEntityFromCache != null) {
commandEntityFromCache.setWaitingForEvent(false);
}
}
}
use of org.ovirt.engine.core.common.businessentities.CommandEntity in project ovirt-engine by oVirt.
the class CommandExecutor method updateCommandResult.
private void updateCommandResult(final Guid commandId, final ActionReturnValue result) {
CommandEntity cmdEntity = commandsRepository.getCommandEntity(commandId);
cmdEntity.setReturnValue(result);
if (!result.isValid()) {
cmdEntity.setCommandStatus(CommandStatus.FAILED);
}
commandsRepository.persistCommand(cmdEntity);
}
use of org.ovirt.engine.core.common.businessentities.CommandEntity in project ovirt-engine by oVirt.
the class CommandsCacheImpl method updateCommandStatus.
@Override
public void updateCommandStatus(Guid commandId, CommandStatus status) {
final CommandEntity cmdEntity = get(commandId);
if (cmdEntity != null) {
cmdEntity.setCommandStatus(status);
saveOrUpdateWithoutTransaction(cmdEntity);
}
}
use of org.ovirt.engine.core.common.businessentities.CommandEntity in project ovirt-engine by oVirt.
the class CommandsCacheImpl method updateCommandData.
@Override
public void updateCommandData(Guid commandId, Map<String, Serializable> data) {
final CommandEntity cmdEntity = get(commandId);
if (cmdEntity != null) {
cmdEntity.setData(data);
saveOrUpdateWithoutTransaction(cmdEntity);
}
}
Aggregations