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
public abstract class AbstractBatchedQueryListener extends AbstractQueryListener
An abstract implementation of aQueryListenerthat batches up multiple events and sends them to the concrete implementation.Concrete implementations must implement the abstract
snapshot(List, boolean)andupdate(List)methods to receive batched up events.
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the thread that calls the batch methods periodicallyvoidexceptionRaised(QueryExceptionEvent event)Event when an exception occurs during the query.voidfinalize()voidqueryClosed(QueryClosedEvent event)Event when a query being listened to is closed.abstract voidsnapshot(List<TupleAddedEvent> eventList, boolean complete)This batch method is called one or more times for snapshot results.voidsnapshotBegin(BeginSnapshotEvent event)Event to indicate the start of the result snapshot.voidsnapshotEnd(EndSnapshotEvent event)Event to indicate the query snapshot is complete.voidtupleAdded(TupleAddedEvent event)Event when a new tuple is added to the result.voidtupleRemoved(TupleRemovedEvent event)Event when an existing tuple is removed from the result.voidtupleUpdated(TupleUpdatedEvent event)Event when an existing tuple in the result is updated.abstract voidupdate(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 Detail
-
AbstractBatchedQueryListener
public AbstractBatchedQueryListener()
Constructs a listener with quarter-second interval and the maximum batch size.
-
AbstractBatchedQueryListener
public AbstractBatchedQueryListener(long interval, TimeUnit unit, boolean collapseEvents)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 Detail
-
snapshot
public abstract void snapshot(List<TupleAddedEvent> eventList, boolean complete)
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
public abstract void update(List<AbstractTupleEvent> eventList)
This batch method is called zero or more times for continuous updates.- Parameters:
eventList- the continuous tuple events
-
tupleRemoved
public void tupleRemoved(TupleRemovedEvent event)
Event when an existing tuple is removed from the result.This method may be extended, ensuring a super call is made.
- Specified by:
tupleRemovedin interfaceQueryListener- Overrides:
tupleRemovedin classAbstractQueryListener- Parameters:
event- remove event
-
tupleAdded
public void tupleAdded(TupleAddedEvent event)
Event when a new tuple is added to the result.This method may be extended, ensuring a super call is made.
- Specified by:
tupleAddedin interfaceQueryListener- Overrides:
tupleAddedin classAbstractQueryListener- Parameters:
event- add event
-
tupleUpdated
public void tupleUpdated(TupleUpdatedEvent event)
Event when an existing tuple in the result is updated.This method may be extended, ensuring a super call is made.
- Specified by:
tupleUpdatedin interfaceQueryListener- Overrides:
tupleUpdatedin classAbstractQueryListener- Parameters:
event- update event
-
snapshotBegin
public void snapshotBegin(BeginSnapshotEvent event)
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:
snapshotBeginin interfaceQueryListener- Overrides:
snapshotBeginin classAbstractQueryListener- Parameters:
event- snapshot begin
-
snapshotEnd
public void snapshotEnd(EndSnapshotEvent event)
Event to indicate the query snapshot is complete.This method may be extended, ensuring a super call is made.
- Specified by:
snapshotEndin interfaceQueryListener- Overrides:
snapshotEndin classAbstractQueryListener- Parameters:
event- snapshot end
-
exceptionRaised
public void exceptionRaised(QueryExceptionEvent event)
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:
exceptionRaisedin interfaceQueryListener- Overrides:
exceptionRaisedin classAbstractQueryListener- Parameters:
event- exception event
-
queryClosed
public void queryClosed(QueryClosedEvent event)
Event when a query being listened to is closed.This method may be extended, ensuring a super call is made.
- Specified by:
queryClosedin interfaceQueryListener- Overrides:
queryClosedin classAbstractQueryListener- Parameters:
event- query closed event
-
close
public void close()
Closes the thread that calls the batch methods periodically
-
-