List of usage examples for org.springframework.boot.actuate.health Health down
public static Builder down()
From source file:pl.java.scalatech.config.HealthConfig.java
@Bean
HealthIndicator myHealthIndicator() {// w ww .ja v a 2 s . c om
return () -> {
if (new Random().nextBoolean()) {
return Health.up().status("ok").build();
}
return Health.down().status("problem").withDetail("my", "przodownik").build();
};
}
From source file:com.netflix.spinnaker.kork.jedis.JedisHealthIndicatorFactory.java
public static HealthIndicator build(Pool<Jedis> jedisPool) { try {//from w ww .j av a2 s.c om final Pool<Jedis> src = jedisPool; final Field poolAccess = Pool.class.getDeclaredField("internalPool"); poolAccess.setAccessible(true); GenericObjectPool<Jedis> internal = (GenericObjectPool<Jedis>) poolAccess.get(jedisPool); return () -> { Jedis jedis = null; Health.Builder health; try { jedis = src.getResource(); if ("PONG".equals(jedis.ping())) { health = Health.up(); } else { health = Health.down(); } } catch (Exception ex) { health = Health.down(ex); } finally { if (jedis != null) jedis.close(); } health.withDetail("maxIdle", internal.getMaxIdle()); health.withDetail("minIdle", internal.getMinIdle()); health.withDetail("numActive", internal.getNumActive()); health.withDetail("numIdle", internal.getNumIdle()); health.withDetail("numWaiters", internal.getNumWaiters()); return health.build(); }; } catch (IllegalAccessException | NoSuchFieldException e) { throw new BeanCreationException("Error creating Redis health indicator", e); } }
From source file:de.msg.service.RouteServiceHealthIndicator.java
@Override public Health health() { boolean serviceStatus = service.getServiceStatus(); if (serviceStatus) { LOGGER.info("RouteService status: down"); return Health.up().build(); } else {//from w w w . j a v a 2 s . c o m LOGGER.warn("RouteService status: up"); return Health.down().build(); } }
From source file:org.moneta.config.springboot.ActuatorHealthIndicator.java
public Health health() { Map<String, HealthCheck.Result> resultMap = healthCheckRegistry.runHealthChecks(); HealthCheck.Result result;/*from w ww .j a v a 2 s.c o m*/ for (String checkName : resultMap.keySet()) { result = resultMap.get(checkName); if (!result.isHealthy()) { return Health.down().withDetail(checkName, result.toString()).build(); } } return Health.up().build(); }
From source file:io.github.resilience4j.circuitbreaker.monitoring.health.CircuitBreakerHealthIndicator.java
private Health mapBackendMonitorState(CircuitBreaker circuitBreaker) { switch (circuitBreaker.getState()) { case CLOSED://from www . java 2s . c o m return addDetails(Health.up(), circuitBreaker).build(); case OPEN: return addDetails(Health.down(), circuitBreaker).build(); case HALF_OPEN: return addDetails(Health.unknown(), circuitBreaker).build(); default: return addDetails(Health.unknown(), circuitBreaker).build(); } }
From source file:io.pivotal.strepsirrhini.chaosloris.destroyer.DestructionScheduler.java
@Override public Health health() { if (this.running.get()) { return Health.up().build(); } else {/*from ww w. j av a2 s . c o m*/ return Health.down().build(); } }
From source file:com.netflix.spinnaker.orca.config.RedisConfiguration.java
@Deprecated // rz - Kept for backwards compat with old connection configs @Bean/*from w w w. j av a 2 s. c om*/ HealthIndicator redisHealth(@Qualifier("jedisPool") Pool<Jedis> jedisPool) { try { final Pool<Jedis> src = jedisPool; final Field poolAccess = Pool.class.getDeclaredField("internalPool"); poolAccess.setAccessible(true); GenericObjectPool<Jedis> internal = (GenericObjectPool<Jedis>) poolAccess.get(jedisPool); return () -> { Jedis jedis = null; Health.Builder health; try { jedis = src.getResource(); if ("PONG".equals(jedis.ping())) { health = Health.up(); } else { health = Health.down(); } } catch (Exception ex) { health = Health.down(ex); } finally { if (jedis != null) jedis.close(); } health.withDetail("maxIdle", internal.getMaxIdle()); health.withDetail("minIdle", internal.getMinIdle()); health.withDetail("numActive", internal.getNumActive()); health.withDetail("numIdle", internal.getNumIdle()); health.withDetail("numWaiters", internal.getNumWaiters()); return health.build(); }; } catch (IllegalAccessException | NoSuchFieldException e) { throw new BeanCreationException("Error creating Redis health indicator", e); } }