Package org.influxdb
Class BatchOptions
java.lang.Object
org.influxdb.BatchOptions
- All Implemented Interfaces:
Cloneable
public final class BatchOptions extends Object implements Cloneable
BatchOptions are used to configure batching of individual data point writes
into InfluxDB. See
InfluxDB.enableBatch(BatchOptions)
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_BATCH_ACTIONS_LIMIT
static int
DEFAULT_BATCH_INTERVAL_DURATION
static int
DEFAULT_BUFFER_LIMIT
static boolean
DEFAULT_DROP_ACTIONS_ON_QUEUE_EXHAUSTION
static int
DEFAULT_JITTER_INTERVAL_DURATION
static TimeUnit
DEFAULT_PRECISION
static BatchOptions
DEFAULTS
Default batch options. -
Method Summary
Modifier and Type Method Description BatchOptions
actions(int actions)
BatchOptions
bufferLimit(int bufferLimit)
The client maintains a buffer for failed writes so that the writes will be retried later on.BatchOptions
consistency(InfluxDB.ConsistencyLevel consistency)
BatchOptions
dropActionsOnQueueExhaustion(boolean dropActionsOnQueueExhaustion)
Set to define the behaviour when the action queue exhausts.BatchOptions
droppedActionHandler(Consumer<Point> droppedActionHandler)
Handler to handle dropped actions due to queue actions.BatchOptions
exceptionHandler(BiConsumer<Iterable<Point>,Throwable> exceptionHandler)
BatchOptions
flushDuration(int flushDuration)
int
getActions()
int
getBufferLimit()
InfluxDB.ConsistencyLevel
getConsistency()
Consumer<Point>
getDroppedActionHandler()
BiConsumer<Iterable<Point>,Throwable>
getExceptionHandler()
int
getFlushDuration()
int
getJitterDuration()
TimeUnit
getPrecision()
ThreadFactory
getThreadFactory()
boolean
isDropActionsOnQueueExhaustion()
BatchOptions
jitterDuration(int jitterDuration)
Jitters the batch flush interval by a random amount.BatchOptions
precision(TimeUnit precision)
Set the time precision to use for the whole batch.BatchOptions
threadFactory(ThreadFactory threadFactory)
-
Field Details
-
DEFAULT_BATCH_ACTIONS_LIMIT
public static final int DEFAULT_BATCH_ACTIONS_LIMIT- See Also:
- Constant Field Values
-
DEFAULT_BATCH_INTERVAL_DURATION
public static final int DEFAULT_BATCH_INTERVAL_DURATION- See Also:
- Constant Field Values
-
DEFAULT_JITTER_INTERVAL_DURATION
public static final int DEFAULT_JITTER_INTERVAL_DURATION- See Also:
- Constant Field Values
-
DEFAULT_BUFFER_LIMIT
public static final int DEFAULT_BUFFER_LIMIT- See Also:
- Constant Field Values
-
DEFAULT_PRECISION
-
DEFAULT_DROP_ACTIONS_ON_QUEUE_EXHAUSTION
public static final boolean DEFAULT_DROP_ACTIONS_ON_QUEUE_EXHAUSTION- See Also:
- Constant Field Values
-
DEFAULTS
Default batch options. This class is immutable, each configuration is built by taking the DEFAULTS and setting specific configuration properties.
-
-
Method Details
-
actions
- Parameters:
actions
- the number of actions to collect- Returns:
- the BatchOptions instance to be able to use it in a fluent manner.
-
flushDuration
- Parameters:
flushDuration
- the time to wait at most (milliseconds).- Returns:
- the BatchOptions instance to be able to use it in a fluent manner.
-
jitterDuration
Jitters the batch flush interval by a random amount. This is primarily to avoid large write spikes for users running a large number of client instances. ie, a jitter of 5s and flush duration 10s means flushes will happen every 10-15s.- Parameters:
jitterDuration
- (milliseconds)- Returns:
- the BatchOptions instance to be able to use it in a fluent manner.
-
bufferLimit
The client maintains a buffer for failed writes so that the writes will be retried later on. This may help to overcome temporary network problems or InfluxDB load spikes. When the buffer is full and new points are written, oldest entries in the buffer are lost. To disable this feature set buffer limit to a value smaller thangetActions()
- Parameters:
bufferLimit
- maximum number of points stored in the retry buffer- Returns:
- the BatchOptions instance to be able to use it in a fluent manner.
-
threadFactory
- Parameters:
threadFactory
- a ThreadFactory instance to be used- Returns:
- the BatchOptions instance to be able to use it in a fluent manner.
-
exceptionHandler
- Parameters:
exceptionHandler
- a consumer function to handle asynchronous errors- Returns:
- the BatchOptions instance to be able to use it in a fluent manner.
-
consistency
- Parameters:
consistency
- cluster consistency setting (how many nodes have to store data points to treat a write as a success)- Returns:
- the BatchOptions instance to be able to use it in a fluent manner.
-
precision
Set the time precision to use for the whole batch. If unspecified, will default toTimeUnit.NANOSECONDS
.- Parameters:
precision
- sets the precision to use- Returns:
- the BatchOptions instance to be able to use it in a fluent manner.
-
dropActionsOnQueueExhaustion
Set to define the behaviour when the action queue exhausts. If unspecified, will default to false which means that theInfluxDB.write(Point)
will be blocked till the space in the queue is created. true means that the newer actions being written to the queue will be dropped anddroppedActionHandler
will be called.- Parameters:
dropActionsOnQueueExhaustion
- sets the behavior- Returns:
- the BatchOptions instance to be able to use it in a fluent manner.
-
droppedActionHandler
Handler to handle dropped actions due to queue actions. This is only valid whendropActionsOnQueueExhaustion
is set to true.- Parameters:
droppedActionHandler
- to handle action drops on action queue exhaustion.- Returns:
- the BatchOptions instance to be able to use it in a fluent manner.
-
getActions
public int getActions()- Returns:
- actions the number of actions to collect
-
getFlushDuration
public int getFlushDuration()- Returns:
- flushDuration the time to wait at most (milliseconds).
-
getJitterDuration
public int getJitterDuration()- Returns:
- batch flush interval jitter value (milliseconds)
-
getBufferLimit
public int getBufferLimit()- Returns:
- Maximum number of points stored in the retry buffer, see
bufferLimit(int)
-
getThreadFactory
- Returns:
- a ThreadFactory instance to be used
-
getExceptionHandler
- Returns:
- a consumer function to handle asynchronous errors
-
getConsistency
- Returns:
- cluster consistency setting (how many nodes have to store data points to treat a write as a success)
-
getPrecision
- Returns:
- the time precision
-
isDropActionsOnQueueExhaustion
public boolean isDropActionsOnQueueExhaustion()- Returns:
- a boolean determining whether to drop actions on action queue exhaustion.
-
getDroppedActionHandler
- Returns:
- a consumer function to handle actions drops on action queue exhaustion.
-