Package com.streambase.liveview.client
Class AbstractBatchedQueryListener
java.lang.Object
com.streambase.liveview.client.AbstractQueryListener
com.streambase.liveview.client.AbstractBatchedQueryListener
- All Implemented Interfaces:
QueryListener
,EventListener
An abstract implementation of a
QueryListener
that batches up multiple events
and sends them to the concrete implementation.
Concrete implementations must implement the abstract snapshot(List, boolean)
and update(List)
methods
to receive batched up events.
-
Constructor Summary
ConstructorDescriptionConstructs 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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the thread that calls the batch methods periodicallyvoid
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.Methods inherited from class com.streambase.liveview.client.AbstractQueryListener
deleteBegin, deleteEnd
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.streambase.liveview.client.QueryListener
aggMarkBegin, aggMarkEnd
-
Constructor Details
-
AbstractBatchedQueryListener
public AbstractBatchedQueryListener()Constructs a listener with quarter-second interval and the maximum batch size. -
AbstractBatchedQueryListener
Constructor to set an interval for receiving batched results.- Parameters:
interval
- notification intervalunit
- notification interval unitcollapseEvents
- whether or not to collapsed multiple updates in the same batch
-
AbstractBatchedQueryListener
public AbstractBatchedQueryListener(long interval, TimeUnit unit, boolean collapseEvents, int maxBatchSize) Constructor to set an interval for receiving batched results.- Parameters:
interval
- notification intervalunit
- notification interval unitcollapseEvents
- whether or not to collapsed multiple updates in the same batchmaxBatchSize
- max batch size before notification
-
-
Method Details
-
snapshot
This batch method is called one or more times for snapshot results.- Parameters:
eventList
- the added tuplescomplete
- indicator whether the snapshot is complete or not
-
update
This batch method is called zero or more times for continuous updates.- Parameters:
eventList
- the continuous tuple events
-
tupleRemoved
Event when an existing tuple is removed from the result.This method may be extended, ensuring a super call is made.
- Specified by:
tupleRemoved
in interfaceQueryListener
- Overrides:
tupleRemoved
in classAbstractQueryListener
- Parameters:
event
- remove event
-
tupleAdded
Event when a new tuple is added to the result.This method may be extended, ensuring a super call is made.
- Specified by:
tupleAdded
in interfaceQueryListener
- Overrides:
tupleAdded
in classAbstractQueryListener
- Parameters:
event
- add event
-
tupleUpdated
Event when an existing tuple in the result is updated.This method may be extended, ensuring a super call is made.
- Specified by:
tupleUpdated
in interfaceQueryListener
- Overrides:
tupleUpdated
in classAbstractQueryListener
- Parameters:
event
- update event
-
snapshotBegin
Event to indicate the start of the result snapshot. This is the first method called when a query starts returning results, but this method is also called to indicate a reset (a complete restart of the query.)This method may be extended, ensuring a super call is made.
- Specified by:
snapshotBegin
in interfaceQueryListener
- Overrides:
snapshotBegin
in classAbstractQueryListener
- Parameters:
event
- snapshot begin
-
snapshotEnd
Event to indicate the query snapshot is complete.This method may be extended, ensuring a super call is made.
- Specified by:
snapshotEnd
in interfaceQueryListener
- Overrides:
snapshotEnd
in classAbstractQueryListener
- Parameters:
event
- snapshot end
-
exceptionRaised
Event when an exception occurs during the query. Since 1.3, reaching the row limit is considered an exception.This method may be extended, ensuring a super call is made.
- Specified by:
exceptionRaised
in interfaceQueryListener
- Overrides:
exceptionRaised
in classAbstractQueryListener
- Parameters:
event
- exception event
-
queryClosed
Event when a query being listened to is closed.This method may be extended, ensuring a super call is made.
- Specified by:
queryClosed
in interfaceQueryListener
- Overrides:
queryClosed
in classAbstractQueryListener
- Parameters:
event
- query closed event
-
close
public void close()Closes the thread that calls the batch methods periodically -
finalize
public void finalize()
-