mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[influxdb] Add compatibility with InfluxDB Cloud Serverless (#16151)
* Use influx client 4.3.0 Signed-off-by: Philipp Leusmann <pl@byteshift.eu> * cleanup Signed-off-by: Philipp Leusmann <pl@byteshift.eu> * changed log level to debug Signed-off-by: Philipp Leusmann <pl@byteshift.eu> * spotless reformat Signed-off-by: Philipp Leusmann <pl@byteshift.eu> --------- Signed-off-by: Philipp Leusmann <pl@byteshift.eu> Co-authored-by: Philipp Leusmann <pl@byteshift.eu> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
5d0b508a03
commit
0f294df5ef
@ -20,7 +20,7 @@
|
||||
</bnd.importpackage>
|
||||
<okhttp3.version>3.14.9</okhttp3.version>
|
||||
<retrofit.version>2.7.2</retrofit.version>
|
||||
<influx2.version>1.15.0</influx2.version>
|
||||
<influx2.version>4.3.0</influx2.version>
|
||||
<influx1.version>2.21</influx1.version>
|
||||
</properties>
|
||||
|
||||
@ -31,6 +31,16 @@
|
||||
<artifactId>influxdb-client-java</artifactId>
|
||||
<version>${influx2.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.influxdb</groupId>
|
||||
<artifactId>influxdb-client-utils</artifactId>
|
||||
<version>${influx2.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>adapter-rxjava2</artifactId>
|
||||
<version>${retrofit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.influxdb</groupId>
|
||||
<artifactId>influxdb-client-core</artifactId>
|
||||
|
@ -44,7 +44,6 @@ 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;
|
||||
@ -78,7 +77,7 @@ public class InfluxDB2RepositoryImpl implements InfluxDBRepository {
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
InfluxDBClient client = this.client;
|
||||
return client != null && client.health().getStatus() == HealthCheck.StatusEnum.PASS;
|
||||
return client != null && client.ping();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,9 +96,10 @@ public class InfluxDB2RepositoryImpl implements InfluxDBRepository {
|
||||
this.client = createdClient;
|
||||
|
||||
queryAPI = createdClient.getQueryApi();
|
||||
writeAPI = createdClient.getWriteApi();
|
||||
writeAPI = createdClient.makeWriteApi();
|
||||
deleteAPI = createdClient.getDeleteApi();
|
||||
logger.debug("Successfully connected to InfluxDB. Instance ready={}", createdClient.ready());
|
||||
|
||||
logger.debug("Successfully connected to InfluxDB. Instance pingable={}", createdClient.ping());
|
||||
|
||||
return checkConnectionStatus();
|
||||
}
|
||||
@ -117,8 +117,16 @@ public class InfluxDB2RepositoryImpl implements InfluxDBRepository {
|
||||
public boolean checkConnectionStatus() {
|
||||
final InfluxDBClient currentClient = client;
|
||||
if (currentClient != null) {
|
||||
boolean isUp = false;
|
||||
Ready ready = currentClient.ready();
|
||||
boolean isUp = ready != null && ready.getStatus() == Ready.StatusEnum.READY;
|
||||
if (ready != null) {
|
||||
isUp = ready.getStatus() == Ready.StatusEnum.READY;
|
||||
} else {
|
||||
logger.debug(
|
||||
"Failure resolving database readiness. Falling back to ping check. This is normal when using InfluxDB Cloud Serverless.");
|
||||
isUp = currentClient.ping();
|
||||
}
|
||||
|
||||
if (isUp) {
|
||||
logger.debug("database status is OK");
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user