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 |
Constructor and Description |
---|
BasicAccumulator(QueryCacheContext context,
AccumulatorInfo info) |
Modifier and Type | Method and Description |
---|---|
void |
accumulate(E event)
Adds event to this accumulator.
|
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, wait
forEach, spliterator
protected final ILogger logger
protected final AccumulatorHandler<E extends Sequenced> handler
protected final AccumulatorInfo info
protected final QueryCacheContext context
protected final CyclicBuffer<E extends Sequenced> buffer
protected final PartitionSequencer partitionSequencer
public BasicAccumulator(QueryCacheContext context, AccumulatorInfo info)
public void accumulate(E event)
Accumulator
event
- event to add.public int poll(AccumulatorHandler<E> handler, int maxItems)
Accumulator
maxItems
, 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 maxItems
public int poll(AccumulatorHandler<E> handler, long delay, TimeUnit unit)
Accumulator
handler
- handler to process this accumulator.delay
- after this duration element will be poll-able.unit
- time-unitpublic Iterator<E> iterator()
Accumulator
public int size()
Accumulator
public boolean isEmpty()
Accumulator
public AccumulatorInfo getInfo()
Accumulator
AccumulatorInfo
of this accumulator.AccumulatorInfo
of this accumulator.public boolean setHead(long sequence)
Accumulator
sequence
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 false
public void reset()
Accumulator
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 © 2018 Hazelcast, Inc.. All Rights Reserved.