public class GridCacheProjectionImpl<K,V> extends GridMetadataAwareAdapter implements GridCacheProjectionEx<K,V>, Externalizable
| Constructor and Description |
|---|
GridCacheProjectionImpl()
Empty constructor required for
Externalizable. |
GridCacheProjectionImpl(GridCacheProjection<K,V> parent,
GridCacheContext<K,V> cctx,
GridBiPredicate<K,V> kvFilter,
GridPredicate<? super GridCacheEntry<K,V>> entryFilter,
Set<GridCacheFlag> flags,
UUID subjId) |
| Modifier and Type | Method and Description |
|---|---|
<K1,V1> GridCache<K1,V1> |
cache()
Gets base cache for this projection.
|
boolean |
clear(K key)
Clears an entry from this cache and swap storage only if the entry
is not currently locked, and is not participating in a transaction.
|
void |
clearAll()
Clears all entries from this cache only if the entry is not
currently locked or participating in a transaction.
|
boolean |
compact(K key)
Clears serialized value bytes from entry (if any) leaving only object representation.
|
void |
compactAll()
Clears serialized value bytes from cache entries (if any) leaving only object representation.
|
boolean |
containsKey(K key)
Returns
true if this cache contains a mapping for the specified
key. |
boolean |
containsValue(V val)
Returns
true if this cache contains given value. |
Collection<GridDrStateTransferDescriptor> |
drListStateTransfers()
List currently active state transfers.
|
void |
drPause()
Pauses data center replication for this cache.
|
GridDrStatus |
drPauseState()
Get DR pause state.
|
void |
drResume()
Resumes data center replication for this cache.
|
GridFuture<?> |
drStateTransfer(Collection<Byte> dataCenterIds)
Starts full state transfer.
|
GridCacheEntry<K,V> |
entry(K key)
Gets entry from cache with the specified key.
|
Set<GridCacheEntry<K,V>> |
entrySet()
Gets set containing all cache entries.
|
Set<GridCacheEntry<K,V>> |
entrySet(int part)
Gets set containing cache entries that belong to provided partition or
null
if partition not found locally. |
Set<GridCacheEntry<K,V>> |
entrySetx(GridPredicate<GridCacheEntry<K,V>>... filter)
Gets entry set containing internal entries.
|
boolean |
evict(K key)
Evicts entry associated with given key from cache.
|
void |
evictAll()
Attempts to evict all cache entries.
|
void |
evictAll(Collection<? extends K> keys)
Attempts to evict all entries associated with keys.
|
Set<GridCacheFlag> |
flags()
Gets cache flags enabled on this projection.
|
GridCacheProjection<K,V> |
flagsOff(GridCacheFlag[] flags)
Gets cache projection base on this but with the specified flags turned off.
|
GridCacheProjection<K,V> |
flagsOn(GridCacheFlag[] flags)
Gets cache projection base on this one, but with the specified flags turned on.
|
boolean |
forAll(GridPredicate<GridCacheEntry<K,V>> vis)
Tests whether the predicate holds for all entries.
|
void |
forEach(GridInClosure<GridCacheEntry<K,V>> vis)
Executes visitor closure on each cache element.
|
GridCacheProjectionEx<K,V> |
forSubjectId(UUID subjId)
Creates projection for specified subject ID.
|
V |
get(K key)
Retrieves value mapped to the specified key from cache.
|
V |
get(K key,
GridCacheEntryEx<K,V> entry,
GridPredicate<GridCacheEntry<K,V>>... filter) |
Map<K,V> |
getAll(Collection<? extends K> keys)
Retrieves values mapped to the specified keys from cache.
|
GridFuture<Map<K,V>> |
getAllAsync(Collection<? extends K> keys)
Asynchronously retrieves values mapped to the specified keys from cache.
|
Map<K,V> |
getAllOutTx(List<K> keys)
Gets values from cache.
|
GridFuture<Map<K,V>> |
getAllOutTxAsync(List<K> keys)
Asynchronously gets values from cache.
|
GridFuture<V> |
getAsync(K key)
Asynchronously retrieves value mapped to the specified key from cache.
|
V |
getForcePrimary(K key)
Gets value from cache.
|
GridFuture<V> |
getForcePrimaryAsync(K key)
Asynchronously gets value from cache.
|
long |
ggfsDataSpaceMax()
Get maximum space available for GGFS.
|
long |
ggfsDataSpaceUsed()
Get current amount of used GGFS space in bytes.
|
void |
globalClearAll()
Clears cache on all nodes that store it's data.
|
GridProjection |
gridProjection()
Gets grid projection for this cache.
|
boolean |
isDrSystemCache()
Checks whether this cache is DR system cache.
|
boolean |
isEmpty()
Returns
true if this map contains no key-value mappings. |
boolean |
isGgfsDataCache()
Checks whether this cache is GGFS data cache.
|
boolean |
isLocked(K key)
Checks if any node owns a lock for this key.
|
boolean |
isLockedByThread(K key)
Checks if current thread owns a lock on this key.
|
boolean |
isMongoDataCache()
Checks whether this cache is Mongo data cache.
|
boolean |
isMongoMetaCache()
Checks whether this cache is Mongo meta cache.
|
Iterator<GridCacheEntry<K,V>> |
iterator() |
Set<K> |
keySet()
Set of cached keys.
|
boolean |
lock(K key,
long timeout,
GridPredicate<GridCacheEntry<K,V>>... filter)
Synchronously acquires lock on a cached object with given
key only if the passed in filter (if any) passes.
|
boolean |
lockAll(Collection<? extends K> keys,
long timeout,
GridPredicate<GridCacheEntry<K,V>>[] filter)
All or nothing synchronous lock for passed in keys.
|
GridFuture<Boolean> |
lockAllAsync(Collection<? extends K> keys,
long timeout,
GridPredicate<GridCacheEntry<K,V>>[] filter)
All or nothing synchronous lock for passed in keys.
|
GridFuture<Boolean> |
lockAsync(K key,
long timeout,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Asynchronously acquires lock on a cached object with given
key only if the passed in filter (if any) passes.
|
String |
name()
Gets name of this cache (
null for default cache). |
int |
nearSize()
Gets size of near cache key set.
|
V |
peek(K key)
Peeks at in-memory cached value using default
GridCachePeekMode.SMART
peek mode. |
V |
peek(K key,
Collection<GridCachePeekMode> modes)
Peeks at cached value using optional set of peek modes.
|
GridPredicate<GridCacheEntry<K,V>> |
predicate()
Gets predicate on which this projection is based on or
null
if predicate is not defined. |
Set<GridCacheEntry<K,V>> |
primaryEntrySet()
Gets set containing cache entries for which local node is the primary node.
|
Set<K> |
primaryKeySet()
Set of cached primary keys for which local node is the primary node.
|
int |
primarySize()
Gets size of all primary keys for this cache.
|
Collection<V> |
primaryValues()
Collection of primary cached values.for which local node is the primary node.
|
<K1,V1> GridCacheProjection<K1,V1> |
projection(Class<? super K1> keyType,
Class<? super V1> valType)
Gets cache projection only for given key and value type.
|
GridCacheProjection<K,V> |
projection(GridBiPredicate<K,V> p)
Gets cache projection based on given key-value predicate.
|
GridCacheProjection<K,V> |
projection(GridPredicate<GridCacheEntry<K,V>> filter)
Gets cache projection based on given entry filter.
|
V |
promote(K key)
This method promotes cache entry from offheap by given key, if any, from offheap or swap storage
into memory.
|
void |
promoteAll(Collection<? extends K> keys)
This method unswaps cache entries by given keys, if any, from swap storage
into memory.
|
V |
put(K key,
V val,
GridCacheEntryEx<K,V> entry,
long ttl,
GridPredicate<GridCacheEntry<K,V>>... filter)
Internal method that is called from
GridCacheEntryImpl. |
V |
put(K key,
V val,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Stores given key-value pair in cache.
|
void |
putAll(Map<? extends K,? extends V> m,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Stores given key-value pairs in cache.
|
GridFuture<?> |
putAllAsync(Map<? extends K,? extends V> m,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Asynchronously stores given key-value pairs in cache.
|
void |
putAllDr(Map<? extends K,GridCacheDrInfo<V>> drMap)
Store DR data.
|
GridFuture<?> |
putAllDrAsync(Map<? extends K,GridCacheDrInfo<V>> drMap)
Store DR data asynchronously.
|
GridFuture<V> |
putAsync(K key,
V val,
GridCacheEntryEx<K,V> entry,
long ttl,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Internal method that is called from
GridCacheEntryImpl. |
GridFuture<V> |
putAsync(K key,
V val,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Asynchronously stores given key-value pair in cache.
|
V |
putIfAbsent(K key,
V val)
Stores given key-value pair in cache only if cache had no previous mapping for it.
|
GridFuture<V> |
putIfAbsentAsync(K key,
V val)
Asynchronously stores given key-value pair in cache only if cache had no previous mapping for it.
|
boolean |
putx(K key,
V val,
GridCacheEntryEx<K,V> entry,
long ttl,
GridPredicate<GridCacheEntry<K,V>>... filter)
Internal method that is called from
GridCacheEntryImpl. |
boolean |
putx(K key,
V val,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Stores given key-value pair in cache.
|
GridFuture<Boolean> |
putxAsync(K key,
V val,
GridCacheEntryEx<K,V> entry,
long ttl,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Internal method that is called from
GridCacheEntryImpl. |
GridFuture<Boolean> |
putxAsync(K key,
V val,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Stores given key-value pair in cache.
|
boolean |
putxIfAbsent(K key,
V val)
Stores given key-value pair in cache only if cache had no previous mapping for it.
|
GridFuture<Boolean> |
putxIfAbsentAsync(K key,
V val)
Asynchronously stores given key-value pair in cache only if cache had no previous mapping for it.
|
GridCacheQueries<K,V> |
queries()
Returns queries facade responsible for creating various SQL, TEXT, or SCAN queries.
|
void |
readExternal(ObjectInput in) |
V |
reload(K key)
Reloads a single key from persistent storage.
|
void |
reloadAll()
Reloads all currently cached keys form persistent storage.
|
void |
reloadAll(Collection<? extends K> keys)
Reloads specified entries from underlying persistent storage.
|
GridFuture<?> |
reloadAllAsync()
Asynchronously reloads all specified entries from underlying
persistent storage.
|
GridFuture<?> |
reloadAllAsync(Collection<? extends K> keys)
Asynchronously reloads all specified entries from underlying
persistent storage.
|
GridFuture<V> |
reloadAsync(K key)
Asynchronously reloads a single key from persistent storage.
|
V |
remove(K key,
GridCacheEntryEx<K,V> entry,
GridPredicate<GridCacheEntry<K,V>>... filter)
Internal method that is called from
GridCacheEntryImpl. |
V |
remove(K key,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Removes given key mapping from cache.
|
boolean |
remove(K key,
V val)
Removes given key mapping from cache if one exists and value is equal to the passed in value.
|
void |
removeAll(Collection<? extends K> keys,
GridPredicate<GridCacheEntry<K,V>>... filter)
Removes given key mappings from cache for entries for which the optionally passed in filters do
pass.
|
void |
removeAll(GridPredicate<GridCacheEntry<K,V>>... filter)
Removes mappings from cache for entries for which the optionally passed in filters do
pass.
|
GridFuture<?> |
removeAllAsync(Collection<? extends K> keys,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Asynchronously removes given key mappings from cache for entries for which the optionally
passed in filters do pass.
|
GridFuture<?> |
removeAllAsync(GridPredicate<GridCacheEntry<K,V>>... filter)
Asynchronously removes mappings from cache for entries for which the optionally passed in filters do
pass.
|
void |
removeAllDr(Map<? extends K,GridCacheVersion> drMap)
Removes DR data.
|
GridFuture<?> |
removeAllDrAsync(Map<? extends K,GridCacheVersion> drMap)
Removes DR data asynchronously.
|
GridFuture<V> |
removeAsync(K key,
GridCacheEntryEx<K,V> entry,
GridPredicate<GridCacheEntry<K,V>>... filter)
Internal method that is called from
GridCacheEntryImpl. |
GridFuture<V> |
removeAsync(K key,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Asynchronously removes given key mapping from cache.
|
GridFuture<Boolean> |
removeAsync(K key,
V val)
Asynchronously removes given key mapping from cache if one exists and value is equal to the passed in value.
|
boolean |
removex(K key,
GridCacheEntryEx<K,V> entry,
GridPredicate<GridCacheEntry<K,V>>... filter)
Internal method that is called from
GridCacheEntryImpl. |
boolean |
removex(K key,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Removes given key mapping from cache.
|
GridCacheReturn<V> |
removex(K key,
V val)
Removes given key mapping from cache if one exists and value is equal to the passed in value.
|
GridFuture<Boolean> |
removexAsync(K key,
GridCacheEntryEx<K,V> entry,
GridPredicate<GridCacheEntry<K,V>>... filter)
Internal method that is called from
GridCacheEntryImpl. |
GridFuture<Boolean> |
removexAsync(K key,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Asynchronously removes given key mapping from cache.
|
GridFuture<GridCacheReturn<V>> |
removexAsync(K key,
V val)
Asynchronously removes given key mapping from cache if one exists and value is equal to the passed in value.
|
V |
replace(K key,
V val)
Stores given key-value pair in cache only if if there is a previous mapping for it.
|
boolean |
replace(K key,
V oldVal,
V newVal)
Stores given key-value pair in cache only if only if the previous value is equal to the
'oldVal' passed in. |
GridFuture<V> |
replaceAsync(K key,
V val)
Asynchronously stores given key-value pair in cache only if if there is a previous mapping for it.
|
GridFuture<Boolean> |
replaceAsync(K key,
V oldVal,
V newVal)
Asynchronously stores given key-value pair in cache only if only if the previous value is equal to the
'oldVal' passed in. |
boolean |
replacex(K key,
V val)
Stores given key-value pair in cache only if only if there is a previous mapping for it.
|
GridCacheReturn<V> |
replacex(K key,
V oldVal,
V newVal)
Stores given key-value pair in cache only if only if the previous value is equal to the
'oldVal' passed in. |
GridFuture<Boolean> |
replacexAsync(K key,
V val)
Asynchronously stores given key-value pair in cache only if only if there is a previous mapping for it.
|
GridFuture<GridCacheReturn<V>> |
replacexAsync(K key,
V oldVal,
V newVal)
Asynchronously stores given key-value pair in cache only if only if the previous value is equal to the
'oldVal' passed in. |
int |
size()
Gets size of cache key set.
|
UUID |
subjectId()
Gets client ID for which this projection was created.
|
ConcurrentMap<K,V> |
toMap()
Converts this API into standard Java
ConcurrentMap interface. |
String |
toString() |
void |
transform(K key,
GridClosure<V,V> transformer)
Stores result of applying
valTransform closure to the previous value associated with
given key in cache. |
void |
transformAll(Map<? extends K,? extends GridClosure<V,V>> m)
Stores result of applying transform closures from the given map to previous values associated
with corresponding keys in cache.
|
void |
transformAll(Set<? extends K> keys,
GridClosure<V,V> transformer)
Stores result of applying the specified transform closure to previous values associated
with the specified keys in cache.
|
GridFuture<?> |
transformAllAsync(Map<? extends K,? extends GridClosure<V,V>> m)
Stores result of applying transform closures from the given map to previous values associated
with corresponding keys in cache.
|
GridFuture<?> |
transformAllAsync(Set<? extends K> keys,
GridClosure<V,V> transformer)
Stores result of applying the specified transform closure to previous values associated
with the specified keys in cache.
|
<R> R |
transformAndCompute(K key,
GridClosure<V,GridBiTuple<V,R>> transformer)
Applies
transformer closure to the previous value associated with given key in cache,
closure should return GridBiTuple instance where first value is new value stored in cache
and second value is returned as result of this method. |
GridFuture<?> |
transformAsync(K key,
GridClosure<V,V> transformer)
Stores result of applying
transformer closure to the previous value associated with
given key in cache. |
GridFuture<?> |
transformAsync(K key,
GridClosure<V,V> transformer,
GridCacheEntryEx<K,V> entry,
long ttl)
Internal method that is called from
GridCacheEntryImpl. |
GridCacheTx |
tx()
Gets transaction started by this thread or
null if this thread does
not have a transaction. |
GridCacheTx |
txStart()
Starts transaction with default isolation, concurrency, timeout, and invalidation policy.
|
GridCacheTx |
txStart(GridCacheTxConcurrency concurrency,
GridCacheTxIsolation isolation)
Starts new transaction with the specified concurrency and isolation.
|
GridCacheTx |
txStart(GridCacheTxConcurrency concurrency,
GridCacheTxIsolation isolation,
long timeout,
int txSize)
Starts transaction with specified isolation, concurrency, timeout, invalidation flag,
and number of participating entries.
|
GridCacheTx |
txStartAffinity(Object affinityKey,
GridCacheTxConcurrency concurrency,
GridCacheTxIsolation isolation,
long timeout,
int txSize)
Starts
affinity-group-locked transaction based on affinity key. |
GridCacheTx |
txStartPartition(int partId,
GridCacheTxConcurrency concurrency,
GridCacheTxIsolation isolation,
long timeout,
int txSize)
Starts
partition-group-locked transaction based on partition ID. |
void |
unlock(K key,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Unlocks given key only if current thread owns the lock.
|
void |
unlockAll(Collection<? extends K> keys,
GridPredicate<GridCacheEntry<K,V>>[] filter)
Unlocks given keys only if current thread owns the locks.
|
Collection<V> |
values()
Collection of cached values.
|
void |
writeExternal(ObjectOutput out) |
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, clone, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, readExternalMeta, removeMeta, removeMeta, replaceMeta, writeExternalMetaequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, removeMeta, removeMeta, replaceMetapublic GridCacheProjectionImpl()
Externalizable.public GridCacheProjectionImpl(GridCacheProjection<K,V> parent, GridCacheContext<K,V> cctx, @Nullable GridBiPredicate<K,V> kvFilter, @Nullable GridPredicate<? super GridCacheEntry<K,V>> entryFilter, @Nullable Set<GridCacheFlag> flags, @Nullable UUID subjId)
parent - Parent projection.cctx - Cache context.kvFilter - Key-value filter.entryFilter - Entry filter.flags - Flags for new projectionpublic <K1,V1> GridCache<K1,V1> cache()
cache in interface GridCacheProjection<K,V>K1 - Cache key type.V1 - Cache value type.public GridCacheQueries<K,V> queries()
queries in interface GridCacheProjection<K,V>public GridCacheProjectionEx<K,V> forSubjectId(UUID subjId)
forSubjectId in interface GridCacheProjectionEx<K,V>subjId - Client ID.@Nullable public UUID subjectId()
public <K1,V1> GridCacheProjection<K1,V1> projection(Class<? super K1> keyType, Class<? super V1> valType)
non-null key-value
pairs that have matching key and value pairs will be used in this projection.projection in interface GridCacheProjection<K,V>K1 - Key type.V1 - Value type.keyType - Key type.valType - Value type.public GridCacheProjection<K,V> projection(GridBiPredicate<K,V> p)
For example, for GridCacheProjection.putAll(Map, GridPredicate[]) method only
elements that pass the filter will be given to GridCache.putAll(m, filter)
where it will be checked once again prior to put.
projection in interface GridCacheProjection<K,V>p - Key-value predicate for this projection. If null, then the
same projection is returned.public GridCacheProjection<K,V> projection(GridPredicate<GridCacheEntry<K,V>> filter)
GridCacheProjection.projection(GridBiPredicate)
method, this filter will not be used for pre-filtering.projection in interface GridCacheProjection<K,V>filter - Filter to be passed through to all cache operations. If null, then the
same projection is returned. If cache operation receives its own filter, then filters
will be 'anded'.public GridCacheProjection<K,V> flagsOn(@Nullable GridCacheFlag[] flags)
flagsOn in interface GridCacheProjection<K,V>flags - Flags to turn on (if empty, then no-op).public GridCacheProjection<K,V> flagsOff(@Nullable GridCacheFlag[] flags)
flagsOff in interface GridCacheProjection<K,V>flags - Flags to turn off (if empty, then all flags will be turned off).public int size()
GridCache projection. It is essentially the
size of cache key set and is semantically identical to {GridCache.keySet().size().size in interface GridCacheProjection<K,V>public int nearSize()
null values and has O(1) complexity on base cache projection.
Note that for LOCAL caches this method will always return 0
nearSize in interface GridCacheProjection<K,V>0 if cache is not GridCacheMode.PARTITIONED.public int primarySize()
GridCacheMode.LOCAL mode,
this method is identical to GridCacheProjection.size().
For GridCacheMode.PARTITIONED and GridCacheMode.REPLICATED modes, this method will
return number of primary entries in the cache (excluding any backups). The complexity of this method
is O(P), where P is the total number of partitions.
primarySize in interface GridCacheProjection<K,V>public boolean isEmpty()
true if this map contains no key-value mappings.isEmpty in interface GridCacheProjection<K,V>true if this map contains no key-value mappings.public boolean containsKey(K key)
true if this cache contains a mapping for the specified
key.containsKey in interface GridCacheProjection<K,V>key - key whose presence in this map is to be tested.true if this map contains a mapping for the specified key.public boolean containsValue(V val)
true if this cache contains given value.containsValue in interface GridCacheProjection<K,V>val - Value to check.True if given value is present in cache.public void forEach(GridInClosure<GridCacheEntry<K,V>> vis)
forEach in interface GridCacheProjection<K,V>vis - Closure which will be invoked for each cache entry.public boolean forAll(GridPredicate<GridCacheEntry<K,V>> vis)
true is returned.
forAll in interface GridCacheProjection<K,V>vis - Predicate to test for each cache entry.True if the given predicate holds for all visited entries, false otherwise.public V reload(K key) throws GridException
GridCacheStore.load(GridCacheTx, Object)
method.
reload in interface GridCacheProjection<K,V>key - Key to reload.GridException - If reloading failed.public GridFuture<V> reloadAsync(K key)
GridCacheStore.load(GridCacheTx, Object)
method.
reloadAsync in interface GridCacheProjection<K,V>key - Key to reload.public void reloadAll()
throws GridException
reloadAll in interface GridCacheProjection<K,V>GridException - If reloading failed.public GridFuture<?> reloadAllAsync()
reloadAllAsync in interface GridCacheProjection<K,V>reload completes.public void reloadAll(@Nullable Collection<? extends K> keys) throws GridException
reloadAll in interface GridCacheProjection<K,V>keys - Keys to reload.GridException - if reloading failed.public GridFuture<?> reloadAllAsync(@Nullable Collection<? extends K> keys)
reloadAllAsync in interface GridCacheProjection<K,V>keys - Keys to reload.reload completes.public V get(K key) throws GridException
null
means entry did not pass the provided filter or cache has no mapping for the
key.
If the value is not present in cache, then it will be looked up from swap storage. If
it's not present in swap, or if swap is disable, and if read-through is allowed, value
will be loaded from GridCacheStore persistent storage via
GridCacheStore.load(GridCacheTx, Object) method.
GridCacheFlag.LOCAL flag is set on projection.get in interface GridCacheProjection<K,V>key - Key to retrieve the value for.GridException - If get operation failed.public V get(K key, @Nullable GridCacheEntryEx<K,V> entry, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
get in interface GridCacheProjectionEx<K,V>key - Key to retrieve the value for.entry - Cached entry when called from entry wrapper.filter - Filter to check prior to getting the value. Note that filter check
together with getting the value is an atomic operation.GridException - If failed.public GridFuture<V> getAsync(K key)
null
means entry did not pass the provided filter or cache has no mapping for the
key.
If the value is not present in cache, then it will be looked up from swap storage. If
it's not present in swap, or if swap is disabled, and if read-through is allowed, value
will be loaded from GridCacheStore persistent storage via
GridCacheStore.load(GridCacheTx, Object) method.
GridCacheFlag.LOCAL flag is set on projection.getAsync in interface GridCacheProjection<K,V>key - Key for the value to get.public V getForcePrimary(K key) throws GridException
getForcePrimary in interface GridCacheProjectionEx<K,V>key - Key to get value for.GridException - If failed.public GridFuture<V> getForcePrimaryAsync(K key)
getForcePrimaryAsync in interface GridCacheProjectionEx<K,V>key - Key to get value for.@Nullable public Map<K,V> getAllOutTx(List<K> keys) throws GridException
getAllOutTx in interface GridCacheProjectionEx<K,V>keys - Keys to get values for.GridException - If failed.public GridFuture<Map<K,V>> getAllOutTxAsync(List<K> keys)
getAllOutTxAsync in interface GridCacheProjectionEx<K,V>keys - Keys to get values for.public boolean isGgfsDataCache()
isGgfsDataCache in interface GridCacheProjectionEx<K,V>True in case this cache is GGFS data cache.public long ggfsDataSpaceUsed()
ggfsDataSpaceUsed in interface GridCacheProjectionEx<K,V>public long ggfsDataSpaceMax()
ggfsDataSpaceMax in interface GridCacheProjectionEx<K,V>public boolean isMongoDataCache()
isMongoDataCache in interface GridCacheProjectionEx<K,V>True if this cache is mongo data cache.public boolean isMongoMetaCache()
isMongoMetaCache in interface GridCacheProjectionEx<K,V>True if this cache is mongo meta cache.public boolean isDrSystemCache()
isDrSystemCache in interface GridCacheProjectionEx<K,V>True if this cache is DR system cache.public Map<K,V> getAll(@Nullable Collection<? extends K> keys) throws GridException
If some value is not present in cache, then it will be looked up from swap storage. If
it's not present in swap, or if swap is disabled, and if read-through is allowed, value
will be loaded from GridCacheStore persistent storage via
GridCacheStore.loadAll(GridCacheTx, Collection, GridBiInClosure) method.
GridCacheFlag.LOCAL flag is set on projection.getAll in interface GridCacheProjection<K,V>keys - Keys to get.GridException - If get operation failed.public GridFuture<Map<K,V>> getAllAsync(@Nullable Collection<? extends K> keys)
If some value is not present in cache, then it will be looked up from swap storage. If
it's not present in swap, or if swap is disabled, and if read-through is allowed, value
will be loaded from GridCacheStore persistent storage via
GridCacheStore.loadAll(GridCacheTx, Collection, GridBiInClosure) method.
GridCacheFlag.LOCAL flag is set on projection.getAllAsync in interface GridCacheProjection<K,V>keys - Key for the value to get.public V put(K key, V val, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter) throws GridException
GridCacheMode.PARTITIONED or GridCacheMode.REPLICATED caches,
the value will be loaded from the primary node, which in its turn may load the value
from the swap storage, and consecutively, if it's not in swap,
from the underlying persistent storage. If value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method GridCacheProjection.putx(Object, Object, GridPredicate[]) should
always be used instead of this one to avoid the overhead associated with returning of the previous value.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.put in interface GridCacheProjection<K,V>key - Key to store in cache.val - Value to be associated with the given key.filter - Optional filter to check prior to putting value in cache. Note
that filter check is atomic with put operation.null
if entry did not pass the filter, or if there was no mapping for the key in swap
or in persistent storage.GridException - If put operation failed.public V put(K key, V val, @Nullable GridCacheEntryEx<K,V> entry, long ttl, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
GridCacheEntryImpl.put in interface GridCacheProjectionEx<K,V>key - Key.val - Value.entry - Cached entry. If not provided, equivalent to {GridCacheProjection#put}.ttl - Optional time-to-live. If negative, leaves ttl value unchanged.filter - Optional filter.GridException - If failed.public GridFuture<V> putAsync(K key, V val, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter)
GridCacheMode.REPLICATED caches, the value will be loaded from swap
and, if it's not there, and read-through is allowed, from the underlying
GridCacheStore storage. In case of GridCacheMode.PARTITIONED caches,
the value will be loaded from the primary node, which in its turn may load the value
from the swap storage, and consecutively, if it's not in swap and read-through is allowed,
from the underlying persistent storage. If value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method GridCacheProjection.putx(Object, Object, GridPredicate[]) should
always be used instead of this one to avoid the overhead associated with returning of the previous value.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.putAsync in interface GridCacheProjection<K,V>key - Key to store in cache.val - Value to be associated with the given key.filter - Optional filter to check prior to putting value in cache. Note
that filter check is atomic with put operation.public GridFuture<V> putAsync(K key, V val, @Nullable GridCacheEntryEx<K,V> entry, long ttl, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter)
GridCacheEntryImpl.putAsync in interface GridCacheProjectionEx<K,V>key - Key.val - Value.entry - Optional cached entry.ttl - Optional time-to-live value. If negative, leaves ttl value unchanged.filter - Optional filter.public boolean putx(K key, V val, @Nullable GridCacheEntryEx<K,V> entry, long ttl, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
GridCacheEntryImpl.putx in interface GridCacheProjectionEx<K,V>key - Key.val - Value.entry - Cached entry. If not provided, equivalent to {GridCacheProjection#put}.ttl - Optional time-to-live. If negative, leaves ttl value unchanged.filter - Optional filter.GridException - If failed.public boolean putx(K key, V val, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter) throws GridException
This method will return true if value is stored in cache and false otherwise.
Unlike GridCacheProjection.put(Object, Object, GridPredicate[]) method, it does not return previous
value and, therefore, does not have any overhead associated with returning a value. It
should be used whenever return value is not required.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.putx in interface GridCacheProjection<K,V>key - Key to store in cache.val - Value to be associated with the given key.filter - Optional filter to check prior to putting value in cache. Note
that filter check is atomic with put operation.True if optional filter passed and value was stored in cache,
false otherwise. Note that this method will return true if filter is not
specified.GridException - If put operation failed.public void putAllDr(Map<? extends K,GridCacheDrInfo<V>> drMap) throws GridException
putAllDr in interface GridCacheProjectionEx<K,V>drMap - DR map.GridException - If put operation failed.public GridFuture<?> putAllDrAsync(Map<? extends K,GridCacheDrInfo<V>> drMap) throws GridException
putAllDrAsync in interface GridCacheProjectionEx<K,V>drMap - DR map.GridException - If put operation failed.public void transform(K key, GridClosure<V,V> transformer) throws GridException
valTransform closure to the previous value associated with
given key in cache. Result of closure application is guaranteed to be atomic, however, closure
itself can be applied more than once.
Note that transform closure must not throw any exceptions. If exception is thrown from apply
method, the transaction will be invalidated and entries participating in transaction will be nullified.
Unlike GridCacheProjection.putx(Object, Object, GridPredicate[]) or GridCacheProjection.put(Object, Object, GridPredicate[])
methods, this method will not transfer the whole updated value over the network, but instead will
transfer the transforming closure that will be applied on each remote node involved in transaction.
It may add significant performance gain when dealing with large values as the value is much larger
than the closure itself. If write-through is enabled, the stored value will be persisted to
GridCacheStore via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.transform in interface GridCacheProjection<K,V>key - Key to store in cache.transformer - Closure to be applied to the previous value in cache. If this closure returns
null, the associated value will be removed from cache.GridException - On any error occurred while storing value in cache.public <R> R transformAndCompute(K key, GridClosure<V,GridBiTuple<V,R>> transformer) throws GridException
transformer closure to the previous value associated with given key in cache,
closure should return GridBiTuple instance where first value is new value stored in cache
and second value is returned as result of this method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.transformAndCompute in interface GridCacheProjection<K,V>key - Key to store in cache.transformer - Closure to be applied to the previous value in cache.GridException - On any error occurred while storing value in cache.public GridFuture<Boolean> putxAsync(K key, V val, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter)
This method will return true if value is stored in cache and false otherwise.
Unlike GridCacheProjection.put(Object, Object, GridPredicate[]) method, it does not return previous
value and, therefore, does not have any overhead associated with returning of a value. It
should always be used whenever return value is not required.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.putxAsync in interface GridCacheProjection<K,V>key - Key to store in cache.val - Value to be associated with the given key.filter - Optional filter to check prior to putting value in cache. Note
that filter check is atomic with put operation.true if optional filter
passed and value was stored in cache, false otherwise. Note that future will
return true if filter is not specified.public GridFuture<Boolean> putxAsync(K key, V val, @Nullable GridCacheEntryEx<K,V> entry, long ttl, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter)
GridCacheEntryImpl.putxAsync in interface GridCacheProjectionEx<K,V>key - Key.val - Value.entry - Cached entry. If not provided, equivalent to {GridCacheProjection#put}.ttl - Optional time-to-live. If negative, leave ttl value unchanged.filter - Optional filter.public GridFuture<?> transformAsync(K key, GridClosure<V,V> transformer)
transformer closure to the previous value associated with
given key in cache. Result of closure application is guaranteed to be atomic, however, closure
itself can be applied more than once.
Note that transform closure must not throw any exceptions. If exception is thrown from apply
method, the transaction will be invalidated and entries participating in transaction will be nullified.
Unlike GridCacheProjection.putx(Object, Object, GridPredicate[]) method, this method will not transfer
the whole updated value over the network, but instead will transfer the transforming closure
that will be applied on each remote node involved in transaction. It may add significant performance
gain when dealing with large values as the value is much larger than the closure itself.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.transformAsync in interface GridCacheProjection<K,V>key - Key to store in cache.transformer - Closure to be applied to the previous value in cache. If this closure returns
null, the associated value will be removed from cache.public V putIfAbsent(K key, V val) throws GridException
GridCacheMode.PARTITIONED or GridCacheMode.REPLICATED caches,
the value will be loaded from the primary node, which in its turn may load the value
from the swap storage, and consecutively, if it's not in swap,
from the underlying persistent storage. If value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method GridCacheProjection.putxIfAbsent(Object, Object) should
always be used instead of this one to avoid the overhead associated with returning of the
previous value.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.putIfAbsent in interface GridCacheProjection<K,V>key - Key to store in cache.val - Value to be associated with the given key.GridException - If put operation failed.public GridFuture<V> putIfAbsentAsync(K key, V val)
GridCacheMode.PARTITIONED or GridCacheMode.REPLICATED caches,
the value will be loaded from the primary node, which in its turn may load the value
from the swap storage, and consecutively, if it's not in swap,
from the underlying persistent storage. If value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method GridCacheProjection.putxIfAbsentAsync(Object, Object) should
always be used instead of this one to avoid the overhead associated with returning of the
previous value.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.putIfAbsentAsync in interface GridCacheProjection<K,V>key - Key to store in cache.val - Value to be associated with the given key.public boolean putxIfAbsent(K key, V val) throws GridException
This method will return true if value is stored in cache and false otherwise.
Unlike GridCacheProjection.putIfAbsent(Object, Object) method, it does not return previous
value and, therefore, does not have any overhead associated with returning of a value. It
should always be used whenever return value is not required.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.putxIfAbsent in interface GridCacheProjection<K,V>key - Key to store in cache.val - Value to be associated with the given key.true if value is stored in cache and false otherwise.GridException - If put operation failed.public GridFuture<Boolean> putxIfAbsentAsync(K key, V val)
This method will return true if value is stored in cache and false otherwise.
Unlike GridCacheProjection.putIfAbsent(Object, Object) method, it does not return previous
value and, therefore, does not have any overhead associated with returning of a value. It
should always be used whenever return value is not required.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.putxIfAbsentAsync in interface GridCacheProjection<K,V>key - Key to store in cache.val - Value to be associated with the given key.public GridFuture<?> transformAsync(K key, GridClosure<V,V> transformer, @Nullable GridCacheEntryEx<K,V> entry, long ttl)
GridCacheEntryImpl.transformAsync in interface GridCacheProjectionEx<K,V>key - Key.transformer - Transformer closure.entry - Cached entry.ttl - Optional time-to-lve.public V replace(K key, V val) throws GridException
GridCacheMode.PARTITIONED or GridCacheMode.REPLICATED caches,
the value will be loaded from the primary node, which in its turn may load the value
from the swap storage, and consecutively, if it's not in swap,
from the underlying persistent storage. If value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method GridCacheProjection.replacex(Object, Object) should
always be used instead of this one to avoid the overhead associated with returning of the
previous value.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.replace in interface GridCacheProjection<K,V>key - Key to store in cache.val - Value to be associated with the given key.GridException - If replace operation failed.public GridFuture<V> replaceAsync(K key, V val)
GridCacheMode.PARTITIONED caches, the value will be loaded from the primary node,
which in its turn may load the value from the swap storage, and consecutively, if it's not in swap,
from the underlying persistent storage. If value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method GridCacheProjection.replacex(Object, Object) should
always be used instead of this one to avoid the overhead associated with returning of the
previous value.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.replaceAsync in interface GridCacheProjection<K,V>key - Key to store in cache.val - Value to be associated with the given key.public boolean replacex(K key, V val) throws GridException
This method will return true if value is stored in cache and false otherwise.
Unlike GridCacheProjection.replace(Object, Object) method, it does not return previous
value and, therefore, does not have any overhead associated with returning of a value. It
should always be used whenever return value is not required.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.replacex in interface GridCacheProjection<K,V>key - Key to store in cache.val - Value to be associated with the given key.True if replace happened, false otherwise.GridException - If replace operation failed.public GridFuture<Boolean> replacexAsync(K key, V val)
This method will return true if value is stored in cache and false otherwise.
Unlike GridCacheProjection.replaceAsync(Object, Object) method, it does not return previous
value and, therefore, does not have any overhead associated with returning of a value. It
should always be used whenever return value is not required.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.replacexAsync in interface GridCacheProjection<K,V>key - Key to store in cache.val - Value to be associated with the given key.public boolean replace(K key, V oldVal, V newVal) throws GridException
'oldVal' passed in.
This method will return true if value is stored in cache and false otherwise.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.replace in interface GridCacheProjection<K,V>key - Key to store in cache.oldVal - Old value to match.newVal - Value to be associated with the given key.True if replace happened, false otherwise.GridException - If replace operation failed.public GridFuture<Boolean> replaceAsync(K key, V oldVal, V newVal)
'oldVal' passed in.
This method will return true if value is stored in cache and false otherwise.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.replaceAsync in interface GridCacheProjection<K,V>key - Key to store in cache.oldVal - Old value to match.newVal - Value to be associated with the given key.public void putAll(Map<? extends K,? extends V> m, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter) throws GridException
If write-through is enabled, the stored values will be persisted to GridCacheStore
via GridCacheStore.putAll(GridCacheTx, Map) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.putAll in interface GridCacheProjection<K,V>m - Key-value pairs to store in cache.filter - Optional entry filter. If provided, then entry will
be stored only if the filter returned true.GridException - If put operation failed.public void transformAll(@Nullable Map<? extends K,? extends GridClosure<V,V>> m) throws GridException
Note that transform closure must not throw any exceptions. If exception is thrown from apply
method, the transaction will be invalidated and entries participating in transaction will be nullified.
Unlike GridCacheProjection.putAll(Map, GridPredicate[]) method, this method will not transfer
the whole updated value over the network, but instead will transfer the transforming closures
that will be applied on each remote node involved in transaction. It may add significant
performance gain when dealing with large values as the value is much larger than the closure itself.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.transformAll in interface GridCacheProjection<K,V>m - Map containing keys and closures to be applied to values.GridException - On any error occurred while storing value in cache.public void transformAll(@Nullable Set<? extends K> keys, GridClosure<V,V> transformer) throws GridException
Note that transform closure must not throw any exceptions. If exception is thrown from apply
method, the transaction will be invalidated and entries participating in transaction will be nullified.
Unlike GridCacheProjection.putAll(Map, GridPredicate[]) method, this method will not transfer
the whole updated value over the network, but instead will transfer the transforming closure
that will be applied on each remote node involved in transaction. It may add significant
performance gain when dealing with large values as the value is much larger than the closure itself.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.transformAll in interface GridCacheProjection<K,V>keys - Keys for entries, to which the transformation closure will be applied.
If the collection is null or empty, this method is no-op.transformer - Transformation closure to be applied to each value.GridException - On any error occurred while storing value in cache.public GridFuture<?> putAllAsync(Map<? extends K,? extends V> m, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter)
If write-through is enabled, the stored values will be persisted to GridCacheStore
via GridCacheStore.putAll(GridCacheTx, Map) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.putAllAsync in interface GridCacheProjection<K,V>m - Key-value pairs to store in cache.filter - Optional entry filter. If provided, then entry will
be stored only if the filter returned true.public GridFuture<?> transformAllAsync(@Nullable Map<? extends K,? extends GridClosure<V,V>> m)
Note that transform closure must not throw any exceptions. If exception is thrown from apply
method, the transaction will be invalidated and entries participating in transaction will be nullified.
Unlike GridCacheProjection.putAll(Map, GridPredicate[]) method, this method will not transfer
the whole updated value over the network, but instead will transfer the transforming closures
that will be applied on each remote node involved in transaction. It may add significant performance
gain when dealing with large values as the value is much larger than the closure itself.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.transformAllAsync in interface GridCacheProjection<K,V>m - Map containing keys and closures to be applied to values.public GridFuture<?> transformAllAsync(@Nullable Set<? extends K> keys, GridClosure<V,V> transformer) throws GridException
Note that transform closure must not throw any exceptions. If exception is thrown from apply
method, the transaction will be invalidated and entries participating in transaction will be nullified.
Unlike GridCacheProjection.putAll(Map, GridPredicate[]) method, this method will not transfer
the whole updated value over the network, but instead will transfer the transforming closure
that will be applied on each remote node involved in transaction. It may add significant
performance gain when dealing with large values as the value is much larger than the closure itself.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.transformAllAsync in interface GridCacheProjection<K,V>keys - Keys for entries, to which the transformation closure will be applied.
If the collection is null or empty, this method is no-op.transformer - Transformation closure to be applied to each value.GridException - On any error occurred while storing value in cache.public Set<K> keySet()
Iterator over this set will not fail if set was concurrently updated by another thread. This means that iterator may or may not return latest keys depending on whether they were added before or after current iterator position.
keySet in interface GridCacheProjection<K,V>public Set<K> primaryKeySet()
null because they were invalidated. You can remove elements from
this set, but you cannot add elements to this set. All removal operation will be
reflected on the cache itself.
Iterator over this set will not fail if set was concurrently updated by another thread. This means that iterator may or may not return latest keys depending on whether they were added before or after current iterator position.
primaryKeySet in interface GridCacheProjection<K,V>public Collection<V> values()
null because they were invalided. You can remove
elements from this collection, but you cannot add elements to this collection.
All removal operation will be reflected on the cache itself.
If filter is provided, then only the values for the entries that pass provided filters are returned.
Iterator over this collection will not fail if collection was concurrently updated by another thread. This means that iterator may or may not return latest values depending on whether they were added before or after current iterator position.
values in interface GridCacheProjection<K,V>public Collection<V> primaryValues()
null
because they were invalided. You can remove elements from this collection,
but you cannot add elements to this collection. All removal operation will be
reflected on the cache itself.
If filter is provided, then only the values for the entries that pass provided filters are returned.
Iterator over this collection will not fail if collection was concurrently updated by another thread. This means that iterator may or may not return latest values depending on whether they were added before or after current iterator position.
primaryValues in interface GridCacheProjection<K,V>public Set<GridCacheEntry<K,V>> entrySet()
If optional filters are provided, then only entries that successfully pass the filters will be included in the resulting set.
entrySet in interface GridCacheProjection<K,V>public Set<GridCacheEntry<K,V>> entrySetx(GridPredicate<GridCacheEntry<K,V>>... filter)
entrySetx in interface GridCacheProjectionEx<K,V>filter - Filter.public Set<GridCacheEntry<K,V>> entrySet(int part)
null
if partition not found locally.entrySet in interface GridCacheProjection<K,V>part - Partition.null if partition
not found locally.public Set<GridCacheEntry<K,V>> primaryEntrySet()
If optional filters are provided, then only entries that successfully pass the filters will be included in the resulting set.
primaryEntrySet in interface GridCacheProjection<K,V>public Set<GridCacheFlag> flags()
flags in interface GridCacheProjection<K,V>public GridPredicate<GridCacheEntry<K,V>> predicate()
null
if predicate is not defined.predicate in interface GridCacheProjectionEx<K,V>public String name()
null for default cache).name in interface GridCacheProjection<K,V>public GridProjection gridProjection()
gridProjection in interface GridCacheProjection<K,V>public V peek(K key)
GridCachePeekMode.SMART
peek mode.
This method will not load value from any persistent store or from a remote node.
GridCachePeekMode.SMART mode
semantics. If you need to look at global cached value even from within transaction,
you can use GridCacheProjection.peek(Object, Collection) method.peek in interface GridCacheProjection<K,V>key - Entry key.public V peek(K key, @Nullable Collection<GridCachePeekMode> modes) throws GridException
non-null value is found, it will be immediately returned.
Note that if modes are not provided this method works exactly the same way as
GridCacheProjection.peek(Object), implicitly using GridCachePeekMode.SMART mode.
peek in interface GridCacheProjection<K,V>key - Entry key.modes - Optional set of peek modes.GridException - If peek operation failed.@Nullable public GridCacheEntry<K,V> entry(K key)
Note that this method can return null if projection is configured as
pre-filtered and entry key and value don't pass key-value filter of the projection.
entry in interface GridCacheProjection<K,V>key - Entry key.null if projection pre-filtering was not passed.public boolean evict(K key)
If GridCacheConfiguration.isSwapEnabled() is set to true and
GridCacheFlag.SKIP_SWAP is not enabled, the evicted entry will
be swapped to offheap, and then to disk.
GridCacheFlag.READ.evict in interface GridCacheProjection<K,V>key - Key to evict from cache.True if entry could be evicted, false otherwise.public void evictAll(@Nullable Collection<? extends K> keys)
If GridCacheConfiguration.isSwapEnabled() is set to true and
GridCacheFlag.SKIP_SWAP is not enabled, the evicted entry will
be swapped to offheap, and then to disk.
GridCacheFlag.READ.evictAll in interface GridCacheProjection<K,V>keys - Keys to evict.public void evictAll()
If GridCacheConfiguration.isSwapEnabled() is set to true and
GridCacheFlag.SKIP_SWAP is not enabled, the evicted entry will
be swapped to offheap, and then to disk.
GridCacheFlag.READ.evictAll in interface GridCacheProjection<K,V>public void clearAll()
If GridCacheConfiguration.isSwapEnabled() is set to true and
GridCacheFlag.SKIP_SWAP is not enabled, the evicted entries will
also be cleared from swap.
Note that this operation is local as it merely clears entries from local cache. It does not remove entries from remote caches or from underlying persistent storage.
GridCacheFlag.READ.clearAll in interface GridCacheProjection<K,V>public void globalClearAll()
throws GridException
GridCacheProjection.clearAll() method which only
clears local node's cache.
GridGain will make the best attempt to clear caches on all nodes. If some caches could not be cleared, then exception will be thrown.
globalClearAll in interface GridCacheProjection<K,V>GridException - In case of cache could not be cleared on any of the nodes.public boolean clear(K key)
If GridCacheConfiguration.isSwapEnabled() is set to true and
GridCacheFlag.SKIP_SWAP is not enabled, the evicted entries will
also be cleared from swap.
Note that this operation is local as it merely clears an entry from local cache. It does not remove entries from remote caches or from underlying persistent storage.
GridCacheFlag.READ.clear in interface GridCacheProjection<K,V>key - Key to clear.True if entry was successfully cleared from cache, false
if entry was in use at the time of this method invocation and could not be
cleared.public boolean compact(K key) throws GridException
compact in interface GridCacheProjection<K,V>key - Key to compact.true if entry was deleted from cache (i.e. was expired).GridException - If failed to compact.public void compactAll()
throws GridException
compactAll in interface GridCacheProjection<K,V>GridException - If failed to compact.public V remove(K key, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter) throws GridException
GridCacheMode.PARTITIONED or GridCacheMode.REPLICATED
caches, the value will be loaded from the primary node, which in its turn may load the value
from the disk-based swap storage, and consecutively, if it's not in swap,
from the underlying persistent storage. If value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method GridCacheProjection.removex(Object, GridPredicate[]) should
always be used instead of this one to avoid the overhead associated with returning of the
previous value.
If write-through is enabled, the value will be removed from GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.remove in interface GridCacheProjection<K,V>key - Key whose mapping is to be removed from cache.filter - Optional filter to check prior to removing value form cache. Note
that filter is checked atomically together with remove operation.null
if there was no value for this key.GridException - If remove operation failed.public V remove(K key, @Nullable GridCacheEntryEx<K,V> entry, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
GridCacheEntryImpl.remove in interface GridCacheProjectionEx<K,V>key - Key to remove.entry - Cached entry. If not provided, equivalent to {GridCacheProjection#put}.filter - Optional filter.GridException - If failed.public GridFuture<V> removeAsync(K key, GridPredicate<GridCacheEntry<K,V>>[] filter)
GridCacheMode.PARTITIONED or GridCacheMode.REPLICATED
caches, the value will be loaded from the primary node, which in its turn may load the value
from the swap storage, and consecutively, if it's not in swap,
from the underlying persistent storage. If value has to be loaded from persistent
storage, GridCacheStore.load(GridCacheTx, Object) method will be used.
If the returned value is not needed, method GridCacheProjection.removex(Object, GridPredicate[]) should
always be used instead of this one to avoid the overhead associated with returning of the
previous value.
If write-through is enabled, the value will be removed from GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.removeAsync in interface GridCacheProjection<K,V>key - Key whose mapping is to be removed from cache.filter - Optional filter to check prior to removing value form cache. Note
that filter is checked atomically together with remove operation.public GridFuture<V> removeAsync(K key, @Nullable GridCacheEntryEx<K,V> entry, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter)
GridCacheEntryImpl.removeAsync in interface GridCacheProjectionEx<K,V>key - Key to remove.entry - Optional cached entry.filter - Optional filter.public boolean removex(K key, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter) throws GridException
This method will return true if remove did occur, which means that all optionally
provided filters have passed and there was something to remove, false otherwise.
If write-through is enabled, the value will be removed from GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.removex in interface GridCacheProjection<K,V>key - Key whose mapping is to be removed from cache.filter - Optional filter to check prior to removing value form cache. Note
that filter is checked atomically together with remove operation.True if filter passed validation and entry was removed, false otherwise.
Note that if filter is not specified, this method will return true.GridException - If remove failed.public void removeAllDr(Map<? extends K,GridCacheVersion> drMap) throws GridException
removeAllDr in interface GridCacheProjectionEx<K,V>drMap - DR map.GridException - If remove failed.public GridFuture<?> removeAllDrAsync(Map<? extends K,GridCacheVersion> drMap) throws GridException
removeAllDrAsync in interface GridCacheProjectionEx<K,V>drMap - DR map.GridException - If remove failed.public boolean removex(K key, @Nullable GridCacheEntryEx<K,V> entry, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
GridCacheEntryImpl.removex in interface GridCacheProjectionEx<K,V>key - Key to remove.entry - Cached entry. If not provided, equivalent to {GridCacheProjection#put}.filter - Optional filter.GridException - If failed.public GridFuture<Boolean> removexAsync(K key, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter)
This method will return true if remove did occur, which means that all optionally
provided filters have passed and there was something to remove, false otherwise.
If write-through is enabled, the value will be removed from GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.removexAsync in interface GridCacheProjection<K,V>key - Key whose mapping is to be removed from cache.filter - Optional filter to check prior to removing value form cache. Note
that filter is checked atomically together with remove operation.true
if optional filters passed validation and remove did occur, false otherwise.
Note that if filter is not specified, this method will return true.public GridFuture<Boolean> removexAsync(K key, @Nullable GridCacheEntryEx<K,V> entry, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter)
GridCacheEntryImpl.removexAsync in interface GridCacheProjectionEx<K,V>key - Key to remove.entry - Cached entry. If not provided, equivalent to {GridCacheProjection#put}.filter - Optional filter.public GridFuture<GridCacheReturn<V>> replacexAsync(K key, V oldVal, V newVal)
'oldVal' passed in.
This method will return true if value is stored in cache and false otherwise.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.replacexAsync in interface GridCacheProjectionEx<K,V>key - Key to store in cache.oldVal - Old value to match.newVal - Value to be associated with the given key.public GridCacheReturn<V> replacex(K key, V oldVal, V newVal) throws GridException
'oldVal' passed in.
This method will return true if value is stored in cache and false otherwise.
If write-through is enabled, the stored value will be persisted to GridCacheStore
via GridCacheStore.put(GridCacheTx, Object, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.replacex in interface GridCacheProjectionEx<K,V>key - Key to store in cache.oldVal - Old value to match.newVal - Value to be associated with the given key.GridException - If replace operation failed.public GridCacheReturn<V> removex(K key, V val) throws GridException
If write-through is enabled, the value will be removed from GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.removex in interface GridCacheProjectionEx<K,V>key - Key whose mapping is to be removed from cache.val - Value to match against currently cached value.GridException - If remove failed.public GridFuture<GridCacheReturn<V>> removexAsync(K key, V val)
This method will return true if remove did occur, which means that all optionally
provided filters have passed and there was something to remove, false otherwise.
If write-through is enabled, the value will be removed from GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.removexAsync in interface GridCacheProjectionEx<K,V>key - Key whose mapping is to be removed from cache.val - Value to match against currently cached value.public boolean remove(K key, V val) throws GridException
If write-through is enabled, the value will be removed from GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.remove in interface GridCacheProjection<K,V>key - Key whose mapping is to be removed from cache.val - Value to match against currently cached value.True if entry was removed and passed in value matched the cached one,
false otherwise.GridException - If remove failed.public GridFuture<Boolean> removeAsync(K key, V val)
This method will return true if remove did occur, which means that all optionally
provided filters have passed and there was something to remove, false otherwise.
If write-through is enabled, the value will be removed from GridCacheStore
via GridCacheStore.remove(GridCacheTx, Object) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.removeAsync in interface GridCacheProjection<K,V>key - Key whose mapping is to be removed from cache.val - Value to match against currently cached value.true
if currently cached value will match the passed in one.public void removeAll(@Nullable Collection<? extends K> keys, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
If write-through is enabled, the values will be removed from GridCacheStore
via GridCacheStore.removeAll(GridCacheTx, Collection) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.removeAll in interface GridCacheProjection<K,V>keys - Keys whose mappings are to be removed from cache.filter - Optional filter to check prior to removing value form cache. Note
that filter is checked atomically together with remove operation.GridException - If remove failed.public GridFuture<?> removeAllAsync(@Nullable Collection<? extends K> keys, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter)
If write-through is enabled, the values will be removed from GridCacheStore
via GridCacheStore.removeAll(GridCacheTx, Collection) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.removeAllAsync in interface GridCacheProjection<K,V>keys - Keys whose mappings are to be removed from cache.filter - Optional filter to check prior to removing value form cache. Note
that filter is checked atomically together with remove operation.public void removeAll(@Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
null, then all entries in cache will be enrolled
into transaction.
USE WITH CARE - if your cache has many entries that pass through the filter or if filter is empty, then transaction will quickly become very heavy and slow. Also, locks are acquired in undefined order, so it may cause a deadlock when used with other concurrent transactional updates.
If write-through is enabled, the values will be removed from GridCacheStore
via GridCacheStore.removeAll(GridCacheTx, Collection) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.removeAll in interface GridCacheProjection<K,V>filter - Filter used to supply keys for remove operation (if null,
then nothing will be removed).GridException - If remove failed.public GridFuture<?> removeAllAsync(@Nullable GridPredicate<GridCacheEntry<K,V>>... filter)
null, then all entries in cache will be enrolled
into transaction.
USE WITH CARE - if your cache has many entries that pass through the filter or if filter is empty, then transaction will quickly become very heavy and slow.
If write-through is enabled, the values will be removed from GridCacheStore
via GridCacheStore.removeAll(GridCacheTx, Collection) method.
GridCacheFlag.LOCAL, GridCacheFlag.READ.removeAllAsync in interface GridCacheProjection<K,V>filter - Filter used to supply keys for remove operation (if null,
then nothing will be removed).public boolean lock(K key, long timeout, @Nullable GridPredicate<GridCacheEntry<K,V>>... filter) throws GridException
GridCacheTxConcurrency.PESSIMISTIC concurrency control for transaction
which will acquire explicit locks for relevant cache operations.
GridCacheFlag.LOCAL, GridCacheFlag.READ.lock in interface GridCacheProjection<K,V>key - Key to lock.timeout - Timeout in milliseconds to wait for lock to be acquired
('0' for no expiration), -1 for immediate failure if
lock cannot be acquired immediately).filter - Optional filter to validate prior to acquiring the lock.True if all filters passed and lock was acquired,
false otherwise.GridException - If lock acquisition resulted in error.public GridFuture<Boolean> lockAsync(K key, long timeout, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter)
GridCacheTxConcurrency.PESSIMISTIC concurrency control for transaction
which will acquire explicit locks for relevant cache operations.
GridCacheFlag.LOCAL, GridCacheFlag.READ.lockAsync in interface GridCacheProjection<K,V>key - Key to lock.timeout - Timeout in milliseconds to wait for lock to be acquired
('0' for no expiration, -1 for immediate failure if
lock cannot be acquired immediately).filter - Optional filter to validate prior to acquiring the lock.true
whenever all filters pass and locks are acquired before timeout is expired,
false otherwise.public boolean lockAll(@Nullable Collection<? extends K> keys, long timeout, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter) throws GridException
GridCacheTxConcurrency.PESSIMISTIC concurrency control for transaction
which will acquire explicit locks for relevant cache operations.
GridCacheFlag.LOCAL, GridCacheFlag.READ.lockAll in interface GridCacheProjection<K,V>keys - Keys to lock.timeout - Timeout in milliseconds to wait for lock to be acquired
('0' for no expiration).filter - Optional filter that needs to atomically pass in order for the locks
to be acquired.True if all filters passed and locks were acquired before
timeout has expired, false otherwise.GridException - If lock acquisition resulted in error.public GridFuture<Boolean> lockAllAsync(@Nullable Collection<? extends K> keys, long timeout, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter)
GridCacheTxConcurrency.PESSIMISTIC concurrency control for transaction
which will acquire explicit locks for relevant cache operations.
GridCacheFlag.LOCAL, GridCacheFlag.READ.lockAllAsync in interface GridCacheProjection<K,V>keys - Keys to lock.timeout - Timeout in milliseconds to wait for lock to be acquired
('0' for no expiration).filter - Optional filter that needs to atomically pass in order for the locks
to be acquired.true if all filters passed and locks were acquired before
timeout has expired, false otherwise.public void unlock(K key, GridPredicate<GridCacheEntry<K,V>>[] filter) throws GridException
GridCacheTxConcurrency.PESSIMISTIC concurrency control for transaction
which will acquire explicit locks for relevant cache operations.
GridCacheFlag.LOCAL, GridCacheFlag.READ.unlock in interface GridCacheProjection<K,V>key - Key to unlock.filter - Optional filter that needs to pass prior to unlock taking effect.GridException - If unlock execution resulted in error.public void unlockAll(@Nullable Collection<? extends K> keys, @Nullable GridPredicate<GridCacheEntry<K,V>>[] filter) throws GridException
GridCacheTxConcurrency.PESSIMISTIC concurrency control for transaction
which will acquire explicit locks for relevant cache operations.
GridCacheFlag.LOCAL, GridCacheFlag.READ.unlockAll in interface GridCacheProjection<K,V>keys - Keys to unlock.filter - Optional filter which needs to pass for individual entries
to be unlocked.GridException - If unlock execution resulted in error.public boolean isLocked(K key)
This is a local in-VM operation and does not involve any network trips or access to persistent storage in any way.
isLocked in interface GridCacheProjection<K,V>key - Key to check.True if lock is owned by some node.public boolean isLockedByThread(K key)
This is a local in-VM operation and does not involve any network trips or access to persistent storage in any way.
isLockedByThread in interface GridCacheProjection<K,V>key - Key to check.True if key is locked by current thread.public V promote(K key) throws GridException
GridCacheFlag.SKIP_SWAP, GridCacheFlag.READ.promote in interface GridCacheProjection<K,V>key - Key to promote entry for.null for non-existing key.GridException - If promote failed.public void promoteAll(@Nullable Collection<? extends K> keys) throws GridException
GridCacheFlag.SKIP_SWAP, GridCacheFlag.READ.promoteAll in interface GridCacheProjection<K,V>keys - Keys to promote entries for.GridException - If promote failed.public GridCacheTx txStart() throws IllegalStateException
GridCacheConfiguration at startup.txStart in interface GridCacheProjection<K,V>IllegalStateException - If transaction is already started by this thread.public GridCacheTx txStart(GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation)
txStart in interface GridCacheProjection<K,V>concurrency - Concurrency.isolation - Isolation.public GridCacheTx txStart(GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation, long timeout, int txSize)
txStart in interface GridCacheProjection<K,V>concurrency - Concurrency.isolation - Isolation.timeout - Timeout.txSize - Number of entries participating in transaction (may be approximate).public GridCacheTx txStartAffinity(Object affinityKey, GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation, long timeout, int txSize) throws IllegalStateException, GridException
affinity-group-locked transaction based on affinity key. In this mode only affinity key
is locked and all other entries in transaction are written without locking. However,
all keys in such transaction must have the same affinity key. Node on which transaction
is started must be primary for the given affinity key (an exception is thrown otherwise).
Since only affinity key is locked, and no individual keys, it is user's responsibility to make sure
there are no other concurrent explicit updates directly on individual keys participating in the
transaction. All updates to the keys involved should always go through affinity-group-locked
transaction, otherwise cache may be left in inconsistent state.
If cache sanity check is enabled (GridConfiguration.isCacheSanityCheckEnabled()),
the following checks are performed:
txStartAffinity in interface GridCacheProjection<K,V>affinityKey - Affinity key for all entries updated by transaction. This node
must be primary for this key.concurrency - Transaction concurrency control.isolation - Cache transaction isolation level.timeout - Timeout (0 for default).txSize - Number of entries participating in transaction (may be approximate), 0 for default.IllegalStateException - If transaction is already started by this thread.GridException - If local node is not primary for any of provided keys.public GridCacheTx txStartPartition(int partId, GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation, long timeout, int txSize) throws IllegalStateException, GridException
partition-group-locked transaction based on partition ID. In this mode the whole partition
is locked and all other entries in transaction are written without locking. However,
all keys in such transaction must belong to the same partition. Node on which transaction
is started must be primary for the given partition (an exception is thrown otherwise).
Since only partition is locked, and no individual keys, it is user's responsibility to make sure
there are no other concurrent explicit updates directly on individual keys participating in the
transaction. All updates to the keys involved should always go through partition-group-locked
transaction, otherwise, cache may be left in inconsistent state.
If cache sanity check is enabled (GridConfiguration.isCacheSanityCheckEnabled()),
the following checks are performed:
txStartPartition in interface GridCacheProjection<K,V>partId - Partition id for which transaction is started. This node
must be primary for this partition.concurrency - Transaction concurrency control.isolation - Cache transaction isolation level.timeout - Timeout (0 for default).txSize - Number of entries participating in transaction (may be approximate), 0 for default.IllegalStateException - If transaction is already started by this thread.GridException - If local node is not primary for any of provided keys.public GridCacheTx tx()
null if this thread does
not have a transaction.tx in interface GridCacheProjection<K,V>null if this thread
does not have a transaction.public ConcurrentMap<K,V> toMap()
ConcurrentMap interface.toMap in interface GridCacheProjection<K,V>ConcurrentMap representation of given cache projection.public Iterator<GridCacheEntry<K,V>> iterator()
iterator in interface Iterable<GridCacheEntry<K,V>>public GridFuture<?> drStateTransfer(Collection<Byte> dataCenterIds)
drStateTransfer in interface GridCacheProjectionEx<K,V>dataCenterIds - Data center IDs for which full state transfer was requested.public Collection<GridDrStateTransferDescriptor> drListStateTransfers()
drListStateTransfers in interface GridCacheProjectionEx<K,V>public void drPause()
drPause in interface GridCacheProjectionEx<K,V>public void drResume()
drResume in interface GridCacheProjectionEx<K,V>@Nullable public GridDrStatus drPauseState()
drPauseState in interface GridCacheProjectionEx<K,V>public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionCopyright © 2014. All rights reserved.