Yair Zaslavsky has uploaded a new change for review.

Change subject: [WIP] core: EndAction transactivity handling more flexible
......................................................................

[WIP] core: EndAction transactivity handling more flexible

Before this patch, for compensatable commands,
@NonTransactiveAttribute was ignored at endAction.
This patch provides more flexibily by adding an attribute
of nonTransactivityScope that defines the scope for
NonTransactivity to take place - either at execute only
or at all flows

Reviewrs please notice - this is my current suggestion for handling
this issue - other suggestions are welcome (this is why
set to WIP)

Bug-Url: https://bugzilla.redhat.com/876627
Change-Id: I6e8edc74bc34676f526dfd24d2f89eb60d8acf1d
Signed-off-by: Yair Zaslavsky <[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/NonTransactiveCommandAttribute.java
2 files changed, 17 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/52/9252/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 85f58a0..74bf3c0 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
@@ -15,6 +15,7 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.exception.ExceptionUtils;
+import 
org.ovirt.engine.core.bll.NonTransactiveCommandAttribute.NonTransactivityScope;
 import org.ovirt.engine.core.bll.context.CommandContext;
 import org.ovirt.engine.core.bll.context.CompensationContext;
 import org.ovirt.engine.core.bll.context.DefaultCompensationContext;
@@ -423,10 +424,14 @@
         // command parameters
         if (!getTransactive()) {
             scope = TransactionScopeOption.Suppress;
+            NonTransactivityScope nonTransactivityScope = 
getNonTransactivityScope();
 
-            // Set the end action scope to suppress only for non-compensating 
commands, or the end action for commands
-            // will run without transaction but compensation is not supported 
for end action.
-            endActionScope = forceCompensation ? endActionScope : scope;
+            //End action scope will be determined the following way:
+            //1. If NonTransactivity is for all flows - endActionScope will be 
supressed.
+            //2. If NonTransactivity is not set for all flows - if this is a 
compensating command, endAction will run in transaction
+            if (!forceCompensation || nonTransactivityScope == 
NonTransactivityScope.ALL_EXECUTION_FLOWS) {
+                endActionScope = TransactionScopeOption.Suppress;
+            }
         }
 
         if (getCompensationContext() == null) {
@@ -1006,6 +1011,10 @@
         return !getReturnValue().getTaskIdList().isEmpty();
     }
 
+    private NonTransactiveCommandAttribute.NonTransactivityScope 
getNonTransactivityScope() {
+        NonTransactiveCommandAttribute annotation = 
getClass().getAnnotation(NonTransactiveCommandAttribute.class);
+        return annotation.nonTransactivityScope();
+    }
     private boolean getForceCompensation() {
         NonTransactiveCommandAttribute annotation = 
getClass().getAnnotation(NonTransactiveCommandAttribute.class);
         return annotation != null && annotation.forceCompensation();
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/NonTransactiveCommandAttribute.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/NonTransactiveCommandAttribute.java
index f2d2e09..4472e4e 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/NonTransactiveCommandAttribute.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/NonTransactiveCommandAttribute.java
@@ -15,4 +15,9 @@
      * @return true if to create compensation context, false if not
      */
     boolean forceCompensation() default false;
+    
+    public static enum NonTransactivityScope {EXECUTE_ACTION, 
ALL_EXECUTION_FLOWS};
+    
+    NonTransactivityScope nonTransactivityScope() default 
NonTransactivityScope.EXECUTE_ACTION;
+    
 }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e8edc74bc34676f526dfd24d2f89eb60d8acf1d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Yair Zaslavsky <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to