Package com.streambase.liveview.client
Class QueryListenerWrapper
java.lang.Object
com.streambase.liveview.client.QueryListenerWrapper
- All Implemented Interfaces:
Query
,QueryListener
,Closeable
,AutoCloseable
,EventListener
This class is used by LiveViewMultiConnectionImpl to wrap BOTH the queryListener that the
user passes in to an execQuery, AND the Query that is passed back to him.
We need the former so that we can intercept the close command that comes from the
server going down -- we don't actually close the query, we just save it so that it can be
failed over to a new server.
We need to wrap the Query so that we can intercept with the client calls close on his own.
In that case, we want to actually close the query, plus we want to remove this query from
our list of ones that need to be reconnected to any new server.
-
Constructor Summary
ConstructorDescriptionQueryListenerWrapper
(com.streambase.liveview.client.internal.ws.LiveViewMultiConnectionImpl liveViewMultiConnectionImpl, QueryConfig config, QueryListener qListener) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the client and server resources associated with this Query.void
deleteBegin
(BeginDeleteEvent event) Event to indicate the start of delete query.void
deleteEnd
(EndDeleteEvent event) Event to indicate the delete query is complete.void
Event when an exception occurs during the query.Returns a QueryConfig object that contains fully parsed pieces like table, predicate, groupByExprs, etc.Returns a list describing the fields of the tuples that will be returned by this Query.Returns a list of fields describing the primary key for this table.short
This will match the queryId on the events.Getter for theSchema
for the query.boolean
isOpen()
If this is false, either you've already gotten a QueryClosed event or you're about to get one.void
queryClosed
(QueryClosedEvent event) Event when a query being listened to is closed.void
setRealQuery
(Query realQuery) void
Setter for theSchema
for the query.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.streambase.liveview.client.QueryListener
aggMarkBegin, aggMarkEnd
-
Constructor Details
-
QueryListenerWrapper
public QueryListenerWrapper(com.streambase.liveview.client.internal.ws.LiveViewMultiConnectionImpl liveViewMultiConnectionImpl, QueryConfig config, QueryListener qListener) - Parameters:
config
-qListener
-liveViewMultiConnectionImpl
-
-
-
Method Details
-
getConfig
Description copied from interface:Query
Returns a QueryConfig object that contains fully parsed pieces like table, predicate, groupByExprs, etc. as well as the query string. -
tupleAdded
Description copied from interface:QueryListener
Event when a new tuple is added to the result.- Specified by:
tupleAdded
in interfaceQueryListener
- Parameters:
event
- add event
-
tupleUpdated
Description copied from interface:QueryListener
Event when an existing tuple in the result is updated.- Specified by:
tupleUpdated
in interfaceQueryListener
- Parameters:
event
- update event
-
tupleRemoved
Description copied from interface:QueryListener
Event when an existing tuple is removed from the result.- Specified by:
tupleRemoved
in interfaceQueryListener
- Parameters:
event
- remove event
-
snapshotBegin
Description copied from interface:QueryListener
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.)- Specified by:
snapshotBegin
in interfaceQueryListener
- Parameters:
event
- snapshot begin
-
snapshotEnd
Description copied from interface:QueryListener
Event to indicate the query snapshot is complete.- Specified by:
snapshotEnd
in interfaceQueryListener
- Parameters:
event
- snapshot end
-
deleteBegin
Description copied from interface:QueryListener
Event to indicate the start of delete query.- Specified by:
deleteBegin
in interfaceQueryListener
- Parameters:
event
- delete begin
-
deleteEnd
Description copied from interface:QueryListener
Event to indicate the delete query is complete.- Specified by:
deleteEnd
in interfaceQueryListener
- Parameters:
event
- delete end
-
exceptionRaised
Description copied from interface:QueryListener
Event when an exception occurs during the query. Since 1.3, reaching the row limit is considered an exception.- Specified by:
exceptionRaised
in interfaceQueryListener
- Parameters:
event
- exception event
-
queryClosed
Description copied from interface:QueryListener
Event when a query being listened to is closed.- Specified by:
queryClosed
in interfaceQueryListener
- Parameters:
event
- query closed event
-
getFields
Description copied from interface:Query
Returns a list describing the fields of the tuples that will be returned by this Query. An empty list may be returned if the result fields are unknown. -
getKeyFields
Description copied from interface:Query
Returns a list of fields describing the primary key for this table. These fields will come from the same schema as getFields, which come from the schema used to create tuples when they arrive, so they will be suitable for calling getXxx against the tuple.- Specified by:
getKeyFields
in interfaceQuery
- Returns:
- The fields describing the key of the tuples returned, or null if the key is simply a Long that is not part of the data record.
-
close
public void close()Description copied from interface:Query
Closes the client and server resources associated with this Query. This call may block while it connects to the server to unregister the query. -
isOpen
public boolean isOpen()Description copied from interface:Query
If this is false, either you've already gotten a QueryClosed event or you're about to get one. -
getQueryId
public short getQueryId()Description copied from interface:Query
This will match the queryId on the events.- Specified by:
getQueryId
in interfaceQuery
- Returns:
- the query ID for the query.
-
getRealQuery
-
setRealQuery
- Parameters:
realQuery
- the realQuery to set
-
getSchema
Getter for theSchema
for the query.- Returns:
Schema
-
setSchema
Setter for theSchema
for the query.- Parameters:
schema
- theSchema
to set
-