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


Java HealthCheckRegistry类代码示例

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

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

示例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));
}
 
开发者ID:bootique,项目名称:bootique-metrics,代码行数:8,代码来源:HeartbeatFactory.java

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

示例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);
    }
}
 
开发者ID:bootique,项目名称:bootique-metrics,代码行数:10,代码来源:HeartbeatFactory.java

示例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);
}
 
开发者ID:bootique,项目名称:bootique-metrics,代码行数:28,代码来源:HeartbeatLauncherTest.java

示例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);
    }
 
开发者ID:bootique,项目名称:bootique-metrics,代码行数:10,代码来源:HeartbeatLauncherTest.java

示例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));
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:12,代码来源:JettyHealthCheckGroupIT.java

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

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

示例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");
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:7,代码来源:JettyMetricsModule.java

示例12: HealthCheckServlet

import io.bootique.metrics.health.HealthCheckRegistry; //导入依赖的package包/类
public HealthCheckServlet(HealthCheckRegistry registry) {
    this.registry = registry;
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:4,代码来源:HealthCheckServlet.java

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


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