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; }
/** * 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#setTestOnReturn(boolean) */ public void setTestOnReturn(boolean testOnReturn) { this.keyedObjectPool.setTestOnReturn(testOnReturn); }
/** * @see org.apache.commons.pool.impl.GenericKeyedObjectPool#setTestOnReturn(boolean) */ public void setTestOnReturn(boolean testOnReturn) { this.keyedObjectPool.setTestOnReturn(testOnReturn); }
/** * @see org.apache.commons.pool.impl.GenericKeyedObjectPool#setTestOnReturn(boolean) */ public void setTestOnReturn(boolean testOnReturn) { this.keyedObjectPool.setTestOnReturn(testOnReturn); }
/** * @see org.apache.commons.pool.impl.GenericKeyedObjectPool#setTestOnReturn(boolean) */ public void setTestOnReturn(boolean testOnReturn) { this.keyedObjectPool.setTestOnReturn(testOnReturn); }
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); pool.setTestOnReturn(true); }
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); pool.setTestOnReturn(true); }
public AbstractConnector(MuleContext context) { muleContext = context; lifecycleManager = new ConnectorLifecycleManager(this); setDynamicNotification(false); updateCachedNotificationHandler(); // always add at least the default protocol supportedProtocols = new ArrayList<>(); supportedProtocols.add(getProtocol().toLowerCase()); // TODO dispatcher pool configuration should be extracted, maybe even // moved into the factory? // 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. requesters.setTestOnBorrow(false); requesters.setTestOnReturn(true); }
@Override protected void doInitialise() throws InitialisationException { socketFactory = new MulticastSocketFactory(); dispatcherSocketsPool.setFactory(socketFactory); dispatcherSocketsPool.setTestOnBorrow(false); dispatcherSocketsPool.setTestOnReturn(true); //For clarity, note that the max active value does not need to be 1 since you can have multiple //Multicast sockets bound to a single port //dispatcherSocketsPool.setMaxActive(1); }
public AbstractConnector(MuleContext context) { muleContext = context; lifecycleManager = new ConnectorLifecycleManager(this); setDynamicNotification(false); updateCachedNotificationHandler(); // always add at least the default protocol supportedProtocols = new ArrayList<>(); supportedProtocols.add(getProtocol().toLowerCase()); // TODO dispatcher pool configuration should be extracted, maybe even // moved into the factory? // 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. requesters.setTestOnBorrow(false); requesters.setTestOnReturn(true); }
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); }
@Override protected void doInitialise() throws InitialisationException { socketFactory = new UdpSocketFactory(); dispatcherSocketsPool.setFactory(socketFactory); dispatcherSocketsPool.setTestOnBorrow(true); dispatcherSocketsPool.setTestOnReturn(true); //There should only be one pooled instance per socket (key) dispatcherSocketsPool.setMaxActive(1); }
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); }
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; }
/** * 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); }
/** * 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); }