Package org.apache.commons.pool.impl

Examples of org.apache.commons.pool.impl.GenericKeyedObjectPool


    private final GenericKeyedObjectPool pool;

    public DefaultConfigurableKeyedObjectPool()
    {
        pool = new GenericKeyedObjectPool();

        // NOTE: testOnBorrow MUST be FALSE. this is a bit of a design bug in
        // commons-pool since validate is used for both activation and passivation,
        // but has no way of knowing which way it is going.
        pool.setTestOnBorrow(false);
View Full Code Here


            try
            {
                dispatcherFactory = new DispatcherPoolFactory();
                dispatcherPool = PoolUtils
                        .synchronizedPool(new GenericKeyedObjectPool(
                                dispatcherFactory, poolConfig));

                enumerateConsumers();

            }
View Full Code Here

        final List calledMethods = new ArrayList();
        final Object key = new Object();

        // Test that the minIdle check doesn't add too many idle objects
        final KeyedPoolableObjectFactory kpof = (KeyedPoolableObjectFactory)createProxy(KeyedPoolableObjectFactory.class, calledMethods);
        final KeyedObjectPool kop = new GenericKeyedObjectPool(kpof);
        PoolUtils.checkMinIdle(kop, key, 2, 100);
        Thread.sleep(400);
        assertEquals(2, kop.getNumIdle(key));
        assertEquals(2, kop.getNumIdle());
        kop.close();
        int makeObjectCount = 0;
        final Iterator iter = calledMethods.iterator();
        while (iter.hasNext()) {
            final String methodName = (String)iter.next();
            if ("makeObject".equals(methodName)) {
View Full Code Here

     */
    GenericKeyedObjectPool _pool;

    public void initializeService()
    {
        _pool = new GenericKeyedObjectPool(this);

        _pool.setMaxActive(Integer.parseInt(_propertySource.getPropertyValue("org.apache.tapestry.page-pool-max-active")));
        _pool.setMaxIdle(Integer.parseInt(_propertySource.getPropertyValue("org.apache.tapestry.page-pool-max-idle")));

        _pool.setMinIdle(Integer.parseInt(_propertySource.getPropertyValue("org.apache.tapestry.page-pool-min-idle")));
View Full Code Here

   
    private Map _escapedPatternStrings = new HashMap();
   
    public RegexpMatcher()
    {
        _pool = new GenericKeyedObjectPool(_factory);
       
        _pool.setMinEvictableIdleTimeMillis(EVICT_IDLE_TIME);
        _pool.setTimeBetweenEvictionRunsMillis(SLEEP_TIME);
    }
View Full Code Here

    {
        GenericKeyedObjectPool.Config conf = poolConfig.getKeyedObjectPoolConfig();
        if (log.isDebugEnabled())
            log.debug("PersistenceBroker pool will be setup with the following configuration " +
                    ToStringBuilder.reflectionToString(conf, ToStringStyle.MULTI_LINE_STYLE));
        GenericKeyedObjectPool pool = new GenericKeyedObjectPool(null, conf);
        pool.setFactory(new PersistenceBrokerFactoryDefaultImpl.PBKeyedPoolableObjectFactory(this, pool));
        return pool;
    }
View Full Code Here

    public XPathPoolImpl(NamespaceContext namespaceContext) {
        this.namespaceContext = namespaceContext;
       
        this.xpathExpressionfactory = new XPathExpressionFactory(this.namespaceContext, variableResolver);
       
        this.pool = new GenericKeyedObjectPool(xpathExpressionfactory);
        this.pool.setMaxActive(500);
        this.pool.setMaxIdle(500);
        this.pool.setTimeBetweenEvictionRunsMillis(TimeUnit.SECONDS.toMillis(60));
        this.pool.setMinEvictableIdleTimeMillis(TimeUnit.MINUTES.toMillis(5));
        this.pool.setNumTestsPerEvictionRun(this.pool.getMaxIdle() / 9);
View Full Code Here

   }

   public void testClosedConnection() throws Exception {
      rc.put("k","v"); //make sure a connection is created

      GenericKeyedObjectPool keyedObjectPool = transportFactory.getConnectionPool();
      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"));
      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

  private final KeyedObjectPool<Object, ListenableFuture<NettyRpcChannel>> connectionPools;

  @Inject
  public ProtoRpcRaftClientProvider(@Nonnull RpcClient client) {
    RpcChannelFactory channelFactory = new RpcChannelFactory(client);
    this.connectionPools = new GenericKeyedObjectPool(channelFactory, config);
  }
View Full Code Here

        if (factory == null) {
            throw new IllegalArgumentException("factory is null!");
        }

        // 创建链接池对象
        pool = new GenericKeyedObjectPool();
        pool.setMaxActive(maxActive);
        pool.setMaxIdle(maxActive);
        pool.setMinIdle(0);
        pool.setMaxWait(60 * 1000); // 60s
        pool.setTestOnBorrow(false);
View Full Code Here

TOP

Related Classes of org.apache.commons.pool.impl.GenericKeyedObjectPool

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.