Java 类org.springframework.boot.actuate.health.AbstractHealthIndicator 实例源码

项目:mesosframework    文件:TaskActuatorConfiguration.java   
@Bean
public HealthIndicator taskHealthIndicator() {
    return new AbstractHealthIndicator() {
        @Override
        protected void doHealthCheck(Health.Builder builder) throws Exception {
            if (correctNumberOfInstances()) {
                builder.up();
            } else {
                builder.down();
            }
            builder.withDetail("mesos.resources.count", instanceCount.getCount());
            builder.withDetail("instances", stateRepository.allTaskInfos().size());

            for (Protos.TaskState taskState : Protos.TaskState.values()) {
                Map<String, Protos.TaskStatus> state = getTasksForState(taskState);
                builder.withDetail(taskState.name(), state.size());
            }
        }
    };
}
项目:sagan    文件:SiteApplication.java   
@Bean
public HealthIndicator dataSourceHealth(DataSource dataSource) {
    if (dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource) {
        org.apache.tomcat.jdbc.pool.DataSource tcDataSource =
                (org.apache.tomcat.jdbc.pool.DataSource) dataSource;
        return new AbstractHealthIndicator() {
            @Override
            protected void doHealthCheck(Health.Builder healthBuilder) throws Exception {
                healthBuilder.up().withDetail("active", tcDataSource.getActive())
                        .withDetail("max_active", tcDataSource.getMaxActive())
                        .withDetail("idle", tcDataSource.getIdle())
                        .withDetail("max_idle", tcDataSource.getMaxIdle())
                        .withDetail("min_idle", tcDataSource.getMinIdle())
                        .withDetail("wait_count", tcDataSource.getWaitCount())
                        .withDetail("max_wait", tcDataSource.getMaxWait());
            }
        };
    }
    return null;
}
项目:spring-cloud-netflix    文件:EurekaHealthCheckHandlerTests.java   
@Bean
public HealthIndicator healthIndicator() {
    return new AbstractHealthIndicator() {
        @Override
        protected void doHealthCheck(Health.Builder builder) throws Exception {
           builder.up();
        }
    };
}
项目:spring-cloud-netflix    文件:EurekaHealthCheckHandlerTests.java   
@Bean
public HealthIndicator healthIndicator() {
    return new AbstractHealthIndicator() {
        @Override
        protected void doHealthCheck(Health.Builder builder) throws Exception {
            builder.down();
        }
    };
}
项目:spring-cloud-netflix    文件:EurekaHealthCheckHandlerTests.java   
@Bean
public HealthIndicator healthIndicator() {
    return new AbstractHealthIndicator() {
        @Override
        protected void doHealthCheck(Health.Builder builder) throws Exception {
            builder.status("fatal");
        }
    };
}