public abstract class AbstractBatchedQueryListener extends AbstractQueryListener
QueryListener
that batches up multiple events
and sends them to the concrete implementation.
Concrete implementations must implement the abstract AbstractBatchedQueryListener.snapshot(List, boolean)
and AbstractBatchedQueryListener.update(List)
methods
to receive batched up events.
Constructor and Description |
---|
AbstractBatchedQueryListener()
Constructs a listener with quarter-second interval and the maximum batch size.
|
AbstractBatchedQueryListener(long interval,
TimeUnit unit,
boolean collapseEvents)
Constructor to set an interval for receiving batched results.
|
AbstractBatchedQueryListener(long interval,
TimeUnit unit,
boolean collapseEvents,
int maxBatchSize)
Constructor to set an interval for receiving batched results.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the thread that calls the batch methods periodically
|
void |
exceptionRaised(QueryExceptionEvent event)
Event when an exception occurs during the query.
|
void |
finalize() |
void |
queryClosed(QueryClosedEvent event)
Event when a query being listened to is closed.
|
abstract void |
snapshot(List<TupleAddedEvent> eventList,
boolean complete)
This batch method is called one or more times for snapshot results.
|
void |
snapshotBegin(BeginSnapshotEvent event)
Event to indicate the start of the result snapshot.
|
void |
snapshotEnd(EndSnapshotEvent event)
Event to indicate the query snapshot is complete.
|
void |
tupleAdded(TupleAddedEvent event)
Event when a new tuple is added to the result.
|
void |
tupleRemoved(TupleRemovedEvent event)
Event when an existing tuple is removed from the result.
|
void |
tupleUpdated(TupleUpdatedEvent event)
Event when an existing tuple in the result is updated.
|
abstract void |
update(List<AbstractTupleEvent> eventList)
This batch method is called zero or more times for continuous updates.
|
deleteBegin, deleteEnd
public AbstractBatchedQueryListener()
public AbstractBatchedQueryListener(long interval, TimeUnit unit, boolean collapseEvents)
interval
- notification intervalunit
- notification interval unitcollapseEvents
- whether or not to collapsed multiple updates in the same batchpublic AbstractBatchedQueryListener(long interval, TimeUnit unit, boolean collapseEvents, int maxBatchSize)
interval
- notification intervalunit
- notification interval unitcollapseEvents
- whether or not to collapsed multiple updates in the same batchmaxBatchSize
- max batch size before notificationpublic abstract void snapshot(List<TupleAddedEvent> eventList, boolean complete)
eventList
- the added tuplescomplete
- indicator whether the snapshot is complete or notpublic abstract void update(List<AbstractTupleEvent> eventList)
eventList
- the continuous tuple eventspublic void tupleRemoved(TupleRemovedEvent event)
This method may be extended, ensuring a super call is made.
tupleRemoved
in interface QueryListener
tupleRemoved
in class AbstractQueryListener
event
- remove eventpublic void tupleAdded(TupleAddedEvent event)
This method may be extended, ensuring a super call is made.
tupleAdded
in interface QueryListener
tupleAdded
in class AbstractQueryListener
event
- add eventpublic void tupleUpdated(TupleUpdatedEvent event)
This method may be extended, ensuring a super call is made.
tupleUpdated
in interface QueryListener
tupleUpdated
in class AbstractQueryListener
event
- update eventpublic void snapshotBegin(BeginSnapshotEvent event)
This method may be extended, ensuring a super call is made.
snapshotBegin
in interface QueryListener
snapshotBegin
in class AbstractQueryListener
event
- snapshot beginpublic void snapshotEnd(EndSnapshotEvent event)
This method may be extended, ensuring a super call is made.
snapshotEnd
in interface QueryListener
snapshotEnd
in class AbstractQueryListener
event
- snapshot endpublic void exceptionRaised(QueryExceptionEvent event)
This method may be extended, ensuring a super call is made.
exceptionRaised
in interface QueryListener
exceptionRaised
in class AbstractQueryListener
event
- exception eventpublic void queryClosed(QueryClosedEvent event)
This method may be extended, ensuring a super call is made.
queryClosed
in interface QueryListener
queryClosed
in class AbstractQueryListener
event
- query closed eventpublic void close()