Search in sources :

Example 1 with AbandonedConfig

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.AbandonedConfig in project datanucleus-rdbms by datanucleus.

the class BasicDataSource method createConnectionPool.

/**
 * Creates a connection pool for this datasource.  This method only exists
 * so subclasses can replace the implementation class.
 *
 * This implementation configures all pool properties other than
 * timeBetweenEvictionRunsMillis.  Setting that property is deferred to
 * {@link #startPoolMaintenance()}, since setting timeBetweenEvictionRunsMillis
 * to a positive value causes {@link GenericObjectPool}'s eviction timer
 * to be started.
 */
protected void createConnectionPool(PoolableConnectionFactory factory) {
    // Create an object pool to contain our active connections
    GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    updateJmxName(config);
    // Disable JMX on the underlying pool if the DS is not registered.
    config.setJmxEnabled(registeredJmxName != null);
    GenericObjectPool<PoolableConnection> gop;
    if (abandonedConfig != null && (abandonedConfig.getRemoveAbandonedOnBorrow() || abandonedConfig.getRemoveAbandonedOnMaintenance())) {
        gop = new GenericObjectPool<>(factory, config, abandonedConfig);
    } else {
        gop = new GenericObjectPool<>(factory, config);
    }
    gop.setMaxTotal(maxTotal);
    gop.setMaxIdle(maxIdle);
    gop.setMinIdle(minIdle);
    gop.setMaxWaitMillis(maxWaitMillis);
    gop.setTestOnCreate(testOnCreate);
    gop.setTestOnBorrow(testOnBorrow);
    gop.setTestOnReturn(testOnReturn);
    gop.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
    gop.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
    gop.setTestWhileIdle(testWhileIdle);
    gop.setLifo(lifo);
    gop.setSwallowedExceptionListener(new SwallowedExceptionLogger(log, logExpiredConnections));
    gop.setEvictionPolicyClassName(evictionPolicyClassName);
    factory.setPool(gop);
    connectionPool = gop;
}
Also used : GenericObjectPoolConfig(org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericObjectPoolConfig)

Example 2 with AbandonedConfig

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.AbandonedConfig in project datanucleus-rdbms by datanucleus.

the class BasicDataSource method setRemoveAbandonedOnMaintenance.

/**
 * @param removeAbandonedOnMaintenance true means abandoned connections may be removed on pool maintenance.
 * @see #getRemoveAbandonedOnMaintenance()
 */
public void setRemoveAbandonedOnMaintenance(final boolean removeAbandonedOnMaintenance) {
    if (abandonedConfig == null) {
        abandonedConfig = new AbandonedConfig();
    }
    abandonedConfig.setRemoveAbandonedOnMaintenance(removeAbandonedOnMaintenance);
    final GenericObjectPool<?> gop = this.connectionPool;
    if (gop != null) {
        gop.setAbandonedConfig(abandonedConfig);
    }
}
Also used : AbandonedConfig(org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.AbandonedConfig)

Example 3 with AbandonedConfig

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.AbandonedConfig in project datanucleus-rdbms by datanucleus.

the class BasicDataSource method setLogAbandoned.

/**
 * @param logAbandoned new logAbandoned property value
 */
public void setLogAbandoned(final boolean logAbandoned) {
    if (abandonedConfig == null) {
        abandonedConfig = new AbandonedConfig();
    }
    abandonedConfig.setLogAbandoned(logAbandoned);
    final GenericObjectPool<?> gop = this.connectionPool;
    if (gop != null) {
        gop.setAbandonedConfig(abandonedConfig);
    }
}
Also used : AbandonedConfig(org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.AbandonedConfig)

Example 4 with AbandonedConfig

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.AbandonedConfig in project tomcat by apache.

the class BasicDataSource method setRemoveAbandonedTimeout.

/**
 * Sets the timeout before an abandoned connection can be removed.
 * <p>
 * Setting this property has no effect if {@link #getRemoveAbandonedOnBorrow()} and
 * {code getRemoveAbandonedOnMaintenance()} are false.
 * </p>
 *
 * @param removeAbandonedTimeout new abandoned timeout
 * @see #getRemoveAbandonedTimeoutDuration()
 * @see #getRemoveAbandonedOnBorrow()
 * @see #getRemoveAbandonedOnMaintenance()
 * @since 2.10.0
 */
public void setRemoveAbandonedTimeout(final Duration removeAbandonedTimeout) {
    if (abandonedConfig == null) {
        abandonedConfig = new AbandonedConfig();
    }
    abandonedConfig.setRemoveAbandonedTimeout(removeAbandonedTimeout);
    final GenericObjectPool<?> gop = this.connectionPool;
    if (gop != null) {
        gop.setAbandonedConfig(abandonedConfig);
    }
}
Also used : AbandonedConfig(org.apache.tomcat.dbcp.pool2.impl.AbandonedConfig)

Example 5 with AbandonedConfig

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.AbandonedConfig in project tomcat by apache.

the class BasicDataSource method setAbandonedLogWriter.

/**
 * Sets the print writer to be used by this configuration to log information on abandoned objects.
 *
 * @param logWriter The new log writer
 */
public void setAbandonedLogWriter(final PrintWriter logWriter) {
    if (abandonedConfig == null) {
        abandonedConfig = new AbandonedConfig();
    }
    abandonedConfig.setLogWriter(logWriter);
    final GenericObjectPool<?> gop = this.connectionPool;
    if (gop != null) {
        gop.setAbandonedConfig(abandonedConfig);
    }
}
Also used : AbandonedConfig(org.apache.tomcat.dbcp.pool2.impl.AbandonedConfig)

Aggregations

AbandonedConfig (org.apache.tomcat.dbcp.pool2.impl.AbandonedConfig)7 AbandonedConfig (org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.AbandonedConfig)6 AbandonedConfig (org.apache.commons.pool2.impl.AbandonedConfig)1 GenericObjectPoolConfig (org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericObjectPoolConfig)1