Yair Zaslavsky has uploaded a new change for review.

Change subject: core: Take into account command transactivity scope when...
......................................................................

core: Take into account command transactivity scope when...

Take into account command transactivity scope when creating new
task duing persistence of place holder.
If the command is transactive - create the place holder in a new
transaction, so the record will be recognized when there will
be association between VDSM task ID and db task ID

Change-Id: I97c27cbb8c869182edeefbd3f2cc8c8d466aa29e
Signed-off-by: Yair Zaslavsky <yzasl...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
1 file changed, 19 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/82/17582/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 4beac60..4fe049e 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
@@ -1365,7 +1365,9 @@
         return persistAsyncTaskPlaceHolder(parentCommand, DEFAULT_TASK_KEY);
     }
 
-    public Guid persistAsyncTaskPlaceHolder(VdcActionType parentCommand, 
String taskKey) {
+
+
+    public Guid persistAsyncTaskPlaceHolder(VdcActionType parentCommand, final 
String taskKey) {
         if (taskKeyToTaskIdMap.containsKey(taskKey)) {
             return taskKeyToTaskIdMap.get(taskKey);
         }
@@ -1374,10 +1376,18 @@
         try {
             AsyncTaskCreationInfo creationInfo = new AsyncTaskCreationInfo();
             creationInfo.setTaskType(getTaskType());
-            AsyncTasks task = createAsyncTask(creationInfo, parentCommand);
+            final AsyncTasks task = createAsyncTask(creationInfo, 
parentCommand);
             taskId = task.getTaskId();
-            getAsyncTaskDao().save(task);
-            taskKeyToTaskIdMap.put(taskKey, taskId);
+            TransactionScopeOption scopeOption =
+                    getTransactive() ? TransactionScopeOption.RequiresNew : 
TransactionScopeOption.Required;
+            TransactionSupport.executeInScope(scopeOption, new 
TransactionMethod<Void>() {
+
+                @Override
+                public Void runInTransaction() {
+                    saveTaskAndPutInMap(taskKey, task);
+                    return null;
+                }
+            });
             addToReturnValueTaskPlaceHolderIdList(taskId);
         } catch (RuntimeException ex) {
             log.errorFormat("Error during persistAsyncTaskPlaceHolder for 
command: {0}. Exception {1}", getClass().getName(), ex);
@@ -1385,6 +1395,11 @@
         return taskId;
     }
 
+    private void saveTaskAndPutInMap(String taskKey, AsyncTasks task) {
+        getAsyncTaskDao().save(task);
+        taskKeyToTaskIdMap.put(taskKey, task.getTaskId());
+    }
+
     private void addToReturnValueTaskPlaceHolderIdList(Guid taskId) {
         if (!getReturnValue().getTaskPlaceHolderIdList().contains(taskId)) {
             getReturnValue().getTaskPlaceHolderIdList().add(taskId);


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

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

Reply via email to