public final class ContinuousQueryWithTransformer<K,V,T> extends AbstractContinuousQuery<K,V>
Continuous queries allow to register a remote filter and a local listener for cache updates. If an update event passes the filter, it will be transformed with transformer and sent to the node that executed the query and local listener will be notified.
Additionally, you can execute initial query to get currently existing data.
Query can be of any type (SQL, TEXT or SCAN) and can be set via setInitialQuery(Query)
method.
Query can be executed either on all nodes in topology using IgniteCache.query(Query)
method, or only on the local node, if Query.setLocal(boolean)
parameter is set to true
.
Note that in case query is distributed and a new node joins, it will get the remote
filter for the query during discovery process before it actually joins topology,
so no updates will be missed.
This will execute query on all nodes that have cache you are working with and
listener will start to receive notifications for cache updates.
To stop receiving updates call QueryCursor.close()
method.
Note that this works even if you didn't provide initial query. Cursor will
be empty in this case, but it will still unregister listeners when QueryCursor.close()
is called.
IgniteAsyncCallback
annotation is supported for CacheEntryEventFilter
(see setRemoteFilterFactory(Factory)
) and CacheEntryUpdatedListener
(see setRemoteTransformerFactory(Factory)
) and CacheEntryUpdatedListener
(see setLocalListener(EventListener)
and ContinuousQueryWithTransformer.EventListener
).
If filter and/or listener are annotated with IgniteAsyncCallback
then annotated callback
is executed in async callback pool (see IgniteConfiguration.getAsyncCallbackPoolSize()
)
and notification order is kept the same as update order for given cache key.
Modifier and Type | Class and Description |
---|---|
static interface |
ContinuousQueryWithTransformer.EventListener<T>
Interface for local listener of
ContinuousQueryWithTransformer to implement. |
DFLT_AUTO_UNSUBSCRIBE, DFLT_PAGE_SIZE, DFLT_TIME_INTERVAL
Constructor and Description |
---|
ContinuousQueryWithTransformer()
Creates new continuous query with transformer.
|
Modifier and Type | Method and Description |
---|---|
ContinuousQueryWithTransformer.EventListener<T> |
getLocalListener()
Gets local transformed event listener
|
javax.cache.configuration.Factory<? extends IgniteClosure<javax.cache.event.CacheEntryEvent<? extends K,? extends V>,T>> |
getRemoteTransformerFactory()
Gets remote transformer factory
|
ContinuousQueryWithTransformer<K,V,T> |
setAutoUnsubscribe(boolean autoUnsubscribe)
Sets automatic unsubscribe flag.
|
ContinuousQueryWithTransformer<K,V,T> |
setInitialQuery(Query<javax.cache.Cache.Entry<K,V>> initQry)
Sets initial query.
|
ContinuousQueryWithTransformer<K,V,T> |
setLocal(boolean loc)
Sets whether this query should be executed on local node only.
|
ContinuousQueryWithTransformer<K,V,T> |
setLocalListener(ContinuousQueryWithTransformer.EventListener<T> locLsnr)
Sets local callback.
|
ContinuousQueryWithTransformer<K,V,T> |
setPageSize(int pageSize)
Sets optional page size, if
0 , then default is used. |
ContinuousQueryWithTransformer<K,V,T> |
setRemoteFilterFactory(javax.cache.configuration.Factory<? extends javax.cache.event.CacheEntryEventFilter<K,V>> rmtFilterFactory)
Sets optional key-value filter factory.
|
ContinuousQueryWithTransformer<K,V,T> |
setRemoteTransformerFactory(javax.cache.configuration.Factory<? extends IgniteClosure<javax.cache.event.CacheEntryEvent<? extends K,? extends V>,T>> factory)
Sets transformer factory.
|
ContinuousQueryWithTransformer<K,V,T> |
setTimeInterval(long timeInterval)
Sets time interval.
|
getInitialQuery, getRemoteFilterFactory, getTimeInterval, isAutoUnsubscribe, isIncludeExpired, setIncludeExpired
getPageSize, isLocal, prepare, toString
public ContinuousQueryWithTransformer()
public ContinuousQueryWithTransformer<K,V,T> setInitialQuery(Query<javax.cache.Cache.Entry<K,V>> initQry)
This query will be executed before continuous listener is registered which allows to iterate through entries which already existed at the time continuous query is executed.
setInitialQuery
in class AbstractContinuousQuery<K,V>
initQry
- Initial query.this
for chaining.public ContinuousQueryWithTransformer<K,V,T> setRemoteFilterFactory(javax.cache.configuration.Factory<? extends javax.cache.event.CacheEntryEventFilter<K,V>> rmtFilterFactory)
WARNING: all operations that involve any kind of JVM-local or distributed locking (e.g., synchronization or transactional cache operations), should be executed asynchronously without blocking the thread that called the filter. Otherwise, you can get deadlocks.
If remote filter are annotated with IgniteAsyncCallback
then it is executed in async callback
pool (see IgniteConfiguration.getAsyncCallbackPoolSize()
) that allow to perform a cache operations.
setRemoteFilterFactory
in class AbstractContinuousQuery<K,V>
rmtFilterFactory
- Key-value filter factory.this
for chaining.IgniteAsyncCallback
,
IgniteConfiguration.getAsyncCallbackPoolSize()
public ContinuousQueryWithTransformer<K,V,T> setRemoteTransformerFactory(javax.cache.configuration.Factory<? extends IgniteClosure<javax.cache.event.CacheEntryEvent<? extends K,? extends V>,T>> factory)
WARNING: all operations that involve any kind of JVM-local or distributed locking (e.g., synchronization or transactional cache operations), should be executed asynchronously without blocking the thread that called the filter. Otherwise, you can get deadlocks.
factory
- Remote transformer factory.this
for chaining.public javax.cache.configuration.Factory<? extends IgniteClosure<javax.cache.event.CacheEntryEvent<? extends K,? extends V>,T>> getRemoteTransformerFactory()
public ContinuousQueryWithTransformer<K,V,T> setLocalListener(ContinuousQueryWithTransformer.EventListener<T> locLsnr)
The callback predicate accepts results of transformed by AbstractContinuousQuery.getRemoteFilterFactory()
events
WARNING: all operations that involve any kind of JVM-local or distributed locking (e.g., synchronization or transactional cache operations), should be executed asynchronously without blocking the thread that called the callback. Otherwise, you can get deadlocks.
If local listener are annotated with IgniteAsyncCallback
then it is executed in async callback pool
(see IgniteConfiguration.getAsyncCallbackPoolSize()
) that allow to perform a cache operations.
locLsnr
- Local callback.this
for chaining.IgniteAsyncCallback
,
IgniteConfiguration.getAsyncCallbackPoolSize()
,
ContinuousQuery.setLocalListener(CacheEntryUpdatedListener)
public ContinuousQueryWithTransformer.EventListener<T> getLocalListener()
public ContinuousQueryWithTransformer<K,V,T> setTimeInterval(long timeInterval)
When a cache update happens, entry is first put into a buffer. Entries from buffer will
be sent to the master node only if the buffer is full (its size can be provided via Query.setPageSize(int)
method) or time provided via this method is exceeded.
Default time interval is 0
which means that
time check is disabled and entries will be sent only when buffer is full.
setTimeInterval
in class AbstractContinuousQuery<K,V>
timeInterval
- Time interval.this
for chaining.public ContinuousQueryWithTransformer<K,V,T> setAutoUnsubscribe(boolean autoUnsubscribe)
This flag indicates that query filters on remote nodes should be
automatically unregistered if master node (node that initiated the query) leaves topology. If this flag is
false
, filters will be unregistered only when the query is cancelled from master node, and won't ever be
unregistered if master node leaves grid.
Default value for this flag is true
.
setAutoUnsubscribe
in class AbstractContinuousQuery<K,V>
autoUnsubscribe
- Automatic unsubscription flag.this
for chaining.public ContinuousQueryWithTransformer<K,V,T> setPageSize(int pageSize)
0
, then default is used.setPageSize
in class Query<javax.cache.Cache.Entry<K,V>>
pageSize
- Optional page size.this
for chaining.
GridGain In-Memory Computing Platform : ver. 8.9.15 Release Date : December 3 2024