Package org.influxdb
Interface InfluxDB
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
InfluxDBImpl
public interface InfluxDB extends AutoCloseable
Interface with all available methods to access a InfluxDB database.
A full list of currently available interfaces is implemented in:
https://github.com/
influxdb/influxdb/blob/master/src/api/http/api.go
- Author:
- stefan.majer [at] gmail.com
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
InfluxDB.Cancellable
A cancelable allows to discontinue a streaming query.static class
InfluxDB.ConsistencyLevel
ConsistencyLevel for write Operations.static class
InfluxDB.LogLevel
Controls the level of logging of the REST layer.static class
InfluxDB.ResponseFormat
Format of HTTP Response body from InfluxDB server. -
Field Summary
Fields Modifier and Type Field Description static String
LOG_LEVEL_PROPERTY
The system property key to set the http logging level across the JVM. -
Method Summary
Modifier and Type Method Description void
close()
close thread for asynchronous batch write and UDP socket to release resources if need.void
createDatabase(String name)
Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a parameterized CREATE DATABASE query.void
createRetentionPolicy(String rpName, String database, String duration, int replicationFactor, boolean isDefault)
Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a parameterized CREATE RETENTION POLICY query.void
createRetentionPolicy(String rpName, String database, String duration, String shardDuration, int replicationFactor)
Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a parameterized CREATE RETENTION POLICY query.void
createRetentionPolicy(String rpName, String database, String duration, String shardDuration, int replicationFactor, boolean isDefault)
Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a parameterized CREATE RETENTION POLICY query.boolean
databaseExists(String name)
Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a SHOW DATABASES query and inspect the result.void
deleteDatabase(String name)
Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a DROP DATABASE query.List<String>
describeDatabases()
Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a SHOW DATABASES query.void
disableBatch()
Disable Batching.InfluxDB
disableGzip()
Disable Gzip compress for http request body.void
dropRetentionPolicy(String rpName, String database)
Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a DROP RETENTION POLICY query.InfluxDB
enableBatch()
Enable batching of single Point writes to speed up writes significantly.InfluxDB
enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit)
Enable batching of single Point writes asenableBatch(int, int, TimeUnit, ThreadFactory)
} using default thread factory.InfluxDB
enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit, ThreadFactory threadFactory)
Enable batching of single Point writes asenableBatch(int, int, TimeUnit, ThreadFactory, BiConsumer)
using with a exceptionHandler that does nothing.InfluxDB
enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit, ThreadFactory threadFactory, BiConsumer<Iterable<Point>,Throwable> exceptionHandler)
Enable batching of single Point writes to speed up writes significant.InfluxDB
enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit, ThreadFactory threadFactory, BiConsumer<Iterable<Point>,Throwable> exceptionHandler, InfluxDB.ConsistencyLevel consistency)
Enable batching of single Point writes with consistency set for an entire batch flushDurations is reached first, a batch write is issued.InfluxDB
enableBatch(BatchOptions batchOptions)
Enable batching of single Point writes to speed up writes significantly.InfluxDB
enableGzip()
Enable Gzip compress for http request body.void
flush()
Send any buffered points to InfluxDB.boolean
isBatchEnabled()
Returns whether Batching is enabled.boolean
isGzipEnabled()
Returns whether Gzip compress for http request body is enabled.Pong
ping()
Ping this influxDB.QueryResult
query(Query query)
Execute a query against a database.void
query(Query query, int chunkSize, BiConsumer<InfluxDB.Cancellable,QueryResult> onNext)
Execute a streaming query against a database.void
query(Query query, int chunkSize, BiConsumer<InfluxDB.Cancellable,QueryResult> onNext, Runnable onComplete)
Execute a streaming query against a database.void
query(Query query, int chunkSize, BiConsumer<InfluxDB.Cancellable,QueryResult> onNext, Runnable onComplete, Consumer<Throwable> onFailure)
Execute a streaming query against a database.void
query(Query query, int chunkSize, Consumer<QueryResult> onNext)
Execute a streaming query against a database.void
query(Query query, int chunkSize, Consumer<QueryResult> onNext, Runnable onComplete)
Execute a streaming query against a database.QueryResult
query(Query query, TimeUnit timeUnit)
Execute a query against a database.void
query(Query query, Consumer<QueryResult> onSuccess, Consumer<Throwable> onFailure)
Execute a query against a database.InfluxDB
setConsistency(InfluxDB.ConsistencyLevel consistency)
Set the consistency level which is used for writing points.InfluxDB
setDatabase(String database)
Set the database which is used for writing points.InfluxDB
setLogLevel(InfluxDB.LogLevel logLevel)
Set the loglevel which is used for REST related actions.InfluxDB
setRetentionPolicy(String retentionPolicy)
Set the retention policy which is used for writing points.String
version()
Return the version of the connected influxDB Server.void
write(int udpPort, String records)
Write a set of Points to the influxdb database with the string records through UDP.void
write(int udpPort, List<String> records)
Write a set of Points to the influxdb database with the list of string records through UDP.void
write(int udpPort, Point point)
Write a single Point to the database through UDP.void
write(String records)
Write a set of Points to the default database with the string records.void
write(String database, String retentionPolicy, Point point)
Write a single Point to the database.void
write(String database, String retentionPolicy, InfluxDB.ConsistencyLevel consistency, String records)
Write a set of Points to the influxdb database with the string records.void
write(String database, String retentionPolicy, InfluxDB.ConsistencyLevel consistency, TimeUnit precision, String records)
Write a set of Points to the influxdb database with the string records.void
write(String database, String retentionPolicy, InfluxDB.ConsistencyLevel consistency, TimeUnit precision, List<String> records)
Write a set of Points to the influxdb database with the list of string records.void
write(String database, String retentionPolicy, InfluxDB.ConsistencyLevel consistency, List<String> records)
Write a set of Points to the influxdb database with the list of string records.void
write(List<String> records)
Write a set of Points to the default database with the list of string records.void
write(BatchPoints batchPoints)
Write a set of Points to the influxdb database with the new (>= 0.9.0rc32) lineprotocol.void
write(Point point)
Write a single Point to the default database.void
writeWithRetry(BatchPoints batchPoints)
Write a set of Points to the influxdb database with the new (>= 0.9.0rc32) lineprotocol.
-
Field Details
-
LOG_LEVEL_PROPERTY
The system property key to set the http logging level across the JVM.- See Also:
for available values
, Constant Field Values
-
-
Method Details
-
setLogLevel
Set the loglevel which is used for REST related actions.- Parameters:
logLevel
- the loglevel to set.- Returns:
- the InfluxDB instance to be able to use it in a fluent manner.
-
enableGzip
InfluxDB enableGzip()Enable Gzip compress for http request body.- Returns:
- the InfluxDB instance to be able to use it in a fluent manner.
-
disableGzip
InfluxDB disableGzip()Disable Gzip compress for http request body.- Returns:
- the InfluxDB instance to be able to use it in a fluent manner.
-
isGzipEnabled
boolean isGzipEnabled()Returns whether Gzip compress for http request body is enabled.- Returns:
- true if gzip is enabled.
-
enableBatch
InfluxDB enableBatch()Enable batching of single Point writes to speed up writes significantly. This is the same as calling InfluxDB.enableBatch(BatchOptions.DEFAULTS)- Returns:
- the InfluxDB instance to be able to use it in a fluent manner.
-
enableBatch
Enable batching of single Point writes to speed up writes significantly. If either number of points written or flushDuration time limit is reached, a batch write is issued. Note that batch processing needs to be explicitly stopped before the application is shutdown. To do so call disableBatch().- Parameters:
batchOptions
- the options to set for batching the writes.- Returns:
- the InfluxDB instance to be able to use it in a fluent manner.
-
enableBatch
Enable batching of single Point writes asenableBatch(int, int, TimeUnit, ThreadFactory)
} using default thread factory.- Parameters:
actions
- the number of actions to collectflushDuration
- the time to wait at most.flushDurationTimeUnit
- the TimeUnit for the given flushDuration.- Returns:
- the InfluxDB instance to be able to use it in a fluent manner.
- See Also:
enableBatch(int, int, TimeUnit, ThreadFactory)
-
enableBatch
InfluxDB enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit, ThreadFactory threadFactory)Enable batching of single Point writes asenableBatch(int, int, TimeUnit, ThreadFactory, BiConsumer)
using with a exceptionHandler that does nothing.- Parameters:
actions
- the number of actions to collectflushDuration
- the time to wait at most.flushDurationTimeUnit
- the TimeUnit for the given flushDuration.threadFactory
- a ThreadFactory instance to be used.- Returns:
- the InfluxDB instance to be able to use it in a fluent manner.
- See Also:
enableBatch(int, int, TimeUnit, ThreadFactory, BiConsumer)
-
enableBatch
InfluxDB enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit, ThreadFactory threadFactory, BiConsumer<Iterable<Point>,Throwable> exceptionHandler, InfluxDB.ConsistencyLevel consistency)Enable batching of single Point writes with consistency set for an entire batch flushDurations is reached first, a batch write is issued. Note that batch processing needs to be explicitly stopped before the application is shutdown. To do so call disableBatch(). Default consistency is ONE.- Parameters:
actions
- the number of actions to collectflushDuration
- the time to wait at most.flushDurationTimeUnit
- the TimeUnit for the given flushDuration.threadFactory
- a ThreadFactory instance to be used.exceptionHandler
- a consumer function to handle asynchronous errorsconsistency
- a consistency setting for batch writes.- Returns:
- the InfluxDB instance to be able to use it in a fluent manner.
-
enableBatch
InfluxDB enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit, ThreadFactory threadFactory, BiConsumer<Iterable<Point>,Throwable> exceptionHandler)Enable batching of single Point writes to speed up writes significant. If either actions or flushDurations is reached first, a batch write is issued. Note that batch processing needs to be explicitly stopped before the application is shutdown. To do so call disableBatch().- Parameters:
actions
- the number of actions to collectflushDuration
- the time to wait at most.flushDurationTimeUnit
- the TimeUnit for the given flushDuration.threadFactory
- a ThreadFactory instance to be used.exceptionHandler
- a consumer function to handle asynchronous errors- Returns:
- the InfluxDB instance to be able to use it in a fluent manner.
-
disableBatch
void disableBatch()Disable Batching. -
isBatchEnabled
boolean isBatchEnabled()Returns whether Batching is enabled.- Returns:
- true if batch is enabled.
-
ping
Pong ping()Ping this influxDB.- Returns:
- the response of the ping execution.
-
version
String version()Return the version of the connected influxDB Server.- Returns:
- the version String, otherwise unknown.
-
write
Write a single Point to the default database.- Parameters:
point
- The point to write
-
write
Write a set of Points to the default database with the string records.- Parameters:
records
- the points in the correct lineprotocol.
-
write
Write a set of Points to the default database with the list of string records.- Parameters:
records
- the List of points in the correct lineprotocol.
-
write
Write a single Point to the database.- Parameters:
database
- the database to write to.retentionPolicy
- the retentionPolicy to use.point
- The point to write
-
write
Write a single Point to the database through UDP.- Parameters:
udpPort
- the udpPort to write to.point
- The point to write.
-
write
Write a set of Points to the influxdb database with the new (>= 0.9.0rc32) lineprotocol.- Parameters:
batchPoints
- the points to write in BatchPoints.- See Also:
- 2696
-
writeWithRetry
Write a set of Points to the influxdb database with the new (>= 0.9.0rc32) lineprotocol. If batching is enabled with appropriateBatchOptions
settings (BatchOptions.bufferLimit
greater thanBatchOptions.actions
) This method will try to retry in case of some recoverable errors. Otherwise it just works aswrite(BatchPoints)
- Parameters:
batchPoints
- the points to write in BatchPoints.- See Also:
- 2696, Retry worth errors
-
write
void write(String database, String retentionPolicy, InfluxDB.ConsistencyLevel consistency, String records)Write a set of Points to the influxdb database with the string records.- Parameters:
database
- the name of the database to writeretentionPolicy
- the retentionPolicy to useconsistency
- the ConsistencyLevel to userecords
- the points in the correct lineprotocol.- See Also:
- 2696
-
write
void write(String database, String retentionPolicy, InfluxDB.ConsistencyLevel consistency, TimeUnit precision, String records)Write a set of Points to the influxdb database with the string records.- Parameters:
database
- the name of the database to writeretentionPolicy
- the retentionPolicy to useconsistency
- the ConsistencyLevel to useprecision
- the time precision to userecords
- the points in the correct lineprotocol.- See Also:
- 2696
-
write
void write(String database, String retentionPolicy, InfluxDB.ConsistencyLevel consistency, List<String> records)Write a set of Points to the influxdb database with the list of string records.- Parameters:
database
- the name of the database to writeretentionPolicy
- the retentionPolicy to useconsistency
- the ConsistencyLevel to userecords
- the List of points in the correct lineprotocol.- See Also:
- 2696
-
write
void write(String database, String retentionPolicy, InfluxDB.ConsistencyLevel consistency, TimeUnit precision, List<String> records)Write a set of Points to the influxdb database with the list of string records.- Parameters:
database
- the name of the database to writeretentionPolicy
- the retentionPolicy to useconsistency
- the ConsistencyLevel to useprecision
- the time precision to userecords
- the List of points in the correct lineprotocol.- See Also:
- 2696
-
write
Write a set of Points to the influxdb database with the string records through UDP.- Parameters:
udpPort
- the udpPort where influxdb is listeningrecords
- the content will be encoded by UTF-8 before sent.
-
write
Write a set of Points to the influxdb database with the list of string records through UDP.- Parameters:
udpPort
- the udpPort where influxdb is listeningrecords
- list of record, the content will be encoded by UTF-8 before sent.
-
query
Execute a query against a database.- Parameters:
query
- the query to execute.- Returns:
- a List of Series which matched the query.
-
query
Execute a query against a database. One of the consumers will be executed.- Parameters:
query
- the query to execute.onSuccess
- the consumer to invoke when result is receivedonFailure
- the consumer to invoke when error is thrown
-
query
Execute a streaming query against a database.- Parameters:
query
- the query to execute.chunkSize
- the number of QueryResults to process in one chunk.onNext
- the consumer to invoke for each received QueryResult
-
query
Execute a streaming query against a database.- Parameters:
query
- the query to execute.chunkSize
- the number of QueryResults to process in one chunk.onNext
- the consumer to invoke for each received QueryResult; with capability to discontinue a streaming query
-
query
Execute a streaming query against a database.- Parameters:
query
- the query to execute.chunkSize
- the number of QueryResults to process in one chunk.onNext
- the consumer to invoke for each received QueryResultonComplete
- the onComplete to invoke for successfully end of stream
-
query
void query(Query query, int chunkSize, BiConsumer<InfluxDB.Cancellable,QueryResult> onNext, Runnable onComplete)Execute a streaming query against a database.- Parameters:
query
- the query to execute.chunkSize
- the number of QueryResults to process in one chunk.onNext
- the consumer to invoke for each received QueryResult; with capability to discontinue a streaming queryonComplete
- the onComplete to invoke for successfully end of stream
-
query
void query(Query query, int chunkSize, BiConsumer<InfluxDB.Cancellable,QueryResult> onNext, Runnable onComplete, Consumer<Throwable> onFailure)Execute a streaming query against a database.- Parameters:
query
- the query to execute.chunkSize
- the number of QueryResults to process in one chunk.onNext
- the consumer to invoke for each received QueryResult; with capability to discontinue a streaming queryonComplete
- the onComplete to invoke for successfully end of streamonFailure
- the consumer for error handling
-
query
Execute a query against a database.- Parameters:
query
- the query to execute.timeUnit
- the time unit of the results.- Returns:
- a List of Series which matched the query.
-
createDatabase
Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a parameterized CREATE DATABASE query.Create a new Database.- Parameters:
name
- the name of the new database.
-
deleteDatabase
Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a DROP DATABASE query.Delete a database.- Parameters:
name
- the name of the database to delete.
-
describeDatabases
Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a SHOW DATABASES query.Describe all available databases.- Returns:
- a List of all Database names.
-
databaseExists
Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a SHOW DATABASES query and inspect the result.Check if a database exists.- Parameters:
name
- the name of the database to search.- Returns:
- true if the database exists or false if it doesn't exist
-
flush
void flush()Send any buffered points to InfluxDB. This method is synchronous and will block while all pending points are written.- Throws:
IllegalStateException
- if batching is not enabled.
-
close
void close()close thread for asynchronous batch write and UDP socket to release resources if need.- Specified by:
close
in interfaceAutoCloseable
-
setConsistency
Set the consistency level which is used for writing points.- Parameters:
consistency
- the consistency level to set.- Returns:
- the InfluxDB instance to be able to use it in a fluent manner.
-
setDatabase
Set the database which is used for writing points.- Parameters:
database
- the database to set.- Returns:
- the InfluxDB instance to be able to use it in a fluent manner.
-
setRetentionPolicy
Set the retention policy which is used for writing points.- Parameters:
retentionPolicy
- the retention policy to set.- Returns:
- the InfluxDB instance to be able to use it in a fluent manner.
-
createRetentionPolicy
@Deprecated void createRetentionPolicy(String rpName, String database, String duration, String shardDuration, int replicationFactor, boolean isDefault)Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a parameterized CREATE RETENTION POLICY query.Creates a retentionPolicy.- Parameters:
rpName
- the name of the retentionPolicy(rp)database
- the name of the databaseduration
- the duration of the rpshardDuration
- the shardDurationreplicationFactor
- the replicationFactor of the rpisDefault
- if the rp is the default rp for the database or not
-
createRetentionPolicy
@Deprecated void createRetentionPolicy(String rpName, String database, String duration, int replicationFactor, boolean isDefault)Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a parameterized CREATE RETENTION POLICY query.Creates a retentionPolicy. (optional shardDuration)- Parameters:
rpName
- the name of the retentionPolicy(rp)database
- the name of the databaseduration
- the duration of the rpreplicationFactor
- the replicationFactor of the rpisDefault
- if the rp is the default rp for the database or not
-
createRetentionPolicy
@Deprecated void createRetentionPolicy(String rpName, String database, String duration, String shardDuration, int replicationFactor)Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a parameterized CREATE RETENTION POLICY query.Creates a retentionPolicy. (optional shardDuration and isDefault)- Parameters:
rpName
- the name of the retentionPolicy(rp)database
- the name of the databaseduration
- the duration of the rpshardDuration
- the shardDurationreplicationFactor
- the replicationFactor of the rp
-
dropRetentionPolicy
Deprecated.(since 2.9, removed in 3.0) Useorg.influxdb.InfluxDB.query(Query)
to execute a DROP RETENTION POLICY query.Drops a retentionPolicy in a database.- Parameters:
rpName
- the name of the retentionPolicydatabase
- the name of the database
-