本文整理汇总了Java中com.zaxxer.hikari.HikariConfig.setLeakDetectionThreshold方法的典型用法代码示例。如果您正苦于以下问题:Java HikariConfig.setLeakDetectionThreshold方法的具体用法?Java HikariConfig.setLeakDetectionThreshold怎么用?Java HikariConfig.setLeakDetectionThreshold使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.zaxxer.hikari.HikariConfig
的用法示例。
在下文中一共展示了HikariConfig.setLeakDetectionThreshold方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HikariWrapper
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
public HikariWrapper(@Nonnull DatabaseCredentials credentials) {
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(25);
config.setPoolName("helper-sql-" + COUNTER.getAndIncrement());
config.setDataSourceClassName("org.mariadb.jdbc.MySQLDataSource");
config.addDataSourceProperty("serverName", credentials.getAddress());
config.addDataSourceProperty("port", credentials.getPort());
config.addDataSourceProperty("databaseName", credentials.getDatabase());
config.setUsername(credentials.getUsername());
config.setPassword(credentials.getPassword());
// hack for the mariadb driver
config.addDataSourceProperty("properties", "useUnicode=true;characterEncoding=utf8");
// We will wait for 15 seconds to get a connection from the pool.
// Default is 30, but it shouldn't be taking that long.
config.setConnectionTimeout(TimeUnit.SECONDS.toMillis(15)); // 15000
// If a connection is not returned within 10 seconds, it's probably safe to assume it's been leaked.
config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(10)); // 10000
hikari = new HikariDataSource(config);
}
示例2: getHikariConfig
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private HikariConfig getHikariConfig(AgroalDataSourceConfiguration dataSourceConfiguration) {
if ( dataSourceConfiguration.isXA() ) {
throw new UnsupportedOperationException( "Unsupported. Hikari does not support XA" );
}
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setDataSourceJNDI( dataSourceConfiguration.jndiName() );
hikariConfig.setLeakDetectionThreshold( poolConfiguration.leakTimeout().toMillis() );
hikariConfig.setIdleTimeout( poolConfiguration.reapTimeout().toMillis() );
hikariConfig.setValidationTimeout( poolConfiguration.validationTimeout().toMillis() );
if ( factoryConfiguration.jdbcTransactionIsolation().isDefined() ) {
hikariConfig.setTransactionIsolation( "TRANSACTION_" + factoryConfiguration.jdbcTransactionIsolation().name() );
}
hikariConfig.setJdbcUrl( factoryConfiguration.jdbcUrl() );
hikariConfig.setAutoCommit( factoryConfiguration.autoCommit() );
hikariConfig.setConnectionInitSql( factoryConfiguration.initialSql() );
Principal principal = factoryConfiguration.principal();
if ( principal != null ) {
hikariConfig.setUsername( factoryConfiguration.principal().getName() );
}
for ( Object credential : factoryConfiguration.credentials() ) {
if ( credential instanceof SimplePassword ) {
hikariConfig.setPassword( ( (SimplePassword) credential ).getWord() );
}
}
hikariConfig.setMaximumPoolSize( poolConfiguration.maxSize() );
hikariConfig.setConnectionTimeout( poolConfiguration.acquisitionTimeout().toMillis() );
hikariConfig.setDriverClassName( factoryConfiguration.driverClassName() );
return hikariConfig;
}
示例3: init
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public void init() {
HikariConfig config = new HikariConfig();
config.setPoolName("luckperms");
appendConfigurationInfo(config);
appendProperties(config, this.configuration);
config.setMaximumPoolSize(this.configuration.getMaxPoolSize());
config.setMinimumIdle(this.configuration.getMinIdleConnections());
config.setMaxLifetime(this.configuration.getMaxLifetime());
config.setConnectionTimeout(this.configuration.getConnectionTimeout());
// If a connection is not returned within 10 seconds, it's probably safe to assume it's been leaked.
config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(10)); // 10000
// The drivers are really old in some of the older Spigot binaries, so Connection#isValid doesn't work.
config.setConnectionTestQuery("/* LuckPerms ping */ SELECT 1");
try {
// don't perform any initial connection validation - we subsequently call #getConnection
// to setup the schema anyways
config.setInitializationFailTimeout(-1);
} catch (NoSuchMethodError e) {
//noinspection deprecation
config.setInitializationFailFast(false);
}
this.hikari = new HikariDataSource(config);
}
示例4: createIndexEngine
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private IndexEngine createIndexEngine() {
if (System.getProperty("postgres") != null) {
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(50);
config.setLeakDetectionThreshold(2000);
config.setConnectionInitSql("SET log_statement = 'all'; SET search_path = 'public'");
return new CascadingIndexEngine(new PostgreSQLIndexEngine(getPostgreSQLDataSource(), config),
new MemoryIndexEngine());
} else {
return new MemoryIndexEngine();
}
}