* [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>
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());
}
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;
@Override
public boolean isConnected() {
- return client != null;
+ InfluxDBClient client = this.client;
+ return client != null && client.health().getStatus() == HealthCheck.StatusEnum.PASS;
}
@Override