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 Details

  • Method Details

    • actions

      public BatchOptions actions​(int actions)
      Parameters:
      actions - the number of actions to collect
      Returns:
      the BatchOptions instance to be able to use it in a fluent manner.
    • flushDuration

      public BatchOptions flushDuration​(int 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

      public BatchOptions jitterDuration​(int 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

      public BatchOptions bufferLimit​(int 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 than getActions()
      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

      public BatchOptions threadFactory​(ThreadFactory threadFactory)
      Parameters:
      threadFactory - a ThreadFactory instance to be used
      Returns:
      the BatchOptions instance to be able to use it in a fluent manner.
    • exceptionHandler

      public BatchOptions exceptionHandler​(BiConsumer<Iterable<Point>,​Throwable> 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

      public BatchOptions consistency​(InfluxDB.ConsistencyLevel 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

      public BatchOptions precision​(TimeUnit precision)
      Set the time precision to use for the whole batch. If unspecified, will default to TimeUnit.NANOSECONDS.
      Parameters:
      precision - sets the precision to use
      Returns:
      the BatchOptions instance to be able to use it in a fluent manner.
    • dropActionsOnQueueExhaustion

      public BatchOptions dropActionsOnQueueExhaustion​(boolean dropActionsOnQueueExhaustion)
      Set to define the behaviour when the action queue exhausts. If unspecified, will default to false which means that the InfluxDB.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 and droppedActionHandler will be called.
      Parameters:
      dropActionsOnQueueExhaustion - sets the behavior
      Returns:
      the BatchOptions instance to be able to use it in a fluent manner.
    • droppedActionHandler

      public BatchOptions droppedActionHandler​(Consumer<Point> droppedActionHandler)
      Handler to handle dropped actions due to queue actions. This is only valid when dropActionsOnQueueExhaustion 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

      public ThreadFactory getThreadFactory()
      Returns:
      a ThreadFactory instance to be used
    • getExceptionHandler

      public BiConsumer<Iterable<Point>,​Throwable> getExceptionHandler()
      Returns:
      a consumer function to handle asynchronous errors
    • getConsistency

      public InfluxDB.ConsistencyLevel getConsistency()
      Returns:
      cluster consistency setting (how many nodes have to store data points to treat a write as a success)
    • getPrecision

      public TimeUnit getPrecision()
      Returns:
      the time precision
    • isDropActionsOnQueueExhaustion

      public boolean isDropActionsOnQueueExhaustion()
      Returns:
      a boolean determining whether to drop actions on action queue exhaustion.
    • getDroppedActionHandler

      public Consumer<Point> getDroppedActionHandler()
      Returns:
      a consumer function to handle actions drops on action queue exhaustion.