Try to search your question here, if you can't find : Ask Any Question Now ?

Correct Way to Use InfluxDB Java API Given Deprecated Methods?

HomeCategory: stackoverflowCorrect Way to Use InfluxDB Java API Given Deprecated Methods?
sourav asked 2 weeks ago

I’m working with InfluxDB-Java-2.9 and have noticed quite a few of the helper methods in the API are deprecated, but all the examples online seem to make use of those deprecated methods. The java doc does indicate we should use the query method in place of these helper methods, but I cannot confirm what the right way to write these queries is. Given the below snippets of code, are these are the right ways to convert the code I have?

InfluxDB influxDB = InfluxDBFactory.connect("http://localhost:8086", "test", "test");
String dbName = "aTimeSeries";
String rpName = "aRetentionPolicy";

Before:

influxDB.databaseExists(dbName);

After:

QueryResult qr = influxDB.query(new Query("SHOW DATABASES", ""));
// do something with QueryResult ???

Before:

influxDB.createDatabase(dbName);

After:

influxDB.query(new Query("CREATE DATABASE" + dbName, "", true));

Before:

influxDB.createRetentionPolicy(rpName, dbName, "30d", "30m", 2, true);

After:

influxDB.query(new Query("CREATE RETENTION POLICY " + rpName + " ON " + dbName + " DURATION 30d REPLICATION 2 SHARD DURATION 30m DEFAULT", "", true));

Before:

influxDB.dropRetentionPolicy(dbName);

After:

influxDB.query(new Query("DROP RETENTION POLICY " + rpName + " ON " + dbName, "", true));

Before:

influxDB.deleteDatabase(dbName);

After:

influxDB.query(new Query("DROP DATABASE " + dbName, "", true));
1 Answers
Best Answer
Amit answered 2 weeks ago
Your Answer

9 + 2 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com