Package org.onlab.util
Class AbstractAccumulator<T>
- java.lang.Object
- 
- org.onlab.util.AbstractAccumulator<T>
 
- 
- All Implemented Interfaces:
- Accumulator<T>
 
 public abstract class AbstractAccumulator<T> extends 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 SummaryConstructors Modifier Constructor Description protectedAbstractAccumulator(Timer timer, int maxItems, int maxBatchMillis, int maxIdleMillis)Creates an item accumulator capable of triggering on the specified thresholds.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(T item)Adds an item to the current batch.booleanisReady()Indicates whether the accumulator is ready to process items.intmaxBatchMillis()Returns the maximum number of millis allowed to expire since the first item before processing is triggered.intmaxIdleMillis()Returns the maximum number of millis allowed to expire since the last item arrival before processing is triggered.intmaxItems()Returns the maximum number of items allowed to accumulate before processing is triggered.Timertimer()Returns the backing timer.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.onlab.util.AccumulatorprocessItems
 
- 
 
- 
- 
- 
Constructor Detail- 
AbstractAccumulatorprotected AbstractAccumulator(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- 
addpublic void add(T item) Description copied from interface:AccumulatorAdds an item to the current batch. This operation may, or may not trigger processing of the current batch of items.- Specified by:
- addin interface- Accumulator<T>
- Parameters:
- item- item to be added to the current batch
 
 - 
isReadypublic boolean isReady() Description copied from interface:AccumulatorIndicates whether the accumulator is ready to process items.- Specified by:
- isReadyin interface- Accumulator<T>
- Returns:
- true if ready to process
 
 - 
timerpublic Timer timer() Returns the backing timer.- Returns:
- backing timer
 
 - 
maxItemspublic int maxItems() Returns the maximum number of items allowed to accumulate before processing is triggered.- Returns:
- max number of items
 
 - 
maxBatchMillispublic 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
 
 - 
maxIdleMillispublic 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
 
 
- 
 
-