public class GridCacheContinuousQueryAdapter<K,V> extends Object implements GridCacheContinuousQuery<K,V>
DFLT_AUTO_UNSUBSCRIBE, DFLT_BUF_SIZE, DFLT_TIME_INTERVAL| Modifier and Type | Method and Description |
|---|---|
void |
autoUnsubscribe(boolean autoUnsubscribe)
Sets automatic unsubscribe flag.
|
int |
bufferSize()
Gets buffer size.
|
void |
bufferSize(int bufSize)
Sets buffer size.
|
GridBiPredicate<UUID,Collection<Map.Entry<K,V>>> |
callback()
Gets local callback.
|
void |
callback(GridBiPredicate<UUID,Collection<Map.Entry<K,V>>> cb)
Sets mandatory local callback.
|
void |
close()
Stops continuous query execution.
|
void |
execute()
Starts continuous query execution on the whole grid.
|
void |
execute(GridProjection prj)
Starts continuous query execution on provided set of nodes.
|
void |
execute(GridProjection prj,
boolean internal)
Starts continuous query execution.
|
GridBiPredicate<K,V> |
filter()
Gets key-value filter.
|
void |
filter(GridBiPredicate<K,V> filter)
Sets optional key-value filter.
|
boolean |
isAutoUnsubscribe()
Gets automatic unsubscribe flag.
|
long |
timeInterval()
Gets time interval.
|
void |
timeInterval(long timeInterval)
Sets time interval.
|
String |
toString() |
public void callback(GridBiPredicate<UUID,Collection<Map.Entry<K,V>>> cb)
The callback predicate accepts ID of the node from where updates
are received and collection of received entries. Note that
for removed entries value will be null.
If the predicate returns false, query execution will
be cancelled.
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.
callback in interface GridCacheContinuousQuery<K,V>cb - Local callback.@Nullable public GridBiPredicate<UUID,Collection<Map.Entry<K,V>>> callback()
GridCacheContinuousQuery.callback(GridBiPredicate) for more information.callback in interface GridCacheContinuousQuery<K,V>public void filter(@Nullable GridBiPredicate<K,V> filter)
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.
filter in interface GridCacheContinuousQuery<K,V>filter - Key-value filter.@Nullable public GridBiPredicate<K,V> filter()
GridCacheContinuousQuery.filter(GridBiPredicate) for more information.filter in interface GridCacheContinuousQuery<K,V>public void bufferSize(int bufSize)
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 or time provided via GridCacheContinuousQuery.timeInterval(long)
method is exceeded.
Default buffer size is 1 which means that entries will
be sent immediately (buffering is disabled).
bufferSize in interface GridCacheContinuousQuery<K,V>bufSize - Buffer size.public int bufferSize()
GridCacheContinuousQuery.bufferSize(int) for more information.bufferSize in interface GridCacheContinuousQuery<K,V>public void timeInterval(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 GridCacheContinuousQuery.bufferSize(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.
timeInterval in interface GridCacheContinuousQuery<K,V>timeInterval - Time interval.public long timeInterval()
GridCacheContinuousQuery.timeInterval(long) for more information.timeInterval in interface GridCacheContinuousQuery<K,V>public void autoUnsubscribe(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.
autoUnsubscribe in interface GridCacheContinuousQuery<K,V>autoUnsubscribe - Automatic unsubscription flag.public boolean isAutoUnsubscribe()
GridCacheContinuousQuery.autoUnsubscribe(boolean)
for more information.isAutoUnsubscribe in interface GridCacheContinuousQuery<K,V>public void execute()
throws GridException
Note that if grid contains nodes without appropriate cache, these nodes will be filtered out.
Also note that for LOCAL
and REPLICATED caches
query will be always executed locally.
execute in interface GridCacheContinuousQuery<K,V>GridException - In case of error.public void execute(@Nullable GridProjection prj) throws GridException
Note that if provided projection contains nodes without appropriate cache, these nodes will be filtered out.
Also note that for LOCAL
and REPLICATED caches
query will be always executed locally.
execute in interface GridCacheContinuousQuery<K,V>prj - Grid projection.GridException - In case of error.public void execute(@Nullable GridProjection prj, boolean internal) throws GridException
prj - Grid projection.internal - If true then query notified about internal entries updates.GridException - If failed.public void close()
throws GridException
Note that one query instance can be executed only once.
After it's cancelled, it's non-operational.
If you need to repeat execution, use GridCacheQueries.createContinuousQuery()
method to create new query.
close in interface AutoCloseableclose in interface GridCacheContinuousQuery<K,V>GridException - In case of error.Copyright © 2014. All rights reserved.