use of com.codahale.metrics.health.HealthCheckRegistry in project incubator-myriad by apache.
the class Main method initHealthChecks.
/**
* Initializes health checks.
*
* @param injector
*/
private void initHealthChecks(Injector injector) {
LOGGER.info("Initializing HealthChecks");
healthCheckRegistry = new HealthCheckRegistry();
healthCheckRegistry.register(MesosMasterHealthCheck.NAME, injector.getInstance(MesosMasterHealthCheck.class));
healthCheckRegistry.register(ZookeeperHealthCheck.NAME, injector.getInstance(ZookeeperHealthCheck.class));
healthCheckRegistry.register(MesosDriverHealthCheck.NAME, injector.getInstance(MesosDriverHealthCheck.class));
}
use of com.codahale.metrics.health.HealthCheckRegistry in project HikariCP by brettwooldridge.
the class TestMetrics method testHealthChecks.
@Test
public void testHealthChecks() throws Exception {
MetricRegistry metricRegistry = new MetricRegistry();
HealthCheckRegistry healthRegistry = new HealthCheckRegistry();
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(10);
config.setMetricRegistry(metricRegistry);
config.setHealthCheckRegistry(healthRegistry);
config.setPoolName("test");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
config.addHealthCheckProperty("connectivityCheckTimeoutMs", "1000");
config.addHealthCheckProperty("expected99thPercentileMs", "100");
try (HikariDataSource ds = new HikariDataSource(config)) {
UtilityElf.quietlySleep(TimeUnit.SECONDS.toMillis(2));
Connection connection = ds.getConnection();
connection.close();
connection = ds.getConnection();
connection.close();
SortedMap<String, Result> healthChecks = healthRegistry.runHealthChecks();
Result connectivityResult = healthChecks.get("test.pool.ConnectivityCheck");
Assert.assertTrue(connectivityResult.isHealthy());
Result slaResult = healthChecks.get("test.pool.Connection99Percent");
Assert.assertTrue(slaResult.isHealthy());
}
}
use of com.codahale.metrics.health.HealthCheckRegistry in project HikariCP by brettwooldridge.
the class TestMetrics method testSetters2.
@Test
public void testSetters2() throws Exception {
HikariDataSource ds = new HikariDataSource();
ds.setMaximumPoolSize(1);
ds.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
MetricRegistry metricRegistry = new MetricRegistry();
HealthCheckRegistry healthRegistry = new HealthCheckRegistry();
ds.setMetricRegistry(metricRegistry);
ds.setHealthCheckRegistry(healthRegistry);
// before the pool is started, we can set it any number of times...
ds.setMetricRegistry(metricRegistry);
ds.setHealthCheckRegistry(healthRegistry);
try {
Connection connection = ds.getConnection();
connection.close();
// after the pool is started, we cannot set it any more
ds.setMetricRegistry(metricRegistry);
Assert.fail("Should not have been allowed to set registry after pool started");
} catch (IllegalStateException ise) {
// pass
} finally {
ds.close();
}
}
use of com.codahale.metrics.health.HealthCheckRegistry in project helios by spotify.
the class TotalHealthCheckGaugeTest method testOneFails.
@Test
public void testOneFails() {
final HealthCheckRegistry registry = new HealthCheckRegistry();
registry.register("pass1", stubHealthCheck(HealthCheck.Result.healthy()));
registry.register("fail1", stubHealthCheck(HealthCheck.Result.unhealthy("error")));
final TotalHealthCheckGauge gauge = new TotalHealthCheckGauge(registry);
assertThat(gauge.getValue(), is(0));
}
use of com.codahale.metrics.health.HealthCheckRegistry in project helios by spotify.
the class TotalHealthCheckGaugeTest method testAllHealthy.
@Test
public void testAllHealthy() {
final HealthCheckRegistry registry = new HealthCheckRegistry();
registry.register("pass1", stubHealthCheck(HealthCheck.Result.healthy()));
registry.register("pass2", stubHealthCheck(HealthCheck.Result.healthy()));
final TotalHealthCheckGauge gauge = new TotalHealthCheckGauge(registry);
assertThat(gauge.getValue(), is(1));
}
Aggregations