Class ArrayListAggregationPolicy<S>
- java.lang.Object
-
- org.opennms.core.ipc.sink.aggregation.ArrayListAggregationPolicy<S>
-
- All Implemented Interfaces:
AggregationPolicy<S,java.util.List<S>,java.util.List<S>>
public class ArrayListAggregationPolicy<S> extends java.lang.Object implements AggregationPolicy<S,java.util.List<S>,java.util.List<S>>
An aggregation policy that createsArrayList
aggregates.- Author:
- Seth
-
-
Constructor Summary
Constructors Constructor Description ArrayListAggregationPolicy(int completionSize, int completionInterval, java.util.function.Function<S,java.lang.Object> keyMapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<S>
aggregate(java.util.List<S> accumulator, S newMessage)
Aggregate the given message into an existing accumulator, or create a new accumulator if no accumulator exists.java.util.List<S>
build(java.util.List<S> accumulator)
Build the resulting message from the accumulator.int
getCompletionIntervalMs()
Maximum number of milliseconds for which buckets should continue accumulating messages after creation.int
getCompletionSize()
Maximum number of messages to be added to a bucket before dispatching.java.lang.Object
key(S message)
Calculate a key for the given message.
-
-
-
Constructor Detail
-
ArrayListAggregationPolicy
public ArrayListAggregationPolicy(int completionSize, int completionInterval, java.util.function.Function<S,java.lang.Object> keyMapper)
-
-
Method Detail
-
key
public java.lang.Object key(S message)
Description copied from interface:AggregationPolicy
Calculate a key for the given message. Objects with the same key will be aggregated together. Returned values should non-null.- Specified by:
key
in interfaceAggregationPolicy<S,java.util.List<S>,java.util.List<S>>
- Parameters:
message
- the message- Returns:
- the message's key
-
aggregate
public java.util.List<S> aggregate(java.util.List<S> accumulator, S newMessage)
Description copied from interface:AggregationPolicy
Aggregate the given message into an existing accumulator, or create a new accumulator if no accumulator exists.- Specified by:
aggregate
in interfaceAggregationPolicy<S,java.util.List<S>,java.util.List<S>>
- Parameters:
accumulator
- the existing accumulator, ornull
if a new accumulator should be creatednewMessage
- the message to aggregate- Returns:
- the new or updated accumulator
-
build
public java.util.List<S> build(java.util.List<S> accumulator)
Description copied from interface:AggregationPolicy
Build the resulting message from the accumulator.- Specified by:
build
in interfaceAggregationPolicy<S,java.util.List<S>,java.util.List<S>>
- Parameters:
accumulator
- an existing accumulator- Returns:
- the aggregated message to dispatch
-
getCompletionSize
public int getCompletionSize()
Description copied from interface:AggregationPolicy
Maximum number of messages to be added to a bucket before dispatching. If this value is <= 1, the buckets should be dispatched immediately after adding a single element.- Specified by:
getCompletionSize
in interfaceAggregationPolicy<S,java.util.List<S>,java.util.List<S>>
- Returns:
- maximum number of messages per bucket
-
getCompletionIntervalMs
public int getCompletionIntervalMs()
Description copied from interface:AggregationPolicy
Maximum number of milliseconds for which buckets should continue accumulating messages after creation. If a bucket has been created for longer than this interval, it will be dispatched regardless of it's current size. Values <= 0 will disable periodic flushing and buckets will only be dispatched once they have reached the maximum size.- Specified by:
getCompletionIntervalMs
in interfaceAggregationPolicy<S,java.util.List<S>,java.util.List<S>>
- Returns:
- number of milliseconds to keep a bucket before dispatching
-
-