public interface InfluxDB extends AutoCloseable
Modifier and Type | Interface and 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.
|
Modifier and Type | Field and Description |
---|---|
static String |
LOG_LEVEL_PROPERTY
The system property key to set the http logging level across the JVM.
|
Modifier and Type | Method and 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) Use org.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) Use org.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) Use org.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) Use org.influxdb.InfluxDB.query(Query) to execute a parameterized
CREATE RETENTION POLICY query.
|
boolean |
databaseExists(String name)
Deprecated.
(since 2.9, removed in 3.0) Use org.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) Use org.influxdb.InfluxDB.query(Query) to execute a
DROP DATABASE query.
|
List<String> |
describeDatabases()
Deprecated.
(since 2.9, removed in 3.0) Use org.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) Use org.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(BatchOptions batchOptions)
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 as
enableBatch(int, int, TimeUnit, ThreadFactory) }
using default thread factory. |
InfluxDB |
enableBatch(int actions,
int flushDuration,
TimeUnit flushDurationTimeUnit,
ThreadFactory threadFactory)
Enable batching of single Point writes as
enableBatch(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 |
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,
Consumer<QueryResult> onSuccess,
Consumer<Throwable> onFailure)
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.
|
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(BatchPoints batchPoints)
Write a set of Points to the influxdb database with the new (>= 0.9.0rc32) lineprotocol.
|
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(int udpPort,
String records)
Write a set of Points to the influxdb database with the string records through UDP.
|
void |
write(List<String> records)
Write a set of Points to the default database with the list of string records.
|
void |
write(Point point)
Write a single Point to the default database.
|
void |
write(String records)
Write a set of Points to the default database with the 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(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,
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,
TimeUnit precision,
String records)
Write a set of Points to the influxdb database with the string records.
|
void |
write(String database,
String retentionPolicy,
Point point)
Write a single Point to the database.
|
void |
writeWithRetry(BatchPoints batchPoints)
Write a set of Points to the influxdb database with the new (>= 0.9.0rc32) lineprotocol.
|
static final String LOG_LEVEL_PROPERTY
for available values
,
Constant Field ValuesInfluxDB setLogLevel(InfluxDB.LogLevel logLevel)
logLevel
- the loglevel to set.InfluxDB enableGzip()
InfluxDB disableGzip()
boolean isGzipEnabled()
InfluxDB enableBatch()
InfluxDB enableBatch(BatchOptions batchOptions)
InfluxDB enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit)
enableBatch(int, int, TimeUnit, ThreadFactory)
}
using default thread factory.actions
- the number of actions to collectflushDuration
- the time to wait at most.flushDurationTimeUnit
- the TimeUnit for the given flushDuration.enableBatch(int, int, TimeUnit, ThreadFactory)
InfluxDB enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit, ThreadFactory threadFactory)
enableBatch(int, int, TimeUnit, ThreadFactory, BiConsumer)
using with a exceptionHandler that does nothing.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.enableBatch(int, int, TimeUnit, ThreadFactory, BiConsumer)
InfluxDB enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit, ThreadFactory threadFactory, BiConsumer<Iterable<Point>,Throwable> exceptionHandler, InfluxDB.ConsistencyLevel consistency)
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.InfluxDB enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit, ThreadFactory threadFactory, BiConsumer<Iterable<Point>,Throwable> exceptionHandler)
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 errorsvoid disableBatch()
boolean isBatchEnabled()
Pong ping()
String version()
void write(Point point)
point
- The point to writevoid write(String records)
records
- the points in the correct lineprotocol.void write(List<String> records)
records
- the List of points in the correct lineprotocol.void write(String database, String retentionPolicy, Point point)
database
- the database to write to.retentionPolicy
- the retentionPolicy to use.point
- The point to writevoid write(int udpPort, Point point)
udpPort
- the udpPort to write to.point
- The point to write.void write(BatchPoints batchPoints)
batchPoints
- the points to write in BatchPoints.void writeWithRetry(BatchPoints batchPoints)
BatchOptions
settings
(BatchOptions.bufferLimit
greater than BatchOptions.actions
)
This method will try to retry in case of some recoverable errors.
Otherwise it just works as write(BatchPoints)
batchPoints
- the points to write in BatchPoints.void write(String database, String retentionPolicy, InfluxDB.ConsistencyLevel consistency, String records)
database
- the name of the database to writeretentionPolicy
- the retentionPolicy to useconsistency
- the ConsistencyLevel to userecords
- the points in the correct lineprotocol.void write(String database, String retentionPolicy, InfluxDB.ConsistencyLevel consistency, TimeUnit precision, String records)
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.void write(String database, String retentionPolicy, InfluxDB.ConsistencyLevel consistency, List<String> records)
database
- the name of the database to writeretentionPolicy
- the retentionPolicy to useconsistency
- the ConsistencyLevel to userecords
- the List of points in the correct lineprotocol.void write(String database, String retentionPolicy, InfluxDB.ConsistencyLevel consistency, TimeUnit precision, List<String> records)
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.void write(int udpPort, String records)
udpPort
- the udpPort where influxdb is listeningrecords
- the content will be encoded by UTF-8 before sent.void write(int udpPort, List<String> records)
udpPort
- the udpPort where influxdb is listeningrecords
- list of record, the content will be encoded by UTF-8 before sent.QueryResult query(Query query)
query
- the query to execute.void query(Query query, Consumer<QueryResult> onSuccess, Consumer<Throwable> onFailure)
query
- the query to execute.onSuccess
- the consumer to invoke when result is receivedonFailure
- the consumer to invoke when error is thrownvoid query(Query query, int chunkSize, Consumer<QueryResult> onNext)
query
- the query to execute.chunkSize
- the number of QueryResults to process in one chunk.onNext
- the consumer to invoke for each received QueryResultvoid query(Query query, int chunkSize, BiConsumer<InfluxDB.Cancellable,QueryResult> onNext)
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 queryvoid query(Query query, int chunkSize, Consumer<QueryResult> onNext, Runnable onComplete)
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 streamvoid query(Query query, int chunkSize, BiConsumer<InfluxDB.Cancellable,QueryResult> onNext, Runnable onComplete)
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 streamvoid query(Query query, int chunkSize, BiConsumer<InfluxDB.Cancellable,QueryResult> onNext, Runnable onComplete, Consumer<Throwable> onFailure)
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 handlingQueryResult query(Query query, TimeUnit timeUnit)
query
- the query to execute.timeUnit
- the time unit of the results.@Deprecated void createDatabase(String name)
name
- the name of the new database.@Deprecated void deleteDatabase(String name)
name
- the name of the database to delete.@Deprecated List<String> describeDatabases()
@Deprecated boolean databaseExists(String name)
name
- the name of the database to search.void flush()
IllegalStateException
- if batching is not enabled.void close()
close
in interface AutoCloseable
InfluxDB setConsistency(InfluxDB.ConsistencyLevel consistency)
consistency
- the consistency level to set.InfluxDB setDatabase(String database)
database
- the database to set.InfluxDB setRetentionPolicy(String retentionPolicy)
retentionPolicy
- the retention policy to set.@Deprecated void createRetentionPolicy(String rpName, String database, String duration, String shardDuration, int replicationFactor, boolean isDefault)
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@Deprecated void createRetentionPolicy(String rpName, String database, String duration, int replicationFactor, boolean isDefault)
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@Deprecated void createRetentionPolicy(String rpName, String database, String duration, String shardDuration, int replicationFactor)
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@Deprecated void dropRetentionPolicy(String rpName, String database)
rpName
- the name of the retentionPolicydatabase
- the name of the databaseCopyright © 2019. All rights reserved.