public class IgniteCacheProxy<K,V> extends AsyncSupportAdapter<IgniteCache<K,V>> implements IgniteCache<K,V>, Externalizable
curFut| Constructor and Description |
|---|
IgniteCacheProxy()
Empty constructor required for
Externalizable. |
IgniteCacheProxy(GridCacheContext<K,V> ctx,
GridCacheProjectionEx<K,V> delegate,
GridCacheProjectionImpl<K,V> prj,
boolean async) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
void |
clear(K key)
Clear entry from the cache and swap storage, without notifying listeners or
CacheWriters. |
void |
clearAll(Set<K> keys)
Clear entries from the cache and swap storage, without notifying listeners or
CacheWriters. |
void |
close() |
boolean |
containsKey(K key) |
boolean |
containsKeys(Set<? extends K> keys) |
GridCacheContext<K,V> |
context() |
protected IgniteCache<K,V> |
createAsyncInstance()
Creates component with asynchronous mode enabled.
|
void |
deregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> lsnrCfg) |
Set<javax.cache.Cache.Entry<K,V>> |
entrySetx(CacheEntryPredicate... filter)
Gets entry set containing internal entries.
|
IgniteCache<K,V> |
flagOn(CacheFlag flag) |
V |
get(K key) |
Map<K,V> |
getAll(Collection<? extends K> keys) |
Map<K,V> |
getAll(Set<? extends K> keys) |
V |
getAndPut(K key,
V val) |
V |
getAndPutIfAbsent(K key,
V val)
Stores given key-value pair in cache only if cache had no previous mapping for it.
|
V |
getAndRemove(K key) |
V |
getAndReplace(K key,
V val) |
javax.cache.CacheManager |
getCacheManager() |
<C extends javax.cache.configuration.Configuration<K,V>> |
getConfiguration(Class<C> clazz) |
String |
getName() |
<T> T |
invoke(K key,
javax.cache.processor.EntryProcessor<K,V,T> entryProcessor,
Object... args) |
<T> T |
invoke(K key,
IgniteEntryProcessor<K,V,T> entryProcessor,
Object... args)
Invokes an
IgniteEntryProcessor against the Entry specified by
the provided key. |
<T> Map<K,javax.cache.processor.EntryProcessorResult<T>> |
invokeAll(Map<? extends K,? extends javax.cache.processor.EntryProcessor<K,V,T>> map,
Object... args) |
<T> Map<K,javax.cache.processor.EntryProcessorResult<T>> |
invokeAll(Set<? extends K> keys,
javax.cache.processor.EntryProcessor<K,V,T> entryProcessor,
Object... args) |
<T> Map<K,javax.cache.processor.EntryProcessorResult<T>> |
invokeAll(Set<? extends K> keys,
IgniteEntryProcessor<K,V,T> entryProcessor,
Object... args)
Invokes an
IgniteEntryProcessor against the set of Entrys
specified by the set of keys. |
boolean |
isClosed() |
boolean |
isLocalLocked(K key,
boolean byCurrThread)
Checks if specified key is locked.
|
Iterator<javax.cache.Cache.Entry<K,V>> |
iterator() |
<K1,V1> IgniteCache<K1,V1> |
keepPortable()
Creates projection that will operate with portable objects.
|
void |
loadAll(Set<? extends K> keys,
boolean replaceExisting,
javax.cache.integration.CompletionListener completionLsnr) |
void |
loadCache(IgniteBiPredicate<K,V> p,
Object... args)
Executes
IgniteCache.localLoadCache(IgniteBiPredicate, Object...) on all cache nodes. |
void |
localClear(K key)
Clear entry from the cache and swap storage, without notifying listeners or
CacheWriters. |
void |
localClearAll(Set<K> keys)
Clear entries from the cache and swap storage, without notifying listeners or
CacheWriters. |
Iterable<javax.cache.Cache.Entry<K,V>> |
localEntries(CachePeekMode... peekModes) |
void |
localEvict(Collection<? extends K> keys)
Attempts to evict all entries associated with keys.
|
void |
localLoadCache(IgniteBiPredicate<K,V> p,
Object... args)
Delegates to
CacheStore.loadCache(IgniteBiInClosure,Object...) method
to load state from the underlying persistent storage. |
V |
localPeek(K key,
CachePeekMode... peekModes)
Peeks at in-memory cached value using default
GridCachePeekMode.SMART
peek mode. |
void |
localPromote(Set<? extends K> keys)
This method unswaps cache entries by given keys, if any, from swap storage
into memory.
|
QueryCursor<javax.cache.Cache.Entry<K,V>> |
localQuery(Query qry)
Queries cache locally.
|
QueryCursor<List<?>> |
localQueryFields(SqlFieldsQuery qry)
Queries separate entry fields locally.
|
int |
localSize(CachePeekMode... peekModes)
Gets the number of all entries cached on this nodes.
|
Lock |
lock(K key)
Creates a
Lock instance associated with passed key. |
Lock |
lockAll(Collection<? extends K> keys)
Creates a
Lock instance associated with passed keys. |
CacheMetrics |
metrics()
Gets snapshot metrics (statistics) for this cache.
|
CacheMetricsMXBean |
mxBean()
Gets MxBean for this cache.
|
void |
put(K key,
V val) |
void |
putAll(Map<? extends K,? extends V> map) |
boolean |
putIfAbsent(K key,
V val) |
QueryCursor<javax.cache.Cache.Entry<K,V>> |
query(Query qry)
Queries cache.
|
QueryCursor<List<?>> |
queryFields(SqlFieldsQuery qry)
Queries separate entry fields.
|
javax.cache.Cache.Entry<K,V> |
randomEntry()
Gets a random entry out of cache.
|
void |
readExternal(ObjectInput in) |
IgniteFuture<?> |
rebalance()
This cache node to re-balance its partitions.
|
void |
registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> lsnrCfg) |
boolean |
remove(K key) |
boolean |
remove(K key,
V oldVal) |
void |
removeAll() |
void |
removeAll(Set<? extends K> keys) |
boolean |
replace(K key,
V val) |
boolean |
replace(K key,
V oldVal,
V newVal) |
int |
size(CachePeekMode... peekModes)
Gets the number of all entries cached across all nodes.
|
String |
toString() |
<T> T |
unwrap(Class<T> clazz) |
IgniteCache<K,V> |
withExpiryPolicy(javax.cache.expiry.ExpiryPolicy plc) |
IgniteCache<K,V> |
withSkipStore() |
void |
writeExternal(ObjectOutput out) |
createFuture, future, future, isAsync, saveOrGet, withAsyncclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitwithAsyncfuture, isAsyncpublic IgniteCacheProxy()
Externalizable.public IgniteCacheProxy(GridCacheContext<K,V> ctx, GridCacheProjectionEx<K,V> delegate, @Nullable GridCacheProjectionImpl<K,V> prj, boolean async)
ctx - Context.delegate - Delegate.prj - Projection.async - Async support flag.public GridCacheContext<K,V> context()
public CacheMetrics metrics()
metrics in interface IgniteCache<K,V>public CacheMetricsMXBean mxBean()
mxBean in interface IgniteCache<K,V>public <C extends javax.cache.configuration.Configuration<K,V>> C getConfiguration(Class<C> clazz)
getConfiguration in interface javax.cache.Cache<K,V>getConfiguration in interface IgniteCache<K,V>@Nullable public javax.cache.Cache.Entry<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.randomEntry in interface IgniteCache<K,V>null if cache is empty.public IgniteCache<K,V> withExpiryPolicy(javax.cache.expiry.ExpiryPolicy plc)
withExpiryPolicy in interface IgniteCache<K,V>public IgniteCache<K,V> withSkipStore()
withSkipStore in interface IgniteCache<K,V>public void loadCache(@Nullable IgniteBiPredicate<K,V> p, @Nullable Object... args)
IgniteCache.localLoadCache(IgniteBiPredicate, Object...) on all cache nodes.loadCache in interface IgniteCache<K,V>p - Optional predicate (may be null). If provided, will be used to
filter values to be put into cache.args - Optional user arguments to be passed into
CacheStore.loadCache(IgniteBiInClosure, Object...) method.public void localLoadCache(@Nullable IgniteBiPredicate<K,V> p, @Nullable Object... args)
CacheStore.loadCache(IgniteBiInClosure,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
CacheStore 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.
localLoadCache in interface IgniteCache<K,V>p - Optional predicate (may be null). If provided, will be used to
filter values to be put into cache.args - Optional user arguments to be passed into
CacheStore.loadCache(IgniteBiInClosure, Object...) method.@Nullable public V getAndPutIfAbsent(K key, V val) throws javax.cache.CacheException
CacheMode.PARTITIONED or CacheMode.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, CacheLoader.load(Object) method will be used.
If the returned value is not needed, method IgniteCache.putIfAbsent(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 CacheStore
via CacheWriter.write(Cache.Entry) method.
CacheFlag.LOCAL, CacheFlag.READ.getAndPutIfAbsent in interface IgniteCache<K,V>key - Key to store in cache.val - Value to be associated with the given key.null if there was no
previous value).javax.cache.CacheException - If put operation failed.public Lock lock(K key) throws javax.cache.CacheException
Lock instance associated with passed key.
This method does not acquire lock immediately, you have to call appropriate method on returned instance.
Returned lock does not support Lock.newCondition() method,
other methods defined in Lock are supported.lock in interface IgniteCache<K,V>key - Key for lock.javax.cache.CacheExceptionLock.lock(),
Lock.tryLock(long, TimeUnit)public Lock lockAll(Collection<? extends K> keys)
Lock instance associated with passed keys.
This method does not acquire lock immediately, you have to call appropriate method on returned instance.
Returned lock does not support Lock.newCondition() method,
other methods defined in Lock are supported.lockAll in interface IgniteCache<K,V>keys - Keys for lock.Lock.lock(),
Lock.tryLock(long, TimeUnit)public boolean isLocalLocked(K key, boolean byCurrThread)
This is a local in-VM operation and does not involve any network trips or access to persistent storage in any way.
isLocalLocked in interface IgniteCache<K,V>key - Key to check.byCurrThread - If true method will check that current thread owns a lock on this key, other vise
will check that any thread on any node owns a lock on this key.True if lock is owned by some node.public QueryCursor<javax.cache.Cache.Entry<K,V>> query(Query qry)
Query.public QueryCursor<List<?>> queryFields(SqlFieldsQuery qry)
queryFields in interface IgniteCache<K,V>qry - SQL Query.public QueryCursor<javax.cache.Cache.Entry<K,V>> localQuery(Query qry)
Query.localQuery in interface IgniteCache<K,V>qry - Query.ScanQuery,
SqlQuery,
TextQuery,
SpiQuerypublic QueryCursor<List<?>> localQueryFields(SqlFieldsQuery qry)
localQueryFields in interface IgniteCache<K,V>qry - SQL Query.public Iterable<javax.cache.Cache.Entry<K,V>> localEntries(CachePeekMode... peekModes) throws javax.cache.CacheException
localEntries in interface IgniteCache<K,V>javax.cache.CacheExceptionpublic void localEvict(Collection<? extends K> keys)
If CacheConfiguration.isSwapEnabled() is set to true and
CacheFlag.SKIP_SWAP is not enabled, the evicted entry will
be swapped to offheap, and then to disk.
CacheFlag.READ.localEvict in interface IgniteCache<K,V>keys - Keys to evict.@Nullable public V localPeek(K key, CachePeekMode... peekModes)
GridCachePeekMode.SMART
peek mode.
This method will not load value from any persistent store or from a remote node.
GridCachePeekMode.SMART mode
semantics.localPeek in interface IgniteCache<K,V>key - Entry key.null if not found.public void localPromote(Set<? extends K> keys) throws javax.cache.CacheException
CacheFlag.SKIP_SWAP, CacheFlag.READ.localPromote in interface IgniteCache<K,V>keys - Keys to promote entries for.javax.cache.CacheException - If promote failed.public int size(CachePeekMode... peekModes) throws javax.cache.CacheException
NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
size in interface IgniteCache<K,V>peekModes - Optional peek modes. If not provided, then total cache size is returned.javax.cache.CacheExceptionpublic int localSize(CachePeekMode... peekModes)
localSize in interface IgniteCache<K,V>peekModes - Optional peek modes. If not provided, then total cache size is returned.public Map<K,V> getAll(Collection<? extends K> keys)
keys - Keys.public Set<javax.cache.Cache.Entry<K,V>> entrySetx(CacheEntryPredicate... filter)
filter - Filter.public boolean containsKey(K key)
containsKey in interface javax.cache.Cache<K,V>containsKey in interface IgniteCache<K,V>public boolean containsKeys(Set<? extends K> keys)
containsKeys in interface IgniteCache<K,V>public void loadAll(Set<? extends K> keys, boolean replaceExisting, @Nullable javax.cache.integration.CompletionListener completionLsnr)
public boolean putIfAbsent(K key, V val)
putIfAbsent in interface javax.cache.Cache<K,V>putIfAbsent in interface IgniteCache<K,V>public boolean remove(K key)
public V getAndRemove(K key)
getAndRemove in interface javax.cache.Cache<K,V>getAndRemove in interface IgniteCache<K,V>public V getAndReplace(K key, V val)
getAndReplace in interface javax.cache.Cache<K,V>getAndReplace in interface IgniteCache<K,V>public void removeAll()
public void clear(K key)
CacheWriters. Entry is cleared only if it is not currently locked,
and is not participating in a transaction.clear in interface IgniteCache<K,V>key - Key to clear.public void clearAll(Set<K> keys)
CacheWriters. Entry is cleared only if it is not currently locked,
and is not participating in a transaction.clearAll in interface IgniteCache<K,V>keys - Keys to clear.public void clear()
public void localClear(K key)
CacheWriters. Entry is cleared only if it is not currently locked,
and is not participating in a transaction.
Note that this operation is local as it merely clears
an entry from local cache, it does not remove entries from
remote caches.localClear in interface IgniteCache<K,V>key - Key to clear.public void localClearAll(Set<K> keys)
CacheWriters. Entry is cleared only if it is not currently locked,
and is not participating in a transaction.
Note that this operation is local as it merely clears
an entry from local cache, it does not remove entries from
remote caches.localClearAll in interface IgniteCache<K,V>keys - Keys to clear.public <T> T invoke(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... args) throws javax.cache.processor.EntryProcessorException
public <T> T invoke(K key, IgniteEntryProcessor<K,V,T> entryProcessor, Object... args) throws javax.cache.processor.EntryProcessorException
IgniteEntryProcessor against the Entry specified by
the provided key. If an Entry does not exist for the specified key,
an attempt is made to load it (if a loader is configured) or a surrogate
Entry, consisting of the key with a null value is used instead.
This method different
invoke in interface IgniteCache<K,V>key - the key to the entryentryProcessor - the IgniteEntryProcessor to invokeargs - additional arguments to pass to the
IgniteEntryProcessorIgniteEntryProcessor implementationjavax.cache.processor.EntryProcessorException - if an exception is thrown by the IgniteEntryProcessor, a Caching Implementation
must wrap any Exception thrown
wrapped in an EntryProcessorException.IgniteEntryProcessorpublic <T> Map<K,javax.cache.processor.EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... args)
public <T> Map<K,javax.cache.processor.EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, IgniteEntryProcessor<K,V,T> entryProcessor, Object... args)
IgniteEntryProcessor against the set of Entrys
specified by the set of keys.
If an Entry does not exist for the specified key, an attempt is made
to load it (if a loader is configured) or a surrogate Entry,
consisting of the key and a value of null is provided.
The order that the entries for the keys are processed is undefined.
Implementations may choose to process the entries in any order, including
concurrently. Furthermore there is no guarantee implementations will
use the same IgniteEntryProcessor instance to process each entry, as
the case may be in a non-local cache topology.
The result of executing the IgniteEntryProcessor is returned as a
Map of EntryProcessorResults, one result per key. Should the
IgniteEntryProcessor or Caching implementation throw an exception, the
exception is wrapped and re-thrown when a call to
EntryProcessorResult.get() is made.
invokeAll in interface IgniteCache<K,V>keys - the set of keys for entries to processentryProcessor - the IgniteEntryProcessor to invokeargs - additional arguments to pass to the
IgniteEntryProcessorEntryProcessorResults of the processing per key,
if any, defined by the IgniteEntryProcessor implementation. No mappings
will be returned for IgniteEntryProcessors that return a
null value for a key.IgniteEntryProcessorpublic <T> Map<K,javax.cache.processor.EntryProcessorResult<T>> invokeAll(Map<? extends K,? extends javax.cache.processor.EntryProcessor<K,V,T>> map, Object... args)
invokeAll in interface IgniteCache<K,V>map - Map containing keys and entry processors to be applied to values.args - Additional arguments to pass to the EntryProcessor.EntryProcessorResults of the processing per key,
if any, defined by the EntryProcessor implementation. No mappings
will be returned for EntryProcessors that return a
null value for a key.public javax.cache.CacheManager getCacheManager()
public void close()
public void registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> lsnrCfg)
public void deregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> lsnrCfg)
protected IgniteCache<K,V> createAsyncInstance()
createAsyncInstance in class AsyncSupportAdapter<IgniteCache<K,V>>public <K1,V1> IgniteCache<K1,V1> keepPortable()
Projection returned by this method will force cache not to deserialize portable objects, so keys and values will be returned from cache API methods without changes. Therefore, signature of the projection can contain only following types:
PortableObject for portable classesString and array of StringsUUID and array of UUIDsDate and array of DatesTimestamp and array of Timestamps
For example, if you use Integer as a key and Value class as a value
(which will be stored in portable format), you should acquire following projection
to avoid deserialization:
CacheProjectionprj = cache.keepPortable(); // Value is not deserialized and returned in portable format. GridPortableObject po = prj.get(1);
Note that this method makes sense only if cache is working in portable mode
(CacheConfiguration#isPortableEnabled() returns true. If not,
this method is no-op and will return current projection.
public IgniteCache<K,V> flagOn(CacheFlag flag)
flag - Flag to turn on.public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic IgniteFuture<?> rebalance()
CacheConfiguration.getRebalanceDelay() configuration parameter has non-zero value.
When many nodes are started or stopped almost concurrently, it is more efficient to delay
rebalancing until the node topology is stable to make sure that no redundant re-partitioning
happens.
In case ofCacheMode.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
rebalanceDelay expires. To place nodes
on the same place in consistent hash ring, use
CacheRendezvousAffinityFunction.setHashIdResolver(CacheAffinityNodeHashResolver) to make sure that
a node maps to the same hash ID if re-started.
See CacheConfiguration.getRebalanceDelay() for more information on how to configure
rebalance re-partition delay.
rebalance in interface IgniteCache<K,V>
Follow @ApacheIgnite
Ignite Fabric : ver. 1.0.0-RC3 Release Date : March 24 2015