public class GridCacheProxyImpl<K,V> extends Object implements GridCacheProxy<K,V>, Externalizable
| Constructor and Description |
|---|
GridCacheProxyImpl()
Empty constructor required for
Externalizable. |
GridCacheProxyImpl(GridCacheContext<K,V> ctx,
GridCacheProjectionEx<K,V> delegate,
GridCacheProjectionImpl<K,V> prj) |
| Modifier and Type | Method and Description |
|---|---|
<V1> V1 |
addMeta(String name,
V1 val)
Adds a new metadata.
|
<V1> V1 |
addMetaIfAbsent(String name,
Callable<V1> c)
Adds given metadata value only if it was absent.
|
<V1> V1 |
addMetaIfAbsent(String name,
V1 val)
Adds given metadata value only if it was absent.
|
GridCacheAffinity<K> |
affinity()
Gets affinity service to provide information about data partitioning
and distribution.
|
<V1> Map<String,V1> |
allMeta()
Gets all metadata in this entry.
|
<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.
|
GridCacheConfiguration |
configuration()
Gets configuration bean for this cache.
|
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. |
void |
copyMeta(GridMetadataAware from)
Copies all metadata from another instance.
|
void |
copyMeta(Map<String,?> data)
Copies all metadata from given map.
|
GridCacheDataStructures |
dataStructures()
Gets data structures service to provide a gateway for creating various
distributed data structures similar in APIs to
java.util.concurrent package. |
GridCacheProjectionEx<K,V> |
delegate() |
void |
dgc()
Runs DGC procedure on demand using
GridCacheConfiguration.getDgcSuspectLockTimeout() to identify suspect locks. |
void |
dgc(long suspectLockTimeout,
boolean global,
boolean rmvLocks)
Runs DGC procedure on demand using provided parameter to identify suspect locks.
|
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.
|
GridFuture<?> |
forceRepartition()
Forces this cache node to re-balance its partitions.
|
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.
|
GridCacheProjectionImpl<K,V> |
gateProjection() |
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 |
hasMeta(String name)
Tests whether or not given metadata is set.
|
<V1> boolean |
hasMeta(String name,
V1 val)
Tests whether or not metadata with given name and value is set.
|
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.
|
void |
loadCache(GridBiPredicate<K,V> p,
long ttl,
Object[] args)
Delegates to
GridCacheStore.loadCache(GridBiInClosure,Object...) method
to load state from the underlying persistent storage. |
GridFuture<?> |
loadCacheAsync(GridBiPredicate<K,V> p,
long ttl,
Object[] args)
Asynchronously delegates to
GridCacheStore.loadCache(GridBiInClosure, Object...) method
to reload state from the underlying persistent storage. |
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.
|
<V1> V1 |
meta(String name)
Gets metadata by name.
|
GridCacheMetrics |
metrics()
Gets metrics (statistics) for this cache.
|
String |
name()
Gets name of this cache (
null for default cache). |
int |
nearSize()
Gets size of near cache key set.
|
long |
offHeapAllocatedSize()
Gets memory size allocated in off-heap.
|
long |
offHeapEntriesCount()
Gets number of cache entries stored in off-heap memory.
|
Iterator<Map.Entry<K,V>> |
offHeapIterator()
Gets iterator over keys and values belonging to this cache off-heap memory on local node.
|
long |
overflowSize()
Gets size (in bytes) of all entries swapped to disk.
|
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.
|
<V1> V1 |
putMetaIfAbsent(String name,
Callable<V1> c)
Adds given metadata value only if it was absent.
|
<V1> V1 |
putMetaIfAbsent(String name,
V1 val)
Adds given metadata value only if it was absent.
|
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.
|
GridCacheEntry<K,V> |
randomEntry()
Gets a random entry out of cache.
|
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.
|
<V1> V1 |
removeMeta(String name)
Removes metadata by name.
|
<V1> boolean |
removeMeta(String name,
V1 val)
Removes metadata only if its current value is equal to
val passed in. |
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. |
<V1> boolean |
replaceMeta(String name,
V1 curVal,
V1 newVal)
Replaces given metadata with new
newVal value only if its current value
is equal to curVal. |
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. |
void |
resetMetrics()
Resets metrics for current cache.
|
int |
size()
Gets size of cache key set.
|
Iterator<Map.Entry<K,V>> |
swapIterator()
Gets iterator over keys and values belonging to this cache swap space on local node.
|
long |
swapKeys()
Gets number of swap entries (keys).
|
long |
swapSize()
Gets size in bytes for swap space.
|
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. |
Collection<GridCacheTxSynchronization> |
txSynchronizations()
Gets registered transaction synchronizations.
|
void |
txSynchronize(GridCacheTxSynchronization syncs)
Registers transactions synchronizations for all transactions started by this cache.
|
void |
txUnsynchronize(GridCacheTxSynchronization syncs)
Removes transaction synchronizations.
|
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) |
public GridCacheProxyImpl()
Externalizable.public GridCacheProxyImpl(GridCacheContext<K,V> ctx, GridCacheProjectionEx<K,V> delegate, @Nullable GridCacheProjectionImpl<K,V> prj)
ctx - Context.delegate - Delegate object.prj - Optional projection which will be passed to gateway.public GridCacheProjectionEx<K,V> delegate()
public GridCacheProjectionImpl<K,V> gateProjection()
public String name()
null for default cache).name in interface GridCacheProjection<K,V>public GridProjection gridProjection()
gridProjection in interface GridCacheProjection<K,V>public <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 GridCacheAffinity<K> affinity()
public GridCacheDataStructures dataStructures()
java.util.concurrent package.dataStructures in interface GridCache<K,V>public void copyMeta(GridMetadataAware from)
copyMeta in interface GridMetadataAwarefrom - Metadata aware instance to copy metadata from.public void copyMeta(Map<String,?> data)
copyMeta in interface GridMetadataAwaredata - Map to copy metadata from.public <V1> V1 addMeta(String name, V1 val)
addMeta in interface GridMetadataAwareV1 - Type of the value.name - Metadata name.val - Metadata value.null if there was none.public <V1> V1 putMetaIfAbsent(String name, V1 val)
putMetaIfAbsent in interface GridMetadataAwareV1 - Type of the value.name - Metadata name.val - Value to add if it's not attached already.null if new value was put, or current value if put didn't happen.public <V1> V1 putMetaIfAbsent(String name, Callable<V1> c)
putMetaIfAbsent in interface GridMetadataAwareV1 - Type of the value.name - Metadata name.c - Factory closure to produce value to add if it's not attached already.
Not that unlike GridMetadataAware.addMeta(String, Object) method the factory closure will
not be called unless the value is required and therefore value will only be created
when it is actually needed.null if new value was put, or current value if put didn't happen.public <V1> V1 addMetaIfAbsent(String name, V1 val)
GridMetadataAware.putMetaIfAbsent(String, Callable), this method always returns
the latest value and never previous one.addMetaIfAbsent in interface GridMetadataAwareV1 - Type of the value.name - Metadata name.val - Value to add if it's not attached already.@Nullable public <V1> V1 addMetaIfAbsent(String name, @Nullable Callable<V1> c)
addMetaIfAbsent in interface GridMetadataAwareV1 - Type of the value.name - Metadata name.c - Factory closure to produce value to add if it's not attached already.
Not that unlike GridMetadataAware.addMeta(String, Object) method the factory closure will
not be called unless the value is required and therefore value will only be created
when it is actually needed. If null and metadata value is missing - null
will be returned from this method.public <V1> V1 meta(String name)
meta in interface GridMetadataAwareV1 - Type of the value.name - Metadata name.null.public <V1> V1 removeMeta(String name)
removeMeta in interface GridMetadataAwareV1 - Type of the value.name - Name of the metadata to remove.null.public <V1> boolean removeMeta(String name, V1 val)
val passed in.removeMeta in interface GridMetadataAwareV1 - Value type.name - Name of metadata attribute.val - Value to compare.True if value was removed, false otherwise.public <V1> Map<String,V1> allMeta()
allMeta in interface GridMetadataAwareV1 - Type of the value.public boolean hasMeta(String name)
hasMeta in interface GridMetadataAwarename - Name of the metadata to test.public <V1> boolean hasMeta(String name, V1 val)
true if
attachment with given name it set and its value is equals to provided value. Otherwise returns
false.hasMeta in interface GridMetadataAwareV1 - Type of the value.name - Name of the metadata.val - Value to compare. Cannot be null.true if metadata with given name is set and its value is equals to provided value -
otherwise returns false.public <V1> boolean replaceMeta(String name, V1 curVal, V1 newVal)
newVal value only if its current value
is equal to curVal. Otherwise, it is no-op.replaceMeta in interface GridMetadataAwarename - Name of the metadata.curVal - Current value to check.newVal - New value.true if replacement occurred, false otherwise.public GridCacheConfiguration configuration()
configuration in interface GridCache<K,V>public void txSynchronize(@Nullable GridCacheTxSynchronization syncs)
txSynchronize in interface GridCache<K,V>syncs - Transaction synchronizations to register.public void txUnsynchronize(@Nullable GridCacheTxSynchronization syncs)
txUnsynchronize in interface GridCache<K,V>syncs - Transactions synchronizations to remove.GridCache.txSynchronize(GridCacheTxSynchronization)public Collection<GridCacheTxSynchronization> txSynchronizations()
txSynchronizations in interface GridCache<K,V>GridCache.txSynchronize(GridCacheTxSynchronization)public GridCacheMetrics metrics()
public long overflowSize()
throws GridException
overflowSize in interface GridCache<K,V>GridException - In case of error.public void loadCache(GridBiPredicate<K,V> p, long ttl, @Nullable Object[] args) throws GridException
GridCacheStore.loadCache(GridBiInClosure,Object...) method
to load state from the underlying persistent storage. The loaded values
will then be given to the optionally passed in predicate, and, if the predicate returns
true, will be stored in cache. If predicate is null, then
all loaded values will be stored in cache.
Note that this method does not receive keys as a parameter, so it is up to
GridCacheStore implementation to provide all the data to be loaded.
This method is not transactional and may end up loading a stale value into cache if another thread has updated the value immediately after it has been loaded. It is mostly useful when pre-loading the cache from underlying data store before start, or for read-only caches.
loadCache in interface GridCache<K,V>p - Optional predicate (may be null). If provided, will be used to
filter values to be put into cache.ttl - Time to live for loaded entries (0 for infinity).args - Optional user arguments to be passed into
GridCacheStore.loadCache(GridBiInClosure, Object...) method.GridException - If loading failed.public GridFuture<?> loadCacheAsync(GridBiPredicate<K,V> p, long ttl, @Nullable Object[] args)
GridCacheStore.loadCache(GridBiInClosure, Object...) method
to reload state from the underlying persistent storage. The reloaded values
will then be given to the optionally passed in predicate, and if the predicate returns
true, will be stored in cache. If predicate is null, then
all reloaded values will be stored in cache.
Note that this method does not receive keys as a parameter, so it is up to
GridCacheStore implementation to provide all the data to be loaded.
This method is not transactional and may end up loading a stale value into cache if another thread has updated the value immediately after it has been loaded. It is mostly useful when pre-loading the cache from underlying data store before start, or for read-only caches.
loadCacheAsync in interface GridCache<K,V>p - Optional predicate (may be null). If provided, will be used to
filter values to be put into cache.ttl - Time to live for loaded entries (0 for infinity).args - Optional user arguments to be passed into
GridCacheStore.loadCache(GridBiInClosure,Object...) method.@Nullable public GridCacheEntry<K,V> randomEntry()
O(S * N/64)where
N is the size of internal hash
table and S is the number of hash table buckets to sample, which is 5
by default. However, if the table is pretty dense, with density factor of N/64,
which is true for near fully populated caches, this method will generally perform significantly
faster with complexity of O(S) where S = 5.
Note that this method is not available on GridCacheProjection API since it is
impossible (or very hard) to deterministically return a number value when pre-filtering
and post-filtering is involved (e.g. projection level predicate filters).
randomEntry in interface GridCache<K,V>null if cache is empty.public ConcurrentMap<K,V> toMap()
ConcurrentMap interface.toMap in interface GridCacheProjection<K,V>ConcurrentMap representation of given cache projection.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 GridCacheProjectionEx<K,V> forSubjectId(UUID subjId)
GridCacheProjectionExforSubjectId in interface GridCacheProjectionEx<K,V>subjId - Client ID.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(@Nullable 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(@Nullable 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 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.@Nullable 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.@Nullable 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.@Nullable 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.@Nullable 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.@Nullable 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(@Nullable 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(@Nullable 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>> 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>> entrySetx(GridPredicate<GridCacheEntry<K,V>>... filter)
entrySetx in interface GridCacheProjectionEx<K,V>filter - Filter.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 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.@Nullable 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.@Nullable 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.@Nullable 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 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>@Nullable 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 Iterator<Map.Entry<K,V>> swapIterator() throws GridException
Returned iterator supports remove operation which delegates to
GridCacheProjection.removex(Object, GridPredicate[]) method.
GridCacheFlag.SKIP_SWAP.swapIterator in interface GridCache<K,V>GridException - If failed.GridCacheProjection.promote(Object)public Iterator<Map.Entry<K,V>> offHeapIterator() throws GridException
Returned iterator supports remove operation which delegates to
GridCacheProjection.removex(Object, GridPredicate[]) method.
offHeapIterator in interface GridCache<K,V>GridException - If failed.public long offHeapEntriesCount()
offHeapEntriesCount in interface GridCache<K,V>public long offHeapAllocatedSize()
offHeapAllocatedSize in interface GridCache<K,V>public long swapSize()
throws GridException
swapSize in interface GridCache<K,V>GridException - If failed.public long swapKeys()
throws GridException
swapKeys in interface GridCache<K,V>GridException - If failed.public Iterator<GridCacheEntry<K,V>> iterator()
iterator in interface Iterable<GridCacheEntry<K,V>>public void dgc()
GridCacheConfiguration.getDgcSuspectLockTimeout() to identify suspect locks.
Method blocks current thread until locks are examined and all DGC requests are sent to remote nodes.
DGC does not remove locks if GridCacheConfiguration.isDgcRemoveLocks()
is set to false.
public void dgc(long suspectLockTimeout,
boolean global,
boolean rmvLocks)
Method blocks current thread until locks are examined and all DGC requests are sent
to remote nodes and (if global is true) all nodes running this cache
will get signal to start GC procedure.
public GridFuture<?> forceRepartition()
GridCacheConfiguration.getPreloadPartitionedDelay() configuration parameter has non-zero value.
When many nodes are started or stopped almost concurrently, it is more efficient to delay
preloading until the node topology is stable to make sure that no redundant re-partitioning
happens.
In case ofGridCacheMode.PARTITIONED caches, for better efficiency user should
usually make sure that new nodes get placed on the same place of consistent hash ring as
the left nodes, and that nodes are restarted before
preloadDelay expires. To place nodes
on the same place in consistent hash ring, use
GridCacheConsistentHashAffinityFunction.setHashIdResolver(GridCacheAffinityNodeHashResolver) to make sure that
a node maps to the same hash ID if re-started.
See GridCacheConfiguration.getPreloadPartitionedDelay() for more information on how to configure
preload re-partition delay.
forceRepartition in interface GridCache<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 ExternalizableIOExceptionClassNotFoundExceptionpublic void resetMetrics()
resetMetrics in interface GridCache<K,V>Copyright © 2014. All rights reserved.