Package com.streambase.liveview.client
Class QueryListenerWrapper
- java.lang.Object
-
- com.streambase.liveview.client.QueryListenerWrapper
-
- All Implemented Interfaces:
Query
,QueryListener
,Closeable
,AutoCloseable
,EventListener
public class QueryListenerWrapper extends Object implements QueryListener, Query
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
Constructors Constructor Description QueryListenerWrapper(LiveViewMultiConnectionImpl liveViewMultiConnectionImpl, QueryConfig config, QueryListener qListener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
exceptionRaised(QueryExceptionEvent event)
Event when an exception occurs during the query.QueryConfig
getConfig()
Returns a QueryConfig object that contains fully parsed pieces like table, predicate, groupByExprs, etc.List<Schema.Field>
getFields()
Returns a list describing the fields of the tuples that will be returned by this Query.List<Schema.Field>
getKeyFields()
Returns a list of fields describing the primary key for this table.short
getQueryId()
This will match the queryId on the events.Query
getRealQuery()
Schema
getSchema()
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
setSchema(Schema schema)
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 Detail
-
QueryListenerWrapper
public QueryListenerWrapper(LiveViewMultiConnectionImpl liveViewMultiConnectionImpl, QueryConfig config, QueryListener qListener)
- Parameters:
config
-qListener
-liveViewMultiConnectionImpl
-
-
-
Method Detail
-
getConfig
public QueryConfig 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
public void tupleAdded(TupleAddedEvent event)
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
public void tupleUpdated(TupleUpdatedEvent event)
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
public void tupleRemoved(TupleRemovedEvent event)
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
public void snapshotBegin(BeginSnapshotEvent event)
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
public void snapshotEnd(EndSnapshotEvent event)
Description copied from interface:QueryListener
Event to indicate the query snapshot is complete.- Specified by:
snapshotEnd
in interfaceQueryListener
- Parameters:
event
- snapshot end
-
deleteBegin
public void deleteBegin(BeginDeleteEvent event)
Description copied from interface:QueryListener
Event to indicate the start of delete query.- Specified by:
deleteBegin
in interfaceQueryListener
- Parameters:
event
- delete begin
-
deleteEnd
public void deleteEnd(EndDeleteEvent event)
Description copied from interface:QueryListener
Event to indicate the delete query is complete.- Specified by:
deleteEnd
in interfaceQueryListener
- Parameters:
event
- delete end
-
exceptionRaised
public void exceptionRaised(QueryExceptionEvent event)
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
public void queryClosed(QueryClosedEvent event)
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
public List<Schema.Field> 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
public List<Schema.Field> 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
public Query getRealQuery()
-
setRealQuery
public void setRealQuery(Query realQuery)
- Parameters:
realQuery
- the realQuery to set
-
-