Search in sources :

Example 1 with Pong

use of org.influxdb.dto.Pong in project openhab1-addons by openhab.

the class InfluxDBPersistenceService method checkConnection.

private boolean checkConnection() {
    boolean dbStatus = false;
    if (!connected) {
        logger.error("checkConnection: database is not connected");
        dbStatus = false;
    } else {
        try {
            Pong pong = influxDB.ping();
            String version = pong.getVersion();
            // may be check for version >= 0.9
            if (version != null && !version.contains("unknown")) {
                dbStatus = true;
                logger.debug("database status is OK, version is {}", version);
            } else {
                logger.error("database ping error, version is: \"{}\" response time was \"{}\"", version, pong.getResponseTime());
                dbStatus = false;
            }
        } catch (RuntimeException e) {
            dbStatus = false;
            logger.error("database connection failed", e);
            handleDatabaseException(e);
        }
    }
    return dbStatus;
}
Also used : Pong(org.influxdb.dto.Pong)

Example 2 with Pong

use of org.influxdb.dto.Pong in project spring-boot by spring-projects.

the class InfluxDbHealthIndicatorTests method influxDbIsUp.

@Test
void influxDbIsUp() {
    Pong pong = mock(Pong.class);
    given(pong.getVersion()).willReturn("0.9");
    InfluxDB influxDb = mock(InfluxDB.class);
    given(influxDb.ping()).willReturn(pong);
    InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDb);
    Health health = healthIndicator.health();
    assertThat(health.getStatus()).isEqualTo(Status.UP);
    assertThat(health.getDetails().get("version")).isEqualTo("0.9");
    then(influxDb).should().ping();
}
Also used : Health(org.springframework.boot.actuate.health.Health) InfluxDB(org.influxdb.InfluxDB) Pong(org.influxdb.dto.Pong) Test(org.junit.jupiter.api.Test)

Example 3 with Pong

use of org.influxdb.dto.Pong in project openhab1-addons by openhab.

the class InfluxDBPersistenceService method checkConnection.

private boolean checkConnection() {
    boolean dbStatus = false;
    if (!connected) {
        logger.error("checkConnection: database is not connected");
        dbStatus = false;
    } else {
        try {
            Pong pong = influxDB.ping();
            if (pong.getStatus().equalsIgnoreCase(OK_STATUS)) {
                dbStatus = true;
                logger.debug("database status is OK");
            } else {
                logger.error("database connection failed with status: \"{}\" response time was \"{}\"", pong.getStatus(), pong.getResponseTime());
                dbStatus = false;
            }
        } catch (RuntimeException e) {
            dbStatus = false;
            logger.error("database connection failed throwing an exception");
            handleDatabaseException(e);
        }
    }
    return dbStatus;
}
Also used : Pong(org.influxdb.dto.Pong)

Example 4 with Pong

use of org.influxdb.dto.Pong in project spring-boot by spring-projects.

the class InfluxDbHealthIndicator method doHealthCheck.

@Override
protected void doHealthCheck(Health.Builder builder) {
    Pong pong = this.influxDb.ping();
    builder.up().withDetail("version", pong.getVersion());
}
Also used : Pong(org.influxdb.dto.Pong)

Aggregations

Pong (org.influxdb.dto.Pong)4 InfluxDB (org.influxdb.InfluxDB)1 Test (org.junit.jupiter.api.Test)1 Health (org.springframework.boot.actuate.health.Health)1