Class AbstractAccumulator<T>

  • All Implemented Interfaces:
    Accumulator<T>

    public abstract class AbstractAccumulator<T>
    extends java.lang.Object
    implements Accumulator<T>
    Base implementation of an item accumulator. It allows triggering based on item inter-arrival time threshold, maximum batch life threshold and maximum batch size.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractAccumulator​(java.util.Timer timer, int maxItems, int maxBatchMillis, int maxIdleMillis)
      Creates an item accumulator capable of triggering on the specified thresholds.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(T item)
      Adds an item to the current batch.
      boolean isReady()
      Indicates whether the accumulator is ready to process items.
      int maxBatchMillis()
      Returns the maximum number of millis allowed to expire since the first item before processing is triggered.
      int maxIdleMillis()
      Returns the maximum number of millis allowed to expire since the last item arrival before processing is triggered.
      int maxItems()
      Returns the maximum number of items allowed to accumulate before processing is triggered.
      java.util.Timer timer()
      Returns the backing timer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractAccumulator

        protected AbstractAccumulator​(java.util.Timer timer,
                                      int maxItems,
                                      int maxBatchMillis,
                                      int maxIdleMillis)
        Creates an item accumulator capable of triggering on the specified thresholds.
        Parameters:
        timer - timer to use for scheduling check-points
        maxItems - maximum number of items to accumulate before processing is triggered

        NB: It is possible that processItems will contain more than maxItems under high load or if isReady() can return false.

        maxBatchMillis - maximum number of millis allowed since the first item before processing is triggered
        maxIdleMillis - maximum number millis between items before processing is triggered
    • Method Detail

      • add

        public void add​(T item)
        Description copied from interface: Accumulator
        Adds an item to the current batch. This operation may, or may not trigger processing of the current batch of items.
        Specified by:
        add in interface Accumulator<T>
        Parameters:
        item - item to be added to the current batch
      • isReady

        public boolean isReady()
        Description copied from interface: Accumulator
        Indicates whether the accumulator is ready to process items.
        Specified by:
        isReady in interface Accumulator<T>
        Returns:
        true if ready to process
      • timer

        public java.util.Timer timer()
        Returns the backing timer.
        Returns:
        backing timer
      • maxItems

        public int maxItems()
        Returns the maximum number of items allowed to accumulate before processing is triggered.
        Returns:
        max number of items
      • maxBatchMillis

        public int maxBatchMillis()
        Returns the maximum number of millis allowed to expire since the first item before processing is triggered.
        Returns:
        max number of millis a batch is allowed to last
      • maxIdleMillis

        public int maxIdleMillis()
        Returns the maximum number of millis allowed to expire since the last item arrival before processing is triggered.
        Returns:
        max number of millis since the last item