use of com.zaxxer.hikari.HikariConfigMXBean in project midpoint by Evolveum.
the class TaskManagerQuartzImpl method getDBPoolStats.
// TODO move to more appropriate place
@Override
public Number[] getDBPoolStats() {
if (dataSource instanceof HikariDataSource) {
HikariPoolMXBean pool = ((HikariDataSource) dataSource).getHikariPoolMXBean();
HikariConfigMXBean config = ((HikariDataSource) dataSource).getHikariConfigMXBean();
if (pool == null || config == null) {
return null;
}
return new Number[] { pool.getActiveConnections(), pool.getIdleConnections(), pool.getThreadsAwaitingConnection(), pool.getTotalConnections(), config.getMaximumPoolSize() };
}
return null;
}
use of com.zaxxer.hikari.HikariConfigMXBean in project HikariCP by brettwooldridge.
the class TestMBean method testMBeanConnectionTimeoutChange.
@Test
public void testMBeanConnectionTimeoutChange() throws SQLException {
HikariConfig config = newHikariConfig();
config.setMinimumIdle(1);
config.setMaximumPoolSize(2);
config.setRegisterMbeans(true);
config.setConnectionTimeout(2800);
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
System.setProperty("com.zaxxer.hikari.housekeeping.periodMs", "250");
try (HikariDataSource ds = new HikariDataSource(config)) {
HikariConfigMXBean hikariConfigMXBean = ds.getHikariConfigMXBean();
assertEquals(2800, hikariConfigMXBean.getConnectionTimeout());
final StubDataSource stubDataSource = ds.unwrap(StubDataSource.class);
// connection acquisition takes more than 0 ms in a real system
stubDataSource.setConnectionAcquistionTime(1200);
hikariConfigMXBean.setConnectionTimeout(1000);
quietlySleep(500);
try (Connection conn1 = ds.getConnection();
Connection conn2 = ds.getConnection()) {
fail("Connection should have timed out.");
conn1.close();
conn2.close();
} catch (SQLException e) {
assertEquals(1000, ds.getConnectionTimeout());
}
} finally {
System.clearProperty("com.zaxxer.hikari.housekeeping.periodMs");
}
}
use of com.zaxxer.hikari.HikariConfigMXBean in project HikariCP by brettwooldridge.
the class TestMBean method testMBeanChange.
@Test
public void testMBeanChange() {
HikariConfig config = newHikariConfig();
config.setMinimumIdle(3);
config.setMaximumPoolSize(5);
config.setRegisterMbeans(true);
config.setConnectionTimeout(2800);
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
try (HikariDataSource ds = new HikariDataSource(config)) {
HikariConfigMXBean hikariConfigMXBean = ds.getHikariConfigMXBean();
hikariConfigMXBean.setIdleTimeout(3000);
assertEquals(3000, ds.getIdleTimeout());
}
}
Aggregations