E - the type which will be accumulated in this Accumulator.public class BasicAccumulator<E extends Sequenced> extends Object
Accumulator.
Subclasses should override required methods according to their context.NonStopPublisherAccumulator,
BatchPublisherAccumulator| Modifier and Type | Field and Description |
|---|---|
protected CyclicBuffer<E> |
buffer |
protected QueryCacheContext |
context |
protected AccumulatorHandler<E> |
handler |
protected AccumulatorInfo |
info |
protected ILogger |
logger |
protected PartitionSequencer |
partitionSequencer |
| Modifier | Constructor and Description |
|---|---|
protected |
BasicAccumulator(QueryCacheContext context,
AccumulatorInfo info) |
| Modifier and Type | Method and Description |
|---|---|
void |
accumulate(E event)
Adds event to this accumulator.
|
protected AccumulatorHandler<E> |
createAccumulatorHandler(QueryCacheContext context,
AccumulatorInfo info) |
protected AccumulatorProcessor<Sequenced> |
createAccumulatorProcessor(AccumulatorInfo info,
QueryCacheEventService eventService) |
CyclicBuffer<E> |
getBuffer() |
protected QueryCacheContext |
getContext() |
AccumulatorInfo |
getInfo()
Returns
AccumulatorInfo of this accumulator. |
protected long |
getNow() |
boolean |
isEmpty()
Returns true if this accumulator contains no elements.
|
protected boolean |
isExpired(QueryCacheEventData entry,
long delayMillis,
long now) |
Iterator<E> |
iterator()
Returns an iterator over the items in this accumulator in proper sequence.
|
int |
poll(AccumulatorHandler<E> handler,
int maxItems)
Reads this accumulator if it contains at least
maxItems, otherwise
do not read anything. |
int |
poll(AccumulatorHandler<E> handler,
long delay,
TimeUnit unit)
Reads all expired items to the supplied handler.
|
void |
reset()
Resets this accumulator.
|
boolean |
setHead(long sequence)
Tries to set head of this accumulator to the supplied
sequence and returns true,
if that sequence is still exist in this accumulator. |
int |
size()
Current size of accumulator.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorprotected final AccumulatorHandler<E extends Sequenced> handler
protected final ILogger logger
protected final AccumulatorInfo info
protected final QueryCacheContext context
protected final CyclicBuffer<E extends Sequenced> buffer
protected final PartitionSequencer partitionSequencer
protected BasicAccumulator(QueryCacheContext context, AccumulatorInfo info)
public void accumulate(E event)
Accumulatorevent - event to add.public int poll(AccumulatorHandler<E> handler, int maxItems)
AccumulatormaxItems, otherwise
do not read anything. If this method adds items to the supplied handler, head of this accumulator advances.
Used for batching purposes.handler - handler to process this accumulator.maxItems - read this accumulator if it contains at least maxItemspublic int poll(AccumulatorHandler<E> handler, long delay, TimeUnit unit)
Accumulatorhandler - handler to process this accumulator.delay - after this duration element will be poll-able.unit - time-unitpublic Iterator<E> iterator()
Accumulatorpublic int size()
Accumulatorpublic boolean isEmpty()
Accumulatorpublic AccumulatorInfo getInfo()
AccumulatorAccumulatorInfo of this accumulator.AccumulatorInfo of this accumulator.public boolean setHead(long sequence)
Accumulatorsequence and returns true,
if that sequence is still exist in this accumulator. Otherwise, returns false.sequence - the sequence number which will be the head of this accumulator.true if sequence is set, otherwise returns falsepublic void reset()
Accumulatorreset in interface Accumulator<E extends Sequenced>protected AccumulatorHandler<E> createAccumulatorHandler(QueryCacheContext context, AccumulatorInfo info)
protected AccumulatorProcessor<Sequenced> createAccumulatorProcessor(AccumulatorInfo info, QueryCacheEventService eventService)
public CyclicBuffer<E> getBuffer()
protected QueryCacheContext getContext()
protected long getNow()
protected boolean isExpired(QueryCacheEventData entry, long delayMillis, long now)
Copyright © 2020 Hazelcast, Inc.. All Rights Reserved.