本文整理汇总了Java中org.springframework.boot.actuate.health.AbstractHealthIndicator类的典型用法代码示例。如果您正苦于以下问题:Java AbstractHealthIndicator类的具体用法?Java AbstractHealthIndicator怎么用?Java AbstractHealthIndicator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractHealthIndicator类属于org.springframework.boot.actuate.health包,在下文中一共展示了AbstractHealthIndicator类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: taskHealthIndicator
import org.springframework.boot.actuate.health.AbstractHealthIndicator; //导入依赖的package包/类
@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());
}
}
};
}
示例2: dataSourceHealth
import org.springframework.boot.actuate.health.AbstractHealthIndicator; //导入依赖的package包/类
@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;
}
示例3: healthIndicator
import org.springframework.boot.actuate.health.AbstractHealthIndicator; //导入依赖的package包/类
@Bean
public HealthIndicator healthIndicator() {
return new AbstractHealthIndicator() {
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
builder.up();
}
};
}