/** * Register method to register services / internal nodes. * * @param name name */ @Override public void registerNoTtl(final String name) { logger.info("HealthService::register() {} ", name); final NodeHealthStat nodeHealthStat = new NodeHealthStat(name); nodeHealthStat.setStatus(HealthStatus.PASS); serviceHealthStatMap.put(name, nodeHealthStat); super.incrementCount("nodes"); super.recordLevel("nodes", serviceHealthStatMap.size()); }
@Override public void warnWithReason(final String name, final HealthFailReason reason) { logger.warn("HealthService::warn() {}", name); super.incrementCount("warn"); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setStatus(HealthStatus.WARN); nodeHealthStat.setReason(reason); nodeHealthStat.setLastCheckIn(super.time); onWarn.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); }
/** * Check in the service. * * @param name name */ @Override public void checkInOk(final String name) { if (debug) logger.debug("HealthService::checkInOk() {} ", name); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setLastCheckIn(super.time); nodeHealthStat.setReason(null); nodeHealthStat.setStatus(HealthStatus.PASS); super.incrementCount("checkin"); onCheckIn.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); }
/** * Check in the service with a specific status. * * @param name name * @param reason reason */ @Override public void failWithReason(final String name, final HealthFailReason reason) { logger.error("HealthService::fail() {}", name); super.incrementCount("fail"); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setStatus(HealthStatus.FAIL); nodeHealthStat.setReason(reason); nodeHealthStat.setLastCheckIn(super.time); onFail.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); }
@Override public void warnWithError(final String name, final Throwable error) { logger.warn("HealthService::warn() {}", name); super.incrementCount("warn"); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setStatus(HealthStatus.WARN); nodeHealthStat.setReason(HealthFailReason.ERROR); nodeHealthStat.setLastCheckIn(super.time); nodeHealthStat.setError(error); onWarn.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); }
/** * Fail the node for the service with a specific status. * * @param name name * @param error error */ @Override public void failWithError(final String name, final Throwable error) { logger.error("HealthService::fail() {}", name); super.incrementCount("fail"); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setStatus(HealthStatus.FAIL); nodeHealthStat.setReason(HealthFailReason.ERROR); nodeHealthStat.setLastCheckIn(super.time); nodeHealthStat.setError(error); onFail.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); }
private void checkTTL(final NodeHealthStat nodeHealthStat) { if (debug) logger.debug("HealthService::checkTTL() {}", nodeHealthStat.getName()); if (!nodeHealthStat.isOk()) { return; } if (nodeHealthStat.isForever()) { return; } final long duration = super.time - nodeHealthStat.getLastCheckIn(); /* If the duration is greater than the ttl interval, then mark it as failed. */ if (duration > nodeHealthStat.getTtlInMS()) { logger.error("HealthService::checkTTL() {} FAILED TTL check, duration {}", nodeHealthStat.getName(), duration); nodeHealthStat.setReason(HealthFailReason.FAILED_TTL); nodeHealthStat.setStatus(HealthStatus.FAIL); onFail.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); } }
/** * Check in the service with a specific status. * * @param name name * @param status status */ @Override public void checkIn(final String name, final HealthStatus status) { super.incrementCount("checkin"); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setStatus(status); nodeHealthStat.setReason(null); nodeHealthStat.setLastCheckIn(super.time); reportStatus(name, nodeHealthStat); }
/** * Register method to register services / internal nodes. * * @param name name */ @Override public void registerNoTtl(final String name) { logger.info("HealthService::register() {} ", name); final NodeHealthStat nodeHealthStat = new NodeHealthStat(name); nodeHealthStat.setStatus(HealthStatus.PASS); serviceHealthStatMap.put(name, nodeHealthStat); super.incrementCount("nodes"); super.recordLevel("nodes", serviceHealthStatMap.size()); }
/** * Register method to register services / internal nodes. * * @param name name */ @Override public void registerNoTtl(final String name) { logger.info("HealthService::register() {} ", name); final NodeHealthStat nodeHealthStat = new NodeHealthStat(name); nodeHealthStat.setStatus(HealthStatus.PASS); serviceHealthStatMap.put(name, nodeHealthStat); super.incrementCount("nodes"); super.recordLevel("nodes", serviceHealthStatMap.size()); }
@Override public void warnWithReason(final String name, final HealthFailReason reason) { logger.warn("HealthService::warn() {}", name); super.incrementCount("warn"); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setStatus(HealthStatus.WARN); nodeHealthStat.setReason(reason); nodeHealthStat.setLastCheckIn(super.time); onWarn.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); }
@Override public void warnWithReason(final String name, final HealthFailReason reason) { logger.warn("HealthService::warn() {}", name); super.incrementCount("warn"); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setStatus(HealthStatus.WARN); nodeHealthStat.setReason(reason); nodeHealthStat.setLastCheckIn(super.time); onWarn.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); }
/** * Check in the service. * * @param name name */ @Override public void checkInOk(final String name) { if (debug) logger.debug("HealthService::checkInOk() {} ", name); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setLastCheckIn(super.time); nodeHealthStat.setReason(null); nodeHealthStat.setStatus(HealthStatus.PASS); super.incrementCount("checkin"); onCheckIn.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); }
/** * Check in the service. * * @param name name */ @Override public void checkInOk(final String name) { if (debug) logger.debug("HealthService::checkInOk() {} ", name); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setLastCheckIn(super.time); nodeHealthStat.setReason(null); nodeHealthStat.setStatus(HealthStatus.PASS); super.incrementCount("checkin"); onCheckIn.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); }
@Override public void warnWithError(final String name, final Throwable error) { logger.warn("HealthService::warn() {}", name); super.incrementCount("warn"); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setStatus(HealthStatus.WARN); nodeHealthStat.setReason(HealthFailReason.ERROR); nodeHealthStat.setLastCheckIn(super.time); nodeHealthStat.setError(error); onWarn.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); }
@Override public void warnWithError(final String name, final Throwable error) { logger.warn("HealthService::warn() {}", name); super.incrementCount("warn"); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setStatus(HealthStatus.WARN); nodeHealthStat.setReason(HealthFailReason.ERROR); nodeHealthStat.setLastCheckIn(super.time); nodeHealthStat.setError(error); onWarn.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); }
/** * Check in the service with a specific status. * * @param name name * @param reason reason */ @Override public void failWithReason(final String name, final HealthFailReason reason) { logger.error("HealthService::fail() {}", name); super.incrementCount("fail"); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setStatus(HealthStatus.FAIL); nodeHealthStat.setReason(reason); nodeHealthStat.setLastCheckIn(super.time); onFail.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); }
/** * Fail the node for the service with a specific status. * * @param name name * @param error error */ @Override public void failWithError(final String name, final Throwable error) { logger.error("HealthService::fail() {}", name); super.incrementCount("fail"); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setStatus(HealthStatus.FAIL); nodeHealthStat.setReason(HealthFailReason.ERROR); nodeHealthStat.setLastCheckIn(super.time); nodeHealthStat.setError(error); onFail.ifPresent(checkIn -> checkIn.accept(BeanUtils.copy(nodeHealthStat))); }
/** * Check in the service with a specific status. * * @param name name * @param status status */ @Override public void checkIn(final String name, final HealthStatus status) { super.incrementCount("checkin"); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setStatus(status); nodeHealthStat.setReason(null); nodeHealthStat.setLastCheckIn(super.time); reportStatus(name, nodeHealthStat); }
/** * Check in the service with a specific status. * * @param name name * @param status status */ @Override public void checkIn(final String name, final HealthStatus status) { super.incrementCount("checkin"); final NodeHealthStat nodeHealthStat = getServiceHealthStat(name); nodeHealthStat.setStatus(status); nodeHealthStat.setReason(null); nodeHealthStat.setLastCheckIn(super.time); reportStatus(name, nodeHealthStat); }