[jboss-cvs] JBossAS SVN: r80828 - in trunk: connector/src/main/org/jboss/resource/deployers/management and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Nov 11 16:01:56 EST 2008


Author: jesper.pedersen
Date: 2008-11-11 16:01:56 -0500 (Tue, 11 Nov 2008)
New Revision: 80828

Added:
   trunk/testsuite/src/resources/jca/deployment/allocation-content-ds.xml
Modified:
   trunk/connector/src/main/org/jboss/resource/connectionmanager/BaseConnectionManager2.java
   trunk/connector/src/main/org/jboss/resource/connectionmanager/BaseConnectionManager2MBean.java
   trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java
   trunk/connector/src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentMetaData.java
   trunk/connector/src/resources/dtd/jboss-ds_5_0.dtd
   trunk/testsuite/src/main/org/jboss/test/jca/test/BaseConnectionManagerUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/jca/test/ManagedDeploymentUnitTestCase.java
Log:
[JBAS-3397] getManagedConnection retries

Modified: trunk/connector/src/main/org/jboss/resource/connectionmanager/BaseConnectionManager2.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/connectionmanager/BaseConnectionManager2.java	2008-11-11 21:00:41 UTC (rev 80827)
+++ trunk/connector/src/main/org/jboss/resource/connectionmanager/BaseConnectionManager2.java	2008-11-11 21:01:56 UTC (rev 80828)
@@ -114,6 +114,12 @@
 
    protected boolean trace;
 
+   protected int allocationRetry;
+
+   protected long allocationRetryWaitMillis;
+
+   protected AtomicBoolean shutdown = new AtomicBoolean(false);
+
    /**
     * Rethrow a throwable as resource exception
     * 
@@ -236,6 +242,44 @@
       return this;
    }
 
+   /**
+    * Set the number of allocation retries
+    * @param number
+    */
+   public void setAllocationRetry(int number)
+   {
+      if (number >= 0)
+         allocationRetry = number;
+   }
+
+   /**
+    * Get the number of allocation retries
+    * @return The number of retries
+    */
+   public int getAllocationRetry()
+   {
+      return allocationRetry;
+   }
+
+   /**
+    * Set the wait time between each allocation retry
+    * @param millis
+    */
+   public void setAllocationRetryWaitMillis(long millis)
+   {
+      if (millis > 0)
+         allocationRetryWaitMillis = millis;
+   }
+
+   /**
+    * Get the wait time between each allocation retry
+    * @return The millis
+    */
+   public long getAllocationRetryWaitMillis()
+   {
+      return allocationRetryWaitMillis;
+   }
+
    public long getTimeLeftBeforeTransactionTimeout(boolean errorRollback) throws RollbackException
    {
       return -1;
@@ -297,21 +341,19 @@
       
       if (poolingStrategy instanceof PreFillPoolSupport)
       {
-                  
          PreFillPoolSupport prefill = (PreFillPoolSupport) poolingStrategy;
          
-         if(prefill.shouldPreFill()){
-
-            prefill.prefill();
-            
-         }
-         
+         if (prefill.shouldPreFill())
+            prefill.prefill();         
       }
    
+      shutdown.set(false);
    }
    
    protected void stopService() throws Exception
    {
+      shutdown.set(true);
+
       //notify the login modules the mcf is going away, they need to look it up again later.
       sendNotification(new Notification(STOPPING_NOTIFICATION, getServiceName(), getNextNotificationSequenceNumber()));
       /*
@@ -351,7 +393,52 @@
    protected ConnectionListener getManagedConnection(Transaction transaction, Subject subject, ConnectionRequestInfo cri)
          throws ResourceException
    {
-      return poolingStrategy.getConnection(transaction, subject, cri);
+      ResourceException failure = null;
+
+      if (shutdown.get())
+         throw new ResourceException("The connection manager is shutdown " + jndiName);
+      
+      // First attempt
+      try
+      {
+         return poolingStrategy.getConnection(transaction, subject, cri);
+      }
+      catch (ResourceException e)
+      {
+         failure = e;
+         
+         // Retry?
+         if (allocationRetry != 0)
+         {
+            for (int i = 0; i < allocationRetry; i++)
+            {
+               if (shutdown.get())
+                  throw new ResourceException("The connection manager is shutdown " + jndiName);
+
+               if (trace)
+                  log.trace("Attempting allocation retry for cri=" + cri);
+
+               try
+               {
+                  if (allocationRetryWaitMillis != 0)
+                     Thread.sleep(allocationRetryWaitMillis);
+
+                  return poolingStrategy.getConnection(transaction, subject, cri);
+               }
+               catch (ResourceException e1)
+               {
+                  failure = e1;
+               }
+               catch (InterruptedException e1)
+               {
+                  JBossResourceException.rethrowAsResourceException("getManagedConnection retry wait was interrupted " + jndiName, e1);
+               }
+            }
+         }
+      }
+
+      // If we get here all retries failed, throw the lastest failure
+      throw failure;
    }
    
    public void returnManagedConnection(ConnectionListener cl, boolean kill)

Modified: trunk/connector/src/main/org/jboss/resource/connectionmanager/BaseConnectionManager2MBean.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/connectionmanager/BaseConnectionManager2MBean.java	2008-11-11 21:00:41 UTC (rev 80827)
+++ trunk/connector/src/main/org/jboss/resource/connectionmanager/BaseConnectionManager2MBean.java	2008-11-11 21:01:56 UTC (rev 80828)
@@ -130,4 +130,28 @@
     * @return a <code>BaseConnectionManager2</code> value
     */
    BaseConnectionManager2 getInstance();
+
+   /**
+    * Set the number of allocation retries
+    * @param number
+    */
+   void setAllocationRetry(int number);
+
+   /**
+    * Get the number of allocation retries
+    * @return The number of retries
+    */
+   int getAllocationRetry();
+
+   /**
+    * Set the wait time between each allocation retry
+    * @param millis
+    */
+   void setAllocationRetryWaitMillis(long millis);
+
+   /**
+    * Get the wait time between each allocation retry
+    * @return The millis
+    */
+   long getAllocationRetryWaitMillis();
 }
\ No newline at end of file

Modified: trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java	2008-11-11 21:00:41 UTC (rev 80827)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java	2008-11-11 21:01:56 UTC (rev 80828)
@@ -227,6 +227,8 @@
       addManagedProperty("isSameRM-override-value", "", true, SimpleMetaType.BOOLEAN, mo);
       addManagedProperty("track-connection-by-tx", "", false, SimpleMetaType.BOOLEAN, Boolean.TRUE, mo);
       addManagedProperty("interleaving", "", false, SimpleMetaType.BOOLEAN, mo);
+      addManagedProperty("allocation-retry", "The number of times allocation retries should be tried", false, SimpleMetaType.INTEGER, new Integer(0), mo);
+      addManagedProperty("allocation-retry-wait-millis", "The time to wait between allocation retries", false, SimpleMetaType.LONG, new Long(5000), mo);
       MetaType type = new MapCompositeMetaType(SimpleMetaType.STRING);
       addManagedProperty("config-property", "The connection factory config properties", false, type, mo);
       addManagedProperty("security-domain", "The security-domain used to validate connections", false, SimpleMetaType.STRING, mo);

Modified: trunk/connector/src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentMetaData.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentMetaData.java	2008-11-11 21:00:41 UTC (rev 80827)
+++ trunk/connector/src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentMetaData.java	2008-11-11 21:01:56 UTC (rev 80828)
@@ -130,6 +130,12 @@
    @XmlElement(name="interleaving")
    private Boolean interleaving;
 
+   @XmlElement(name="allocation-retry")
+   private int allocationRetry = 0;
+   
+   @XmlElement(name="allocation-retry-wait-millis")
+   private long allocationRetryWaitMillis = 5000;
+   
    /** The transactionSupportMetaData */
    @XmlTransient
    private ManagedConnectionFactoryTransactionSupportMetaData transactionSupportMetaData = ManagedConnectionFactoryTransactionSupportMetaData.NONE;
@@ -415,7 +421,6 @@
    public int getMinSize()
    {
       return this.minSize;
-      
    }
    
    @ManagementProperty(name="max-pool-size", includeInTemplate=true)
@@ -432,20 +437,17 @@
       } else {
          return this.minSize;
       }
-      
    }
    
    @ManagementProperty(name="blocking-timeout-millis", includeInTemplate=true)
    public void setBlockingTimeoutMilliSeconds(long blockTimeout)
    {
      this.blockingTimeout = blockTimeout;
-      
    }
    
    public long getBlockingTimeoutMilliSeconds()
    {
       return this.blockingTimeout;
-      
    }
    
    @ManagementProperty(name="idle-timeout-minutes", includeInTemplate=true)
@@ -457,7 +459,6 @@
    public int getIdleTimeoutMinutes()
    {
       return this.idleTimeout;
-      
    }
 
    @ManagementProperty(name="prefill", includeInTemplate=true)
@@ -502,7 +503,6 @@
    public boolean isValidateOnMatch()
    {
       return this.validateOnMatch;
-      
    }
 
    @ManagementProperty(name="isSameRM-override-value", includeInTemplate=true)
@@ -542,6 +542,28 @@
       this.interleaving = interleaving;
    }
 
+   @ManagementProperty(name="allocation-retry", includeInTemplate=true)
+   public int getAllocationRetry()
+   {
+      return this.allocationRetry;
+   }
+   
+   public void setAllocationRetry(int ar)
+   {
+      this.allocationRetry = ar;
+   } 
+   
+   @ManagementProperty(name="allocation-retry-wait-millis", includeInTemplate=true)
+   public long getAllocationRetryWaitMillis()
+   {
+      return this.allocationRetryWaitMillis;
+   }
+   
+   public void setAllocationRetryWaitMillis(long arwm)
+   {
+      this.allocationRetryWaitMillis = arwm;
+   } 
+   
    @ManagementProperty(name="local-transaction", use={ViewUse.RUNTIME})
    public Boolean getLocalTransactions()
    {
@@ -596,6 +618,4 @@
    {
       this.dbmsMetaData = dbmsMetaData;
    }
-   
-
 }

Modified: trunk/connector/src/resources/dtd/jboss-ds_5_0.dtd
===================================================================
--- trunk/connector/src/resources/dtd/jboss-ds_5_0.dtd	2008-11-11 21:00:41 UTC (rev 80827)
+++ trunk/connector/src/resources/dtd/jboss-ds_5_0.dtd	2008-11-11 21:01:56 UTC (rev 80828)
@@ -27,7 +27,7 @@
 driver-class , connection-property* , user-name? , password? ,
 (application-managed-security | security-domain | security-domain-and-application)? ,
 min-pool-size? , max-pool-size? , blocking-timeout-millis? , background-validation?, background-validation-minutes? , idle-timeout-minutes?,
-validate-on-match?, new-connection-sql?, check-valid-connection-sql?, valid-connection-checker-class-name?,
+allocation-retry?, allocation-retry-wait-millis?, validate-on-match?, new-connection-sql?, check-valid-connection-sql?, valid-connection-checker-class-name?,
 exception-sorter-class-name?, stale-connection-checker-class-name?, track-statements?, 
 prefill?, use-fast-fail?,
 prepared-statement-cache-size?, share-prepared-statements? , set-tx-query-timeout?, query-timeout?, use-try-lock?,
@@ -41,7 +41,7 @@
 driver-class, transaction-isolation? , connection-property* , user-name? , password? ,
 (application-managed-security | security-domain | security-domain-and-application)? ,
 min-pool-size? , max-pool-size? , blocking-timeout-millis? , background-validation?, background-validation-minutes?, 
-validate-on-match?, idle-timeout-minutes? ,
+validate-on-match?, idle-timeout-minutes? , allocation-retry?, allocation-retry-wait-millis?, 
 no-tx-separate-pools? , new-connection-sql? , check-valid-connection-sql? ,
 valid-connection-checker-class-name? , exception-sorter-class-name? , stale-connection-checker-class-name?, track-statements? ,
 prefill?, use-fast-fail?,
@@ -55,7 +55,7 @@
 isSameRM-override-value? , transaction-isolation? , user-name? , password? ,
 (application-managed-security | security-domain | security-domain-and-application)? ,
 min-pool-size? , max-pool-size? , blocking-timeout-millis? , background-validation?, background-validation-minutes? , idle-timeout-minutes? ,
-validate-on-match?, no-tx-separate-pools? , xa-resource-timeout?, new-connection-sql? , check-valid-connection-sql? ,
+allocation-retry?, allocation-retry-wait-millis?, validate-on-match?, no-tx-separate-pools? , xa-resource-timeout?, new-connection-sql? , check-valid-connection-sql? ,
 valid-connection-checker-class-name? , exception-sorter-class-name? , stale-connection-checker-class-name?, track-statements? ,
 prefill?, use-fast-fail?,
 prepared-statement-cache-size?, share-prepared-statements? , set-tx-query-timeout?, query-timeout?, use-try-lock?,
@@ -178,6 +178,17 @@
 -->
 <!ELEMENT idle-timeout-minutes (#PCDATA)>
 
+<!-- The allocation retry element indicates the number of times that allocating
+a connection should be tried before throwing an exception. The default is 0.
+-->
+<!ELEMENT allocation-retry (#PCDATA)>
+
+<!-- The allocation retry wait millis element indicates the time in
+milliseconds to wait between retrying to allocate a connection. 
+The default is 5000 (5 seconds).
+-->
+<!ELEMENT allocation-retry-wait-millis (#PCDATA)>
+
 <!-- The validate-on-match element indicates whether or not connection level validation should be done when a connection factory attempts to
 match a managed connection for a given set. This is typically exclusive to the use of background validation -->
 
@@ -402,7 +413,7 @@
 track-connection-by-tx? , rar-name?, connection-definition?, config-property* ,
 (application-managed-security | security-domain | security-domain-and-application)? ,
 min-pool-size? , max-pool-size? , blocking-timeout-millis? , background-validation?, background-validation-minutes? , idle-timeout-minutes? ,
-no-tx-separate-pools?, prefill?, use-fast-fail?, xa-resource-timeout?,
+allocation-retry?, allocation-retry-wait-millis?, no-tx-separate-pools?, prefill?, use-fast-fail?, xa-resource-timeout?,
 metadata?, type-mapping?, depends*)>
 
 <!-- The no-tx-connection-factory element is used to configure generic resource
@@ -411,7 +422,7 @@
 <!ELEMENT no-tx-connection-factory (jndi-name , rar-name?, connection-definition? , config-property* ,
 (application-managed-security | security-domain | security-domain-and-application)? ,
 min-pool-size? , max-pool-size? , blocking-timeout-millis? , background-validation?, background-validation-minutes? , idle-timeout-minutes? ,
-prefill?, use-fast-fail?, metadata?, type-mapping?, depends*)>
+allocation-retry?, allocation-retry-wait-millis?, prefill?, use-fast-fail?, metadata?, type-mapping?, depends*)>
 
 <!-- The rar deployment to associate with the connection manager mbean.
 e.g. jms-ra.rar or myapplication.ear#my.rar for nested rars
@@ -468,7 +479,7 @@
 driver-class, transaction-isolation? , connection-property* , user-name? , password?,
 (application-managed-security | security-domain | security-domain-and-application)? ,
 min-pool-size? , max-pool-size? , blocking-timeout-millis? , idle-timeout-minutes? ,
-no-tx-separate-pools? , new-connection-sql? , check-valid-connection-sql? ,
+allocation-retry?, allocation-retry-wait-millis?, no-tx-separate-pools? , new-connection-sql? , check-valid-connection-sql? ,
 valid-connection-checker-class-name? , exception-sorter-class-name? , track-statements? ,
 prepared-statement-cache-size?, share-prepared-statements? , set-tx-query-timeout?, query-timeout?, use-try-lock?,
 metadata?, type-mapping?, depends*)>
@@ -481,7 +492,7 @@
 user-name? , password? ,
 (application-managed-security | security-domain | security-domain-and-application)? ,
 min-pool-size? , max-pool-size? , blocking-timeout-millis? , idle-timeout-minutes? ,
-no-tx-separate-pools? , xa-resource-timeout? ,
+allocation-retry?, allocation-retry-wait-millis?, no-tx-separate-pools? , xa-resource-timeout? ,
 new-connection-sql? , check-valid-connection-sql? ,
 valid-connection-checker-class-name? , exception-sorter-class-name? , track-statements? ,
 prepared-statement-cache-size?, share-prepared-statements? , set-tx-query-timeout?, query-timeout?, use-try-lock?,

Modified: trunk/testsuite/src/main/org/jboss/test/jca/test/BaseConnectionManagerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jca/test/BaseConnectionManagerUnitTestCase.java	2008-11-11 21:00:41 UTC (rev 80827)
+++ trunk/testsuite/src/main/org/jboss/test/jca/test/BaseConnectionManagerUnitTestCase.java	2008-11-11 21:01:56 UTC (rev 80828)
@@ -24,6 +24,8 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ConnectionRequestInfo;
@@ -75,21 +77,24 @@
    }
 
 
-   private BaseConnectionManager2 getCM(
-      InternalManagedConnectionPool.PoolParams pp)
-      throws Exception
+   private BaseConnectionManager2 getCM(InternalManagedConnectionPool.PoolParams pp) throws Exception
    {
+      return getCM(pp, 0, 5000);
+   }
+
+   private BaseConnectionManager2 getCM(InternalManagedConnectionPool.PoolParams pp, int ar, int arwm) throws Exception
+   {
       ManagedConnectionFactory mcf = new TestManagedConnectionFactory();
       ManagedConnectionPool poolingStrategy = new JBossManagedConnectionPool.OnePool(mcf, pp, false, log);
       BaseConnectionManager2 cm = new NoTxConnectionManager(ccm, poolingStrategy);
+      cm.setAllocationRetry(ar);
+      cm.setAllocationRetryWaitMillis(arwm);
       poolingStrategy.setConnectionListenerFactory(cm);
       
-      
-      if(pp.prefill){
-         
+      if (pp.prefill)
+      {
          BasePool bp = (BasePool)poolingStrategy;
          bp.prefill(null, null, false);
-         
       }
       
       return cm;
@@ -363,5 +368,144 @@
       }
    }
 
+   public void testAllocationRetry() throws Exception
+   {
+      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();
+      pp.minSize = 0;
+      pp.maxSize = 5;
+      pp.blockingTimeout = 100;
+      pp.idleTimeout = 500;
+      BaseConnectionManager2 cm = getCM(pp, 1, 1000);
 
-}//
+      assertEquals("Wrong allocation retry value", 1, cm.getAllocationRetry());
+      assertEquals("Wrong allocation retry wait millis value", 1000, cm.getAllocationRetryWaitMillis());
+
+      try
+      {
+         ArrayList cs = new ArrayList();
+         for (int i = 0; i < pp.maxSize; i++)
+         {
+            ConnectionListener cl = cm.getManagedConnection(null, null);
+            assertTrue("Got a null connection!", cl.getManagedConnection() != null);
+            cs.add(cl);
+         }
+
+         assertTrue("Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == pp.maxSize);
+
+         try
+         {
+            cm.getManagedConnection(null, null);
+            fail("Got a connection more than maxSize!");
+         }
+         catch (ResourceException ignore)
+         {
+         }
+
+         for (Iterator i = cs.iterator(); i.hasNext();)
+         {
+            cm.returnManagedConnection((ConnectionListener)i.next(), true);
+         }
+
+         assertTrue("Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == 0);
+      }
+      finally
+      {
+         shutdown(cm);
+      }
+   }
+
+   public void testAllocationRetryMultiThread() throws Exception
+   {
+      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();
+      pp.minSize = 0;
+      pp.maxSize = 6;
+      pp.blockingTimeout = 100;
+      pp.idleTimeout = 500;
+
+      final BaseConnectionManager2 cm = getCM(pp, 1, 1000);
+
+      assertEquals("Wrong allocation retry value", 1, cm.getAllocationRetry());
+      assertEquals("Wrong allocation retry wait millis value", 1000, cm.getAllocationRetryWaitMillis());
+
+      final int numOfThreads = 2;
+      final int iterations = pp.maxSize / numOfThreads;
+
+      final CountDownLatch start = new CountDownLatch(1);
+      final CountDownLatch cont = new CountDownLatch(1);
+      final CountDownLatch firstPart = new CountDownLatch(numOfThreads);
+      final CountDownLatch done = new CountDownLatch(numOfThreads);
+
+      try
+      {
+         for (int i = 0; i < numOfThreads; i++)
+         {
+            Runnable t = new Runnable()
+            {
+               public void run()
+               {
+                  List cs = new ArrayList();
+
+                  try
+                  {
+                     start.await();
+
+                     for (int i = 0; i < iterations; i++)
+                     {
+                        try
+                        {
+                           ConnectionListener cl = cm.getManagedConnection(null, null);
+                           assertTrue("Got a null connection!", cl.getManagedConnection() != null);
+                           cs.add(cl);
+                        }
+                        catch (ResourceException re)
+                        {
+                           fail("ResourceException: " + re);
+                        }
+                     }
+
+                     assertEquals("1: Wrong number of connections", iterations, cs.size());
+
+                     firstPart.countDown();
+
+                     cont.await();
+
+                     try
+                     {
+                        cm.getManagedConnection(null, null);
+                        fail("Got a connection");
+                     }
+                     catch (ResourceException ignore)
+                     {
+                     }
+
+                     for (Iterator i = cs.iterator(); i.hasNext();)
+                     {
+                        cm.returnManagedConnection((ConnectionListener)i.next(), true);
+                     }
+
+                     done.countDown();
+                  }
+                  catch (InterruptedException ie)
+                  {
+                  }
+               }
+            };
+            new Thread(t).start();
+         }
+         start.countDown();
+
+         firstPart.await();
+         assertTrue("2: Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == pp.maxSize);
+
+         cont.countDown();
+
+         done.await();
+
+         assertTrue("3: Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == 0);
+      }
+      finally
+      {
+         shutdown(cm);
+      }
+   }
+}

Modified: trunk/testsuite/src/main/org/jboss/test/jca/test/ManagedDeploymentUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jca/test/ManagedDeploymentUnitTestCase.java	2008-11-11 21:00:41 UTC (rev 80827)
+++ trunk/testsuite/src/main/org/jboss/test/jca/test/ManagedDeploymentUnitTestCase.java	2008-11-11 21:01:56 UTC (rev 80828)
@@ -118,6 +118,8 @@
       assertFalse(md.isInterleaving());
       assertTrue(md.getNoTxSeparatePools());
       assertTrue(md.getUseStrictMin());
+      assertEquals(0, md.getAllocationRetry());
+      assertEquals(5000, md.getAllocationRetryWaitMillis());
    }
 
    public void testEmptyContentMarshal() throws Exception
@@ -130,7 +132,8 @@
       assertFalse(md.isInterleaving());
       assertTrue(md.getNoTxSeparatePools());
       assertTrue(md.getUseStrictMin());
-
+      assertEquals(0, md.getAllocationRetry());
+      assertEquals(5000, md.getAllocationRetryWaitMillis());
    }
 
    public void testXAWithInterleavingMarshal() throws Exception
@@ -220,6 +223,19 @@
       }
    }
 
+   public void testAllocationRetry() throws Exception
+   {
+      ManagedConnectionFactoryDeploymentGroup group = ManagedDeploymentSupportHelper.unmarshalResource("jca/deployment/allocation-content-ds.xml");
+      List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
+      assertEquals(5, deployments.size());
+
+      for (ManagedConnectionFactoryDeploymentMetaData md : deployments)
+      {
+         assertEquals(1, md.getAllocationRetry());
+         assertEquals(1000, md.getAllocationRetryWaitMillis());
+      }
+   }
+
    public static Test suite() throws Exception
    {
       TestSuite suite = new TestSuite();
@@ -232,8 +248,8 @@
       suite.addTest(new ManagedDeploymentUnitTestCase("testConnectionPoolUnmarshal"));
       suite.addTest(new ManagedDeploymentUnitTestCase("testTrackConnectionByTxUnmarshal"));
       suite.addTest(new ManagedDeploymentUnitTestCase("testXAWithInterleavingMarshal"));
+      suite.addTest(new ManagedDeploymentUnitTestCase("testAllocationRetry"));
 
       return suite;
    }
-
 }

Added: trunk/testsuite/src/resources/jca/deployment/allocation-content-ds.xml
===================================================================
--- trunk/testsuite/src/resources/jca/deployment/allocation-content-ds.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/jca/deployment/allocation-content-ds.xml	2008-11-11 21:01:56 UTC (rev 80828)
@@ -0,0 +1,43 @@
+<datasources>   
+  <no-tx-datasource>
+    <jndi-name>RemoteDS</jndi-name>
+    <connection-url>jdbc:hsqldb:mem:RemoteDSDB</connection-url>
+    <driver-class>org.hsqldb.jdbcDriver</driver-class>
+    <allocation-retry>1</allocation-retry>
+    <allocation-retry-wait-millis>1000</allocation-retry-wait-millis>
+    <metadata>
+      <type-mapping>Hypersonic SQL</type-mapping>
+    </metadata>
+    <application-managed-security/>
+  </no-tx-datasource>
+  
+  <local-tx-datasource>
+    <jndi-name>RemoteDS</jndi-name>
+    <connection-url>jdbc:hsqldb:mem:RemoteDSDB</connection-url>
+    <driver-class>org.hsqldb.jdbcDriver</driver-class>
+    <application-managed-security/>
+    <allocation-retry>1</allocation-retry>
+    <allocation-retry-wait-millis>1000</allocation-retry-wait-millis>
+    <metadata>
+      <type-mapping>Hypersonic SQL</type-mapping>
+    </metadata>
+  </local-tx-datasource>
+  
+  <xa-datasource>   	     
+    <allocation-retry>1</allocation-retry>
+    <allocation-retry-wait-millis>1000</allocation-retry-wait-millis>
+  </xa-datasource>
+  
+  <tx-connection-factory>
+    <jndi-name>Local</jndi-name>		
+    <allocation-retry>1</allocation-retry>
+    <allocation-retry-wait-millis>1000</allocation-retry-wait-millis>
+  </tx-connection-factory>	
+  
+  <no-tx-connection-factory>
+    <jndi-name>NoLocal</jndi-name>		
+    <allocation-retry>1</allocation-retry>
+    <allocation-retry-wait-millis>1000</allocation-retry-wait-millis>
+  </no-tx-connection-factory>	
+  
+</datasources>




More information about the jboss-cvs-commits mailing list