Ravi Nori has uploaded a new change for review.

Change subject: engine : Generate CommandContext on engine restart
......................................................................

engine : Generate CommandContext on engine restart

After engine restart the command context map
in memory is empty and we need to regenerate
the CommandContexts for those commands that do
not have a constructor with out CommandContext

Change-Id: I641802c6e0e05abaa2ecd84d0718f0d95ab59d9e
Bug-Url: https://bugzilla.redhat.com/1115127
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/tasks/CommandCoordinatorImpl.java
2 files changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/65/29565/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 bb12626..5b9fdef 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
@@ -142,6 +142,10 @@
         return getCommandClass(name, QueryPrefix);
     }
 
+    public static <P extends VdcActionParametersBase> boolean 
hasConstructor(VdcActionType action, P parameters) {
+        return ReflectionUtils.findConstructor(getCommandClass(action.name(), 
CommandSuffix), parameters.getClass()) != null;
+    }
+
     private static Class<CommandBase<? extends VdcActionParametersBase>> 
getCommandClass(String name, String suffix) {
         // try the cache first
         String key = name + suffix;
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandCoordinatorImpl.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandCoordinatorImpl.java
index 071cec8..c919d0a 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandCoordinatorImpl.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandCoordinatorImpl.java
@@ -11,6 +11,7 @@
 import org.ovirt.engine.core.bll.CommandBase;
 import org.ovirt.engine.core.bll.CommandsFactory;
 import org.ovirt.engine.core.bll.context.CommandContext;
+import org.ovirt.engine.core.bll.context.EngineContext;
 import org.ovirt.engine.core.bll.interfaces.BackendInternal;
 import org.ovirt.engine.core.bll.job.ExecutionContext;
 import org.ovirt.engine.core.bll.tasks.interfaces.CommandContextsCache;
@@ -122,6 +123,9 @@
     private CommandBase<?> buildCommand(CommandEntity cmdEntity, 
CommandContext cmdContext) {
         CommandBase<?> command = null;
         if (cmdEntity != null) {
+            if (!CommandsFactory.hasConstructor(cmdEntity.getCommandType(), 
cmdEntity.getActionParameters())) {
+                cmdContext = new CommandContext(new EngineContext());
+            }
             command = 
CommandsFactory.createCommand(cmdEntity.getCommandType(), 
cmdEntity.getActionParameters(), cmdContext);
             command.setCommandStatus(cmdEntity.getCommandStatus(), false);
             if (!Guid.isNullOrEmpty(cmdEntity.getRootCommandId()) &&


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I641802c6e0e05abaa2ecd84d0718f0d95ab59d9e
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