[jboss-cvs] JBossAS SVN: r77979 - in branches/JBPAPP_4_2_0_GA_CP: testsuite/src/main/org/jboss/test/cluster/invokerha and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 4 11:12:48 EDT 2008


Author: galder.zamarreno at jboss.com
Date: 2008-09-04 11:12:48 -0400 (Thu, 04 Sep 2008)
New Revision: 77979

Modified:
   branches/JBPAPP_4_2_0_GA_CP/cluster/src/main/org/jboss/invocation/unified/interfaces/UnifiedInvokerHAProxy.java
   branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java
   branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaUnitTestCase.java
   branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaUnitTestCase.java
Log:
[JBPAPP-1162] Weak hash map is now a synchronized map in order to avoid k,v pairs dissapearing under load. Removed any synchronization on tpc except if putIfAbsent type of operations done. Fixed test case classes to deal with new txFailoverAuthorizations type (WeakHashMap -> Map).

Modified: branches/JBPAPP_4_2_0_GA_CP/cluster/src/main/org/jboss/invocation/unified/interfaces/UnifiedInvokerHAProxy.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/cluster/src/main/org/jboss/invocation/unified/interfaces/UnifiedInvokerHAProxy.java	2008-09-04 15:10:31 UTC (rev 77978)
+++ branches/JBPAPP_4_2_0_GA_CP/cluster/src/main/org/jboss/invocation/unified/interfaces/UnifiedInvokerHAProxy.java	2008-09-04 15:12:48 UTC (rev 77979)
@@ -30,7 +30,9 @@
 import java.rmi.RemoteException;
 import java.rmi.ServerException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.WeakHashMap;
 import org.jboss.ha.framework.interfaces.ClusteringTargetsRepository;
 import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
@@ -47,6 +49,7 @@
 import org.jboss.remoting.serialization.IMarshalledValue;
 import org.jboss.tm.TransactionPropagationContextFactory;
 import org.jboss.tm.TransactionPropagationContextUtil;
+import org.jboss.util.Strings;
 
 
 /**
@@ -67,7 +70,7 @@
 
    private FamilyClusterInfo familyClusterInfo = null;
 
-   public static final WeakHashMap txFailoverAuthorizations = new WeakHashMap();
+   public static final Map txFailoverAuthorizations = Collections.synchronizedMap(new WeakHashMap());
 
    /** Trace level logging flag only set when the proxy is created or read from JNDI */
    private static boolean trace = false;
@@ -104,16 +107,13 @@
       Object tpc = getTransactionPropagationContext();
       if(tpc != null)
       {
-         synchronized(tpc)
+         if (trace)
          {
-            if (trace)
-            {
-               log.trace("checking tx failover authorisation map with tpc " + tpc);
-            }
-
-            /* if the map contains the tpc, then we can't allow a failover */
-            return ! txFailoverAuthorizations.containsKey(tpc);
+            log.trace("Checking tx failover authorisation map with tpc " + tpc);
          }
+
+         /* if the map contains the tpc, then we can't allow a failover */
+         return ! txFailoverAuthorizations.containsKey(tpc);
       }
       
       return true;
@@ -124,22 +124,19 @@
       Object tpc = getTransactionPropagationContext();
       if(tpc != null)
       {
-         synchronized(tpc)
+         if (trace)
          {
-            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);
+            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);
       }
    }
 
@@ -529,6 +526,10 @@
    protected Object getTransactionPropagationContext()
    {
       TransactionPropagationContextFactory tpcFactory = TransactionPropagationContextUtil.getTPCFactoryClientSide();
+      if (trace)
+      {
+         log.trace("Using tpc factory " + tpcFactory);
+      }
       return (tpcFactory == null) ? null : tpcFactory.getTransactionPropagationContext();
    }
    
@@ -542,24 +543,22 @@
    {
       if (tpc != null)
       {
-         synchronized (tpc)
+         if (trace)
          {
+            log.trace("In the proxy, transaction propagation context (tpc) is " + tpc);
+            log.trace("Contains key returns " + txFailoverAuthorizations.containsKey(tpc));
+         }
+
+         Object stickyTarget = txFailoverAuthorizations.get(tpc);
+            
+         if (stickyTarget != null)
+         {
             if (trace)
             {
-               log.trace("in the proxy, transaction propagation context (tpc) is " + tpc);
+               log.trace("Put transaction bound target [" + stickyTarget + "] into transient payload");
             }
-
-            Object stickyTarget = txFailoverAuthorizations.get(tpc);
-               
-            if (stickyTarget != null)
-            {
-               if (trace)
-               {
-                  log.trace("put transaction bound target [" + stickyTarget + "] into transient payload");
-               }
-               
-               invocation.getTransientPayload().put("TX_STICKY_TARGET", stickyTarget);
-            }
+            
+            invocation.getTransientPayload().put("TX_STICKY_TARGET", stickyTarget);
          }
       }
    }

Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java	2008-09-04 15:10:31 UTC (rev 77978)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java	2008-09-04 15:12:48 UTC (rev 77979)
@@ -26,7 +26,7 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
-import java.util.WeakHashMap;
+import java.util.Map;
 
 import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
@@ -374,7 +374,7 @@
        * 
        * @return WeakHashMap containing the tx failover authorisations.
        */
-      WeakHashMap getTxFailoverAuthorizationsMap();
+      Map getTxFailoverAuthorizationsMap();
       
       /**
        * Creates an instance of invoker endpoint.

Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaUnitTestCase.java	2008-09-04 15:10:31 UTC (rev 77978)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaUnitTestCase.java	2008-09-04 15:12:48 UTC (rev 77979)
@@ -21,7 +21,7 @@
  */
 package org.jboss.test.cluster.invokerha;
 
-import java.util.WeakHashMap;
+import java.util.Map;
 
 import org.jboss.invocation.InvokerHA;
 import org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxyHA;
@@ -63,7 +63,7 @@
          return new InvokerHaInfrastructure(serverCount, this);
       }
       
-      public WeakHashMap getTxFailoverAuthorizationsMap()
+      public Map getTxFailoverAuthorizationsMap()
       {
          return JRMPInvokerProxyHA.txFailoverAuthorizations;
       }

Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaUnitTestCase.java	2008-09-04 15:10:31 UTC (rev 77978)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaUnitTestCase.java	2008-09-04 15:12:48 UTC (rev 77979)
@@ -23,7 +23,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.WeakHashMap;
+import java.util.Map;
 
 import javax.management.ObjectName;
 
@@ -87,7 +87,7 @@
          return new UnifiedInvokerHaInfrastructure(serverCount, this);
       }
       
-      public WeakHashMap getTxFailoverAuthorizationsMap()
+      public Map getTxFailoverAuthorizationsMap()
       {
          return UnifiedInvokerHAProxy.txFailoverAuthorizations;
       }




More information about the jboss-cvs-commits mailing list