Class Aggregator<S,T>
- java.lang.Object
-
- org.opennms.core.ipc.sink.aggregation.Aggregator<S,T>
-
- Type Parameters:
S
- individual messageT
- aggregated message (i.e. bucket)
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.lang.Runnable
- Direct Known Subclasses:
SinkAggregator
public class Aggregator<S,T> extends java.lang.Object implements java.lang.AutoCloseable, java.lang.Runnable
This aggregator is used to realize a givenAggregationPolicy
. This class is designed to delegate dispatching to the calling threads as much as possible (those which make calls to {@link #aggregate(Message).}- Author:
- jwhite
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
Aggregator.Bucket
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_NUM_STRIPE_LOCKS
static java.lang.String
NUM_STRIPE_LOCKS_SYS_PROP
System property used to override the default number of stripe locks.
-
Constructor Summary
Constructors Constructor Description Aggregator(java.lang.String id, AggregationPolicy<S,T,?> policy, AggregatingMessageProducer<S,T> messageProducer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
aggregate(S message)
Aggregates the given messages into a bucket and returns the bucket if it is ready to be dispatched.void
close()
void
run()
-
-
-
Field Detail
-
NUM_STRIPE_LOCKS_SYS_PROP
public static final java.lang.String NUM_STRIPE_LOCKS_SYS_PROP
System property used to override the default number of stripe locks.- See Also:
- Constant Field Values
-
DEFAULT_NUM_STRIPE_LOCKS
public static final int DEFAULT_NUM_STRIPE_LOCKS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Aggregator
public Aggregator(java.lang.String id, AggregationPolicy<S,T,?> policy, AggregatingMessageProducer<S,T> messageProducer)
-
-
Method Detail
-
aggregate
public T aggregate(S message)
Aggregates the given messages into a bucket and returns the bucket if it is ready to be dispatched.- Parameters:
message
- the message to aggregated- Returns:
- the bucket if it is ready to be dispatched, or
null
if nothing is ready to be dispatched
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
close
public void close() throws java.lang.Exception
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.Exception
-
-