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); }
/** * Set the minimum amount of time a transport may sit idle, before it is eligible for eviction. Set to non positive prevent * eviction based on idle time. * * This value has no affect if timeBetweenEvictionRuns is non positive. * * Default value is 30 seconds. */ public void setMinEvictableIdleTime(long time) { transportPool.setMinEvictableIdleTimeMillis(time); }
/** * Set the minimum amount of time a transport may sit idle, before it is eligible for eviction. Set to non positive prevent * eviction based on idle time. * * This value has no affect if timeBetweenEvictionRuns is non positive. * * Default value is 30 seconds. */ public void setMinEvictableIdleTime(long time) { transportPool.setMinEvictableIdleTimeMillis(time); }
/** * @see org.apache.commons.pool.impl.GenericKeyedObjectPool#setMinEvictableIdleTimeMillis(long) */ public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { this.keyedObjectPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); }
/** * @see org.apache.commons.pool.impl.GenericKeyedObjectPool#setMinEvictableIdleTimeMillis(long) */ public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { this.keyedObjectPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); }
/** * @see org.apache.commons.pool.impl.GenericKeyedObjectPool#setMinEvictableIdleTimeMillis(long) */ public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { this.keyedObjectPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); }
/** * @see org.apache.commons.pool.impl.GenericKeyedObjectPool#setMinEvictableIdleTimeMillis(long) */ public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { this.keyedObjectPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); }
public RegexpMatcher() { _pool = new GenericKeyedObjectPool(_factory); _pool.setMinEvictableIdleTimeMillis(EVICT_IDLE_TIME); _pool.setTimeBetweenEvictionRunsMillis(SLEEP_TIME); }
public RegexpMatcher() { _pool = new GenericKeyedObjectPool(_factory); _pool.setMinEvictableIdleTimeMillis(EVICT_IDLE_TIME); _pool.setTimeBetweenEvictionRunsMillis(SLEEP_TIME); }
public AlfrescoJavaMailSender() { transportPool.setMaxActive(-1); transportPool.setTestOnBorrow(true); transportPool.setTestOnReturn(true); transportPool.setTimeBetweenEvictionRunsMillis(DEAFULT_TIME_BETWEEN_EVICTION_RUNS); transportPool.setMinEvictableIdleTimeMillis(DEAFULT_TIME_BETWEEN_EVICTION_RUNS); }
public AlfrescoJavaMailSender() { transportPool.setMaxActive(-1); transportPool.setTestOnBorrow(true); transportPool.setTestOnReturn(true); transportPool.setTimeBetweenEvictionRunsMillis(DEAFULT_TIME_BETWEEN_EVICTION_RUNS); transportPool.setMinEvictableIdleTimeMillis(DEAFULT_TIME_BETWEEN_EVICTION_RUNS); }
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); } }
public synchronized static void initializeConnectionPool(EventSyncConnectionPoolFactory factory, int maxActive, int maxTotal, int maxIdle, long maxWait, long minEvictableIdleTimeMillis) { if (connectionPool == null) { connectionPool = new GenericKeyedObjectPool(); connectionPool.setFactory(factory); connectionPool.setMaxTotal(maxTotal); connectionPool.setMaxActive(maxActive); connectionPool.setTestOnBorrow(true); connectionPool.setTimeBetweenEvictionRunsMillis(12000); connectionPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); connectionPool.setMaxIdle(maxIdle); connectionPool.setMaxWait(maxWait); connectionPool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK); } }
/** * 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); }
/** * 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); }