Package org.jboss.resource.connectionmanager

Examples of org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener


                                                      ObjectName transactionManagerObjectName,
                                                      ObjectName cachedConnectionManagerObjectName,
                                                      ObjectName managedConnectionPoolObjectName)
      throws Exception
   {
      TxConnectionManager cm = new TxConnectionManager();
      cm.preRegister(mbeanServer, on);
      cm.setTrackConnectionByTx(trackConnectionByTx);
      cm.setLocalTransactions(localTransactions);

      // dependencies
      cm.setTransactionManagerService(transactionManagerObjectName);
      cm.setCachedConnectionManager(cachedConnectionManagerObjectName);
      cm.setManagedConnectionPool(managedConnectionPoolObjectName);

      mbeanServer.registerMBean(cm, on);
      mbeanServer.invoke(on, "start", new Object[0], new String[0]);
      log.debug("started " + on);
View Full Code Here


      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();

      ManagedConnectionPool poolingStrategy = new JBossManagedConnectionPool.OnePool(mcf, pp, false, log);

      cm = new TxConnectionManager(ccm, poolingStrategy, tm);

      poolingStrategy.setConnectionListenerFactory(cm);

      MBeanServer server = MBeanServerLocator.locateJBoss();
      ObjectName onCE = new ObjectName("jboss.jta:name=CoordinatorEnvironmentBean");
View Full Code Here

   private TxConnectionManager getCM(InternalManagedConnectionPool.PoolParams pp, boolean trackByTx) throws Exception
   {
      ManagedConnectionFactory mcf = new TestManagedConnectionFactory();
      ManagedConnectionPool poolingStrategy = new TestPool(mcf, pp, false, log);

      TxConnectionManager cm = new TxConnectionManager(ccm, poolingStrategy, tm);
      cm.setTrackConnectionByTx(trackByTx);

      poolingStrategy.setConnectionListenerFactory(cm);
      return cm;
   }
View Full Code Here

      pp.minSize = min;
      pp.maxSize = getBeanCount();
      pp.blockingTimeout = 30000;
      pp.idleTimeout = idle;

      final TxConnectionManager cm = getCM(pp, trackByTx);

      try
      {
         int totalThreads = pp.maxSize * threadsPerConnection;
         finishedThreadCount = new CountDownLatch(totalThreads);

         log.info("Blocking test with connections: " + pp.maxSize + " totalThreads: " + totalThreads + " reps: " + reps);
         for (int i = 0; i < totalThreads; i++)
         {
            Runnable t = new Runnable()
            {
               int id;
               public void run()
               {
                  id = startedThreadCount.getAndIncrement();

                  long duration = 0;
                  long getConnection = 0;
                  long returnConnection = 0;
                  long heldConnection = 0;
                  for (int j = 0; j < reps; j++)
                  {
                     ConnectionListener cl = null;
                     try
                     {
                        if (tm == null)
                           throw new SystemException("TM is null");

                        tm.begin();

                        long startGetConnection = System.currentTimeMillis();
                        cl = cm.getManagedConnection(subject, cri);
                        cl.enlist();
                        long endGetConnection = System.currentTimeMillis();

                        TxConnectionManagerStressTestCase.this.connectionCount.incrementAndGet();

                        Thread.sleep(sleepTime);

                        if (tm == null)
                           throw new SystemException("TM is null");

                        tm.commit();

                        long startReturnConnection = System.currentTimeMillis();
                        if (!trackByTx)
                        {
                           cl.delist();
                           cm.returnManagedConnection(cl, false);
                        }
                        cl = null;
                        long endReturnConnection = System.currentTimeMillis();
                       
                        duration += (endReturnConnection - startGetConnection);
                        getConnection += (endGetConnection - startGetConnection);
                        returnConnection += (endReturnConnection - startReturnConnection);
                        heldConnection += (startReturnConnection - endGetConnection);
                      }
                      catch (NotSupportedException nse)
                      {
                         TxConnectionManagerStressTestCase.this.log.info("error: iterationCount: " + j + ", connectionCount: " + TxConnectionManagerStressTestCase.this.connectionCount.get() + " " + nse.getMessage());
                         TxConnectionManagerStressTestCase.this.errorCount.incrementAndGet();
                         TxConnectionManagerStressTestCase.this.error = nse;
                         TxConnectionManagerStressTestCase.this.failed = true;
                      }
                      catch (SystemException se)
                      {
                         TxConnectionManagerStressTestCase.this.log.info("error: iterationCount: " + j + ", connectionCount: " + TxConnectionManagerStressTestCase.this.connectionCount.get() + " " + se.getMessage());
                         TxConnectionManagerStressTestCase.this.errorCount.incrementAndGet();
                         TxConnectionManagerStressTestCase.this.error = se;
                         TxConnectionManagerStressTestCase.this.failed = true;
                      }
                      catch (RollbackException rbe)
                      {
                         TxConnectionManagerStressTestCase.this.log.info("error: iterationCount: " + j + ", connectionCount: " + TxConnectionManagerStressTestCase.this.connectionCount.get() + " " + rbe.getMessage());
                         TxConnectionManagerStressTestCase.this.errorCount.incrementAndGet();
                         TxConnectionManagerStressTestCase.this.error = rbe;
                         TxConnectionManagerStressTestCase.this.failed = true;
                      }
                      catch (HeuristicMixedException hme)
                      {
                         TxConnectionManagerStressTestCase.this.log.info("error: iterationCount: " + j + ", connectionCount: " + TxConnectionManagerStressTestCase.this.connectionCount.get() + " " + hme.getMessage());
                         TxConnectionManagerStressTestCase.this.errorCount.incrementAndGet();
                         TxConnectionManagerStressTestCase.this.error = hme;
                         TxConnectionManagerStressTestCase.this.failed = true;
                      }
                      catch (HeuristicRollbackException hre)
                      {
                         TxConnectionManagerStressTestCase.this.log.info("error: iterationCount: " + j + ", connectionCount: " + TxConnectionManagerStressTestCase.this.connectionCount.get() + " " + hre.getMessage());
                         TxConnectionManagerStressTestCase.this.errorCount.incrementAndGet();
                         TxConnectionManagerStressTestCase.this.error = hre;
                         TxConnectionManagerStressTestCase.this.failed = true;
                      }
                      catch (ResourceException re)
                      {
                         TxConnectionManagerStressTestCase.this.log.info("error: iterationCount: " + j + ", connectionCount: " + TxConnectionManagerStressTestCase.this.connectionCount.get() + " " + re.getMessage());
                         TxConnectionManagerStressTestCase.this.errorCount.incrementAndGet();
                         TxConnectionManagerStressTestCase.this.error = re;
                         TxConnectionManagerStressTestCase.this.failed = true;
                      }
                      catch (InterruptedException ie)
                      {
                         break;
                      }
                      finally
                      {
                         if (cl != null)
                            cm.returnManagedConnection(cl, true);

                         try
                         {
                            if (tm == null)
                               throw new SystemException("TM is null");

                            Transaction tx = tm.getTransaction();
                            if (tx != null)
                               log.info("TX STATUS=" + TxUtils.getStatusAsString(tx.getStatus()));
                            if (tx != null && TxUtils.isUncommitted(tx))
                            {
                               tm.rollback();
                            }
                         }
                         catch (SystemException se)
                         {
                            TxConnectionManagerStressTestCase.this.log.info("error: iterationCount: " + j + ", connectionCount: " + TxConnectionManagerStressTestCase.this.connectionCount.get() + " " + se.getMessage());
                            TxConnectionManagerStressTestCase.this.errorCount.incrementAndGet();
                            TxConnectionManagerStressTestCase.this.error = se;
                            TxConnectionManagerStressTestCase.this.failed = true;
                         }
                      }
                  }

                   TxConnectionManagerStressTestCase.this.elapsed.addAndGet(duration);
                   TxConnectionManagerStressTestCase.this.getConnection.addAndGet(getConnection);
                   TxConnectionManagerStressTestCase.this.returnConnection.addAndGet(returnConnection);
                   TxConnectionManagerStressTestCase.this.held.addAndGet(heldConnection);

                   finishedThreadCount.countDown();
               }
            };
            new Thread(t).start();
         }
         finishedThreadCount.await();
        
         // Stop the pool/idle remover, otherwise the following checks will be random
         TestPool pool = (TestPool) cm.getPoolingStrategy();
         pool.shutdownWithoutClear();
        
         float expected = totalThreads * reps;
         float lessWaiting = getConnection.get() - (threadsPerConnection - 1) * held.get();
         log.info("completed " + getName() + " with connectionCount: " + connectionCount.get() + ", expected : " + expected);
View Full Code Here

      pp.minSize = min;
      pp.maxSize = getBeanCount();
      pp.blockingTimeout = 30000;
      pp.idleTimeout = idle;

      final TxConnectionManager cm = getCM(pp, trackByTx);

      try
      {
         int totalThreads = pp.maxSize * threadsPerConnection;
         finishedThreadCount = new CountDownLatch(totalThreads);
View Full Code Here

                                                      ObjectName transactionManagerObjectName,
                                                      ObjectName cachedConnectionManagerObjectName,
                                                      ObjectName managedConnectionPoolObjectName)
      throws Exception
   {
      TxConnectionManager cm = new TxConnectionManager();
      cm.preRegister(mbeanServer, on);
      cm.setTrackConnectionByTx(trackConnectionByTx);
      cm.setLocalTransactions(localTransactions);

      // dependencies
      cm.setTransactionManagerService(transactionManagerObjectName);
      cm.setCachedConnectionManager(cachedConnectionManagerObjectName);
      cm.setManagedConnectionPool(managedConnectionPoolObjectName);

      mbeanServer.registerMBean(cm, on);
      mbeanServer.invoke(on, "start", new Object[0], new String[0]);
      log.debug("started " + on);
View Full Code Here

                                                      ObjectName transactionManagerObjectName,
                                                      ObjectName cachedConnectionManagerObjectName,
                                                      ObjectName managedConnectionPoolObjectName)
      throws Exception
   {
      TxConnectionManager cm = new TxConnectionManager();
      cm.preRegister(mbeanServer, on);
      cm.setTrackConnectionByTx(trackConnectionByTx);
      cm.setLocalTransactions(localTransactions);

      // dependencies
      cm.setTransactionManagerService(transactionManagerObjectName);
      cm.setCachedConnectionManager(cachedConnectionManagerObjectName);
      cm.setManagedConnectionPool(managedConnectionPoolObjectName);

      mbeanServer.registerMBean(cm, on);
      mbeanServer.invoke(on, "start", new Object[0], new String[0]);
      log.debug("started " + on);
View Full Code Here

         boolean trackConnectionByTx, boolean localTransactions,
         ObjectName transactionManagerObjectName,
         ObjectName cachedConnectionManagerObjectName,
         ObjectName managedConnectionPoolObjectName) throws Exception
   {
      TxConnectionManager cm = new TxConnectionManager();
      cm.preRegister(mbeanServer, on);
      cm.setTrackConnectionByTx(trackConnectionByTx);
      cm.setLocalTransactions(localTransactions);
     
      // dependencies
      cm.setTransactionManagerService(transactionManagerObjectName);
      cm.setCachedConnectionManager(cachedConnectionManagerObjectName);
      cm.setManagedConnectionPool(managedConnectionPoolObjectName);
     
      mbeanServer.registerMBean(cm, on);
      mbeanServer.invoke(on, "start", new Object[0], new String[0]);
      log.debug("started " + on);
     
View Full Code Here

      mcf = new TestManagedConnectionFactory();
      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();
      pp.maxSize = getMaxPoolSize();
      ManagedConnectionPool poolingStrategy = new JBossManagedConnectionPool.OnePool(mcf, pp, false, poolLog);
      cri = new TestConnectionRequestInfo();
      cm = new TxConnectionManager(ccm, poolingStrategy, tm);
      if (isSticky())
      {
         cm.setInterleaving(false);
         mcf.setFailJoin(true);
      }
View Full Code Here

  
   private BaseConnectionManager2 getTxCM(ManagedConnectionPool poolingStrategy) throws Exception
   {
      MBeanServer server = MBeanServerLocator.locateJBoss();
      CachedConnectionManager ccm = (CachedConnectionManager) server.getAttribute(CachedConnectionManagerMBean.OBJECT_NAME, "Instance");
      BaseConnectionManager2 cm = new TxConnectionManager(ccm, poolingStrategy, tm);
      poolingStrategy.setConnectionListenerFactory(cm);
      return cm;
   }
View Full Code Here

TOP

Related Classes of org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener

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.