@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()); } } }; }
@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; }
@Bean public HealthIndicator healthIndicator() { return new AbstractHealthIndicator() { @Override protected void doHealthCheck(Health.Builder builder) throws Exception { builder.up(); } }; }
@Bean public HealthIndicator healthIndicator() { return new AbstractHealthIndicator() { @Override protected void doHealthCheck(Health.Builder builder) throws Exception { builder.down(); } }; }
@Bean public HealthIndicator healthIndicator() { return new AbstractHealthIndicator() { @Override protected void doHealthCheck(Health.Builder builder) throws Exception { builder.status("fatal"); } }; }