本文整理汇总了Java中io.bootique.metrics.health.HealthCheckRegistry类的典型用法代码示例。如果您正苦于以下问题:Java HealthCheckRegistry类的具体用法?Java HealthCheckRegistry怎么用?Java HealthCheckRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HealthCheckRegistry类属于io.bootique.metrics.health包,在下文中一共展示了HealthCheckRegistry类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDerbyHealth
import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
@Test
public void testDerbyHealth() {
BQRuntime runtime = testFactory.app("--config=classpath:db.yml").autoLoadModules().createRuntime();
HealthCheckRegistry healthChecks = runtime.getInstance(HealthCheckRegistry.class);
Map<String, HealthCheckOutcome> results = healthChecks.runHealthChecks();
assertEquals(3, results.size());
HealthCheckOutcome one = results.get("bq.jdbc.derby1.canConnect");
assertNotNull(one);
assertEquals(HealthCheckStatus.OK, one.getStatus());
HealthCheckOutcome two = results.get("bq.jdbc.derby2.canConnect");
assertNotNull(two);
assertEquals(HealthCheckStatus.OK, two.getStatus());
HealthCheckOutcome three = results.get("bq.jdbc.derby3.canConnect");
assertNotNull(three);
assertEquals(HealthCheckStatus.CRITICAL, three.getStatus());
}
示例2: HeartbeatLauncher
import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
public HeartbeatLauncher(HealthCheckRegistry heartbeatChecks) {
this.heartbeatChecks = Objects.requireNonNull(heartbeatChecks);
this.initialDelayMs = INITIAL_DELAY_MS_DEFAULT;
this.fixedDelayMs = FIXED_DELAY_MS_DEFAULT;
this.healthCheckTimeoutMs = HEALTH_CHECK_TIMEOUT_DEFAULT;
this.threadPool = ForkJoinPool.commonPool();
this.listeners = new HashSet<>();
}
示例3: createHeartbeat
import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
public Heartbeat createHeartbeat(
HealthCheckRegistry registry,
Set<HeartbeatListener> listeners) {
HealthCheckRegistry filtered = filterRegistry(registry);
return new Heartbeat(() -> startHeartbeat(filtered, listeners));
}
示例4: filterRegistry
import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
protected HealthCheckRegistry filterRegistry(HealthCheckRegistry registry) {
// no explicit health checks means run all available health check...
if (healthChecks == null || healthChecks.isEmpty()) {
return registry;
}
HealthCheckRegistry filtered = registry.filtered(healthChecks::contains);
// Report health checks configured in the factory, but missing from the registry.
// those are likely human errors and a warning is needed.
reportMissingHealthChecks(filtered);
return filtered;
}
示例5: reportMissingHealthChecks
import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
private void reportMissingHealthChecks(HealthCheckRegistry registry) {
int bad = healthChecks.size() - registry.size();
if (bad > 0) {
String badNames = healthChecks.stream()
.filter(hc -> !registry.containsHealthCheck(hc))
.collect(Collectors.joining(", "));
LOGGER.warn("The following health check names are invalid and will be ignored: {}", badNames);
}
}
示例6: testStart
import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
@Test
public void testStart() throws InterruptedException {
TestListener listener = new TestListener();
HealthCheckRegistry registry = createRegistry(success, failure);
this.threadPool = Executors.newFixedThreadPool(2);
this.timer = new HeartbeatLauncher(registry)
.initialDelayMs(3)
.fixedDelayMs(50)
.listener(listener)
.start();
// we can't reliably predict the exact number of invocations at any given moment in the test, but we can
// check that the heart is beating...
int c1 = listener.counter;
Thread.sleep(100);
int c2 = listener.counter;
assertTrue(c1 < c2);
Thread.sleep(100);
int c3 = listener.counter;
assertTrue(c2 < c3);
}
示例7: createRegistry
import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
private HealthCheckRegistry createRegistry(HealthCheck... checks) {
Map<String, HealthCheck> healthChecks = new HashMap<>();
for (int i = 0; i < checks.length; i++) {
healthChecks.put(String.valueOf(i), checks[i]);
}
return new HealthCheckRegistry(healthChecks);
}
示例8: testChecksLoaded
import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
@Test
public void testChecksLoaded() {
BQRuntime runtime = testFactory.app("-s").createRuntime();
runtime.run();
HealthCheckRegistry registry = runtime.getInstance(HealthCheckRegistry.class);
Map<String, HealthCheckOutcome> results = registry.runHealthChecks();
assertTrue(results.containsKey(JettyHealthCheckGroupFactory.THREAD_POOL_UTILIZATION_CHECK));
assertTrue(results.containsKey(JettyHealthCheckGroupFactory.QUEUED_REQUESTS_CHECK));
}
示例9: testUtilizationCheck
import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
private void testUtilizationCheck(BQRuntime runtime, HealthCheckStatus expectedStatus) {
HealthCheckRegistry registry = runtime.getInstance(HealthCheckRegistry.class);
AssertExtras.assertWithRetry(() -> {
HealthCheckOutcome result = registry.runHealthCheck(JettyHealthCheckGroupFactory.THREAD_POOL_UTILIZATION_CHECK);
assertEquals(result.toString(), expectedStatus, result.getStatus());
});
}
示例10: testQueuedCheck
import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
private void testQueuedCheck(BQRuntime runtime, HealthCheckStatus expectedStatus) {
HealthCheckRegistry registry = runtime.getInstance(HealthCheckRegistry.class);
AssertExtras.assertWithRetry(() -> {
HealthCheckOutcome result = registry.runHealthCheck(JettyHealthCheckGroupFactory.QUEUED_REQUESTS_CHECK);
assertEquals(result.toString(), expectedStatus, result.getStatus());
});
}
示例11: provideHealthCheckServlet
import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
@Singleton
@Provides
MappedServlet<HealthCheckServlet> provideHealthCheckServlet(HealthCheckRegistry registry) {
HealthCheckServlet servlet = new HealthCheckServlet(registry);
return new MappedServlet<HealthCheckServlet>(servlet, Collections.singleton("/health"), "health");
}
示例12: HealthCheckServlet
import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
public HealthCheckServlet(HealthCheckRegistry registry) {
this.registry = registry;
}
示例13: before
import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
@Before
public void before() {
mockRegistry = Mockito.mock(HealthCheckRegistry.class);
mockRequest = Mockito.mock(HttpServletRequest.class);
mockResponse = Mockito.mock(HttpServletResponse.class);
}