Ravi Nori has uploaded a new change for review.

Change subject: engine : Introduction of CommandManager
......................................................................

engine : Introduction of CommandManager

This patch introducs the command manager and two new
interfaces CallBack and TaskHelper. ICommandsFactory and
IExecutionHandler have been removed as they are no longer needed.

Change-Id: Ibdd7585bfcfa6adeb761a8532218ba1aaa5e3c5d
Signed-off-by: Ravi Nori <rn...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/ExecutionHandler.java
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandManager.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/TaskManagerUtil.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/CallBack.java
D 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/ICommandsFactory.java
D 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/IExecutionHandler.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/TaskHelper.java
M 
backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/AsyncTaskFactory.java
M 
backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/AsyncTaskManager.java
M 
backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/EntityAsyncTask.java
M 
backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/SPMAsyncTask.java
12 files changed, 197 insertions(+), 387 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/52/13152/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
index 7c3559f..eb8f6cf 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
@@ -12,12 +12,11 @@
 import org.ovirt.engine.core.common.queries.VdcQueryParametersBase;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
 import org.ovirt.engine.core.compat.Guid;
-import org.ovirt.engine.core.common.interfaces.ICommandsFactory;
 import org.ovirt.engine.core.utils.ReflectionUtils;
 import org.ovirt.engine.core.utils.log.Log;
 import org.ovirt.engine.core.utils.log.LogFactory;
 
-public final class CommandsFactory implements ICommandsFactory {
+public final class CommandsFactory {
     private final String CLASS_NAME_FORMAT = "%1$s.%2$s%3$s";
     private final String CommandSuffix = "Command";
     private final String QueryPrefix = "Query";
@@ -45,7 +44,6 @@
     }
 
     @SuppressWarnings("unchecked")
-    @Override
     public <P extends VdcActionParametersBase> ICommandBase<P> 
CreateCommand(VdcActionType action, P parameters) {
         try {
             Constructor<ICommandBase<? extends VdcActionParametersBase>> 
constructor =
@@ -71,7 +69,6 @@
      *            the command id used by the compensation.
      * @return command instance or null if exception occurred.
      */
-    @Override
     public ICommandBase<?> CreateCommand(String className, Guid commandId) {
         Constructor<?> constructor = null;
         Boolean isAcessible = null;
@@ -95,7 +92,6 @@
         }
     }
 
-    @Override
     public IQueriesCommandBase<?> CreateQueryCommand(VdcQueryType query, 
VdcQueryParametersBase parameters) {
         Class<?> type = null;
         try {
@@ -108,12 +104,10 @@
         }
     }
 
-    @Override
     public Class<ICommandBase<? extends VdcActionParametersBase>> 
getCommandClass(String name) {
         return getCommandClass(name, CommandSuffix);
     }
 
-    @Override
     public Class<ICommandBase<? extends VdcActionParametersBase>> 
getQueryClass(String name) {
         return getCommandClass(name, QueryPrefix);
     }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/ExecutionHandler.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/ExecutionHandler.java
index 3d4c360..a6ec87a 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/ExecutionHandler.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/ExecutionHandler.java
@@ -1,6 +1,5 @@
 package org.ovirt.engine.core.bll.job;
 
-import org.ovirt.engine.core.common.interfaces.IExecutionHandler;
 import org.ovirt.engine.core.common.job.ExecutionContext;
 import java.util.Arrays;
 import java.util.Date;
@@ -46,7 +45,7 @@
  * <li>End job.
  * <ul>
  */
-public class ExecutionHandler implements IExecutionHandler {
+public class ExecutionHandler {
 
     private static Log log = LogFactory.getLog(ExecutionHandler.class);
 
@@ -67,7 +66,6 @@
      *            The {@code CommandBase} instance which the job entity 
describes.
      * @return An initialized {@code Job} instance.
      */
-    @Override
     public Job createJob(VdcActionType actionType, ICommandBase<?> command) {
         Job job = new Job();
 
@@ -104,7 +102,6 @@
      * @param exitStatus
      *            Indicates if the execution described by the step ended 
successfully or not.
      */
-    @Override
     public void endStep(ExecutionContext context, Step step, boolean 
exitStatus) {
         if (context == null) {
             return;
@@ -153,7 +150,6 @@
      * @param exitStatus
      *            The status which the step should be ended with.
      */
-    @Override
     public void endTaskStep(NGuid stepId, JobExecutionStatus exitStatus) {
         try {
             if (stepId != null) {
@@ -187,7 +183,6 @@
      * @param hasCorrelationId
      *            Indicates if the current command was executed under a 
correlation-ID
      */
-    @Override
     public void prepareCommandForMonitoring(ICommandBase<?> command,
             VdcActionType actionType,
             boolean runAsInternal,
@@ -252,7 +247,6 @@
      *            {@code stepName}.
      * @return The created instance of the step or {@code null}.
      */
-    @Override
     public Step addStep(ExecutionContext context, StepEnum stepName, String 
description) {
         if (context == null) {
             return null;
@@ -303,7 +297,6 @@
      *            {@code stepName}.
      * @return The created instance of the step or {@code null}.
      */
-    @Override
     public Step addTaskStep(ExecutionContext context, StepEnum stepName, 
String description) {
         if (context == null) {
             return null;
@@ -356,7 +349,6 @@
      *            {@code stepName}.
      * @return The created instance of the step or {@code null}.
      */
-    @Override
     public Step addSubStep(ExecutionContext context, Step parentStep, StepEnum 
newStepName, String description) {
         Step step = null;
 
@@ -402,7 +394,6 @@
      * @param exitStatus
      *            Indicates if the execution described by the job ended 
successfully or not.
      */
-    @Override
     public void endJob(ExecutionContext context, boolean exitStatus) {
         if (context == null) {
             return;
@@ -452,7 +443,6 @@
      *
      * @return an execution context as a Job
      */
-    @Override
     public CommandContext createInternalJobContext() {
         ExecutionContext executionContext = new ExecutionContext();
         executionContext.setJobRequired(true);
@@ -469,7 +459,6 @@
      *            The context of the parent command
      * @return A context by which the internal command should be monitored.
      */
-    @Override
     public CommandContext createDefaultContexForTasks(ExecutionContext 
parentContext) {
         return createDefaultContexForTasks(parentContext, null);
     }
@@ -484,7 +473,6 @@
      *            The lock which should be released at child command
      * @return A context by which the internal command should be monitored.
      */
-    @Override
     public CommandContext createDefaultContexForTasks(ExecutionContext 
parentContext, IEngineLock lock) {
         ExecutionContext executionContext = new ExecutionContext();
 
@@ -509,7 +497,6 @@
      *            The unique identifier of the step. Must not be {@code null}.
      * @return The context for monitoring the finalizing step of the job, or 
{@code null} if no such step.
      */
-    @Override
     public ExecutionContext createFinalizingContext(Guid stepId) {
         ExecutionContext context = null;
         try {
@@ -545,7 +532,6 @@
      *            The context of the job
      * @return A created instance of the Finalizing step
      */
-    @Override
     public Step startFinalizingStep(ExecutionContext executionContext) {
         if (executionContext == null) {
             return null;
@@ -601,7 +587,6 @@
      * @param systemType
      *            The type of the system
      */
-    @Override
     public void updateStepExternalId(Step step, Guid externalId, 
ExternalSystemType systemType) {
         if (step != null) {
             step.getExternalSystem().setId(externalId);
@@ -628,7 +613,6 @@
      * @param isAsync
      *            indicates if the job should be ended by current action
      */
-    @Override
     public void setAsyncJob(ExecutionContext executionContext, boolean 
isAsync) {
         if (executionContext == null) {
             return;
@@ -649,7 +633,6 @@
      * @return A {@code null} object emphasis correlation-ID is valid or 
{@code VdcReturnValueBase} contains the
      *         correlation-ID violation message
      */
-    @Override
     public VdcReturnValueBase evaluateCorrelationId(VdcActionParametersBase 
parameters) {
         VdcReturnValueBase returnValue = null;
         String correlationId = parameters.getCorrelationId();
@@ -680,7 +663,6 @@
      * @param exitStatus
      *            Indicates if the execution described by the job ended 
successfully or not.
      */
-    @Override
     public void endTaskJob(ExecutionContext context, boolean exitStatus) {
         if (context == null) {
             return;
@@ -725,7 +707,6 @@
      *            The context of the execution stores the Job
      * @return true if Job has any Step for VDSM Task, else false.
      */
-    @Override
     public boolean checkIfJobHasTasks(ExecutionContext context) {
         if (context == null || !context.isMonitored()) {
             return false;
@@ -759,7 +740,6 @@
      * @param status
      *            The exist status to be set for the job
      */
-    @Override
     public void updateSpecificActionJobCompleted(Guid entityId, VdcActionType 
actionType, boolean status) {
         try {
             List<Job> jobs = 
JobRepositoryFactory.getJobRepository().getJobsByEntityAndAction(entityId, 
actionType);
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandManager.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandManager.java
new file mode 100644
index 0000000..02a8e52
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandManager.java
@@ -0,0 +1,102 @@
+package org.ovirt.engine.core.bll.tasks;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.ovirt.engine.core.bll.Backend;
+import org.ovirt.engine.core.bll.CommandsFactory;
+import org.ovirt.engine.core.bll.job.ExecutionHandler;
+import org.ovirt.engine.core.common.action.VdcActionParametersBase;
+import org.ovirt.engine.core.common.action.VdcActionType;
+import org.ovirt.engine.core.common.action.VdcReturnValueBase;
+import org.ovirt.engine.core.common.interfaces.CallBack;
+import org.ovirt.engine.core.common.interfaces.ICommandBase;
+import org.ovirt.engine.core.common.interfaces.TaskHelper;
+import org.ovirt.engine.core.common.job.CommandContext;
+import org.ovirt.engine.core.common.job.ExecutionContext;
+import org.ovirt.engine.core.common.job.ExternalSystemType;
+import org.ovirt.engine.core.common.job.JobExecutionStatus;
+import org.ovirt.engine.core.common.job.Step;
+import org.ovirt.engine.core.common.job.StepEnum;
+import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
+import org.ovirt.engine.core.common.vdscommands.VDSParametersBase;
+import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
+import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.compat.NGuid;
+
+public class CommandManager implements CallBack, TaskHelper {
+
+    private static final CommandManager instance = new CommandManager();
+
+    public static CommandManager getInstance() {
+        return instance;
+    }
+
+    Map<NGuid, ExecutionContext> executionContextMap = new HashMap<NGuid, 
ExecutionContext>();
+
+    @Override
+    public VdcReturnValueBase endAction(
+            NGuid stepId,
+            VdcActionType actionType,
+            VdcActionParametersBase parameters) {
+        ExecutionContext context = null;
+        if (stepId != null) {
+            context = createFinalizingContext(stepId.getValue());
+            executionContextMap.put(stepId, context);
+        }
+
+        ICommandBase<?> command = 
CommandsFactory.getInstance().CreateCommand(actionType, parameters);
+        command.setContext(new CommandContext(context));
+        return command.endAction();
+    }
+
+    @Override
+    public Step addTaskStep(ExecutionContext context, StepEnum stepName, 
String description) {
+        return ExecutionHandler.getInstance().addTaskStep(context, stepName, 
description);
+    }
+
+    @Override
+    public void endTaskStep(NGuid stepId, JobExecutionStatus exitStatus) {
+        ExecutionHandler.getInstance().endTaskStep(stepId, exitStatus);
+    }
+
+    @Override
+    public void updateStepExternalId(Step step, Guid externalId, 
ExternalSystemType systemType) {
+        ExecutionHandler.getInstance().updateStepExternalId(step, externalId, 
systemType);
+    }
+
+    @Override
+    public boolean acquireLockAsyncTask() {
+        return false;
+    }
+
+    @Override
+    public VDSReturnValue RunVdsCommand(VDSCommandType commandType, 
VDSParametersBase parameters) {
+        return 
Backend.getInstance().getResourceManager().RunVdsCommand(commandType, 
parameters);
+    }
+
+    @Override
+    public <P extends VdcActionParametersBase> ICommandBase<P> 
CreateCommand(VdcActionType action, P parameters) {
+        return CommandsFactory.getInstance().CreateCommand(action, parameters);
+    }
+
+    @Override
+    public void endTaskJob(NGuid stepId, boolean exitStatus) {
+        if (stepId != null) {
+            ExecutionContext context = executionContextMap.get(stepId);
+            ExecutionHandler.getInstance().endTaskJob(context, exitStatus);
+        }
+    }
+
+    @Override
+    public ExecutionContext createFinalizingContext(Guid stepId) {
+        return ExecutionHandler.getInstance().createFinalizingContext(stepId);
+    }
+
+    @Override
+    public boolean taskHasContext(NGuid stepId) {
+        if (stepId == null) {
+            return false;
+        }
+        return executionContextMap.containsKey(stepId);
+    }
+}
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 24f3763..ca82005 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
@@ -1,9 +1,6 @@
 package org.ovirt.engine.core.bll.tasks;
 
 import java.util.ArrayList;
-import org.ovirt.engine.core.bll.Backend;
-import org.ovirt.engine.core.bll.CommandsFactory;
-import org.ovirt.engine.core.bll.job.ExecutionHandler;
 import org.ovirt.engine.core.common.VdcObjectType;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo;
@@ -79,7 +76,7 @@
     }
 
     private static AsyncTaskManager getAsyncTaskManager() {
-        return AsyncTaskManager.getInstance(Backend.getInstance(), 
ExecutionHandler.getInstance(), CommandsFactory.getInstance());
+        return AsyncTaskManager.getInstance(CommandManager.getInstance(), 
CommandManager.getInstance());
     }
 
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/CallBack.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/CallBack.java
new file mode 100644
index 0000000..afc7af7
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/CallBack.java
@@ -0,0 +1,10 @@
+package org.ovirt.engine.core.common.interfaces;
+
+import org.ovirt.engine.core.common.action.VdcActionParametersBase;
+import org.ovirt.engine.core.common.action.VdcActionType;
+import org.ovirt.engine.core.common.action.VdcReturnValueBase;
+import org.ovirt.engine.core.compat.NGuid;
+
+public interface CallBack {
+    public VdcReturnValueBase endAction(NGuid stepId, VdcActionType 
actionType, VdcActionParametersBase actionParameters);
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/ICommandsFactory.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/ICommandsFactory.java
deleted file mode 100644
index 98b82f1..0000000
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/ICommandsFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.ovirt.engine.core.common.interfaces;
-
-import org.ovirt.engine.core.common.action.VdcActionParametersBase;
-import org.ovirt.engine.core.common.action.VdcActionType;
-import org.ovirt.engine.core.common.queries.VdcQueryParametersBase;
-import org.ovirt.engine.core.common.queries.VdcQueryType;
-import org.ovirt.engine.core.compat.Guid;
-
-public interface ICommandsFactory {
-
-    @SuppressWarnings(value = "unchecked")
-    <P extends VdcActionParametersBase> ICommandBase<P> 
CreateCommand(VdcActionType action, P parameters);
-
-    /**
-     * Creates an instance of the given command class and passed the command 
id to it's constructor
-     *
-     * @param className
-     *            command class name to be created
-     * @param commandId
-     *            the command id used by the compensation.
-     * @return command instance or null if exception occurred.
-     */
-    ICommandBase<?> CreateCommand(String className, Guid commandId);
-
-    IQueriesCommandBase<?> CreateQueryCommand(VdcQueryType query, 
VdcQueryParametersBase parameters);
-
-    Class<ICommandBase<? extends VdcActionParametersBase>> 
getCommandClass(String name);
-
-    Class<ICommandBase<? extends VdcActionParametersBase>> 
getQueryClass(String name);
-
-}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/IExecutionHandler.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/IExecutionHandler.java
deleted file mode 100644
index 7346813..0000000
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/IExecutionHandler.java
+++ /dev/null
@@ -1,251 +0,0 @@
-package org.ovirt.engine.core.common.interfaces;
-
-import org.ovirt.engine.core.common.action.VdcActionParametersBase;
-import org.ovirt.engine.core.common.action.VdcActionType;
-import org.ovirt.engine.core.common.action.VdcReturnValueBase;
-import org.ovirt.engine.core.common.job.CommandContext;
-import org.ovirt.engine.core.common.job.ExecutionContext;
-import org.ovirt.engine.core.common.job.ExternalSystemType;
-import org.ovirt.engine.core.common.job.Job;
-import org.ovirt.engine.core.common.job.JobExecutionStatus;
-import org.ovirt.engine.core.common.job.Step;
-import org.ovirt.engine.core.common.job.StepEnum;
-import org.ovirt.engine.core.compat.Guid;
-import org.ovirt.engine.core.compat.NGuid;
-
-public interface IExecutionHandler {
-
-    /**
-     * Adds a {@link Step} entity by the provided context. A {@link Step} will 
not be created if
-     * {@code ExecutionContext.isMonitored()} returns false.
-     *
-     * @param context
-     *            The context of the execution which defines visibility and 
execution method.
-     * @param stepName
-     *            The name of the step.
-     * @param description
-     *            A presentation name for the step. If not provided, the 
presentation name is resolved by the
-     *            {@code stepName}.
-     * @return The created instance of the step or {@code null}.
-     */
-    Step addStep(ExecutionContext context, StepEnum stepName, String 
description);
-
-    /**
-     * Adds a {@link Step} entity by the provided context as a child step of a 
given parent step. A {@link Step} will
-     * not be created if {@code ExecutionContext.isMonitored()} returns false.
-     *
-     * @param context
-     *            The context of the execution which defines visibility and 
execution method.
-     * @param parentStep
-     *            The parent step which the new step will be added as its 
child.
-     * @param newStepName
-     *            The name of the step.
-     * @param description
-     *            A presentation name for the step. If not provided, the 
presentation name is resolved by the
-     *            {@code stepName}.
-     * @return The created instance of the step or {@code null}.
-     */
-    Step addSubStep(ExecutionContext context, Step parentStep, StepEnum 
newStepName, String description);
-
-    /**
-     * Adds a {@link Step} entity which describes a VDSM task by the provided 
context. A {@link Step} will not be
-     * created if {@code ExecutionContext.isTasksMonitored()} returns false.
-     *
-     * @param context
-     *            The context of the execution which defines visibility of 
tasks.
-     * @param stepName
-     *            The name of the step.
-     * @param description
-     *            A presentation name for the step. If not provided, the 
presentation name is resolved by the
-     *            {@code stepName}.
-     * @return The created instance of the step or {@code null}.
-     */
-    Step addTaskStep(ExecutionContext context, StepEnum stepName, String 
description);
-
-    /**
-     * Checks if a Job has any Step associated with VDSM task
-     *
-     * @param context
-     *            The context of the execution stores the Job
-     * @return true if Job has any Step for VDSM Task, else false.
-     */
-    boolean checkIfJobHasTasks(ExecutionContext context);
-
-    /**
-     * Creates a default execution context for an inner command which creates 
VDSM tasks so the tasks will be monitored
-     * under the parent {@code StepEnum.EXECUTING} step. If the parent command 
is an internal command, its parent task
-     * step is passed to its internal command.
-     *
-     * @param parentContext
-     *            The context of the parent command
-     * @return A context by which the internal command should be monitored.
-     */
-    CommandContext createDefaultContexForTasks(ExecutionContext parentContext);
-
-    /**
-     * Creates a default execution context for an inner command which creates 
VDSM tasks so the tasks will be monitored
-     * under the parent {@code StepEnum.EXECUTING} step. If the parent command 
is an internal command, its parent task
-     * step is passed to its internal command.
-     * @param parentContext
-     *            The context of the parent command
-     * @param lock
-     *            The lock which should be released at child command
-     * @return A context by which the internal command should be monitored.
-     */
-    CommandContext createDefaultContexForTasks(ExecutionContext parentContext, 
IEngineLock lock);
-
-    /**
-     * Creates {@code ExecutionContext} which defines the context for 
executing the finalizing step of the job. If the
-     * step exists, it must be part of a job, therefore the {@code Job} entity 
is being set as part of the context.
-     *
-     * @param stepId
-     *            The unique identifier of the step. Must not be {@code null}.
-     * @return The context for monitoring the finalizing step of the job, or 
{@code null} if no such step.
-     */
-    ExecutionContext createFinalizingContext(Guid stepId);
-
-    /**
-     * Creates a context for execution of internal command as a monitored Job
-     *
-     * @return an execution context as a Job
-     */
-    CommandContext createInternalJobContext();
-
-    /**
-     * Creates and returns an instance of {@link Job} entity.
-     *
-     * @param actionType
-     *            The action type the job entity represents.
-     * @param command
-     *            The {@code CommandBase} instance which the job entity 
describes.
-     * @return An initialized {@code Job} instance.
-     */
-    Job createJob(VdcActionType actionType, ICommandBase<?> command);
-
-    /**
-     * Finalizes a {@code Job} execution by a given context in which the job 
was performed and by the exit status of
-     * the step. If the {@code Job} execution continues beyond the scope of 
the command, the {@code Job.isAsyncJob()}
-     * should be set to {@code true}. If {@code ExecutionMethod.AsStep} is 
defined, the current active step can end the
-     * running {@code Job} by setting the {@ExecutionContext.shouldEndJob()} to
-     * {@code true}.
-     *
-     * @param executionContext
-     *            The context of the execution which defines how the job 
should be ended
-     * @param exitStatus
-     *            Indicates if the execution described by the job ended 
successfully or not.
-     */
-    void endJob(ExecutionContext context, boolean exitStatus);
-
-    /**
-     * Finalizes a {@code Step} execution by a given context in which the step 
was performed and by the exit status of
-     * the step.
-     *
-     * @param context
-     *            The context in which the {@code Step} was executed.
-     * @param step
-     *            The step to finalize.
-     * @param exitStatus
-     *            Indicates if the execution described by the step ended 
successfully or not.
-     */
-    void endStep(ExecutionContext context, Step step, boolean exitStatus);
-
-    /**
-     * Finalizes Job with VDSM tasks, as this case requires verification that 
no other steps are running in order to
-     * close the entire Job
-     *
-     * @param executionContext
-     *            The context of the execution which defines how the job 
should be ended
-     * @param exitStatus
-     *            Indicates if the execution described by the job ended 
successfully or not.
-     */
-    void endTaskJob(ExecutionContext context, boolean exitStatus);
-
-    /**
-     * Finalizes a {@code Step} execution which represents a VDSM task. In 
case of a failure status, the job will not be
-     * marked as failed at this stage, but via executing the {@code 
CommandBase.endAction} with the proper status by
-     * {@code the AsyncTaskManager}.
-     *
-     * @param stepId
-     *            A unique identifier of the step to finalize.
-     * @param exitStatus
-     *            The status which the step should be ended with.
-     */
-    void endTaskStep(NGuid stepId, JobExecutionStatus exitStatus);
-
-    /**
-     * Evaluates if a given correlation-ID as part of the parameters is set 
correctly. If the correlation-ID is null or
-     * empty, a valid correlation-ID will be set. If the correlation-ID 
exceeds its permitted length, an error return
-     * value will be created and returned.
-     *
-     * @param parameters
-     *            The parameters input of the command
-     * @return A {@code null} object emphasis correlation-ID is valid or 
{@code VdcReturnValueBase} contains the
-     *         correlation-ID violation message
-     */
-    VdcReturnValueBase evaluateCorrelationId(VdcActionParametersBase 
parameters);
-
-    /**
-     * Prepares the monitoring objects for the command by the default behavior:
-     * <ul>
-     * <li> {@link ExecutionContext} determines how the command should be 
monitored. By default, non-internal commands
-     * will be associated with {@code Job} to represent the command execution. 
Internal commands will not be monitored
-     * by default, therefore the {@code ExecutionContext} is created as 
non-monitored context.
-     * <li> {@link Job} is created for monitored actions
-     * </ul>
-     *
-     * @param command
-     *            The created instance of the command (can't be 
<code>null</code>).
-     * @param actionType
-     *            The action type of the command
-     * @param runAsInternal
-     *            Indicates if the command should be run as internal action or 
not
-     * @param hasCorrelationId
-     *            Indicates if the current command was executed under a 
correlation-ID
-     */
-    void prepareCommandForMonitoring(ICommandBase<?> command, VdcActionType 
actionType, boolean runAsInternal, boolean hasCorrelationId);
-
-    /**
-     * Mark the Job as an Async Job which should be terminated by external 
process to the current command scope.
-     *
-     * @param executionContext
-     *            The context which describe the running job.
-     * @param isAsync
-     *            indicates if the job should be ended by current action
-     */
-    void setAsyncJob(ExecutionContext executionContext, boolean isAsync);
-
-    /**
-     * Method should be called when finalizing the command. The execution step 
is being ended with success and the
-     * finalization step is started.
-     *
-     * @param executionContext
-     *            The context of the job
-     * @return A created instance of the Finalizing step
-     */
-    Step startFinalizingStep(ExecutionContext executionContext);
-
-    /**
-     * Updates Job for the same entity for a specific action as completed with 
a given exit status.
-     *
-     * @param entityId
-     *            The entity to search for its jobs
-     * @param actionType
-     *            The action type to search for
-     * @param status
-     *            The exist status to be set for the job
-     */
-    void updateSpecificActionJobCompleted(Guid entityId, VdcActionType 
actionType, boolean status);
-
-    /**
-     * Updates the step with the id in the external system in which the 
describe task runs.
-     *
-     * @param step
-     *            The step which represents the external task
-     * @param externalId
-     *            The id of the task in the external system
-     * @param systemType
-     *            The type of the system
-     */
-    void updateStepExternalId(Step step, Guid externalId, ExternalSystemType 
systemType);
-
-}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/TaskHelper.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/TaskHelper.java
new file mode 100644
index 0000000..599e138
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/TaskHelper.java
@@ -0,0 +1,30 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.ovirt.engine.core.common.interfaces;
+
+import org.ovirt.engine.core.common.action.VdcActionParametersBase;
+import org.ovirt.engine.core.common.action.VdcActionType;
+import org.ovirt.engine.core.common.job.ExecutionContext;
+import org.ovirt.engine.core.common.job.ExternalSystemType;
+import org.ovirt.engine.core.common.job.JobExecutionStatus;
+import org.ovirt.engine.core.common.job.Step;
+import org.ovirt.engine.core.common.job.StepEnum;
+import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
+import org.ovirt.engine.core.common.vdscommands.VDSParametersBase;
+import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
+import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.compat.NGuid;
+
+public interface TaskHelper {
+    Step addTaskStep(ExecutionContext context, StepEnum stepName, String 
description);
+    void endTaskStep(NGuid stepId, JobExecutionStatus exitStatus);
+    void updateStepExternalId(Step step, Guid externalId, ExternalSystemType 
systemType);
+    boolean acquireLockAsyncTask();
+    VDSReturnValue RunVdsCommand(VDSCommandType commandType, VDSParametersBase 
parameters);
+    <P extends VdcActionParametersBase> ICommandBase<P> 
CreateCommand(VdcActionType action, P parameters);
+    void endTaskJob(NGuid stepId, boolean exitStatus);
+    ExecutionContext createFinalizingContext(Guid stepId);
+    boolean taskHasContext(NGuid stepId);
+}
diff --git 
a/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/AsyncTaskFactory.java
 
b/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/AsyncTaskFactory.java
index 800b558..36e5219 100644
--- 
a/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/AsyncTaskFactory.java
+++ 
b/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/AsyncTaskFactory.java
@@ -8,11 +8,10 @@
 import org.ovirt.engine.core.common.businessentities.AsyncTaskResultEnum;
 import org.ovirt.engine.core.common.businessentities.AsyncTaskStatusEnum;
 import org.ovirt.engine.core.common.businessentities.AsyncTasks;
-import org.ovirt.engine.core.common.interfaces.BackendLocal;
-import org.ovirt.engine.core.common.interfaces.IExecutionHandler;
+import org.ovirt.engine.core.common.interfaces.CallBack;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
-import org.ovirt.engine.core.common.interfaces.ICommandsFactory;
+import org.ovirt.engine.core.common.interfaces.TaskHelper;
 import org.ovirt.engine.core.utils.log.Log;
 import org.ovirt.engine.core.utils.log.LogFactory;
 
@@ -31,9 +30,8 @@
      * @return
      */
     public static SPMAsyncTask Construct(
-            BackendLocal backend,
-            IExecutionHandler executionHandler,
-            ICommandsFactory commandsFactory,
+            CallBack callback,
+            TaskHelper taskHelper,
             AsyncTaskCreationInfo creationInfo) {
         AsyncTasks asyncTask = 
DbFacade.getInstance().getAsyncTaskDao().get(creationInfo.getTaskID());
         if (asyncTask == null || asyncTask.getActionParameters() == null) {
@@ -51,7 +49,7 @@
             creationInfo.setTaskType(AsyncTaskType.unknown);
         }
         AsyncTaskParameters asyncTaskParams = new 
AsyncTaskParameters(creationInfo, asyncTask);
-        return Construct(backend, executionHandler, commandsFactory, 
creationInfo.getTaskType(), asyncTaskParams, true);
+        return Construct(callback, taskHelper, creationInfo.getTaskType(), 
asyncTaskParams, true);
     }
 
     /**
@@ -68,18 +66,17 @@
      * @return
      */
     public static SPMAsyncTask Construct(
-            BackendLocal backend,
-            IExecutionHandler executionHandler,
-            ICommandsFactory commandsFactory,
+            CallBack callback,
+            TaskHelper taskHelper,
             AsyncTaskType taskType,
             AsyncTaskParameters asyncTaskParams,
             boolean duringInit) {
         try {
             SPMAsyncTask result = null;
             if (taskType == AsyncTaskType.unknown) {
-                result = new SPMAsyncTask(backend, executionHandler, 
asyncTaskParams);
+                result = new SPMAsyncTask(callback, taskHelper, 
asyncTaskParams);
             } else {
-                result = new EntityAsyncTask(backend, executionHandler, 
commandsFactory, asyncTaskParams, duringInit);
+                result = new EntityAsyncTask(callback, taskHelper, 
asyncTaskParams, duringInit);
             }
             return result;
         }
diff --git 
a/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/AsyncTaskManager.java
 
b/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/AsyncTaskManager.java
index ccd1bfa..653a7c3 100644
--- 
a/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/AsyncTaskManager.java
+++ 
b/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/AsyncTaskManager.java
@@ -44,10 +44,9 @@
 import org.ovirt.engine.core.utils.timer.SchedulerUtilQuartzImpl;
 import org.ovirt.engine.core.utils.transaction.TransactionMethod;
 import org.ovirt.engine.core.utils.transaction.TransactionSupport;
-import org.ovirt.engine.core.common.interfaces.BackendLocal;
+import org.ovirt.engine.core.common.interfaces.CallBack;
 import org.ovirt.engine.core.common.interfaces.ICommandBase;
-import org.ovirt.engine.core.common.interfaces.IExecutionHandler;
-import org.ovirt.engine.core.common.interfaces.ICommandsFactory;
+import org.ovirt.engine.core.common.interfaces.TaskHelper;
 import org.ovirt.engine.core.common.job.ExternalSystemType;
 import org.ovirt.engine.core.common.job.Step;
 import org.ovirt.engine.core.common.job.StepEnum;
@@ -72,28 +71,26 @@
     /**Map of tasks in DB per storage pool that exist after restart **/
     private ConcurrentMap<Guid, List<AsyncTasks>> tasksInDbAfterRestart = null;
 
-    private BackendLocal backend;
-    private IExecutionHandler executionHandler;
-    private ICommandsFactory commandsFactory;
+    private CallBack callback;
+    private TaskHelper taskHelper;
 
     private static AsyncTaskManager taskManager;
     private static final Object LOCK = new Object();
 
-    public static AsyncTaskManager getInstance(BackendLocal backend, 
IExecutionHandler executionHandler, ICommandsFactory commandsFactory) {
+    public static AsyncTaskManager getInstance(CallBack callback, TaskHelper 
taskHelper) {
         if (taskManager == null) {
             synchronized(LOCK) {
                 if (taskManager == null) {
-                    taskManager = new AsyncTaskManager(backend, 
executionHandler, commandsFactory);
+                    taskManager = new AsyncTaskManager(callback, taskHelper);
                 }
             }
         }
         return taskManager;
     }
 
-    private AsyncTaskManager(BackendLocal backend, IExecutionHandler 
executionHandler, ICommandsFactory commandsFactory) {
-        this.backend = backend;
-        this.executionHandler = executionHandler;
-        this.commandsFactory = commandsFactory;
+    private AsyncTaskManager(CallBack callback, TaskHelper taskHelper) {
+        this.callback = callback;
+        this.taskHelper = taskHelper;
         _tasks = new ConcurrentHashMap<Guid, SPMAsyncTask>();
 
         SchedulerUtil scheduler = SchedulerUtilQuartzImpl.getInstance();
@@ -318,7 +315,7 @@
         for (Guid storagePoolID : poolsOfActiveTasks) {
             try {
                 Map<Guid, AsyncTaskStatus> map =
-                        (Map<Guid, AsyncTaskStatus>) 
backend.getResourceManager().RunVdsCommand(
+                        (Map<Guid, AsyncTaskStatus>) taskHelper.RunVdsCommand(
                                 VDSCommandType.SPMGetAllTasksStatuses,
                                 new 
IrsBaseVDSCommandParameters(storagePoolID)).getReturnValue();
                 if (map != null) {
@@ -460,7 +457,7 @@
     }
 
     public SPMAsyncTask CreateTask(AsyncTaskType taskType, AsyncTaskParameters 
taskParameters) {
-        return AsyncTaskFactory.Construct(backend, executionHandler, 
commandsFactory, taskType, taskParameters, false);
+        return AsyncTaskFactory.Construct(callback, taskHelper, taskType, 
taskParameters, false);
     }
 
     public synchronized void StartPollingTask(Guid taskID) {
@@ -509,7 +506,7 @@
     public void AddStoragePoolExistingTasks(storage_pool sp) {
         List<AsyncTaskCreationInfo> currPoolTasks = null;
         try {
-            currPoolTasks = (ArrayList<AsyncTaskCreationInfo>) 
backend.getResourceManager()
+            currPoolTasks = (ArrayList<AsyncTaskCreationInfo>) taskHelper
                     .RunVdsCommand(VDSCommandType.SPMGetAllTasksInfo, new 
IrsBaseVDSCommandParameters(sp.getId()))
                     .getReturnValue();
         } catch (RuntimeException e) {
@@ -528,7 +525,7 @@
                     creationInfo.setStoragePoolID(sp.getId());
                     if (!_tasks.containsKey(creationInfo.getTaskID())) {
                         try {
-                            SPMAsyncTask task = 
AsyncTaskFactory.Construct(backend, executionHandler, commandsFactory, 
creationInfo);
+                            SPMAsyncTask task = 
AsyncTaskFactory.Construct(callback, taskHelper, creationInfo);
                             addTaskToManager(task);
                             newlyAddedTasks.add(task);
                         } catch (Exception e) {
@@ -671,7 +668,7 @@
 
         try {
             Step taskStep =
-                    executionHandler.addTaskStep(command.getExecutionContext(),
+                    taskHelper.addTaskStep(command.getExecutionContext(),
                             
StepEnum.getStepNameByTaskType(asyncTaskCreationInfo.getTaskType()),
                             description);
             if (taskStep != null) {
@@ -684,7 +681,7 @@
             AsyncTaskUtils.addOrUpdateTaskInDB(task);
             lockAndAddTaskToManager(task);
             retValue = task.getTaskID();
-            executionHandler.updateStepExternalId(taskStep, retValue, 
ExternalSystemType.VDSM);
+            taskHelper.updateStepExternalId(taskStep, retValue, 
ExternalSystemType.VDSM);
         } catch (RuntimeException ex) {
             log.errorFormat("Error during CreateTask for command: {0}. 
Exception {1}", this.getClass().getName(), ex);
         } finally {
diff --git 
a/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/EntityAsyncTask.java
 
b/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/EntityAsyncTask.java
index 8f83824..494d621 100644
--- 
a/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/EntityAsyncTask.java
+++ 
b/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/EntityAsyncTask.java
@@ -9,13 +9,10 @@
 import org.ovirt.engine.core.common.asynctasks.AsyncTaskParameters;
 import org.ovirt.engine.core.common.asynctasks.EndedTaskInfo;
 import org.ovirt.engine.core.common.businessentities.AsyncTasks;
-import org.ovirt.engine.core.common.interfaces.BackendLocal;
+import org.ovirt.engine.core.common.interfaces.CallBack;
 import org.ovirt.engine.core.common.interfaces.ICommandBase;
-import org.ovirt.engine.core.common.job.CommandContext;
-import org.ovirt.engine.core.common.job.ExecutionContext;
 import org.ovirt.engine.core.compat.NGuid;
-import org.ovirt.engine.core.common.interfaces.ICommandsFactory;
-import org.ovirt.engine.core.common.interfaces.IExecutionHandler;
+import org.ovirt.engine.core.common.interfaces.TaskHelper;
 import org.ovirt.engine.core.utils.log.Log;
 import org.ovirt.engine.core.utils.log.LogFactory;
 import org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil;
@@ -52,12 +49,11 @@
     }
 
     public EntityAsyncTask(
-            BackendLocal backend,
-            IExecutionHandler executionHandler,
-            ICommandsFactory commandsFactory,
+            CallBack callback,
+            TaskHelper taskHelper,
             AsyncTaskParameters parameters,
             boolean duringInit) {
-        super(backend, executionHandler, parameters);
+        super(callback, taskHelper, parameters);
         boolean isNewCommandAdded = false;
         synchronized (_lockObject) {
             if (!_multiTasksByEntities.containsKey(getContainerId())) {
@@ -69,7 +65,7 @@
         }
         if (duringInit && isNewCommandAdded) {
             ICommandBase<?> command =
-                    
commandsFactory.CreateCommand(parameters.getDbAsyncTask().getaction_type(),
+                    
taskHelper.CreateCommand(parameters.getDbAsyncTask().getaction_type(),
                             parameters.getDbAsyncTask().getActionParameters());
             if (!command.acquireLockAsyncTask()) {
                 log.warnFormat("Failed to acquire locks for command {0} with 
parameters {1}",
@@ -131,8 +127,6 @@
     private void EndCommandAction() {
         EntityMultiAsyncTasks entityInfo = GetEntityMultiAsyncTasks();
         VdcReturnValueBase vdcReturnValue = null;
-        ExecutionContext context = null;
-
         AsyncTasks dbAsyncTask = getParameters().getDbAsyncTask();
         ArrayList<VdcActionParametersBase> imagesParameters = new 
ArrayList<VdcActionParametersBase>();
         for (EndedTaskInfo taskInfo : 
entityInfo.getEndedTasksInfo().getTasksInfo()) {
@@ -158,14 +152,10 @@
                  * Creates context for the job which monitors the action
                  */
                 NGuid stepId = dbAsyncTask.getStepId();
-                if (stepId != null) {
-                    context = 
executionHandler.createFinalizingContext(stepId.getValue());
-                }
-
                 vdcReturnValue =
-                        backend.endAction(entityInfo.getActionType(),
-                                dbAsyncTask.getActionParameters(),
-                                new CommandContext(context)
+                        callback.endAction(stepId,
+                                entityInfo.getActionType(),
+                                dbAsyncTask.getActionParameters()
                         );
             } catch (RuntimeException ex) {
                 log.error(getErrorMessage(entityInfo));
@@ -181,8 +171,7 @@
         }
 
         finally {
-            boolean isTaskGroupSuccess = 
dbAsyncTask.getActionParameters().getTaskGroupSuccess();
-            handleEndActionResult(executionHandler, entityInfo, 
vdcReturnValue, context, isTaskGroupSuccess);
+            handleEndActionResult(taskHelper, entityInfo, vdcReturnValue, 
dbAsyncTask);
             _endActionsInProgress.decrementAndGet();
         }
     }
@@ -193,11 +182,11 @@
     }
 
     private static void handleEndActionResult(
-            IExecutionHandler executionHandler,
+            TaskHelper taskHelper,
             EntityMultiAsyncTasks entityInfo,
             VdcReturnValueBase vdcReturnValue,
-            ExecutionContext context,
-            boolean isTaskGroupSuccess) {
+            AsyncTasks dbAsyncTask) {
+        boolean isTaskGroupSuccess = 
dbAsyncTask.getActionParameters().getTaskGroupSuccess();
         try {
             if (entityInfo != null) {
                 log.infoFormat(
@@ -222,8 +211,8 @@
                      * Terminate the job by the return value of EndAction.
                      * The operation will end also the FINALIZING step.
                      */
-                    if (context != null) {
-                        executionHandler.endTaskJob(context, 
vdcReturnValue.getSucceeded() && isTaskGroupSuccess);
+                    if (taskHelper.taskHasContext(dbAsyncTask.getStepId())) {
+                        taskHelper.endTaskJob(dbAsyncTask.getStepId(), 
vdcReturnValue.getSucceeded() && isTaskGroupSuccess);
                     }
 
                     entityInfo.ClearTasks();
diff --git 
a/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/SPMAsyncTask.java
 
b/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/SPMAsyncTask.java
index c203387..2c69633 100644
--- 
a/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/SPMAsyncTask.java
+++ 
b/backend/manager/modules/taskmgr/src/main/java/org/ovirt/engine/core/taskmgr/SPMAsyncTask.java
@@ -1,6 +1,5 @@
 package org.ovirt.engine.core.taskmgr;
 
-import org.ovirt.engine.core.common.interfaces.BackendLocal;
 import static 
org.ovirt.engine.core.common.config.ConfigValues.UknownTaskPrePollingLapse;
 
 import org.ovirt.engine.core.common.VdcObjectType;
@@ -9,7 +8,8 @@
 import org.ovirt.engine.core.common.businessentities.AsyncTaskStatusEnum;
 import org.ovirt.engine.core.common.config.Config;
 import org.ovirt.engine.core.common.errors.VdcBllErrors;
-import org.ovirt.engine.core.common.interfaces.IExecutionHandler;
+import org.ovirt.engine.core.common.interfaces.CallBack;
+import org.ovirt.engine.core.common.interfaces.TaskHelper;
 import org.ovirt.engine.core.common.job.JobExecutionStatus;
 import 
org.ovirt.engine.core.common.vdscommands.SPMTaskGuidBaseVDSCommandParameters;
 import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
@@ -20,11 +20,11 @@
 import org.ovirt.engine.core.utils.log.LogFactory;
 
 public class SPMAsyncTask {
-    protected BackendLocal backend;
-    protected IExecutionHandler executionHandler;
-    public SPMAsyncTask(BackendLocal backend, IExecutionHandler 
executionHandler, AsyncTaskParameters parameters) {
-        this.backend = backend;
-        this.executionHandler = executionHandler;
+    protected CallBack callback;
+    protected TaskHelper taskHelper;
+    public SPMAsyncTask(CallBack callback, TaskHelper taskHelper, 
AsyncTaskParameters parameters) {
+        this.callback = callback;
+        this.taskHelper = taskHelper;
         setParameters(parameters);
         setState(AsyncTaskState.Initializing);
     }
@@ -222,17 +222,17 @@
         }
 
         if (HasTaskEndedSuccessfully()) {
-            
executionHandler.endTaskStep(privateParameters.getDbAsyncTask().getStepId(), 
JobExecutionStatus.FINISHED);
+            
taskHelper.endTaskStep(privateParameters.getDbAsyncTask().getStepId(), 
JobExecutionStatus.FINISHED);
             OnTaskEndSuccess();
         }
 
         else if (HasTaskEndedInFailure()) {
-            
executionHandler.endTaskStep(privateParameters.getDbAsyncTask().getStepId(), 
JobExecutionStatus.FAILED);
+            
taskHelper.endTaskStep(privateParameters.getDbAsyncTask().getStepId(), 
JobExecutionStatus.FAILED);
             OnTaskEndFailure();
         }
 
         else if (!DoesTaskExist()) {
-            
executionHandler.endTaskStep(privateParameters.getDbAsyncTask().getStepId(), 
JobExecutionStatus.UNKNOWN);
+            
taskHelper.endTaskStep(privateParameters.getDbAsyncTask().getStepId(), 
JobExecutionStatus.UNKNOWN);
             OnTaskDoesNotExist();
         }
     }
@@ -379,8 +379,7 @@
         AsyncTaskStatus returnValue = null;
 
         try {
-            Object tempVar = backend
-                    .getResourceManager()
+            Object tempVar = taskHelper
                     .RunVdsCommand(VDSCommandType.SPMGetTaskStatus,
                             new 
SPMTaskGuidBaseVDSCommandParameters(getStoragePoolID(), 
getTaskID())).getReturnValue();
             returnValue = (AsyncTaskStatus) ((tempVar instanceof 
AsyncTaskStatus) ? tempVar : null);
@@ -451,8 +450,7 @@
                         (getParameters().getDbAsyncTask().getaction_type()),
                         getParameters().getClass().getName());
 
-                backend.getResourceManager()
-                        .RunVdsCommand(VDSCommandType.SPMStopTask,
+                taskHelper.RunVdsCommand(VDSCommandType.SPMStopTask,
                                 new 
SPMTaskGuidBaseVDSCommandParameters(getStoragePoolID(), getTaskID()));
             } catch (RuntimeException e) {
                 log.error(
@@ -479,9 +477,7 @@
 
         try {
             log.infoFormat("SPMAsyncTask::ClearAsyncTask: Attempting to clear 
task '{0}'", getTaskID());
-            vdsReturnValue = backend
-                    .getResourceManager()
-                    .RunVdsCommand(VDSCommandType.SPMClearTask,
+            vdsReturnValue = 
taskHelper.RunVdsCommand(VDSCommandType.SPMClearTask,
                             new 
SPMTaskGuidBaseVDSCommandParameters(getStoragePoolID(), getTaskID()));
         }
 


--
To view, visit http://gerrit.ovirt.org/13152
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibdd7585bfcfa6adeb761a8532218ba1aaa5e3c5d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Ravi Nori <rn...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to