org.apache.commons.pool2.impl.AbandonedConfig Java Examples
The following examples show how to use
org.apache.commons.pool2.impl.AbandonedConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultSessionPool.java From cyberduck with GNU General Public License v3.0 | 6 votes |
public DefaultSessionPool(final ConnectionService connect, final X509TrustManager trust, final X509KeyManager key, final VaultRegistry registry, final Cache<Path> cache, final TranscriptListener transcript, final Host bookmark) { this.connect = connect; this.registry = registry; this.cache = cache; this.bookmark = bookmark; this.transcript = transcript; final GenericObjectPoolConfig<Session> configuration = new GenericObjectPoolConfig<Session>(); configuration.setJmxEnabled(false); configuration.setEvictionPolicyClassName(CustomPoolEvictionPolicy.class.getName()); configuration.setBlockWhenExhausted(true); configuration.setMaxWaitMillis(BORROW_MAX_WAIT_INTERVAL); this.pool = new GenericObjectPool<Session>(new PooledSessionFactory(connect, trust, key, cache, bookmark, registry), configuration); final AbandonedConfig abandon = new AbandonedConfig(); abandon.setUseUsageTracking(true); this.pool.setAbandonedConfig(abandon); }
Example #2
Source File: BaseTestProxiedObjectPool.java From commons-pool with Apache License 2.0 | 6 votes |
@Before public void setUp() { log = new StringWriter(); final PrintWriter pw = new PrintWriter(log); final AbandonedConfig abandonedConfig = new AbandonedConfig(); abandonedConfig.setLogAbandoned(true); abandonedConfig.setRemoveAbandonedOnBorrow(true); abandonedConfig.setUseUsageTracking(true); abandonedConfig.setRemoveAbandonedTimeout(ABANDONED_TIMEOUT_SECS); abandonedConfig.setLogWriter(pw); final GenericObjectPoolConfig<TestObject> config = new GenericObjectPoolConfig<>(); config.setMaxTotal(3); final PooledObjectFactory<TestObject> factory = new TestObjectFactory(); @SuppressWarnings("resource") final ObjectPool<TestObject> innerPool = new GenericObjectPool<>(factory, config, abandonedConfig); pool = new ProxiedObjectPool<>(innerPool, getproxySource()); }
Example #3
Source File: DataLoaderFactory.java From AutoLoadCache with Apache License 2.0 | 5 votes |
private DataLoaderFactory() { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(1024); config.setMaxIdle(50); config.setMinIdle(8); // 当Pool中没有对象时不等待,而是直接new个新的 config.setBlockWhenExhausted(false); AbandonedConfig abandonConfig = new AbandonedConfig(); abandonConfig.setRemoveAbandonedTimeout(300); abandonConfig.setRemoveAbandonedOnBorrow(true); abandonConfig.setRemoveAbandonedOnMaintenance(true); factory = new GenericObjectPool<DataLoader>(this, config, abandonConfig); }
Example #4
Source File: SvnObjectPools.java From proctor with Apache License 2.0 | 5 votes |
private static <T> ObjectPool<T> createObjectPool(final PooledObjectFactory<T> factory) { final GenericObjectPoolConfig objectPoolConfig = new GenericObjectPoolConfig(); objectPoolConfig.setMinEvictableIdleTimeMillis(TimeUnit.HOURS.toMillis(1)); // arbitrary, but positive so objects do get evicted objectPoolConfig.setTimeBetweenEvictionRunsMillis(TimeUnit.MINUTES.toMillis(10)); // arbitrary, but positive so objects do get evicted objectPoolConfig.setJmxEnabled(false); objectPoolConfig.setBlockWhenExhausted(false); objectPoolConfig.setMaxTotal(-1); // uncapped number of objects in the pool final AbandonedConfig abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnBorrow(true); abandonedConfig.setRemoveAbandonedTimeout((int) TimeUnit.MINUTES.toSeconds(30)); return new GenericObjectPool<T>(factory, objectPoolConfig, abandonedConfig); }
Example #5
Source File: BasicDataSource.java From commons-dbcp with Apache License 2.0 | 5 votes |
/** * Creates an object pool used to provide pooling support for {@link Connection JDBC connections}. * * @param factory the object factory * @param poolConfig the object pool configuration * @param abandonedConfig the abandoned objects configuration * @return a non-null instance */ protected GenericObjectPool<PoolableConnection> createObjectPool(final PoolableConnectionFactory factory, final GenericObjectPoolConfig<PoolableConnection> poolConfig, final AbandonedConfig abandonedConfig) { GenericObjectPool<PoolableConnection> gop; if (abandonedConfig != null && (abandonedConfig.getRemoveAbandonedOnBorrow() || abandonedConfig.getRemoveAbandonedOnMaintenance())) { gop = new GenericObjectPool<>(factory, poolConfig, abandonedConfig); } else { gop = new GenericObjectPool<>(factory, poolConfig); } return gop; }
Example #6
Source File: HdfsPool.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 4 votes |
public HdfsPool(final HdfsFactory factory, final GenericObjectPoolConfig<FileSystem> config, final AbandonedConfig abandonedConfig) { super(factory, config, abandonedConfig); }
Example #7
Source File: ElasticsearchClientPool.java From super-cloudops with Apache License 2.0 | 4 votes |
public ElasticsearchClientPool(PooledObjectFactory<RestHighLevelClient> factory, GenericObjectPoolConfig<RestHighLevelClient> config, AbandonedConfig abandonedConfig) { super(factory, config, abandonedConfig); }
Example #8
Source File: FTPClientPool.java From hsweb-framework with Apache License 2.0 | 4 votes |
public FTPClientPool(PooledObjectFactory<FTPClient> factory, GenericObjectPoolConfig config, AbandonedConfig abandonedConfig) { super(factory, config, abandonedConfig); }
Example #9
Source File: SmtpConnectionPool.java From smtp-connection-pool with Apache License 2.0 | 4 votes |
public SmtpConnectionPool(SmtpConnectionFactory factory, GenericObjectPoolConfig config, AbandonedConfig abandonedConfig) { super(factory, config, abandonedConfig); }
Example #10
Source File: DbcpFactory.java From seldon-server with Apache License 2.0 | 4 votes |
private void createDbcp(DbcpConfig conf) { if (!dataSources.containsKey(conf.name)) { try { Class.forName(conf.driverClassName); DriverManagerConnectionFactory cf = new DriverManagerConnectionFactory(conf.jdbc,conf.user,conf.password); PoolableConnectionFactory pcf = new PoolableConnectionFactory(cf,null); pcf.setValidationQuery(conf.validationQuery); //, pool, null, conf.validationQuery, false, true,abandondedConfig); logger.info("Creating pool "+conf.toString()); // create a generic pool GenericObjectPool<PoolableConnection> pool = new GenericObjectPool<PoolableConnection>(pcf); pool.setMaxTotal(conf.maxTotal); pool.setMaxIdle(conf.maxIdle); pool.setMinIdle(conf.minIdle); pool.setMaxWaitMillis(conf.maxWait); pool.setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis); pool.setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis); pool.setTestWhileIdle(conf.testWhileIdle); pool.setTestOnBorrow(conf.testOnBorrow); AbandonedConfig abandonedConfig = new AbandonedConfig(); abandonedConfig.setRemoveAbandonedOnMaintenance(conf.removeAbanadoned); abandonedConfig.setRemoveAbandonedTimeout(conf.removeAbandonedTimeout); abandonedConfig.setLogAbandoned(conf.logAbandonded); pool.setAbandonedConfig(abandonedConfig); pcf.setPool(pool); DataSource ds = new PoolingDataSource(pool); dataSources.put(conf.name, ds); } catch (ClassNotFoundException e) { logger.error("Failed to create datasource for "+conf.name+ " with class "+conf.driverClassName); } } else { logger.error("Pool "+conf.name+" already exists. Can't change existing datasource at present."); } }
Example #11
Source File: PoolClientInvocationHandler.java From incubator-sentry with Apache License 2.0 | 4 votes |
public PoolClientInvocationHandler(Configuration conf) throws Exception { this.conf = conf; readConfiguration(); poolFactory = new SentryServiceClientPoolFactory(conf); pool = new GenericObjectPool<SentryPolicyServiceClient>(poolFactory, poolConfig, new AbandonedConfig()); }