Package org.apache.commons.pool.impl

Examples of org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject()


            PerformanceTest test = new PerformanceTest() {

                @Override
                public void doOperation(int id) throws Exception {
                    Integer key = id % numKeys;
                    String s = (String) pool.borrowObject(key);
                    pool.returnObject(key, s);
                }
            };
            test.run(numRequests, numThreads);
            test.printStats();
View Full Code Here


      InetSocketAddress address = new InetSocketAddress("127.0.0.1", hotRodServer.getPort());

      assertEquals(0, keyedObjectPool.getNumActive(address));
      assertEquals(1, keyedObjectPool.getNumIdle(address));

      TcpTransport tcpConnection = (TcpTransport) keyedObjectPool.borrowObject(address);
      keyedObjectPool.returnObject(address, tcpConnection);//now we have a reference to the single connection in pool

      tcpConnection.destroy();

      assertEquals("v", rc.get("k"));
View Full Code Here

      assertEquals("v", rc.get("k"));
      assertEquals(0, keyedObjectPool.getNumActive(address));
      assertEquals(1, keyedObjectPool.getNumIdle(address));

      TcpTransport tcpConnection2 = (TcpTransport) keyedObjectPool.borrowObject(address);

      assert tcpConnection2.getId() != tcpConnection.getId();
   }

}
View Full Code Here

        KeyedCPDSConnectionFactory factory =
            new KeyedCPDSConnectionFactory(cpds, pool, null, false);
       
        // Checkout a pair of connections
        PooledConnection pcon1 =
            ((PooledConnectionAndInfo) pool.borrowObject(key))
                .getPooledConnection();
        Connection con1 = pcon1.getConnection();
        PooledConnection pcon2 =
            ((PooledConnectionAndInfo) pool.borrowObject(key))
                .getPooledConnection();
View Full Code Here

        PooledConnection pcon1 =
            ((PooledConnectionAndInfo) pool.borrowObject(key))
                .getPooledConnection();
        Connection con1 = pcon1.getConnection();
        PooledConnection pcon2 =
            ((PooledConnectionAndInfo) pool.borrowObject(key))
                .getPooledConnection();
        assertEquals(2, pool.getNumActive(key));
        assertEquals(0, pool.getNumIdle(key));
       
        // Verify listening
View Full Code Here

        assertEquals(0, pool.getNumIdle(key));
       
        // Ask for another connection - should trigger makeObject, which causes
        // cleanup, removing listeners.
        PooledConnection pcon3 =
            ((PooledConnectionAndInfo) pool.borrowObject(key))
                .getPooledConnection();
        assertTrue(!pcon3.equals(pcon1)); // better not get baddie back
        assertTrue(!pc.getListeners().contains(factory)); // verify cleanup
        assertEquals(2, pool.getNumActive(key));
        assertEquals(0, pool.getNumIdle(key));
View Full Code Here

      InetSocketAddress address = new InetSocketAddress("127.0.0.1", hotRodServer.getPort());

      assertEquals(0, keyedObjectPool.getNumActive(address));
      assertEquals(1, keyedObjectPool.getNumIdle(address));

      TcpTransport tcpConnection = (TcpTransport) keyedObjectPool.borrowObject(address);
      keyedObjectPool.returnObject(address, tcpConnection);//now we have a reference to the single connection in pool

      tcpConnection.destroy();

      assertEquals("v", rc.get("k"));
View Full Code Here

      assertEquals("v", rc.get("k"));
      assertEquals(0, keyedObjectPool.getNumActive(address));
      assertEquals(1, keyedObjectPool.getNumIdle(address));

      TcpTransport tcpConnection2 = (TcpTransport) keyedObjectPool.borrowObject(address);

      assert tcpConnection2.getId() != tcpConnection.getId();
   }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.