当前位置: 首页>>代码示例>>Java>>正文


Java HikariConfig.setLeakDetectionThreshold方法代码示例

本文整理汇总了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);
}
 
开发者ID:lucko,项目名称:helper,代码行数:26,代码来源:HikariWrapper.java

示例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;
}
 
开发者ID:agroal,项目名称:agroal,代码行数:37,代码来源:HikariUnderTheCovers.java

示例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);
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:32,代码来源:HikariConnectionFactory.java

示例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();
    }
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:15,代码来源:TestWithRepository.java


注:本文中的com.zaxxer.hikari.HikariConfig.setLeakDetectionThreshold方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。