Examples of ConnectionPool


Examples of com.l2client.dao.derby.ConnectionPool

public class DAOPoolTest extends TestCase {

  public void testSelf() {

    final ConnectionPool pool = ConnectionPool.getInstance();
    try {
      Connection con1 = pool.getConnection();
      Connection con2 = pool.getConnection();
      Connection con3 = pool.getConnection();
      Connection con4 = pool.getConnection();

      System.out.println(System.nanoTime() + " connections fetched:"
          + (ConnectionPool.MAX_CONNECTIONS - pool.getFreeSize())
          + " of maximum " + ConnectionPool.MAX_CONNECTIONS
          + " conections");
      Thread t = new Thread("waiting for a connection to be returned") {

        @Override
        public void run() {
          System.out.println(System.nanoTime()
              + " INNER connections fetched:"
              + (ConnectionPool.MAX_CONNECTIONS - pool
                  .getFreeSize()) + " of maximum "
              + ConnectionPool.MAX_CONNECTIONS + " conections");
          try {
            Connection con1 = pool.getConnection();
         
            System.out.println(System.nanoTime()
                + " INNER connections fetched:"
                + (ConnectionPool.MAX_CONNECTIONS - pool
                    .getFreeSize()) + " of maximum "
                + ConnectionPool.MAX_CONNECTIONS
                + " conections");
            Connection con2 = pool.getConnection();
            Connection con3 = pool.getConnection();
            System.out.println(System.nanoTime()
                + " INNER connections fetched:"
                + (ConnectionPool.MAX_CONNECTIONS - pool
                    .getFreeSize()) + " of maximum "
                + ConnectionPool.MAX_CONNECTIONS
                + " conections");
            con2.close();
            con3.close();
            System.out.println(System.nanoTime()
                + " INNER connections fetched:"
                + (ConnectionPool.MAX_CONNECTIONS - pool
                    .getFreeSize()) + " of maximum "
                + ConnectionPool.MAX_CONNECTIONS
                + " conections");
            con1.close();
            System.out.println(System.nanoTime()
                + " INNER connections fetched:"
                + (ConnectionPool.MAX_CONNECTIONS - pool
                    .getFreeSize()) + " of maximum "
                + ConnectionPool.MAX_CONNECTIONS
                + " conections");
          } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }

      };
      t.start();
      Connection con5 = pool.getConnection();
      System.out.println(System.nanoTime() + " connections fetched:"
          + (ConnectionPool.MAX_CONNECTIONS - pool.getFreeSize())
          + " of maximum " + ConnectionPool.MAX_CONNECTIONS
          + " conections");
      assertNotNull(con5);
      System.out.println(System.nanoTime() + " connections assert");
      con5.close();
      System.out.println(System.nanoTime() + " C5 connections fetched:"
          + (ConnectionPool.MAX_CONNECTIONS - pool.getFreeSize())
          + " of maximum " + ConnectionPool.MAX_CONNECTIONS
          + " conections");
      con4.close();
      System.out.println(System.nanoTime() + " C4 connections fetched:"
          + (ConnectionPool.MAX_CONNECTIONS - pool.getFreeSize())
          + " of maximum " + ConnectionPool.MAX_CONNECTIONS
          + " conections");
      con3.close();
      System.out.println(System.nanoTime() + " C3 connections fetched:"
          + (ConnectionPool.MAX_CONNECTIONS - pool.getFreeSize())
          + " of maximum " + ConnectionPool.MAX_CONNECTIONS
          + " conections");
      con2.close();
      System.out.println(System.nanoTime() + " C2 connections fetched:"
          + (ConnectionPool.MAX_CONNECTIONS - pool.getFreeSize())
          + " of maximum " + ConnectionPool.MAX_CONNECTIONS
          + " conections");
      con1.close();
      System.out.println(System.nanoTime() + " C1 connections fetched:"
          + (ConnectionPool.MAX_CONNECTIONS - pool.getFreeSize())
          + " of maximum " + ConnectionPool.MAX_CONNECTIONS
          + " conections");
      con5.close();
      System.out.println(System.nanoTime() + " C0 connections fetched:"
          + (ConnectionPool.MAX_CONNECTIONS - pool.getFreeSize())
          + " of maximum " + ConnectionPool.MAX_CONNECTIONS
          + " conections");
      t.join();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    assertEquals(ConnectionPool.MAX_CONNECTIONS,pool.getFreeSize());
  }
View Full Code Here

Examples of com.squareup.okhttp.ConnectionPool

        Field f = http.getClass().getDeclaredField("client");
        f.setAccessible(true);
        OkHttpClient client = (OkHttpClient) f.get(http);
        assertNotNull("ensure that OkHttpClient is used", client);

        ConnectionPool p = client.getConnectionPool();
        assertEquals(1, p.getConnectionCount());
        assertEquals(0, p.getHttpConnectionCount());
        assertEquals(1, p.getSpdyConnectionCount());

        assertEquals("HTTP-draft-09/2.0", http.getLastRequestProtocol());
    }
View Full Code Here

Examples of com.sun.enterprise.config.serverbeans.ConnectionPool

        return transports;

    }

    private void migrateConnectionPool(NetworkConfig config, HttpService httpService) throws TransactionFailure {
        final ConnectionPool pool = httpService.getConnectionPool();
        if (pool == null) {
            return;
        }
        /*
                final Transport transport = (Transport) ConfigSupport.apply(new SingleConfigCode<Transports>() {
View Full Code Here

Examples of de.zib.scalaris.ConnectionPool

        String clientName = new BigInteger(128, random).toString(16);
        cFactory.setClientName(cFactory.getClientName() + '_' + clientName);
        cFactory.setClientNameAppendUUID(true);
//        cFactory.setConnectionPolicy(new RoundRobinConnectionPolicy(cFactory.getNodes()));

        cPool = new ConnectionPool(cFactory, CONNECTION_POOL_SIZE);
        loadSiteInfo();
        loadPlugins();
    }
View Full Code Here

Examples of net.dataforte.cassandra.pool.ConnectionPool

            prop.setKeySpace(keyspace);

            CassandraUtilities.setPoolConfigPolicy((CassandraHost) host, prop);
            try
            {
                ConnectionPool pool = new ConnectionPool(prop);
                hostPools.put(host, pool);
            }
            catch (TException e)
            {
                logger.warn("Node {} are down, Caused by {} .", host.getHost(), e.getMessage());
View Full Code Here

Examples of org.apache.activemq.jms.pool.ConnectionPool

        return new PooledConnection(connection);
    }

    @Override
    protected org.apache.activemq.jms.pool.ConnectionPool createConnectionPool(Connection connection) {
        return new ConnectionPool(connection) {

            @Override
            protected Connection wrap(final Connection connection) {
                // Add a transport Listener so that we can notice if this connection
                // should be expired due to a connection failure.
View Full Code Here

Examples of org.apache.aries.transaction.jms.internal.ConnectionPool

        if (pools == null) {
            pools = new LinkedList<ConnectionPool>();
            cache.put(key, pools);
        }

        ConnectionPool connection = null;
        if (pools.size() == maxConnections) {
            connection = pools.removeFirst();
        }

        // Now.. we might get a connection, but it might be that we need to
        // dump it..
        if (connection != null && connection.expiredCheck()) {
            connection = null;
        }

        if (connection == null) {
            Connection delegate = createConnection(key);
View Full Code Here

Examples of org.apache.aries.transaction.jms.internal.ConnectionPool

        pools.add(connection);
        return new PooledConnection(connection);
    }

    protected ConnectionPool createConnectionPool(Connection connection) throws JMSException {
        ConnectionPool result =  new ConnectionPool(connection, getPoolFactory());
        result.setIdleTimeout(getIdleTimeout());
        result.setExpiryTimeout(getExpiryTimeout());
        return result;
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.jdbc.ConnectionPool

        // For each connection in a connection pool, assign an HTablePool max size of 25 references per table
        ConnectionPool.setMaxPoolReferencesPerTablePerConnection(25);

        // Create connection pool with max of 25 connections and prime it with 5 initial connections
        ConnectionPool pool = new ConnectionPool(5, 25);

        PooledConnection pooledConnection = pool.getPooledConnection();
        Connection conn = pooledConnection.getConnection();

        // Do some work with connection

        // Release connection back to pool
View Full Code Here

Examples of org.apache.tomcat.jdbc.pool.ConnectionPool

            super(poolProperties);
        }

        @Override
        public ConnectionPool createPool() throws SQLException {
            ConnectionPool pool = super.createPool();
            registerJmxLazily(pool);
            return pool;
        }
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.