Ejemplo n.º 1
0
  private RestrictedHealthStatus getHealth() throws HealthException {
    RestrictedHealthStatus currentState = RestrictedHealthStatus.OK;

    if (monitorRegistry == null) {
      logger.log(Level.SEVERE, "MonitorRegistry is null");
      throw new HealthException(ResponseCode.InternalError, HealthExceptionErrorCodeEnum.NULL);
    }
    StatusAggregator agg = monitorRegistry.getStatusAggregator();
    if (agg == null) {
      logger.log(Level.SEVERE, "StatusAggregator is null");
      throw new HealthException(ResponseCode.InternalError, HealthExceptionErrorCodeEnum.NULL);
    }
    Status status = agg.getStatus();
    if (status == null) {
      logger.log(Level.SEVERE, "Status is null");
      throw new HealthException(ResponseCode.InternalError, HealthExceptionErrorCodeEnum.NULL);
    }
    if (status.equals(Status.FAIL)) {
      currentState = RestrictedHealthStatus.FAIL;
    }
    return currentState;
  }