Search in sources :

Example 11 with GenericObjectPool

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericObjectPool in project cas by apereo.

the class MemcachedMonitorConfiguration method memcachedHealthClientPool.

@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "memcachedHealthClientPool")
public ObjectPool<MemcachedClientIF> memcachedHealthClientPool(@Qualifier("memcachedMonitorTranscoder") final Transcoder memcachedMonitorTranscoder, final CasConfigurationProperties casProperties) {
    val memcached = casProperties.getMonitor().getMemcached();
    val factory = new MemcachedPooledClientConnectionFactory(memcached, memcachedMonitorTranscoder);
    return new GenericObjectPool<>(factory);
}
Also used : lombok.val(lombok.val) MemcachedPooledClientConnectionFactory(org.apereo.cas.memcached.MemcachedPooledClientConnectionFactory) GenericObjectPool(org.apache.commons.pool2.impl.GenericObjectPool) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 12 with GenericObjectPool

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericObjectPool in project cas by apereo.

the class MemcachedPooledClientConnectionFactory method getObjectPool.

/**
 * Gets object pool.
 *
 * @return the object pool
 */
public ObjectPool<MemcachedClientIF> getObjectPool() {
    val pool = new GenericObjectPool<>(this);
    pool.setMaxIdle(memcachedProperties.getMaxIdle());
    pool.setMinIdle(memcachedProperties.getMinIdle());
    pool.setMaxTotal(memcachedProperties.getMaxTotal());
    return pool;
}
Also used : lombok.val(lombok.val) GenericObjectPool(org.apache.commons.pool2.impl.GenericObjectPool)

Example 13 with GenericObjectPool

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericObjectPool in project spring-framework by spring-projects.

the class CommonsPool2TargetSource method createObjectPool.

/**
 * Subclasses can override this if they want to return a specific Commons pool.
 * They should apply any configuration properties to the pool here.
 * <p>Default is a GenericObjectPool instance with the given pool size.
 * @return an empty Commons {@code ObjectPool}.
 * @see GenericObjectPool
 * @see #setMaxSize
 */
protected ObjectPool createObjectPool() {
    GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    config.setMaxTotal(getMaxSize());
    config.setMaxIdle(getMaxIdle());
    config.setMinIdle(getMinIdle());
    config.setMaxWaitMillis(getMaxWait());
    config.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
    config.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
    config.setBlockWhenExhausted(isBlockWhenExhausted());
    return new GenericObjectPool(this, config);
}
Also used : GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) GenericObjectPool(org.apache.commons.pool2.impl.GenericObjectPool)

Example 14 with GenericObjectPool

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericObjectPool in project ddf by codice.

the class SslLdapLoginModule method installLdapConnectionPool.

private void installLdapConnectionPool(String connectionPoolId) {
    BundleContext bundleContext = getContext();
    if (bundleContext != null) {
        try {
            Collection<ServiceReference<GenericObjectPool>> serviceReferences = bundleContext.getServiceReferences(GenericObjectPool.class, String.format("(id=%s)", connectionPoolId));
            ServiceReference<GenericObjectPool> serviceReference = serviceReferences.stream().findFirst().orElseThrow(() -> new IllegalStateException("No LDAPConnectionPool service found with id:" + connectionPoolId));
            ldapConnectionPool = bundleContext.getService(serviceReference);
        } catch (InvalidSyntaxException | IllegalStateException e) {
            LOGGER.error("Unable to get LDAP Connection pool. LDAP log in will not be possible.", e);
        }
    }
}
Also used : InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) GenericObjectPool(org.apache.commons.pool2.impl.GenericObjectPool) BundleContext(org.osgi.framework.BundleContext) ServiceReference(org.osgi.framework.ServiceReference)

Example 15 with GenericObjectPool

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericObjectPool in project athenz by yahoo.

the class DataSourceFactory method create.

static PoolableDataSource create(ConnectionFactory connectionFactory) {
    // setup our pool config object
    GenericObjectPoolConfig config = setupPoolConfig();
    PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, null);
    // Set max lifetime of a connection in milli-secs, after which it will
    // always fail activation, passivation, and validation.
    // Value of -1 means infinite life time. The default value
    // defined in this class is 10 minutes.
    long connTtlMillis = retrieveConfigSetting(ATHENZ_PROP_DBPOOL_MAX_TTL, MAX_TTL_CONN_MS);
    poolableConnectionFactory.setMaxConnLifetimeMillis(connTtlMillis);
    if (LOG.isInfoEnabled()) {
        LOG.info("Setting Time-To-Live interval for live connections ({}) msecs", connTtlMillis);
    }
    // set the validation query for our jdbc connector
    final String validationQuery = System.getProperty(ATHENZ_PROP_DBPOOL_VALIDATION_QUERY, MYSQL_VALIDATION_QUERY);
    poolableConnectionFactory.setValidationQuery(validationQuery);
    ObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<>(poolableConnectionFactory, config);
    poolableConnectionFactory.setPool(connectionPool);
    return new AthenzDataSource(connectionPool);
}
Also used : GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) PoolableConnection(org.apache.commons.dbcp2.PoolableConnection) GenericObjectPool(org.apache.commons.pool2.impl.GenericObjectPool) PoolableConnectionFactory(org.apache.commons.dbcp2.PoolableConnectionFactory)

Aggregations

GenericObjectPool (org.apache.commons.pool2.impl.GenericObjectPool)24 PoolableConnectionFactory (org.apache.commons.dbcp2.PoolableConnectionFactory)9 GenericObjectPoolConfig (org.apache.commons.pool2.impl.GenericObjectPoolConfig)9 ConnectionFactory (org.apache.commons.dbcp2.ConnectionFactory)7 PoolableConnection (org.apache.commons.dbcp2.PoolableConnection)6 AbandonedConfig (org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.AbandonedConfig)6 DriverManagerConnectionFactory (org.apache.commons.dbcp2.DriverManagerConnectionFactory)5 PoolingDataSource (org.apache.commons.dbcp2.PoolingDataSource)4 SQLException (java.sql.SQLException)3 Properties (java.util.Properties)3 File (java.io.File)2 IOException (java.io.IOException)2 ConnectionPoolDataSource (javax.sql.ConnectionPoolDataSource)2 lombok.val (lombok.val)2 PoolingDriver (org.apache.commons.dbcp2.PoolingDriver)2 MemcachedPooledClientConnectionFactory (org.apereo.cas.memcached.MemcachedPooledClientConnectionFactory)2 GenericObjectPool (org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericObjectPool)2 Bean (org.springframework.context.annotation.Bean)2 NettyClient (com.ctrip.xpipe.netty.commands.NettyClient)1 NettyClientFactory (com.ctrip.xpipe.netty.commands.NettyClientFactory)1