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;
}
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();
}
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;
}
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());
}