All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nitorcreations.nflow.metrics.DatabaseConnectionHealthCheck Maven / Gradle / Ivy

There is a newer version: 3.3.0
Show newest version
package com.nitorcreations.nflow.metrics;

import com.codahale.metrics.health.HealthCheck;
import com.nitorcreations.nflow.engine.service.HealthCheckService;

/**
 * Check that connection to nflow database can be made.
 */
public class DatabaseConnectionHealthCheck extends HealthCheck {

  private final HealthCheckService healthCheckService;

  public DatabaseConnectionHealthCheck(HealthCheckService healthCheckService) {
    this.healthCheckService = healthCheckService;
  }

  @Override
  protected Result check() {
    try {
      healthCheckService.checkDatabaseConnection();
      return HealthCheck.Result.healthy("Connection to nFlow database is OK.");
    } catch(Exception e) {
      return HealthCheck.Result.unhealthy(e);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy