mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 07:02:02 +01:00
[influxdb] Improve connection handling (#15879)
* [influxdb] Improve connection handling Especially for InfluxDB2 the connection check was not properly implemented. It only checked if a connections was ever successfully established. Since we removed the full crash when a write error occured, this lead to a situation where a broken connection was not detected. A ping is now implemented and also a failed write results in a disconnect. --------- Signed-off-by: Jan N. Klug <github@klug.nrw>
This commit is contained in:
parent
1b466fb319
commit
28927310eb
@ -286,6 +286,7 @@ public class InfluxDBPersistenceService implements ModifiablePersistenceService
|
||||
if (!influxDBRepository.write(points)) {
|
||||
logger.warn("Re-queuing {} elements, failed to write batch.", points.size());
|
||||
pointsQueue.addAll(points);
|
||||
influxDBRepository.disconnect();
|
||||
} else {
|
||||
logger.trace("Wrote {} elements to database", points.size());
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ import com.influxdb.client.InfluxDBClientFactory;
|
||||
import com.influxdb.client.InfluxDBClientOptions;
|
||||
import com.influxdb.client.QueryApi;
|
||||
import com.influxdb.client.WriteApi;
|
||||
import com.influxdb.client.domain.HealthCheck;
|
||||
import com.influxdb.client.domain.Ready;
|
||||
import com.influxdb.client.domain.WritePrecision;
|
||||
import com.influxdb.client.write.Point;
|
||||
@ -76,7 +77,8 @@ public class InfluxDB2RepositoryImpl implements InfluxDBRepository {
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return client != null;
|
||||
InfluxDBClient client = this.client;
|
||||
return client != null && client.health().getStatus() == HealthCheck.StatusEnum.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user