public final class JFluxHttpClient extends Object implements AutoCloseable
JFluxHttpClient.Builder| Modifier and Type | Class and Description |
|---|---|
static class |
JFluxHttpClient.Builder
Used to construct
JFluxHttpClient instances. |
| Modifier and Type | Method and Description |
|---|---|
ApiResponse |
batchQuery(String query)
Executes a query and returns the result.
|
void |
close() |
void |
execute(String statement)
Executes DDL statements, such as
CREATE or ALTER. |
String |
getHostUrl()
Gets the URL of the InfluxDB instance this client is pointed to.
|
ResponseMetadata |
ping()
Tests the connection to the InfluxDB API and returns the result.
|
Measurement |
query(String query)
Executes a query and returns the result.
|
QueryResult |
queryMultipleSeries(String query)
Executes a query and returns the result.
|
ApiResponse |
write(String database,
String lineProtocol)
Writes points into the default retention policy.
|
ApiResponse |
write(String database,
String retentionPolicy,
String lineProtocol)
Writes points into the specified retention policy.
|
public String getHostUrl()
public ResponseMetadata ping() throws IOException
IOException - if the instance is not reachablepublic Measurement query(String query) throws IOException
This method expects that the query will produce a single result, i.e. is a single statement, querying a single measurement. The following example query can be executed with this method:
SELECT * FROM measurement_1
The following queries will result in an exception:
SELECT * FROM measurement_1, measurement_2 SELECT * FROM measurement_1; SELECT * FROM measurement_2
For multi-series or batch queries, see queryMultipleSeries(String) and
batchQuery(String) respectively instead.
query - the query to executenull if no resultsIllegalStatementException - if the query format is invalidIOException - if query execution failsqueryMultipleSeries(String),
batchQuery(String)public QueryResult queryMultipleSeries(String query) throws IOException
This method can be used to query across multiple series. Queries such as the following can be used:
SELECT * FROM measurement_1, measurement_2
Note that while single series queries are possible with this method, the responsibility of
unwrapping the result falls then on the caller. For a more convenient way of executing
single series queries see query(String).
query - the query to executeIllegalStatementException - if the query format is invalidIOException - if query execution failsquery(String),
batchQuery(String)public ApiResponse batchQuery(String query) throws IOException
This method can be used to execute multiple queries at once, spanning one or more measurements. Queries such as the following can be executed:
SELECT * FROM measurement_1; SELECT * FROM measurement_2, measurement_3;
Note that while single statement and/or single series queries are also possible with this
method, the responsibility of unwrapping the result falls then on the caller. For more
convenient ways of executing single statement and single series queries see
query(String) and queryMultipleSeries(String).
query - the query to executeIllegalStatementException - if the query format is invalidIOException - if query execution failsquery(String),
queryMultipleSeries(String)public void execute(String statement) throws IOException
CREATE or ALTER.statement - the statement to executeIOException - if execution failspublic ApiResponse write(String database, String lineProtocol) throws IOException
Points to be written are specified using InfluxDB's
line protocol format. Multiple points can be written by separating them with a \n
character.
database - the database to write tolineProtocol - the point(s) to writeIOException - if InfluxDB cannot be reachedInfluxClientException - if the points are not in the correct formatpublic ApiResponse write(String database, String retentionPolicy, String lineProtocol) throws IOException
Points to be written are specified using InfluxDB's
line protocol format. Multiple points can be written by separating them with a \n
character.
database - the database to write toretentionPolicy - the retention policy to uselineProtocol - the point(s) to writeIOException - if InfluxDB cannot be reachedInfluxClientException - if the points are not in the correct formatpublic void close()
close in interface AutoCloseableCopyright © 2020. All rights reserved.