Search in sources :

Example 6 with HealthCheck

use of com.codahale.metrics.health.HealthCheck in project dropwizard by dropwizard.

the class FakeApplication method run.

@Override
public void run(Configuration configuration, Environment environment) throws Exception {
    environment.jersey().register(new FakeResource());
    environment.healthChecks().register("fake-health-check", new HealthCheck() {

        @Override
        protected Result check() throws Exception {
            return Result.healthy();
        }
    });
}
Also used : HealthCheck(com.codahale.metrics.health.HealthCheck)

Example 7 with HealthCheck

use of com.codahale.metrics.health.HealthCheck in project chassis by Kixeye.

the class MetricsConfiguration method healthCheckRegistry.

/***
     * Initializes the health check registry
     *
     * @return health check registry bean
     */
@Bean
public HealthCheckRegistry healthCheckRegistry(ApplicationContext context) {
    final HealthCheckRegistry bean = new HealthCheckRegistry();
    // auto-register beans implementing health checks
    Map<String, HealthCheck> healthChecks = context.getBeansOfType(HealthCheck.class);
    for (HealthCheck check : healthChecks.values()) {
        bean.register(check.getClass().getName(), check);
    }
    return bean;
}
Also used : HealthCheckRegistry(com.codahale.metrics.health.HealthCheckRegistry) HealthCheck(com.codahale.metrics.health.HealthCheck) Bean(org.springframework.context.annotation.Bean)

Example 8 with HealthCheck

use of com.codahale.metrics.health.HealthCheck in project chassis by Kixeye.

the class ChassisConfiguration method healthCheckRegistry.

/**
     * Initializes the health check registry
     *
     * @return health check registry bean
     */
@Bean
public HealthCheckRegistry healthCheckRegistry(ApplicationContext context, DiscoveryManager eureka) {
    final HealthCheckRegistry bean = new HealthCheckRegistry();
    // auto-register beans implementing health checks
    Map<String, HealthCheck> healthChecks = context.getBeansOfType(HealthCheck.class);
    for (HealthCheck check : healthChecks.values()) {
        bean.register(check.getClass().getName(), check);
    }
    // connect health checks into Eureka
    if (!disableEureka) {
        eureka.getDiscoveryClient().registerHealthCheckCallback(new HealthCheckCallback() {

            @Override
            public boolean isHealthy() {
                for (Entry<String, HealthCheck.Result> entry : bean.runHealthChecks().entrySet()) {
                    if (!entry.getValue().isHealthy()) {
                        return false;
                    }
                }
                return true;
            }
        });
    }
    return bean;
}
Also used : Entry(java.util.Map.Entry) HealthCheckRegistry(com.codahale.metrics.health.HealthCheckRegistry) HealthCheck(com.codahale.metrics.health.HealthCheck) HealthCheckCallback(com.netflix.appinfo.HealthCheckCallback) OperatingSystemMXBean(java.lang.management.OperatingSystemMXBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

HealthCheck (com.codahale.metrics.health.HealthCheck)8 Test (org.junit.Test)4 ServletException (javax.servlet.ServletException)3 HealthCheckRegistry (com.codahale.metrics.health.HealthCheckRegistry)2 Bean (org.springframework.context.annotation.Bean)2 AsmGauge (com.alibaba.jstorm.common.metric.AsmGauge)1 AsmHistogram (com.alibaba.jstorm.common.metric.AsmHistogram)1 AsmMeter (com.alibaba.jstorm.common.metric.AsmMeter)1 QueueGauge (com.alibaba.jstorm.common.metric.QueueGauge)1 JStormHealthCheck (com.alibaba.jstorm.metric.JStormHealthCheck)1 ThreadDeadlockDetector (com.codahale.metrics.jvm.ThreadDeadlockDetector)1 HealthCheckCallback (com.netflix.appinfo.HealthCheckCallback)1 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)1 Entry (java.util.Map.Entry)1 TreeSet (java.util.TreeSet)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1