[jboss-cvs] JBossAS SVN: r112251 - projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Sep 16 11:03:12 EDT 2011


Author: pferraro
Date: 2011-09-16 11:03:12 -0400 (Fri, 16 Sep 2011)
New Revision: 112251

Modified:
   projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/ClusterChooserInterceptor.java
   projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/FamilyWrapper.java
Log:
Add system property to optionally disable tx stickiness.

Modified: projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/ClusterChooserInterceptor.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/ClusterChooserInterceptor.java	2011-09-16 13:37:11 UTC (rev 112250)
+++ projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/ClusterChooserInterceptor.java	2011-09-16 15:03:12 UTC (rev 112251)
@@ -71,24 +71,27 @@
       
       InvokerLocator target = null;
       InvokerLocator txStickyTarget = null;
-      Object tpc = this.getTransactionPropagationContext();
-      if (tpc != null)
-      {
-         txStickyTarget = txStickyTargets.get(tpc);
-         if (txStickyTarget != null)
+      boolean supportsTxStickiness = family.isTxStickinessSupported();
+      if (supportsTxStickiness) {
+         Object tpc = this.getTransactionPropagationContext();
+         if (tpc != null)
          {
-            if (family.get().getTargets().contains(txStickyTarget))
+            txStickyTarget = txStickyTargets.get(tpc);
+            if (txStickyTarget != null)
             {
-               if (trace)
+               if (family.get().getTargets().contains(txStickyTarget))
                {
-                  log.trace("Using transaction sticky target: " + txStickyTarget);
+                  if (trace)
+                  {
+                     log.trace("Using transaction sticky target: " + txStickyTarget);
+                  }
+                  target = txStickyTarget;
                }
-               target = txStickyTarget;
+               else
+               {
+                  throw new RuntimeException("Current transaction is stuck to " + txStickyTarget + " which is no longer available.  Halting invocation.");
+               }
             }
-            else
-            {
-               throw new RuntimeException("Current transaction is stuck to " + txStickyTarget + " which is no longer available.  Halting invocation.");
-            }
          }
       }
       
@@ -227,10 +230,10 @@
 
             throw new RuntimeException("cluster invocation failed");
          }
-         failoverAuthorized = txContextAllowsFailover();
+         failoverAuthorized = !supportsTxStickiness || txContextAllowsFailover();
          failoverCounter++;
       }
-      if (!failoverAuthorized)
+      if (supportsTxStickiness && !failoverAuthorized)
       {
          throw new RuntimeException("Current transaction is stuck to " + txStickyTarget + " which is no longer available.  Halting invocation.");
       }

Modified: projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/FamilyWrapper.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/FamilyWrapper.java	2011-09-16 13:37:11 UTC (rev 112250)
+++ projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/FamilyWrapper.java	2011-09-16 15:03:12 UTC (rev 112251)
@@ -35,19 +35,24 @@
  */
 public class FamilyWrapper implements java.io.Externalizable
 {
+   public static final String DISABLE_TX_STICKINESS = "jboss.ejb3.clustering.disableTxStickiness";
    private static final long serialVersionUID = 3880844152274576311L;
 
    private FamilyClusterInfo info;
+   private boolean txStickinessSupported;
 
    public FamilyWrapper() {}
 
    public FamilyWrapper(String proxyFamilyName, List targets)
    {
       info = ClusteringTargetsRepository.initTarget(proxyFamilyName, targets);
+      txStickinessSupported = !Boolean.getBoolean(DISABLE_TX_STICKINESS);
    }
 
    public FamilyClusterInfo get() { return info; }
 
+   public boolean isTxStickinessSupported() { return this.txStickinessSupported; }
+
    @SuppressWarnings("unchecked")
    public void writeExternal(final java.io.ObjectOutput out)
       throws IOException
@@ -55,6 +60,7 @@
       out.writeObject(info.getFamilyName());
       // JBAS-6345 -- write an ArrayList for compatibility with AS 3.x/4.x clients
       out.writeObject(new ArrayList(info.getTargets()));
+      out.writeBoolean(txStickinessSupported);
    }
    
    /**
@@ -69,6 +75,7 @@
       // keep a reference on our family object
       //
       this.info = ClusteringTargetsRepository.initTarget(proxyFamilyName, targets);
+      this.txStickinessSupported = (in.available() > 0) ? in.readBoolean() : true;
    }
    
 }



More information about the jboss-cvs-commits mailing list