Class DebounceStorageStrategy

java.lang.Object
com.inductiveautomation.historian.gateway.api.storage.strategy.PointStorageStrategy
com.inductiveautomation.historian.gateway.api.storage.strategy.DebounceStorageStrategy

public class DebounceStorageStrategy extends PointStorageStrategy
Buffers incoming points per point type and forwards them to the storage engine in batches. A flush fires when submissions go idle for the debounce time, when the oldest point has waited the max-wait time, or when a queue reaches DebounceBatchConfig.maxBatchSize().

Oversized submissions are split into batches of at most maxBatchSize points. The timer and size settings can be changed at runtime through apply(DebounceBatchConfig).

Concurrent flushes: when DebounceBatchConfig.maxConcurrentFlushes() is greater than 1, up to that many flushes run in parallel, so the downstream engine must tolerate concurrent calls. Listeners that need flushes to complete in order must keep it at the default of 1. Parallel flushes only occur when a queue holds more than one maxBatchSize chunk of points.

  • Method Details

    • create

      public static DebounceStorageStrategy create(DebounceBatchConfig config)
      Creates a strategy with the given configuration.
      Parameters:
      config - the initial timer, batch-size and concurrency settings.
      Returns:
      a new strategy.
    • createDefault

      public static DebounceStorageStrategy createDefault(String processorName)
      Creates a strategy with the default configuration.
      Parameters:
      processorName - the name that identifies this strategy in logs and thread names.
      Returns:
      a new strategy.
    • operatingPoint

      public DebounceBatchConfig operatingPoint()
      Returns the timer and size configuration currently in effect.
      Returns:
      the live operating point.
    • apply

      public void apply(DebounceBatchConfig next)
      Replaces the debounce, max-wait and batch-size settings. Flushes already under way finish with the previous settings.

      Not synchronized against concurrent callers; an ingest tuner is expected to be the only writer.

      Parameters:
      next - the replacement point, validated by DebounceBatchConfig itself.
      Throws:
      IllegalArgumentException - if its key or maxConcurrentFlushes differs from the configuration this strategy was constructed with.
    • processAtomic

      public CompletionStage<StorageResult<AtomicPoint<?>>> processAtomic(List<AtomicPoint<?>> atomicPoints)
      Description copied from class: PointStorageStrategy
      Processes atomic points asynchronously.
      Specified by:
      processAtomic in class PointStorageStrategy
      Parameters:
      atomicPoints - the points to process.
      Returns:
      a stage completing with the storage result.
    • processComplex

      public <C extends ComplexPoint<?>> CompletionStage<StorageResult<C>> processComplex(List<C> complexPoints)
      Description copied from class: PointStorageStrategy
      Processes complex points asynchronously.
      Specified by:
      processComplex in class PointStorageStrategy
      Type Parameters:
      C - the complex point type.
      Parameters:
      complexPoints - the points to process.
      Returns:
      a stage completing with the storage result.
    • processChanges

      public <C extends ChangePoint<?>> CompletionStage<StorageResult<C>> processChanges(List<C> changePoints)
      Description copied from class: PointStorageStrategy
      Processes change points asynchronously.
      Specified by:
      processChanges in class PointStorageStrategy
      Type Parameters:
      C - the change point type.
      Parameters:
      changePoints - the points to process.
      Returns:
      a stage completing with the storage result.
    • metrics

      public Optional<StorageStrategyMetrics> metrics()
      Reports the queued-point count and oldest dwell time as one consistent snapshot.
      Overrides:
      metrics in class PointStorageStrategy
      Returns:
      the metrics; always present for this strategy.
    • flushTelemetry

      public Optional<FlushTelemetry> flushTelemetry()
      Reports batch size, queue dwell and engine time over the last 256 flushes.
      Overrides:
      flushTelemetry in class PointStorageStrategy
      Returns:
      the telemetry; always present for this strategy, with zeroed percentiles until the first flush completes.
    • queuedPointCount

      public int queuedPointCount()
      Returns the number of points queued across all point types, awaiting flush.
      Returns:
      the queued-point count, or 0 when every queue is empty.
    • oldestDwellMillis

      public long oldestDwellMillis()
      Returns how long the oldest queued batch has been waiting, without draining anything.
      Returns:
      the age of the oldest queued batch in milliseconds, or 0 when every queue is empty.
    • flushNow

      public void flushNow()
      Starts draining the whole backlog now, without waiting for the timers.

      Returns once the flush is scheduled, not when it completes. If every flush permit is busy the drain starts when one frees up. No-op when the queues are empty or after stopProcessing().

      Overrides:
      flushNow in class PointStorageStrategy
    • resumeProcessing

      public void resumeProcessing()
      Description copied from class: PointStorageStrategy
      Specified by:
      resumeProcessing in class PointStorageStrategy
    • pauseProcessing

      public void pauseProcessing()
      Suspends forwarding, e.g. for an engine restart, while still accepting and buffering points. Buffered points are forwarded after resumeProcessing(). Unlike stopProcessing(), nothing is rejected or drained.

      Blocks until flushes already in flight finish (up to 30 seconds), so call it before the engine is marked unavailable and without holding a lock those flushes need. No-op once stopped.

      Overrides:
      pauseProcessing in class PointStorageStrategy
    • stopProcessing

      public void stopProcessing()
      Rejects new points, waits for in-flight flushes, then forwards everything still queued.

      Every queued batch is completed: batches no listener accepts resolve with PointStorageStrategy.SHUTDOWN_FAILURE_CODE.

      Blocks for up to 30 seconds waiting on in-flight flushes.

      Specified by:
      stopProcessing in class PointStorageStrategy