use of com.zaxxer.hikari.HikariConfig in project storm by apache.
the class HikariCPConnectionProvider method prepare.
@Override
public synchronized void prepare() {
if (dataSource == null) {
Properties properties = new Properties();
properties.putAll(configMap);
HikariConfig config = new HikariConfig(properties);
if (properties.containsKey("dataSource.url")) {
LOG.info("DataSource Url: " + properties.getProperty("dataSource.url"));
} else if (config.getJdbcUrl() != null) {
LOG.info("JDBC Url: " + config.getJdbcUrl());
}
this.dataSource = new HikariDataSource(config);
this.dataSource.setAutoCommit(false);
}
}
use of com.zaxxer.hikari.HikariConfig in project hive by apache.
the class TxnHandler method setupJdbcConnectionPool.
private static synchronized void setupJdbcConnectionPool(HiveConf conf) throws SQLException {
if (connPool != null)
return;
String driverUrl = HiveConf.getVar(conf, HiveConf.ConfVars.METASTORECONNECTURLKEY);
String user = getMetastoreJdbcUser(conf);
String passwd = getMetastoreJdbcPasswd(conf);
String connectionPooler = conf.getVar(HiveConf.ConfVars.METASTORE_CONNECTION_POOLING_TYPE).toLowerCase();
if ("bonecp".equals(connectionPooler)) {
BoneCPConfig config = new BoneCPConfig();
config.setJdbcUrl(driverUrl);
//if we are waiting for connection for 60s, something is really wrong
//better raise an error than hang forever
config.setConnectionTimeoutInMs(60000);
config.setMaxConnectionsPerPartition(10);
config.setPartitionCount(1);
config.setUser(user);
config.setPassword(passwd);
connPool = new BoneCPDataSource(config);
// Enable retries to work around BONECP bug.
doRetryOnConnPool = true;
} else if ("dbcp".equals(connectionPooler)) {
ObjectPool objectPool = new GenericObjectPool();
ConnectionFactory connFactory = new DriverManagerConnectionFactory(driverUrl, user, passwd);
// This doesn't get used, but it's still necessary, see
// http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/doc/ManualPoolingDataSourceExample.java?view=markup
PoolableConnectionFactory poolConnFactory = new PoolableConnectionFactory(connFactory, objectPool, null, null, false, true);
connPool = new PoolingDataSource(objectPool);
} else if ("hikaricp".equals(connectionPooler)) {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(driverUrl);
config.setUsername(user);
config.setPassword(passwd);
connPool = new HikariDataSource(config);
} else if ("none".equals(connectionPooler)) {
LOG.info("Choosing not to pool JDBC connections");
connPool = new NoPoolConnectionPool(conf);
} else {
throw new RuntimeException("Unknown JDBC connection pooling " + connectionPooler);
}
}
use of com.zaxxer.hikari.HikariConfig in project killbill by killbill.
the class TestKillbillJdbcTenantRealm method beforeMethod.
@Override
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
super.beforeMethod();
// Create the tenant
final DefaultTenantDao tenantDao = new DefaultTenantDao(dbi, clock, cacheControllerDispatcher, new DefaultNonEntityDao(dbi), Mockito.mock(InternalCallContextFactory.class), securityConfig);
tenant = new DefaultTenant(UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString());
tenantDao.create(new TenantModelDao(tenant), internalCallContext);
// Setup the security manager
final HikariConfig dbConfig = new HikariConfig();
dbConfig.setJdbcUrl(helper.getJdbcConnectionString());
dbConfig.setUsername(helper.getUsername());
dbConfig.setPassword(helper.getPassword());
final KillbillJdbcTenantRealm jdbcRealm = new KillbillJdbcTenantRealm(shiroDataSource, securityConfig);
jdbcRealm.setDataSource(new HikariDataSource(dbConfig));
securityManager = new DefaultSecurityManager(jdbcRealm);
}
use of com.zaxxer.hikari.HikariConfig in project hibernate-orm by hibernate.
the class HikariConfigurationUtil method loadConfiguration.
/**
* Create/load a HikariConfig from Hibernate properties.
*
* @param props a map of Hibernate properties
* @return a HikariConfig
*/
@SuppressWarnings("rawtypes")
public static HikariConfig loadConfiguration(Map props) {
Properties hikariProps = new Properties();
copyProperty(AvailableSettings.AUTOCOMMIT, props, "autoCommit", hikariProps);
copyProperty(AvailableSettings.DRIVER, props, "driverClassName", hikariProps);
copyProperty(AvailableSettings.URL, props, "jdbcUrl", hikariProps);
copyProperty(AvailableSettings.USER, props, "username", hikariProps);
copyProperty(AvailableSettings.PASS, props, "password", hikariProps);
copyIsolationSetting(props, hikariProps);
for (Object keyo : props.keySet()) {
if (!(keyo instanceof String)) {
continue;
}
String key = (String) keyo;
if (key.startsWith(CONFIG_PREFIX)) {
hikariProps.setProperty(key.substring(CONFIG_PREFIX.length()), (String) props.get(key));
}
}
return new HikariConfig(hikariProps);
}
use of com.zaxxer.hikari.HikariConfig in project pinpoint by naver.
the class HikariCpIT method setup.
@BeforeClass
public static void setup() {
final HikariConfig config = new HikariConfig();
config.setDataSourceClassName("org.h2.jdbcx.JdbcDataSource");
config.addDataSourceProperty("url", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
dataSource = new HikariDataSource(config);
}
Aggregations