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 voidclose()Closes the client and server resources associated with this Query.voiddeleteBegin(BeginDeleteEvent event)Event to indicate the start of delete query.voiddeleteEnd(EndDeleteEvent event)Event to indicate the delete query is complete.voidexceptionRaised(QueryExceptionEvent event)Event when an exception occurs during the query.QueryConfiggetConfig()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.shortgetQueryId()This will match the queryId on the events.QuerygetRealQuery()SchemagetSchema()Getter for theSchemafor the query.booleanisOpen()If this is false, either you've already gotten a QueryClosed event or you're about to get one.voidqueryClosed(QueryClosedEvent event)Event when a query being listened to is closed.voidsetRealQuery(Query realQuery)voidsetSchema(Schema schema)Setter for theSchemafor the query.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.-
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:QueryReturns 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:QueryListenerEvent when a new tuple is added to the result.- Specified by:
tupleAddedin interfaceQueryListener- Parameters:
event- add event
-
tupleUpdated
public void tupleUpdated(TupleUpdatedEvent event)
Description copied from interface:QueryListenerEvent when an existing tuple in the result is updated.- Specified by:
tupleUpdatedin interfaceQueryListener- Parameters:
event- update event
-
tupleRemoved
public void tupleRemoved(TupleRemovedEvent event)
Description copied from interface:QueryListenerEvent when an existing tuple is removed from the result.- Specified by:
tupleRemovedin interfaceQueryListener- Parameters:
event- remove event
-
snapshotBegin
public void snapshotBegin(BeginSnapshotEvent event)
Description copied from interface:QueryListenerEvent 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:
snapshotBeginin interfaceQueryListener- Parameters:
event- snapshot begin
-
snapshotEnd
public void snapshotEnd(EndSnapshotEvent event)
Description copied from interface:QueryListenerEvent to indicate the query snapshot is complete.- Specified by:
snapshotEndin interfaceQueryListener- Parameters:
event- snapshot end
-
deleteBegin
public void deleteBegin(BeginDeleteEvent event)
Description copied from interface:QueryListenerEvent to indicate the start of delete query.- Specified by:
deleteBeginin interfaceQueryListener- Parameters:
event- delete begin
-
deleteEnd
public void deleteEnd(EndDeleteEvent event)
Description copied from interface:QueryListenerEvent to indicate the delete query is complete.- Specified by:
deleteEndin interfaceQueryListener- Parameters:
event- delete end
-
exceptionRaised
public void exceptionRaised(QueryExceptionEvent event)
Description copied from interface:QueryListenerEvent when an exception occurs during the query. Since 1.3, reaching the row limit is considered an exception.- Specified by:
exceptionRaisedin interfaceQueryListener- Parameters:
event- exception event
-
queryClosed
public void queryClosed(QueryClosedEvent event)
Description copied from interface:QueryListenerEvent when a query being listened to is closed.- Specified by:
queryClosedin interfaceQueryListener- Parameters:
event- query closed event
-
getFields
public List<Schema.Field> getFields()
Description copied from interface:QueryReturns 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:QueryReturns 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:
getKeyFieldsin 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:QueryCloses 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:QueryIf 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:QueryThis will match the queryId on the events.- Specified by:
getQueryIdin interfaceQuery- Returns:
- the query ID for the query.
-
getRealQuery
public Query getRealQuery()
-
setRealQuery
public void setRealQuery(Query realQuery)
- Parameters:
realQuery- the realQuery to set
-
-