@Override
  public Result check() throws Exception {
    HealthCheckResults results = _pool.checkForHealthyEndPoint();
    boolean healthy = results.hasHealthyResult();
    HealthCheckResult healthyResult = results.getHealthyResult();

    // Get stats about any failed health checks
    int numUnhealthy = 0;
    long totalUnhealthyResponseTimeInMicros = 0;
    for (HealthCheckResult unhealthy : results.getUnhealthyResults()) {
      ++numUnhealthy;
      totalUnhealthyResponseTimeInMicros += unhealthy.getResponseTime(TimeUnit.MICROSECONDS);
    }

    if (!healthy && numUnhealthy == 0) {
      return Result.unhealthy("No end points.");
    }

    String unhealthyMessage =
        numUnhealthy + " failures in " + totalUnhealthyResponseTimeInMicros + "us";
    if (!healthy) {
      return Result.unhealthy(unhealthyMessage);
    }
    return Result.healthy(
        healthyResult.getEndPointId()
            + " succeeded in "
            + healthyResult.getResponseTime(TimeUnit.MICROSECONDS)
            + "us; "
            + unhealthyMessage);
  }
  @Override
  protected Result check() throws Exception {

    try {
      PreparedStatement pst = connection.prepareStatement("SELECT * FROM RECEIPTS LIMIT 1");
      if (pst.execute()) {
        return Result.healthy();
      } else {
        return Result.unhealthy("Failed to query Phoenix Receipts table.");
      }
    } catch (SQLException sqlEx) {
      logger.warn("Phoenix Health Check has encountered errors!");
      return Result.unhealthy("Failed to connect to Phoenix");
    }
  }
 @Override
 protected Result check() throws Exception {
   if (gaia.ping()) {
     return Result.healthy();
   }
   return Result.unhealthy("gaia ping returned something else than 200 OK");
 }
 @Override
 protected Result check() throws Exception {
   final String saying = String.format(template, "TEST");
   if (!saying.contains("TEST")) {
     return Result.unhealthy("template doesn't include a name");
   }
   return Result.healthy();
 }
 @Override
 protected Result check() throws Exception {
   if (dead.get()) {
     return Result.unhealthy("Marked as down.");
   } else {
     return Result.healthy("Marked as up.");
   }
 }
 @Override
 protected Result check() throws Exception {
   if (hibernateBundle.getSessionFactory().isClosed()) {
     return Result.unhealthy("Database Session is closed");
   } else {
     return Result.healthy("Database Session is open for requests");
   }
 }
 @Override
 protected Result check() throws Exception {
   try {
     ProcessEngines.getDefaultProcessEngine().getIdentityService().createGroupQuery().list();
     return Result.healthy();
   } catch (final Exception e) {
     return Result.unhealthy(e);
   }
 }
 @Override
 public Result check() {
   try {
     javaMailSender.getSession().getTransport().connect();
     return Result.healthy();
   } catch (MessagingException e) {
     log.debug("Cannot connect to e-mail server: {}", e);
     return Result.unhealthy("Cannot connect to e-mail server");
   }
 }
 @Override
 protected Result check() throws Exception {
   try {
     // String statement = "select * from system.schema_keyspaces;";
     String statement = "select * from system.paxos;";
     ResultSet resultSet = session.execute(statement);
     return Result.healthy();
   } catch (Exception e) {
     return Result.unhealthy(e.toString());
   }
 }
 @Override
 protected Result check() throws Exception {
   ClusterHealthResponse health =
       client.admin().cluster().prepareHealth(ElasticsearchSearcher.INDEX).execute().actionGet();
   // though it sounds bad, status yellow is in fact ok for our setup
   if (health.getStatus() != ClusterHealthStatus.RED) {
     return Result.healthy();
   } else {
     return Result.unhealthy(health.getStatus().name());
   }
 }
  @Override
  protected Result check() throws Exception {
    ExecutorService executor = null;

    try {

      executor = Executors.newSingleThreadExecutor();

      Future<String> future = executor.submit(() -> mongo.listDatabaseNames().first());

      String dbName = future.get(250, TimeUnit.MILLISECONDS);

      if (StringUtils.isEmpty(dbName)) return Result.unhealthy("Can't connect to database.");

      return Result.healthy();
    } catch (Exception e) {
      return Result.unhealthy(e);
    } finally {

      if (executor != null) executor.shutdownNow();
    }
  }
 @Override
 public Result check() {
   try {
     javaMailSender
         .getSession()
         .getTransport()
         .connect(
             javaMailSender.getHost(), javaMailSender.getUsername(), javaMailSender.getPassword());
     return Result.healthy();
   } catch (Exception e) {
     log.debug("Cannot connect to e-mail server: {}", e);
     return Result.unhealthy("Cannot connect to e-mail server");
   }
 }
  /** Check to see if the system is healthy (doesn't have too many messages). */
  @Override
  protected Result check() throws Exception {

    // Running total.
    int numberOfMessages = 0;

    // Iterate over all mailboxes
    for (List<UserNotification> notificationsPerUser :
        this.notificationMailbox.getAllNotifications().values()) {

      // Add the messages per mailbox to our running total.
      numberOfMessages += notificationsPerUser.size();
    }

    // If the number of messages in the system exceeds our limit,
    // the system is unhealthy.
    return (numberOfMessages > UNHEALTHY_NUMBER_OF_MESSAGES)
        ? Result.unhealthy(String.format("too many messages: %s", numberOfMessages))
        : Result.healthy();
  }