[jboss-cvs] JBossAS SVN: r80604 - in trunk/cluster/src/main/org/jboss: invocation/jrmp/interfaces and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Nov 6 13:14:24 EST 2008
Author: galder.zamarreno at jboss.com
Date: 2008-11-06 13:14:24 -0500 (Thu, 06 Nov 2008)
New Revision: 80604
Modified:
trunk/cluster/src/main/org/jboss/ha/framework/interfaces/TransactionSticky.java
trunk/cluster/src/main/org/jboss/invocation/jrmp/interfaces/JRMPInvokerProxyHA.java
trunk/cluster/src/main/org/jboss/invocation/unified/interfaces/UnifiedInvokerHAProxy.java
Log:
[JBAS-6056] [JBAS-6153] UserTransaction can now be deployed with transaction sticky load balance policies. Added in server test that verify that the stickyness happens all throughout the user transaction API and bean invocations. Also, "Transaction sticky target not available" is now wrapped in ServiceUnavailableException.
Modified: trunk/cluster/src/main/org/jboss/ha/framework/interfaces/TransactionSticky.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/interfaces/TransactionSticky.java 2008-11-06 18:06:46 UTC (rev 80603)
+++ trunk/cluster/src/main/org/jboss/ha/framework/interfaces/TransactionSticky.java 2008-11-06 18:14:24 UTC (rev 80604)
@@ -66,7 +66,7 @@
{
trace = log.isTraceEnabled();
Object txStickyTarget = routingDecision.getTransientValue("TX_STICKY_TARGET");
- if (txStickyTarget != null)
+ if (txStickyTarget != null && clusterFamily.getTargets().contains(txStickyTarget))
{
if (trace)
{
Modified: trunk/cluster/src/main/org/jboss/invocation/jrmp/interfaces/JRMPInvokerProxyHA.java
===================================================================
--- trunk/cluster/src/main/org/jboss/invocation/jrmp/interfaces/JRMPInvokerProxyHA.java 2008-11-06 18:06:46 UTC (rev 80603)
+++ trunk/cluster/src/main/org/jboss/invocation/jrmp/interfaces/JRMPInvokerProxyHA.java 2008-11-06 18:14:24 UTC (rev 80604)
@@ -443,7 +443,7 @@
* target associated to it and add it to the invocation transient payload so
* that the load balance policy can choose the right target.
*/
- protected void putIfExistsTransactionTarget(Invocation invocation, Object tpc) throws GenericClusteringException
+ protected void putIfExistsTransactionTarget(Invocation invocation, Object tpc) throws Exception
{
if (tpc != null)
{
@@ -469,8 +469,7 @@
}
else
{
- throw new GenericClusteringException(GenericClusteringException.COMPLETED_YES,
- "Transaction sticky target is no longer available, so invocation needs to be halted");
+ throw new ServiceUnavailableException("Transaction sticky target is no longer available, so invocation needs to be halted");
}
}
}
Modified: trunk/cluster/src/main/org/jboss/invocation/unified/interfaces/UnifiedInvokerHAProxy.java
===================================================================
--- trunk/cluster/src/main/org/jboss/invocation/unified/interfaces/UnifiedInvokerHAProxy.java 2008-11-06 18:06:46 UTC (rev 80603)
+++ trunk/cluster/src/main/org/jboss/invocation/unified/interfaces/UnifiedInvokerHAProxy.java 2008-11-06 18:14:24 UTC (rev 80604)
@@ -124,7 +124,6 @@
log.trace("Failover authorised, so we remove the sticky target associated with tpc " + tpc);
}
- txFailoverAuthorizations.put(tpc, null);
invocation.getTransientPayload().put("TX_STICKY_TARGET", null);
}
@@ -135,25 +134,19 @@
return true;
}
- public void invocationHasReachedAServer(Invocation invocation)
+ public void invocationHasReachedAServer(Invocation invocation, Object response)
{
Object tpc = getTransactionPropagationContext();
- if(tpc != null)
+ /* Idea here is you store the return value if there's no TPC, on the
+ * chance it is a TPC. This won't leak anything since it's a WeakHashMap.
+ * When you do a txFailoverAuthorization.get() it's always passing a TPC
+ * as the key, so you won't accidentally find some random object you put
+ * in the map.*/
+ Object key = (tpc == null) ? response : tpc;
+ if(key != null)
{
- if (trace)
- {
- log.trace("After reaching the server, transaction propagation context (tpc) is " + tpc);
- }
-
- Object stickyTarget = invocation.getTransientValue("TX_STICKY_TARGET");
-
- if (trace && stickyTarget != null)
- {
- log.trace("Remember transaction bound target[" + stickyTarget + "] for tpc " + tpc);
- }
-
- txFailoverAuthorizations.put(tpc, stickyTarget);
- }
+ rememberTransactionTarget(invocation, key);
+ }
}
public String getProxyFamilyName()
@@ -213,6 +206,9 @@
//
int failoverCounter = 0;
invocation.setValue("FAILOVER_COUNTER", new Integer(failoverCounter), PayloadKey.AS_IS);
+
+ // If transaction sticky, put chosen target
+ putIfExistsTransactionTarget(invocation, getTransactionPropagationContext());
Object response = null;
Exception lastException = null;
@@ -232,9 +228,6 @@
log.trace(printPossibleTargets());
}
- // If transaction sticky, put chosen target
- putIfExistsTransactionTarget(invocation, getTransactionPropagationContext());
-
Client clientInstance = getClient(invocation);
if (trace)
@@ -291,7 +284,7 @@
}
else
{
- invocationHasReachedAServer(invocation);
+ invocationHasReachedAServer(invocation, null);
throw new ServerException("Clustering error", gcex);
}
}
@@ -315,9 +308,8 @@
updateClusterInfo(haResponse.newReplicants, haResponse.currentViewId);
}
- invocationHasReachedAServer(invocation);
-
response = haResponse.response;
+ invocationHasReachedAServer(invocation, response);
return response;
}
@@ -371,7 +363,7 @@
}
else
{
- invocationHasReachedAServer(invocation);
+ invocationHasReachedAServer(invocation, null);
throw new ServerException("Clustering error", gcex);
}
}
@@ -559,7 +551,7 @@
* be halted because a previous invocation within the transaction succeeded
* (tx sticky target was set), so we can't failover to a different node.
*/
- protected void putIfExistsTransactionTarget(Invocation invocation, Object tpc) throws GenericClusteringException
+ protected void putIfExistsTransactionTarget(Invocation invocation, Object tpc) throws Exception
{
if (tpc != null)
{
@@ -584,10 +576,26 @@
}
else
{
- throw new GenericClusteringException(GenericClusteringException.COMPLETED_YES,
- "Transaction sticky target is no longer available, so invocation needs to be halted");
+ throw new ServiceUnavailableException("Transaction sticky target is no longer available, so invocation needs to be halted");
}
}
}
}
+
+ protected void rememberTransactionTarget(Invocation invocation, Object target)
+ {
+ if (trace)
+ {
+ log.trace("After reaching the server, transaction propagation context (tpc) is " + target);
+ }
+
+ Object stickyTarget = invocation.getTransientValue("TX_STICKY_TARGET");
+
+ if (trace && stickyTarget != null)
+ {
+ log.trace("Remember transaction bound target [" + stickyTarget + "] for tpc " + target);
+ }
+
+ txFailoverAuthorizations.put(target, stickyTarget);
+ }
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list