Package org.jboss.resource.connectionmanager

Examples of org.jboss.resource.connectionmanager.BaseConnectionManager2$GetCredentialAction


      pp.maxSize = 5;
      pp.blockingTimeout = 10;
      pp.idleTimeout = 2000;
      pp.prefill = true;
     
      BaseConnectionManager2 cm = getCM(pp);
      //Sleep to let pool filler do it's job
      Thread.sleep(3000);
      assertTrue("Prefilled pool: " + cm.getConnectionCount(), pp.minSize == cm.getConnectionCount());
     
   }
View Full Code Here


      pp.maxSize = 15;
      pp.blockingTimeout = 10;
      pp.idleTimeout = 1000;
      pp.prefill = true;
     
      BaseConnectionManager2 cm = getCM(pp);
      JBossManagedConnectionPool.OnePool pool = (JBossManagedConnectionPool.OnePool) cm.getPoolingStrategy();
      Thread.sleep(5000);
      assertTrue("Non StrictMin pool should allow destroyed connections below minimum connections", pool.getConnectionDestroyedCount() > 0);

   }
View Full Code Here

      pp.blockingTimeout = 10;
      pp.idleTimeout = 1000;
      pp.prefill = true;
      pp.stictMin = true;
     
      BaseConnectionManager2 cm = getCM(pp);
      JBossManagedConnectionPool.OnePool pool = (JBossManagedConnectionPool.OnePool) cm.getPoolingStrategy();
      //Let Idle remover run
      Thread.sleep(3500);
      assertTrue("StrictMin pool should not destroy below minimum connections", pool.getConnectionDestroyedCount() == 0);
           
   }
View Full Code Here

      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();
      pp.minSize = 6;
      pp.maxSize = 5;
      pp.blockingTimeout = 10;
      pp.idleTimeout = 2000;
      BaseConnectionManager2 cm = getCM(pp);
      try
      {
         ConnectionListener cl = cm.getManagedConnection(subject, cri);
         cm.returnManagedConnection(cl, false);
         // Allow fill to min to work
         Thread.sleep(1000);
         assertTrue("Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == pp.maxSize);
         // Allow the idle remover to work
         Thread.sleep(3000);
         assertTrue("Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == pp.maxSize);
      }
      finally
      {
         shutdown(cm);
      }
View Full Code Here

      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();
      pp.minSize = 0;
      pp.maxSize = 5;
      pp.blockingTimeout = 100;
      pp.idleTimeout = 0;
      BaseConnectionManager2 cm = getCM(pp);
      JBossManagedConnectionPool.OnePool pool = (JBossManagedConnectionPool.OnePool) cm.getPoolingStrategy();
      try
      {
         // Checkout all the connections
         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);

         // Reconfigure
         pp.maxSize = 6;
         pool.flush();

         // Put the connections back (should destroy/close them with no errors)
         for (Iterator i = cs.iterator(); i.hasNext();)
         {
            cm.returnManagedConnection((ConnectionListener)i.next(), true);
         }

         // Checkout all the connections with the new maximum size
         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 expected)
         {
         }

         // Put the connections back into the new pool
         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);
      }
View Full Code Here

      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);
      }
View Full Code Here

      pp.minSize = 0;
      pp.maxSize = 6;
      pp.blockingTimeout = 100;
      pp.idleTimeout = 2000;

      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);

      failed = false;
      failedDescription = null;
      failedException = null;

      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)
                        {
                           failed = true;
                           failedDescription = "Failed to get a connection";
                           failedException = re;
                        }
                     }

                     assertEquals("1: Wrong number of connections", iterations, cs.size());

                     firstPart.countDown();

                     cont.await();

                     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);

         try
         {
            ConnectionListener cl = cm.getManagedConnection(null, null);
            cm.returnManagedConnection(cl, true);

            failedDescription = "Got a connection";
            failedException = new Exception(cl.toString());
            failed = true;
         }
         catch (ResourceException ignore)
         {
         }

         cont.countDown();

         done.await();

         assertTrue("3: Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == 0);

         if (failed)
         {
            if (failedDescription == null)
            {
View Full Code Here

TOP

Related Classes of org.jboss.resource.connectionmanager.BaseConnectionManager2$GetCredentialAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.