@Override public Health health() { return Optional.of(circuitBreaker) .map(this::mapBackendMonitorState) .orElse(Health.up().build()); }
@Override public Health health() { return Optional.of(circuitBreaker) .map(this::mapBackendMonitorState) .orElse(Health.up().build()); }
@Override public Health health() { int errorCode = check(); if (errorCode != 0) { return Health.down().withDetail("Error Code", errorCode).build(); } return Health.up().build(); }
@Override public Health health() { int errorCode = check(); if (errorCode != 0) { return Health.down().withDetail("Error Code", errorCode).build(); } return Health.up().build(); }
private Health mapBackendMonitorState(CircuitBreaker circuitBreaker) { switch (circuitBreaker.getState()) { case CLOSED: 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(); } }
private Health mapBackendMonitorState(CircuitBreaker circuitBreaker) { switch (circuitBreaker.getState()) { case CLOSED: 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(); } }
@Bean HealthIndicator redisHealth(JedisPool jedisPool) { return () -> { Jedis jedis = null; Health.Builder health = null; try { jedis = jedisPool.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(); } } return health.build(); }; } }
@Override public Health health() { int errorCode = check(); if (errorCode != 0) { return Health.down() .withDetail("status", errorCode) .withDetail("message", "服务故障") .build(); } return Health.up().build(); }
@ConditionalOnMissingBean(name = "memoryHealthIndicator") @Bean public HealthIndicator memoryHealthIndicator() { val freeMemThreshold = casProperties.getMonitor().getFreeMemThreshold(); if (freeMemThreshold > 0) { LOGGER.debug("Configured memory monitor with free-memory threshold [{}]", freeMemThreshold); return new MemoryMonitor(freeMemThreshold); } return () -> Health.up().build(); }
@Override public Health health() { try { RestTemplate rest = new RestTemplate(); rest.getForObject("http://www.amazon.com", String.class); return Health.up().withDetail("detail", "成功啦").build(); } catch (Exception e) { return Health.down().build(); } } }
@Override public Health health() { // Assess the application's Greeting health. If the application's // Greeting components have data to service user requests, the Greeting // component is considered 'healthy', otherwise it is not. Collection<Greeting> greetings = greetingService.findAll(); if (greetings == null || greetings.size() == 0) { return Health.down().withDetail("count", 0).build(); } return Health.up().withDetail("count", greetings.size()).build(); }
@Override public Health health() { // Assess the application's Greeting health. If the application's // Greeting components have data to service user requests, the Greeting // component is considered 'healthy', otherwise it is not. Collection<Greeting> greetings = greetingService.findAll(); if (greetings == null || greetings.size() == 0) { return Health.down().withDetail("count", 0).build(); } return Health.up().withDetail("count", greetings.size()).build(); }
@Override public Health health() { JSONObject cpu = getCpu(); if (null != cpu) { return Health.up().withDetail("cpu", Collections.synchronizedMap(cpu)).build(); }else { return Health.down().build(); } }
@Override public Health health() { JSONObject memory = getMemory(); if (null != memory) { return Health.up().withDetail("memory", Collections.synchronizedMap(memory)).build(); } else { return Health.down().build(); } }
@Override protected Health getHealth(JenkinsConfiguration config) { try { jenkinsClientFactory.getClient(config).getInfo(); return Health.up().build(); } catch (Exception ex) { return Health.down(ex).build(); } } }
@Override public Health health() { int errorCode = check(); // perform some specific health check if (errorCode != 0) { return Health.down() .withDetail("Error Code", errorCode).build(); } return Health.up().build(); }
@Override protected Health getHealth(ArtifactoryConfiguration config) { try { List<String> buildNames = clientFactory.getClient(config).getBuildNames(); return Health.up().withDetail("buildNames", buildNames).build(); } catch (Exception ex) { return Health.down(ex).build(); } } }
/** synchronized to prevent overlapping requests to a storage backend */ @Override public synchronized Health health() { CheckResult result = component.check(); return result.ok() ? Health.up().build() : Health.down((Exception) result.error()).build(); } }
@Override protected Health getHealth(JIRAConfiguration config) { try (JIRAClient client = sessionFactory.create(config).getClient()) { List<String> projects = client.getProjects(); return Health.up().withDetail("projects", projects).build(); } catch (Exception ex) { return Health.down(ex).build(); } } }
@Override public Health health() { int code = check(); if (code != 0) { Health.down().withDetail("code", code).withDetail("version", VERSION).build(); } return Health.up().withDetail("code", code) .withDetail("version", VERSION).up().build(); }