Ravi Nori has uploaded a new change for review. Change subject: engine: Persist command at end of execution ......................................................................
engine: Persist command at end of execution Persist command at the end of command execution Change-Id: I1610e115fb215b9f2dcd587a41c748580f98260d Bug-Url: https://bugzilla.redhat.com/1127774 Signed-off-by: Ravi Nori <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/TaskManagerUtil.java 2 files changed, 28 insertions(+), 12 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/44/31344/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java index cf29108..3149ad4 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java @@ -35,8 +35,8 @@ import org.ovirt.engine.core.bll.quota.QuotaManager; import org.ovirt.engine.core.bll.quota.QuotaStorageDependent; import org.ovirt.engine.core.bll.quota.QuotaVdsDependent; -import org.ovirt.engine.core.bll.tasks.SPMAsyncTaskHandler; import org.ovirt.engine.core.bll.tasks.TaskManagerUtil; +import org.ovirt.engine.core.bll.tasks.SPMAsyncTaskHandler; import org.ovirt.engine.core.bll.tasks.interfaces.Command; import org.ovirt.engine.core.bll.tasks.interfaces.CommandCallBack; import org.ovirt.engine.core.bll.tasks.interfaces.SPMTask; @@ -2141,30 +2141,38 @@ getReturnValue().setCanDoAction(internalReturnValue.getCanDoAction()); } + public void persistCommand(VdcActionType parentCommand) { + persistCommand(parentCommand, getContext(), false); + } + public void persistCommand(VdcActionType parentCommand, boolean enableCallBack) { persistCommand(parentCommand, getContext(), enableCallBack); } public void persistCommand(VdcActionType parentCommand, CommandContext cmdContext, boolean enableCallBack) { - VdcActionParametersBase parentParameters = getParentParameters(parentCommand); Transaction transaction = TransactionSupport.suspend(); try { TaskManagerUtil.persistCommand( - CommandEntity.buildCommandEntity(getCommandId(), - parentParameters.getCommandId(), - getExecutionContext().getJob() == null ? Guid.Empty : getExecutionContext().getJob().getId(), - getExecutionContext().getStep() == null ? Guid.Empty : getExecutionContext().getStep().getId(), - getActionType(), - getParameters(), - commandStatus, - enableCallBack, - getReturnValue()), + buildCommandEntity(getParentParameters(parentCommand).getCommandId(), + enableCallBack), cmdContext); } finally { if (transaction != null) { TransactionSupport.resume(transaction); } } + } + + private CommandEntity buildCommandEntity(Guid parentCommandId, boolean callBackEnabled) { + return CommandEntity.buildCommandEntity(getCommandId(), + parentCommandId, + getExecutionContext().getJob() == null ? Guid.Empty : getExecutionContext().getJob().getId(), + getExecutionContext().getStep() == null ? Guid.Empty : getExecutionContext().getStep().getId(), + getActionType(), + getParameters(), + commandStatus, + callBackEnabled, + getReturnValue()); } protected void removeCommand() { @@ -2199,7 +2207,11 @@ public void setCommandExecuted() { Transaction transaction = TransactionSupport.suspend(); try { - TaskManagerUtil.updateCommandExecuted(getCommandId()); + CommandEntity cmdEntity = TaskManagerUtil.getCommandEntity(getCommandId()); + if (cmdEntity != null) { + TaskManagerUtil.persistCommand(buildCommandEntity(cmdEntity.getRootCommandId(), cmdEntity.isCallBackEnabled()), getContext()); + TaskManagerUtil.updateCommandExecuted(getCommandId()); + } } finally { if (transaction != null) { TransactionSupport.resume(transaction); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/TaskManagerUtil.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/TaskManagerUtil.java index 3022564..7b31e84 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/TaskManagerUtil.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/TaskManagerUtil.java @@ -139,6 +139,10 @@ return coco.getChildCommandIds(commandId); } + public static CommandEntity getCommandEntity(Guid commandId) { + return coco.getCommandEntity(commandId); + } + public static CommandBase<?> retrieveCommand(Guid commandId) { return coco.retrieveCommand(commandId); } -- To view, visit http://gerrit.ovirt.org/31344 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1610e115fb215b9f2dcd587a41c748580f98260d Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Ravi Nori <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
