@Override public void setMaxIdle(int maxIdle) { this.pool.setMaxIdle(maxIdle); }
private <K, V> GenericKeyedObjectPool<K, V> getObjectPool(KeyedPoolableObjectFactory<K, V> factory, String poolName, long maxWaitMillis) { GenericKeyedObjectPool<K, V> pool = new GenericKeyedObjectPool<>(factory); pool.setTestOnBorrow(true); pool.setMaxActive(-1); pool.setMaxIdle(-1); pool.setTimeBetweenEvictionRunsMillis(MILLISECONDS.convert(5, MINUTES)); pool.setMinEvictableIdleTimeMillis(MILLISECONDS.convert(5, MINUTES)); pool.setMaxWait(maxWaitMillis); pool.setTestOnReturn(true); pool.setTestOnBorrow(true); try { ManagedGenericKeyedObjectPool mbean = new ManagedGenericKeyedObjectPool( pool, poolName); ManagementFactory.getPlatformMBeanServer() .registerMBean(mbean, mbean.getObjectName()); } catch (Exception e) { log.error("Could not register mbean for pool [{}]", poolName, e); } return pool; }
@Override public void start() throws LifecycleException { try { pool = new GenericKeyedObjectPool<>(new DatagramSocketFactory()); pool.setTestOnBorrow(true); pool.setMaxActive(-1); pool.setMaxIdle(-1); pool.setTimeBetweenEvictionRunsMillis(MILLISECONDS.convert(5, MINUTES)); pool.setMinEvictableIdleTimeMillis(MILLISECONDS.convert(5, MINUTES)); this.mbean = new ManagedGenericKeyedObjectPool((GenericKeyedObjectPool) pool, "StatsdConnectionPool"); ManagementFactory.getPlatformMBeanServer() .registerMBean(this.mbean, this.mbean.getObjectName()); } catch (Exception e) { throw new LifecycleException(e); } }
/** * Sets the configuration. * @param conf the new configuration to use. * @see GenericKeyedObjectPool.Config */ public synchronized void setConfig(GenericKeyedObjectPool.Config conf) { setMaxIdle(conf.maxIdle); setMaxActive(conf.maxActive); setMaxTotal(conf.maxTotal); setMinIdle(conf.minIdle); setMaxWait(conf.maxWait); setWhenExhaustedAction(conf.whenExhaustedAction); setTestOnBorrow(conf.testOnBorrow); setTestOnReturn(conf.testOnReturn); setTestWhileIdle(conf.testWhileIdle); setNumTestsPerEvictionRun(conf.numTestsPerEvictionRun); setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis); setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis); }
/** * @see org.apache.commons.pool.impl.GenericKeyedObjectPool#setMaxIdle(int) */ public void setMaxIdle(int maxIdle) { this.keyedObjectPool.setMaxIdle(maxIdle); }
/** * Set the maximum number of transports that can sit idle in the pool. Use a negative value for no limit. Default is 8. */ public void setMaxIdle(int maxIdle) { transportPool.setMaxIdle(maxIdle); }
public void setMaxIdle(int maxIdle) { pool.setMaxIdle(maxIdle); }
@Override public void setMaxIdle(int maxIdle) { this.pool.setMaxIdle(maxIdle); }
/** * @see org.apache.commons.pool.impl.GenericKeyedObjectPool#setMaxIdle(int) */ public void setMaxIdle(int maxIdle) { this.keyedObjectPool.setMaxIdle(maxIdle); }
/** * @see org.apache.commons.pool.impl.GenericKeyedObjectPool#setMaxIdle(int) */ public void setMaxIdle(int maxIdle) { this.keyedObjectPool.setMaxIdle(maxIdle); }
/** * Set the maximum number of transports that can sit idle in the pool. Use a negative value for no limit. Default is 8. */ public void setMaxIdle(int maxIdle) { transportPool.setMaxIdle(maxIdle); }
/** * @see org.apache.commons.pool.impl.GenericKeyedObjectPool#setMaxIdle(int) */ public void setMaxIdle(int maxIdle) { this.keyedObjectPool.setMaxIdle(maxIdle); }
public void setMaxIdle(int maxIdle) { pool.setMaxIdle(maxIdle); }
/** * Configures the maximum number of requesters that can be concurrently active per endpoint * * @param maxActive max. number of active requesters */ public void setMaxRequestersActive(int maxActive) { this.requesters.setMaxActive(maxActive); // adjust maxIdle in tandem to avoid thrashing this.requesters.setMaxIdle(maxActive); // this tells the pool to expire some objects eventually if we start // running out. This happens if one is using a lot of dynamic endpoints. this.requesters.setMaxTotal(20 * maxActive); }
/** * Configures the maximum number of requesters that can be concurrently active * per endpoint * * @param maxActive max. number of active requesters */ public void setMaxRequestersActive(int maxActive) { this.requesters.setMaxActive(maxActive); // adjust maxIdle in tandem to avoid thrashing this.requesters.setMaxIdle(maxActive); // this tells the pool to expire some objects eventually if we start // running out. This happens if one is using a lot of dynamic endpoints. this.requesters.setMaxTotal(20 * maxActive); }
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"))); _pool.setMinEvictableIdleTimeMillis(MINUTE * Long.parseLong(_propertySource.getPropertyValue("org.apache.tapestry.page-pool-evict-idle-page-minutes"))); _pool.setTimeBetweenEvictionRunsMillis(MINUTE * Long.parseLong(_propertySource.getPropertyValue("org.apache.tapestry.page-pool-evict-thread-sleep-minutes"))); _pool.setTestWhileIdle(false); _pool.setTestOnBorrow(false); _pool.setTestOnReturn(false); }
@Override public void start() throws LifecycleException { try { pool = new GenericKeyedObjectPool<>(new DatagramSocketFactory()); pool.setTestOnBorrow(true); pool.setMaxActive(-1); pool.setMaxIdle(-1); pool.setTimeBetweenEvictionRunsMillis(MILLISECONDS.convert(5, MINUTES)); pool.setMinEvictableIdleTimeMillis(MILLISECONDS.convert(5, MINUTES)); this.mbean = new ManagedGenericKeyedObjectPool((GenericKeyedObjectPool) pool, "StatsdConnectionPool"); ManagementFactory.getPlatformMBeanServer() .registerMBean(this.mbean, this.mbean.getObjectName()); } catch (Exception e) { throw new LifecycleException(e); } }
public GroovyPool(String scriptBaseClass) { super(); Configuration conf = Configuration.getInstance(); try { pool = new GenericKeyedObjectPool<>(new GroovyPoolFactory(scriptBaseClass)); pool.setTestOnBorrow(true); pool.setMaxTotal(conf.getPropertyAsInteger("tec.expressions.pool.maxtotal",1000)); pool.setMaxActive(-1); pool.setMaxIdle(conf.getPropertyAsInteger("tec.expressions.pool.maxidle",-1)); pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK); pool.setTimeBetweenEvictionRunsMillis(30000); pool.setMinEvictableIdleTimeMillis(-1); } catch(Exception e) { logger.error("An error occurred while starting GroovyPool.", e); } }
/** * Sets the configuration. * @param conf the new configuration to use. * @see GenericKeyedObjectPool.Config */ public synchronized void setConfig(GenericKeyedObjectPool.Config conf) { setMaxIdle(conf.maxIdle); setMaxActive(conf.maxActive); setMaxTotal(conf.maxTotal); setMinIdle(conf.minIdle); setMaxWait(conf.maxWait); setWhenExhaustedAction(conf.whenExhaustedAction); setTestOnBorrow(conf.testOnBorrow); setTestOnReturn(conf.testOnReturn); setTestWhileIdle(conf.testWhileIdle); setNumTestsPerEvictionRun(conf.numTestsPerEvictionRun); setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis); setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis); }
/** * Sets the configuration. * @param conf the new configuration to use. * @see GenericKeyedObjectPool.Config */ public synchronized void setConfig(GenericKeyedObjectPool.Config conf) { setMaxIdle(conf.maxIdle); setMaxActive(conf.maxActive); setMaxTotal(conf.maxTotal); setMinIdle(conf.minIdle); setMaxWait(conf.maxWait); setWhenExhaustedAction(conf.whenExhaustedAction); setTestOnBorrow(conf.testOnBorrow); setTestOnReturn(conf.testOnReturn); setTestWhileIdle(conf.testWhileIdle); setNumTestsPerEvictionRun(conf.numTestsPerEvictionRun); setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis); setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis); }