/** * This method checks if any entry in the Transient Exception Registry is newer than the time now, minus the elapsed time interval. If * an entry is found within the range the health check returns Unhealthy. If the Transient Exception Registry is empty or no entries * are found within the range the health check returns Healthy. * * @return HealthResult the result of the Transient Health Check, Healthy or Unhealthy */ @Override public HealthResult healthCheck() { LOG.debug("Transient Health Check executing"); HealthResult healthResult = HealthResult.RESULT_HEALTHY; synchronized (transientExceptionRegistryLock) { for (Map.Entry<String, LocalDateTime> entry : transientExceptionRegistry.entrySet()) { if (entry.getValue().toEpochSecond(ZoneOffset.UTC) < LocalDateTime.now().minusSeconds(elapsedTime).toEpochSecond(ZoneOffset.UTC)) { healthResult = HealthResult.RESULT_HEALTHY; } else { healthResult = new HealthResult(HealthStatus.UNHEALTHY); break; } } if (healthResult.equals(HealthResult.RESULT_HEALTHY)) { LOG.debug("Transient Health Check is currently Healthy, therefore clearing the Transient Exception Registry"); transientExceptionRegistry.clear(); } LOG.debug("Transient Health Check is currently [{}]", healthResult.getStatus().toString()); return healthResult; } }
@Override protected Result check() throws Exception { HealthResult result = reporter.healthCheck(); String message = result.getMessage(); if (result.getStatus() == HealthStatus.HEALTHY) { return message == null ? Result.healthy() : Result.healthy(message); } else { return Result.unhealthy(message); } } }
@Override protected HealthCheck.Result check() throws Exception { HealthResult result = reporter.healthCheck(); String message = result.getMessage(); if ( result.getStatus() == HealthStatus.HEALTHY ) { return message == null ? HealthCheck.Result.healthy() : HealthCheck.Result.healthy(message); } else { return HealthCheck.Result.unhealthy(message); } } }