use of com.frameworkset.commons.pool2.impl.GenericObjectPool in project terra-workspace-manager by DataBiosphere.
the class BaseDatabaseConfiguration method configureDataSource.
private void configureDataSource() {
Properties props = new Properties();
props.setProperty("user", getUsername());
props.setProperty("password", getPassword());
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(getUri(), props);
PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, null);
ObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<>(poolableConnectionFactory);
poolableConnectionFactory.setPool(connectionPool);
dataSource = new PoolingDataSource<>(connectionPool);
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPool in project micrometer by micrometer-metrics.
the class CommonsObjectPool2MetricsTest method createGenericObjectPool.
private GenericObjectPool<Object> createGenericObjectPool() {
genericObjectPoolCount++;
GenericObjectPoolConfig<Object> config = new GenericObjectPoolConfig<>();
config.setMaxTotal(10);
return new GenericObjectPool<>(new BasePooledObjectFactory<Object>() {
@Override
public Object create() {
return new Object();
}
@Override
public PooledObject<Object> wrap(Object testObject) {
return new DefaultPooledObject<>(testObject);
}
}, config);
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPool in project businessautomation-cop by redhat-cop.
the class JPAAdditionalPersistence method auditDatasource.
@Bean
public DataSource auditDatasource() {
DataSourceXAConnectionFactory dataSourceXAConnectionFactory = new DataSourceXAConnectionFactory(tm, h2DataSource());
PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(dataSourceXAConnectionFactory, null);
GenericObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<>(poolableConnectionFactory);
poolableConnectionFactory.setPool(connectionPool);
return new ManagedDataSource<>(connectionPool, dataSourceXAConnectionFactory.getTransactionRegistry());
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPool in project jans by JanssenProject.
the class SqlConnectionProvider method open.
private void open() {
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectionUri, connectionProperties);
PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, null);
ObjectPool<PoolableConnection> objectPool = new GenericObjectPool<>(poolableConnectionFactory, objectPoolConfig);
this.poolingDataSource = new PoolingDataSource<>(objectPool);
poolableConnectionFactory.setPool(objectPool);
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPool in project spring-amqp by spring-projects.
the class PooledChannelConnectionFactoryTests method evictShouldCloseAllUnneededChannelsWithoutErrors.
@Test
public void evictShouldCloseAllUnneededChannelsWithoutErrors() throws Exception {
PooledChannelConnectionFactory pcf = new PooledChannelConnectionFactory(new ConnectionFactory());
AtomicReference<GenericObjectPool<Channel>> channelsReference = new AtomicReference<>();
AtomicReference<GenericObjectPool<Channel>> txChannelsReference = new AtomicReference<>();
AtomicInteger swallowedExceptionsCount = new AtomicInteger();
pcf.setPoolConfigurer((pool, tx) -> {
if (tx) {
channelsReference.set(pool);
} else {
txChannelsReference.set(pool);
}
pool.setEvictionPolicy((ec, u, idleCount) -> idleCount > ec.getMinIdle());
pool.setSwallowedExceptionListener(ex -> swallowedExceptionsCount.incrementAndGet());
pool.setNumTestsPerEvictionRun(5);
pool.setMinIdle(1);
pool.setMaxIdle(5);
});
createAndCloseFiveChannelTxAndChannelNonTx(pcf);
final GenericObjectPool<Channel> channels = channelsReference.get();
channels.evict();
assertThat(channels.getNumIdle()).isEqualTo(1);
assertThat(channels.getDestroyedByEvictorCount()).isEqualTo(4);
final GenericObjectPool<Channel> txChannels = txChannelsReference.get();
txChannels.evict();
assertThat(txChannels.getNumIdle()).isEqualTo(1);
assertThat(txChannels.getDestroyedByEvictorCount()).isEqualTo(4);
assertThat(swallowedExceptionsCount.get()).isZero();
}
Aggregations