Class GatewayProtectedCacheProxy<K,V>
- java.lang.Object
-
- org.apache.ignite.internal.AsyncSupportAdapter<IgniteCache<K,V>>
-
- org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy<K,V>
-
- All Implemented Interfaces:
Closeable,Externalizable,Serializable,AutoCloseable,Iterable<javax.cache.Cache.Entry<K,V>>,javax.cache.Cache<K,V>,IgniteCache<K,V>,IgniteCacheProxy<K,V>,IgniteAsyncSupport
public class GatewayProtectedCacheProxy<K,V> extends AsyncSupportAdapter<IgniteCache<K,V>> implements IgniteCacheProxy<K,V>
Cache proxy wrapper with gateway lock provided operations and possibility to change cache operation context.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.ignite.internal.AsyncSupportAdapter
curFut
-
-
Constructor Summary
Constructors Constructor Description GatewayProtectedCacheProxy()Empty constructor required forExternalizable.GatewayProtectedCacheProxy(@NotNull IgniteCacheProxy<K,V> delegate, @NotNull CacheOperationContext opCtx, boolean lock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GatewayProtectedCacheProxy<K,V>cacheNoGate()Gets cache proxy which does not acquire read lock on gateway enter, should be used only if grid read lock is externally acquired.voidclear()Clears the contents of the cache, without notifying listeners orCacheWriters.voidclear(K key)Clears entry from the cache and swap storage, without notifying listeners orCacheWriters.voidclearAll(Set<? extends K> keys)Clears entries from the cache and swap storage, without notifying listeners orCacheWriters.IgniteFuture<Void>clearAllAsync(Set<? extends K> keys)Asynchronously clears entries from the cache and swap storage, without notifying listeners orCacheWriters.IgniteFuture<Void>clearAsync()Asynchronously clears the contents of the cache, without notifying listeners orCacheWriters.IgniteFuture<Void>clearAsync(K key)Asynchronously clears entry from the cache and swap storage, without notifying listeners orCacheWriters.voidclearStatistics()Clear cluster statistics for this cache.voidclose()Closes this cache instance.IgniteFuture<?>closeAsync()voidcloseProxy()Closes this proxy instance.booleancontainsKey(K key)IgniteFuture<Boolean>containsKeyAsync(K key)Asynchronously determines if theCachecontains an entry for the specified key.booleancontainsKeys(Set<? extends K> keys)Determines if theCachecontains entries for the specified keys.IgniteFuture<Boolean>containsKeysAsync(Set<? extends K> keys)Asynchronously determines if theCachecontains entries for the specified keys.GridCacheContext<K,V>context()voidderegisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)voiddestroy()Completely deletes the cache with all its data from the system on all cluster nodes.IgniteFuture<?>destroyAsync()voidenableStatistics(boolean enabled)Sets statistics enabled flag cluster wide for this cache.booleanequals(Object another)<R> IgniteFuture<R>future()Gets and resets future for previous asynchronous operation.Vget(K key)Map<K,V>getAll(Set<? extends K> keys)IgniteFuture<Map<K,V>>getAllAsync(Set<? extends K> keys)Asynchronously gets a collection of entries from theCache, returning them asMapof the values associated with the set of keys requested.Map<K,V>getAllOutTx(Set<? extends K> keys)Gets values from cache.IgniteFuture<Map<K,V>>getAllOutTxAsync(Set<? extends K> keys)Asynchronously gets values from cache.VgetAndPut(K key, V val)IgniteFuture<V>getAndPutAsync(K key, V val)Asynchronously associates the specified value with the specified key in this cache, returning an existing value if one existed as the future result.VgetAndPutIfAbsent(K key, V val)Stores given key-value pair in cache only if cache had no previous mapping for it.IgniteFuture<V>getAndPutIfAbsentAsync(K key, V val)Asynchronously stores given key-value pair in cache only if cache had no previous mapping for it.VgetAndRemove(K key)IgniteFuture<V>getAndRemoveAsync(K key)Asynchronously removes the entry for a key only if currently mapped to some value.VgetAndReplace(K key, V val)IgniteFuture<V>getAndReplaceAsync(K key, V val)Asynchronously replaces the value for a given key if and only if there is a value currently mapped by the key.IgniteFuture<V>getAsync(K key)Asynchronously gets an entry from the cache.javax.cache.CacheManagergetCacheManager()<C extends javax.cache.configuration.Configuration<K,V>>
CgetConfiguration(Class<C> clazz)Collection<CacheEntry<K,V>>getEntries(Set<? extends K> keys)Gets a collection of entries from theCache.IgniteFuture<Collection<CacheEntry<K,V>>>getEntriesAsync(Set<? extends K> keys)Asynchronously gets a collection of entries from theCache.CacheEntry<K,V>getEntry(K key)Gets an entry from the cache.IgniteFuture<CacheEntry<K,V>>getEntryAsync(K key)Asynchronously gets an entry from the cache.StringgetName()inthashCode()IgniteFuture<?>indexReadyFuture()Returns future that will be completed when all indexes for this cache are ready to use.GridCacheProxyImpl<K,V>internalProxy()<T> Tinvoke(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments)<T> Tinvoke(K key, CacheEntryProcessor<K,V,T> entryProcessor, Object... arguments)Invokes anCacheEntryProcessoragainst theCache.Entryspecified 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)Asynchronously invokes eachEntryProcessorfrom map's values against the correspondentCache.Entryspecified by map's key set.<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, CacheEntryProcessor<K,V,T> entryProcessor, Object... args)Invokes anCacheEntryProcessoragainst the set ofCache.Entrys specified by the set of keys.<T> IgniteFuture<Map<K,javax.cache.processor.EntryProcessorResult<T>>>invokeAllAsync(Map<? extends K,? extends javax.cache.processor.EntryProcessor<K,V,T>> map, Object... args)Asynchronous version of theIgniteCache.invokeAll(Map, Object...)method.<T> IgniteFuture<Map<K,javax.cache.processor.EntryProcessorResult<T>>>invokeAllAsync(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... args)Asynchronously invokes anEntryProcessoragainst the set ofCache.Entrys specified by the set of keys.<T> IgniteFuture<Map<K,javax.cache.processor.EntryProcessorResult<T>>>invokeAllAsync(Set<? extends K> keys, CacheEntryProcessor<K,V,T> entryProcessor, Object... args)Asynchronously invokes anCacheEntryProcessoragainst the set ofCache.Entrys specified by the set of keys.<T> IgniteFuture<T>invokeAsync(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments)Asynchronously invokes anEntryProcessoragainst theCache.Entryspecified by the provided key.<T> IgniteFuture<T>invokeAsync(K key, CacheEntryProcessor<K,V,T> entryProcessor, Object... arguments)Asynchronously invokes anCacheEntryProcessoragainst theCache.Entryspecified by the provided key.booleanisAsync()booleanisClosed()booleanisLocalLocked(K key, boolean byCurrThread)Checks if specified key is locked.booleanisProxyClosed()Iterator<javax.cache.Cache.Entry<K,V>>iterator()<K1,V1>
GatewayProtectedCacheProxy<K1,V1>keepBinary()Creates projection that will operate with binary objects.voidloadAll(Set<? extends K> keys, boolean replaceExisting, javax.cache.integration.CompletionListener completionListener)voidloadCache(@Nullable IgniteBiPredicate<K,V> p, @Nullable Object... args)ExecutesIgniteCache.localLoadCache(IgniteBiPredicate, Object...)on all cache nodes.IgniteFuture<Void>loadCacheAsync(@Nullable IgniteBiPredicate<K,V> p, @Nullable Object... args)Asynchronously executesIgniteCache.localLoadCache(IgniteBiPredicate, Object...)on all cache nodes.voidlocalClear(K key)Clears entry from the cache and swap storage, without notifying listeners orCacheWriters.voidlocalClearAll(Set<? extends K> keys)Clears entries from the cache and swap storage, without notifying listeners orCacheWriters.Iterable<javax.cache.Cache.Entry<K,V>>localEntries(CachePeekMode... peekModes)Allows for iteration over local cache entries.voidlocalEvict(Collection<? extends K> keys)Attempts to evict all entries associated with keys.voidlocalLoadCache(@Nullable IgniteBiPredicate<K,V> p, @Nullable Object... args)Delegates toCacheStore.loadCache(IgniteBiInClosure,Object...)method to load state from the underlying persistent storage.IgniteFuture<Void>localLoadCacheAsync(@Nullable IgniteBiPredicate<K,V> p, @Nullable Object... args)Asynchronously loads state from the underlying persistent storage by delegating toCacheStore.loadCache(IgniteBiInClosure,Object...)method.CacheMetricslocalMetrics()Gets local snapshot metrics (statistics) for this cache.VlocalPeek(K key, CachePeekMode... peekModes)Peeks at a value in the local storage using an optional peek mode.booleanlocalPreloadPartition(int part)Efficiently preloads cache partition into page memory if it exists on the local node.intlocalSize(CachePeekMode... peekModes)Gets the number of all entries cached on this node.longlocalSizeLong(int partition, CachePeekMode... peekModes)Gets the number of all entries cached on this node for the partition as a long value.longlocalSizeLong(CachePeekMode... peekModes)Gets the number of all entries cached on this node as a long value.Locklock(K key)Creates aLockinstance associated with passed key.LocklockAll(Collection<? extends K> keys)Creates aLockinstance associated with passed keys.Collection<Integer>lostPartitions()Gets a collection of lost partition IDs.CacheMetricsmetrics()Gets whole cluster snapshot metrics (statistics) for this cache.CacheMetricsmetrics(ClusterGroup grp)Gets cluster group snapshot metrics for caches in cluster group.voidpreloadPartition(int part)Efficiently preloads cache primary partition into page memory.IgniteFuture<Void>preloadPartitionAsync(int part)Efficiently preloads cache partition into page memory.voidput(K key, V val)voidputAll(Map<? extends K,? extends V> map)IgniteFuture<Void>putAllAsync(Map<? extends K,? extends V> map)Asynchronously copies all of the entries from the specified map to theCache.IgniteFuture<Void>putAsync(K key, V val)Asynchronously associates the specified value with the specified key in the cache.booleanputIfAbsent(K key, V val)IgniteFuture<Boolean>putIfAbsentAsync(K key, V val)Asynchronously associates the specified key with the given value if it is not already associated with a value.<R> QueryCursor<R>query(Query<R> qry)Queries cache.<T,R>
QueryCursor<R>query(Query<T> qry, IgniteClosure<T,R> transformer)Queries the cache transforming the entries on the server nodes.FieldsQueryCursor<List<?>>query(SqlFieldsQuery qry)Queries cache.Collection<? extends QueryDetailMetrics>queryDetailMetrics()Gets query detail metrics.QueryMetricsqueryMetrics()Gets query metrics.List<FieldsQueryCursor<List<?>>>queryMultipleStatements(SqlFieldsQuery qry)Queries cache with multiple statements.voidreadExternal(ObjectInput in)IgniteFuture<Boolean>rebalance()This cache node to re-balance its partitions.voidregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)booleanremove(K key)booleanremove(K key, V oldVal)voidremoveAll()Removes all of the mappings from this cache.voidremoveAll(Set<? extends K> keys)IgniteFuture<Void>removeAllAsync()Asynchronously removes all of the mappings from this cache.IgniteFuture<Void>removeAllAsync(Set<? extends K> keys)Asynchronously removes entries for the specified keys.IgniteFuture<Boolean>removeAsync(K key)Asynchronously removes the mapping for a key from this cache if it is present.IgniteFuture<Boolean>removeAsync(K key, V oldVal)Asynchronously removes the mapping for a key only if currently mapped to the given value.booleanreplace(K key, V val)booleanreplace(K key, V oldVal, V newVal)IgniteFuture<Boolean>replaceAsync(K key, V val)Asynchronously replaces the entry for a key only if currently mapped to a given value.IgniteFuture<Boolean>replaceAsync(K key, V oldVal, V newVal)Asynchronous version of theIgniteCache.replace(Object, Object, Object).voidresetQueryDetailMetrics()Reset query detail metrics.voidresetQueryMetrics()Reset query metrics.voidsetCacheManager(CacheManager cacheMgr)Sets CacheManager to delegate.intsize(CachePeekMode... peekModes)Gets the number of all entries cached across all nodes.IgniteFuture<Integer>sizeAsync(CachePeekMode... peekModes)Asynchronously gets the number of all entries cached across all nodes.longsizeLong(int partition, CachePeekMode... peekModes)Gets the number of all entries cached in a partition as a long value.longsizeLong(CachePeekMode... peekModes)Gets the number of all entries cached across all nodes as a long value.IgniteFuture<Long>sizeLongAsync(int partition, CachePeekMode... peekModes)Asynchronously gets the number of all entries cached in a partition as a long value.IgniteFuture<Long>sizeLongAsync(CachePeekMode... peekModes)Asynchronously gets the number of all entries cached across all nodes as a long value.GatewayProtectedCacheProxy<K,V>skipStore()<T> Tunwrap(Class<T> clazz)IgniteCache<K,V>withAsync()Gets instance of this component with asynchronous mode enabled.GatewayProtectedCacheProxy<K,V>withDataCenterId(byte dataCenterId)GatewayProtectedCacheProxy<K,V>withExpiryPolicy(javax.cache.expiry.ExpiryPolicy plc)Returns cache with the specified expired policy set.<K1,V1>
GatewayProtectedCacheProxy<K1,V1>withKeepBinary()Returns cache that will operate with binary objects.GatewayProtectedCacheProxy<K,V>withNoRetries()GatewayProtectedCacheProxy<K,V>withPartitionRecover()Gets an instance ofIgniteCachethat will be allowed to execute cache read operations regardless of partition loss policy.IgniteCache<K,V>withReadRepair(ReadRepairStrategy strategy)This is an experimental API.GatewayProtectedCacheProxy<K,V>withSkipStore()voidwriteExternal(ObjectOutput out)-
Methods inherited from class org.apache.ignite.internal.AsyncSupportAdapter
createAsyncInstance, createFuture, future, saveOrGet
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
GatewayProtectedCacheProxy
public GatewayProtectedCacheProxy()
Empty constructor required forExternalizable.
-
GatewayProtectedCacheProxy
public GatewayProtectedCacheProxy(@NotNull @NotNull IgniteCacheProxy<K,V> delegate, @NotNull @NotNull CacheOperationContext opCtx, boolean lock)- Parameters:
delegate- Cache proxy delegate.opCtx- Cache operation context.lock- True if cache proxy should be protected with gateway lock, false in other case.
-
-
Method Detail
-
setCacheManager
public void setCacheManager(CacheManager cacheMgr)
Sets CacheManager to delegate.- Parameters:
cacheMgr- Cache Manager.
-
context
public GridCacheContext<K,V> context()
- Specified by:
contextin interfaceIgniteCacheProxy<K,V>- Returns:
- Context.
-
getConfiguration
public <C extends javax.cache.configuration.Configuration<K,V>> C getConfiguration(Class<C> clazz)
- Specified by:
getConfigurationin interfacejavax.cache.Cache<K,V>- Specified by:
getConfigurationin interfaceIgniteCache<K,V>
-
getCacheManager
public javax.cache.CacheManager getCacheManager()
-
internalProxy
public GridCacheProxyImpl<K,V> internalProxy()
- Specified by:
internalProxyin interfaceIgniteCacheProxy<K,V>- Returns:
- Internal proxy.
-
cacheNoGate
public GatewayProtectedCacheProxy<K,V> cacheNoGate()
Gets cache proxy which does not acquire read lock on gateway enter, should be used only if grid read lock is externally acquired.- Specified by:
cacheNoGatein interfaceIgniteCacheProxy<K,V>- Returns:
- Ignite cache proxy with simple gate.
-
withExpiryPolicy
public GatewayProtectedCacheProxy<K,V> withExpiryPolicy(javax.cache.expiry.ExpiryPolicy plc)
Returns cache with the specified expired policy set. This policy will be used for each operation invoked on the returned cache.This method does not modify existing cache instance.
- Specified by:
withExpiryPolicyin interfaceIgniteCache<K,V>- Parameters:
plc- Expire policy to use.- Returns:
- Cache instance with the specified expiry policy set.
-
withSkipStore
public GatewayProtectedCacheProxy<K,V> withSkipStore()
- Specified by:
withSkipStorein interfaceIgniteCache<K,V>- Returns:
- Cache with read-through write-through behavior disabled.
-
skipStore
public GatewayProtectedCacheProxy<K,V> skipStore()
- Specified by:
skipStorein interfaceIgniteCacheProxy<K,V>- Returns:
- Cache with skip store enabled.
-
withNoRetries
public GatewayProtectedCacheProxy<K,V> withNoRetries()
- Specified by:
withNoRetriesin interfaceIgniteCache<K,V>- Returns:
- Cache with no-retries behavior enabled.
-
withPartitionRecover
public GatewayProtectedCacheProxy<K,V> withPartitionRecover()
Gets an instance ofIgniteCachethat will be allowed to execute cache read operations regardless of partition loss policy.- Specified by:
withPartitionRecoverin interfaceIgniteCache<K,V>- Returns:
- Cache without partition loss protection.
-
withReadRepair
public IgniteCache<K,V> withReadRepair(ReadRepairStrategy strategy)
This is an experimental API.Gets an instance of
IgniteCachethat will perform backup nodes check on each get attempt.Read Repair means that each backup node will be checked to have the same entry as the primary node has.
In case consistency violations were found, the values across the topology will be replaced by repaired values according to the chosen strategy, see
ReadRepairStrategyfor the details.A consistency violation exception will be thrown when the repair is impossible.
CacheConsistencyViolationEventwill be recorded for each violation in case it's configured as recordable.- For transactional caches, values will be repaired:
- automatically for transactions that have
TransactionConcurrency.OPTIMISTICconcurrency mode orTransactionIsolation.READ_COMMITTEDisolation level, - at commit() phase for transactions that have
TransactionConcurrency.PESSIMISTICconcurrency mode and isolation level other thanTransactionIsolation.READ_COMMITTED
This proxy usage does not guarantee "all copies check" in case the value have been already cached inside the transaction. In case you don't use a READ_COMMITTED isolation mode and already have a cached value, for example have already read the value or performed a write, you'll just get the cached value.
- automatically for transactions that have
- For atomic caches, values will be repaired automatically.
Warning:
Due to the nature of an atomic cache, false-positive results can be observed. For example, an attempt to check consistency under cache's loading may lead to a consistency violation exception. By default, the implementation tries to check the given key three times. The number of attempts can be changed using
IgniteSystemProperties.IGNITE_NEAR_GET_MAX_REMAPSproperty.
- Caches without backups.
- Near caches.
- Caches that use "read-through" mode.
Full list of repairable methods:
IgniteCache.containsKey(K)&&IgniteCache.containsKeyAsync(K)IgniteCache.containsKeys(java.util.Set<? extends K>)&&IgniteCache.containsKeysAsync(java.util.Set<? extends K>)IgniteCache.getEntry(K)&&IgniteCache.getEntryAsync(K)IgniteCache.getEntries(java.util.Set<? extends K>)&&IgniteCache.getEntriesAsync(java.util.Set<? extends K>)IgniteCache.get(K)&&IgniteCache.getAsync(K)IgniteCache.getAll(java.util.Set<? extends K>)&&IgniteCache.getAllAsync(java.util.Set<? extends K>)
- Specified by:
withReadRepairin interfaceIgniteCache<K,V>- Parameters:
strategy- Read Repair strategy.- Returns:
- Cache with explicit consistency check on each read and repair if necessary.
- For transactional caches, values will be repaired:
-
withKeepBinary
public <K1,V1> GatewayProtectedCacheProxy<K1,V1> withKeepBinary()
Returns cache that will operate with binary objects.Cache returned by this method will not be forced to deserialize binary objects, so keys and values will be returned from cache API methods without changes. Therefore, signature of the cache can contain only following types:
org.apache.ignite.binary.BinaryObjectfor binary classes- All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)
- Arrays of primitives (byte[], int[], ...)
Stringand array ofStringsUUIDand array ofUUIDsDateand array ofDatesTimestampand array ofTimestamps- Enums and array of enums
- Maps, collections and array of objects (but objects inside them will still be converted if they are binary)
For example, if you use
Integeras a key andValueclass as a value (which will be stored in binary format), you should acquire following projection to avoid deserialization:IgniteCache<Integer, BinaryObject> prj = cache.withKeepBinary(); // Value is not deserialized and returned in binary format. BinaryObject po = prj.get(1);
Note that this method makes sense only if cache is working in binary mode if default marshaller is used. If not, this method is no-op and will return current cache.
- Specified by:
withKeepBinaryin interfaceIgniteCache<K,V>- Type Parameters:
K1- Type of the cache key.V1- Type of the cache value binary objects.- Returns:
- New cache instance for binary objects.
-
keepBinary
public <K1,V1> GatewayProtectedCacheProxy<K1,V1> keepBinary()
Creates projection that will operate with binary objects.Projection returned by this method will force cache not to deserialize binary objects, so keys and values will be returned from cache API methods without changes. Therefore, signature of the projection can contain only following types:
BinaryObjectfor binary classes- All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)
- Arrays of primitives (byte[], int[], ...)
Stringand array ofStringsUUIDand array ofUUIDsDateand array ofDatesTimestampand array ofTimestamps- Enums and array of enums
- Maps, collections and array of objects (but objects inside them will still be converted if they are binary)
For example, if you use
Integeras a key andValueclass as a value (which will be stored in binary format), you should acquire following projection to avoid deserialization:IgniteInternalCache
prj = cache.keepBinary(); // Value is not deserialized and returned in binary format. GridBinaryObject po = prj.get(1); Note that this method makes sense only if cache is working in binary mode (
CacheConfiguration#isBinaryEnabled()returnstrue. If not, this method is no-op and will return current projection.- Specified by:
keepBinaryin interfaceIgniteCacheProxy<K,V>- Returns:
- Projection for binary objects.
-
withDataCenterId
public GatewayProtectedCacheProxy<K,V> withDataCenterId(byte dataCenterId)
- Specified by:
withDataCenterIdin interfaceIgniteCacheProxy<K,V>- Parameters:
dataCenterId- Data center ID.- Returns:
- Projection for data center id.
-
loadCache
public void loadCache(@Nullable @Nullable IgniteBiPredicate<K,V> p, @Nullable @Nullable Object... args) throws javax.cache.CacheExceptionExecutesIgniteCache.localLoadCache(IgniteBiPredicate, Object...)on all cache nodes.- Specified by:
loadCachein interfaceIgniteCache<K,V>- Parameters:
p- Optional predicate (may benull). If provided, will be used to filter values loaded from storage before they are put into cache.args- Optional user arguments to be passed intoCacheStore.loadCache(IgniteBiInClosure, Object...)method.- Throws:
javax.cache.CacheException- If loading failed.
-
loadCacheAsync
public IgniteFuture<Void> loadCacheAsync(@Nullable @Nullable IgniteBiPredicate<K,V> p, @Nullable @Nullable Object... args) throws javax.cache.CacheException
Asynchronously executesIgniteCache.localLoadCache(IgniteBiPredicate, Object...)on all cache nodes.- Specified by:
loadCacheAsyncin interfaceIgniteCache<K,V>- Parameters:
p- Optional predicate (may benull). If provided, will be used to filter values loaded from storage before they are put into cache.args- Optional user arguments to be passed intoCacheStore.loadCache(IgniteBiInClosure, Object...)method.- Returns:
- a Future representing pending completion of the cache loading.
- Throws:
javax.cache.CacheException- If loading failed.
-
localLoadCache
public void localLoadCache(@Nullable @Nullable IgniteBiPredicate<K,V> p, @Nullable @Nullable Object... args) throws javax.cache.CacheExceptionDelegates toCacheStore.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 returnstrue, will be stored in cache. If predicate isnull, 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
CacheStoreimplementation 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.
- Specified by:
localLoadCachein interfaceIgniteCache<K,V>- Parameters:
p- Optional predicate (may benull). If provided, will be used to filter values to be put into cache.args- Optional user arguments to be passed intoCacheStore.loadCache(IgniteBiInClosure, Object...)method.- Throws:
javax.cache.CacheException- If loading failed.
-
localLoadCacheAsync
public IgniteFuture<Void> localLoadCacheAsync(@Nullable @Nullable IgniteBiPredicate<K,V> p, @Nullable @Nullable Object... args) throws javax.cache.CacheException
Asynchronously loads state from the underlying persistent storage by delegating toCacheStore.loadCache(IgniteBiInClosure,Object...)method. The loaded values will then be given to the optionally passed in predicate, and, if the predicate returnstrue, will be stored in cache. If predicate isnull, 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
CacheStoreimplementation 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.
- Specified by:
localLoadCacheAsyncin interfaceIgniteCache<K,V>- Parameters:
p- Optional predicate (may benull). If provided, will be used to filter values to be put into cache.args- Optional user arguments to be passed intoCacheStore.loadCache(IgniteBiInClosure, Object...)method.- Returns:
- a Future representing pending completion of the cache loading.
- Throws:
javax.cache.CacheException- If loading failed.
-
getAndPutIfAbsent
public V getAndPutIfAbsent(K key, V val) throws javax.cache.CacheException, TransactionException
Stores given key-value pair in cache only if cache had no previous mapping for it. If cache previously contained value for the given key, then this value is returned. In case ofCacheMode.PARTITIONEDorCacheMode.REPLICATEDcaches, 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
CacheStoreviaCacheWriter.write(javax.cache.Cache.Entry)method.Transactions
This method is transactional and will enlist the entry into ongoing transaction if there is one.- Specified by:
getAndPutIfAbsentin interfaceIgniteCache<K,V>- Parameters:
key- Key to store in cache.val- Value to be associated with the given key.- Returns:
- Previously contained value regardless of whether put happened or not (
nullif there was no previous value). - Throws:
javax.cache.CacheException- If put operation failed.TransactionException- If operation within transaction is failed.
-
getAndPutIfAbsentAsync
public IgniteFuture<V> getAndPutIfAbsentAsync(K key, V val) throws javax.cache.CacheException, TransactionException
Asynchronously stores given key-value pair in cache only if cache had no previous mapping for it. If cache previously contained value for the given key, then this value is returned. In case ofCacheMode.PARTITIONEDorCacheMode.REPLICATEDcaches, 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.putIfAbsentAsync(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
CacheStoreviaCacheWriter.write(javax.cache.Cache.Entry)method.Transactions
This method is transactional and will enlist the entry into ongoing transaction if there is one.- Specified by:
getAndPutIfAbsentAsyncin interfaceIgniteCache<K,V>- Parameters:
key- Key to store in cache.val- Value to be associated with the given key.- Returns:
- a Future representing pending completion of the operation.
- Throws:
javax.cache.CacheException- If put operation failed.TransactionException- If operation within transaction is failed.
-
lock
public Lock lock(K key)
Creates aLockinstance associated with passed key. This method does not acquire lock immediately, you have to call appropriate method on returned instance. Returned lock does not supportLock.newCondition()method, other methods defined inLockare supported.- Specified by:
lockin interfaceIgniteCache<K,V>- Parameters:
key- Key for lock.- Returns:
- New lock instance associated with passed key.
- See Also:
Lock.lock(),Lock.tryLock(long, TimeUnit)
-
lockAll
public Lock lockAll(Collection<? extends K> keys)
Creates aLockinstance associated with passed keys. This method does not acquire lock immediately, you have to call appropriate method on returned instance. Returned lock does not supportLock.newCondition()method, other methods defined inLockare supported.- Specified by:
lockAllin interfaceIgniteCache<K,V>- Parameters:
keys- Keys for lock.- Returns:
- New lock instance associated with passed key.
- See Also:
Lock.lock(),Lock.tryLock(long, TimeUnit)
-
isLocalLocked
public boolean isLocalLocked(K key, boolean byCurrThread)
Checks if specified key is locked.This is a local in-VM operation and does not involve any network trips or access to persistent storage in any way.
- Specified by:
isLocalLockedin interfaceIgniteCache<K,V>- Parameters:
key- Key to check.byCurrThread- Iftruemethod will check that current thread owns a lock on this key, otherwise will check that any thread on any node owns a lock on this key.- Returns:
Trueif lock is owned by some node.
-
query
public <R> QueryCursor<R> query(Query<R> qry)
Queries cache. Accepts any subclass ofQueryinterface. See alsoIgniteCache.query(SqlFieldsQuery).- Specified by:
queryin interfaceIgniteCache<K,V>- Type Parameters:
R- Type of the query result.- Parameters:
qry- Query.- Returns:
- Cursor.
- See Also:
ScanQuery,SqlFieldsQuery,TextQuery,SpiQuery
-
query
public FieldsQueryCursor<List<?>> query(SqlFieldsQuery qry)
Queries cache. AcceptsSqlFieldsQueryclass.- Specified by:
queryin interfaceIgniteCache<K,V>- Parameters:
qry- SqlFieldsQuery.- Returns:
- Cursor.
- See Also:
SqlFieldsQuery
-
queryMultipleStatements
public List<FieldsQueryCursor<List<?>>> queryMultipleStatements(SqlFieldsQuery qry)
Queries cache with multiple statements. AcceptsSqlFieldsQueryclass.- Specified by:
queryMultipleStatementsin interfaceIgniteCacheProxy<K,V>- Parameters:
qry- SqlFieldsQuery.- Returns:
- List of cursors.
- See Also:
SqlFieldsQuery
-
query
public <T,R> QueryCursor<R> query(Query<T> qry, IgniteClosure<T,R> transformer)
Queries the cache transforming the entries on the server nodes. Can be used, for example, to avoid network overhead in case only one field out of the large is required by client.Currently transformers are supported ONLY for
ScanQuery. Passing any other subclass ofQueryinterface to this method will end up withUnsupportedOperationException.- Specified by:
queryin interfaceIgniteCache<K,V>- Type Parameters:
T- Type of the initial query result.R- Type of the transformed query result.- Parameters:
qry- Query.transformer- Transformer.- Returns:
- Cursor.
-
localEntries
public Iterable<javax.cache.Cache.Entry<K,V>> localEntries(CachePeekMode... peekModes) throws javax.cache.CacheException
Allows for iteration over local cache entries.- Specified by:
localEntriesin interfaceIgniteCache<K,V>- Parameters:
peekModes- Peek modes.- Returns:
- Iterable over local cache entries.
- Throws:
javax.cache.CacheException- If failed.
-
queryMetrics
public QueryMetrics queryMetrics()
Gets query metrics.- Specified by:
queryMetricsin interfaceIgniteCache<K,V>- Returns:
- Metrics.
-
resetQueryMetrics
public void resetQueryMetrics()
Reset query metrics.- Specified by:
resetQueryMetricsin interfaceIgniteCache<K,V>
-
queryDetailMetrics
public Collection<? extends QueryDetailMetrics> queryDetailMetrics()
Gets query detail metrics. Query detail metrics could be enabled viaCacheConfiguration.setQueryDetailMetricsSize(int)method.- Specified by:
queryDetailMetricsin interfaceIgniteCache<K,V>- Returns:
- Metrics.
-
resetQueryDetailMetrics
public void resetQueryDetailMetrics()
Reset query detail metrics.- Specified by:
resetQueryDetailMetricsin interfaceIgniteCache<K,V>
-
localEvict
public void localEvict(Collection<? extends K> keys)
Attempts to evict all entries associated with keys. Note, that entry will be evicted only if it's not used (not participating in any locks or transactions).- Specified by:
localEvictin interfaceIgniteCache<K,V>- Parameters:
keys- Keys to evict.
-
localPeek
public V localPeek(K key, CachePeekMode... peekModes)
Peeks at a value in the local storage using an optional peek mode.This method will not load a value from the configured
CacheStoreor from a remote node.Transactions
This method does not participate in any transactions.- Specified by:
localPeekin interfaceIgniteCache<K,V>- Parameters:
key- Entry key.peekModes- Peek modes.- Returns:
- Peeked value, or
nullif not found.
-
size
public int size(CachePeekMode... peekModes) throws javax.cache.CacheException
Gets the number of all entries cached across all nodes. By default, ifpeekModesvalue isn't defined, only size of primary copies across all nodes will be returned. This behavior is identical to calling this method withCachePeekMode.PRIMARYpeek mode.NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
- Specified by:
sizein interfaceIgniteCache<K,V>- Parameters:
peekModes- Optional peek modes. If not provided, then total cache size is returned.- Returns:
- Cache size across all nodes.
- Throws:
javax.cache.CacheException- On error.
-
sizeAsync
public IgniteFuture<Integer> sizeAsync(CachePeekMode... peekModes) throws javax.cache.CacheException
Asynchronously gets the number of all entries cached across all nodes. By default, ifpeekModesvalue isn't defined, only size of primary copies across all nodes will be returned. This behavior is identical to calling this method withCachePeekMode.PRIMARYpeek mode.NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
- Specified by:
sizeAsyncin interfaceIgniteCache<K,V>- Parameters:
peekModes- Optional peek modes. If not provided, then total cache size is returned.- Returns:
- a Future representing pending completion of the operation.
- Throws:
javax.cache.CacheException- On error.
-
sizeLong
public long sizeLong(CachePeekMode... peekModes) throws javax.cache.CacheException
Gets the number of all entries cached across all nodes as a long value. By default, ifpeekModesvalue isn't defined, only size of primary copies across all nodes will be returned. This behavior is identical to calling this method withCachePeekMode.PRIMARYpeek mode.NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
- Specified by:
sizeLongin interfaceIgniteCache<K,V>- Parameters:
peekModes- Optional peek modes. If not provided, then total cache size is returned.- Returns:
- Cache size across all nodes.
- Throws:
javax.cache.CacheException- On error.
-
sizeLongAsync
public IgniteFuture<Long> sizeLongAsync(CachePeekMode... peekModes) throws javax.cache.CacheException
Asynchronously gets the number of all entries cached across all nodes as a long value. By default, ifpeekModesvalue isn't defined, only size of primary copies across all nodes will be returned. This behavior is identical to calling this method withCachePeekMode.PRIMARYpeek mode.NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
- Specified by:
sizeLongAsyncin interfaceIgniteCache<K,V>- Parameters:
peekModes- Optional peek modes. If not provided, then total cache size is returned.- Returns:
- a Future representing pending completion of the operation.
- Throws:
javax.cache.CacheException- On error.
-
sizeLong
public long sizeLong(int partition, CachePeekMode... peekModes) throws javax.cache.CacheExceptionGets the number of all entries cached in a partition as a long value. By default, ifpeekModesvalue isn't defined, only size of primary copies across all nodes will be returned. This behavior is identical to calling this method withCachePeekMode.PRIMARYpeek mode.NOTE: this operation is distributed and will query all participating nodes for their partition cache sizes.
- Specified by:
sizeLongin interfaceIgniteCache<K,V>- Parameters:
partition- partition.peekModes- Optional peek modes. If not provided, then total partition cache size is returned.- Returns:
- Partition cache size across all nodes.
- Throws:
javax.cache.CacheException- On error.
-
sizeLongAsync
public IgniteFuture<Long> sizeLongAsync(int partition, CachePeekMode... peekModes) throws javax.cache.CacheException
Asynchronously gets the number of all entries cached in a partition as a long value. By default, ifpeekModesvalue isn't defined, only size of primary copies across all nodes will be returned. This behavior is identical to calling this method withCachePeekMode.PRIMARYpeek mode.NOTE: this operation is distributed and will query all participating nodes for their partition cache sizes.
- Specified by:
sizeLongAsyncin interfaceIgniteCache<K,V>- Parameters:
partition- partition.peekModes- Optional peek modes. If not provided, then total partition cache size is returned.- Returns:
- a Future representing pending completion of the operation.
- Throws:
javax.cache.CacheException- On error.
-
localSize
public int localSize(CachePeekMode... peekModes)
Gets the number of all entries cached on this node. By default, ifpeekModesvalue isn't defined, only size of primary copies will be returned. This behavior is identical to calling this method withCachePeekMode.PRIMARYpeek mode.- Specified by:
localSizein interfaceIgniteCache<K,V>- Parameters:
peekModes- Optional peek modes. If not provided, then total cache size is returned.- Returns:
- Cache size on this node.
-
localSizeLong
public long localSizeLong(CachePeekMode... peekModes)
Gets the number of all entries cached on this node as a long value. By default, ifpeekModesvalue isn't defined, only size of primary copies will be returned. This behavior is identical to calling this method withCachePeekMode.PRIMARYpeek mode.- Specified by:
localSizeLongin interfaceIgniteCache<K,V>- Parameters:
peekModes- Optional peek modes. If not provided, then total cache size is returned.- Returns:
- Cache size on this node.
-
localSizeLong
public long localSizeLong(int partition, CachePeekMode... peekModes)Gets the number of all entries cached on this node for the partition as a long value. By default, ifpeekModesvalue isn't defined, only size of primary copies will be returned. This behavior is identical to calling this method withCachePeekMode.PRIMARYpeek mode.- Specified by:
localSizeLongin interfaceIgniteCache<K,V>- Parameters:
partition- partition.peekModes- Optional peek modes. If not provided, then total cache size is returned.- Returns:
- Cache size on this node.
-
invokeAll
public <T> Map<K,javax.cache.processor.EntryProcessorResult<T>> invokeAll(Map<? extends K,? extends javax.cache.processor.EntryProcessor<K,V,T>> map, Object... args) throws TransactionException
Asynchronously invokes eachEntryProcessorfrom map's values against the correspondentCache.Entryspecified by map's key set.If an
Cache.Entrydoes not exist for the specified key, an attempt is made to load it (if a loader is configured) or a surrogateCache.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
EntryProcessorinstance to process each entry, as the case may be in a non-local cache topology.The result of executing the
EntryProcessoris returned in the future as aMapofEntryProcessorResults, one result per key. Should theEntryProcessoror Caching implementation throw an exception, the exception is wrapped and re-thrown when a call toEntryProcessorResult.get()is made.Please refer to documentation for
CacheAtomicityMode.ATOMICfor information on system behavior in crash scenarios for atomic caches.Keys are locked in the order in which they appear in map. It is caller's responsibility to make sure keys always follow same order, such as by using
TreeMap. Using unordered map, such asHashMap, while calling this method in parallel will lead to deadlock.- Specified by:
invokeAllin interfaceIgniteCache<K,V>- Type Parameters:
T- Type of the cache entry processing result.- Parameters:
map- Map containing keys and entry processors to be applied to values.args- Additional arguments to pass to theEntryProcessor.- Returns:
- The map of
EntryProcessorResults of the processing per key, if any, defined by theEntryProcessorimplementation. No mappings will be returned forEntryProcessors that return anullvalue for a key. - Throws:
TransactionException- If operation within transaction is failed.
-
invokeAllAsync
public <T> IgniteFuture<Map<K,javax.cache.processor.EntryProcessorResult<T>>> invokeAllAsync(Map<? extends K,? extends javax.cache.processor.EntryProcessor<K,V,T>> map, Object... args) throws TransactionException
Asynchronous version of theIgniteCache.invokeAll(Map, Object...)method.- Specified by:
invokeAllAsyncin interfaceIgniteCache<K,V>- Type Parameters:
T- Type of the cache entry processing result.- Parameters:
map- Map containing keys and entry processors to be applied to values.args- Additional arguments to pass to theEntryProcessor.- Returns:
- a Future representing pending completion of the operation. See more about future result
at the
IgniteCache.invokeAll(Map, Object...). - Throws:
TransactionException- If operation within transaction is failed.
-
get
public V get(K key) throws TransactionException
- Specified by:
getin interfacejavax.cache.Cache<K,V>- Specified by:
getin interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
getAsync
public IgniteFuture<V> getAsync(K key)
Asynchronously gets an entry from the cache.If the cache is configured to use read-through, and a future result would be null because the entry is missing from the cache, the Cache's
CacheLoaderis called in an attempt to load the entry.- Specified by:
getAsyncin interfaceIgniteCache<K,V>- Parameters:
key- Key.- Returns:
- a Future representing pending completion of the operation.
-
getEntry
public CacheEntry<K,V> getEntry(K key) throws TransactionException
Gets an entry from the cache.If the cache is configured to use read-through, and get would return null because the entry is missing from the cache, the Cache's
CacheLoaderis called in an attempt to load the entry.- Specified by:
getEntryin interfaceIgniteCache<K,V>- Parameters:
key- The key whose associated value is to be returned.- Returns:
- The element, or null, if it does not exist.
- Throws:
TransactionException- If operation within transaction is failed.
-
getEntryAsync
public IgniteFuture<CacheEntry<K,V>> getEntryAsync(K key) throws TransactionException
Asynchronously gets an entry from the cache.If the cache is configured to use read-through, and a future result would be null because the entry is missing from the cache, the Cache's
CacheLoaderis called in an attempt to load the entry.- Specified by:
getEntryAsyncin interfaceIgniteCache<K,V>- Parameters:
key- The key whose associated value is to be returned.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
getAll
public Map<K,V> getAll(Set<? extends K> keys) throws TransactionException
- Specified by:
getAllin interfacejavax.cache.Cache<K,V>- Specified by:
getAllin interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
getAllAsync
public IgniteFuture<Map<K,V>> getAllAsync(Set<? extends K> keys) throws TransactionException
Asynchronously gets a collection of entries from theCache, returning them asMapof the values associated with the set of keys requested.If the cache is configured read-through, and a future result for a key would be null because an entry is missing from the cache, the Cache's
CacheLoaderis called in an attempt to load the entry. If an entry cannot be loaded for a given key, the key will not be present in the returned Map.- Specified by:
getAllAsyncin interfaceIgniteCache<K,V>- Parameters:
keys- Keys set.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
getEntries
public Collection<CacheEntry<K,V>> getEntries(Set<? extends K> keys) throws TransactionException
Gets a collection of entries from theCache.If the cache is configured read-through, and a get for a key would return null because an entry is missing from the cache, the Cache's
CacheLoaderis called in an attempt to load the entry. If an entry cannot be loaded for a given key, the key will not be present in the returned Collection.- Specified by:
getEntriesin interfaceIgniteCache<K,V>- Parameters:
keys- The keys whose associated values are to be returned.- Returns:
- A collection of entries that were found for the given keys. Entries not found in the cache are not in the returned collection.
- Throws:
TransactionException- If operation within transaction is failed.
-
getEntriesAsync
public IgniteFuture<Collection<CacheEntry<K,V>>> getEntriesAsync(Set<? extends K> keys) throws TransactionException
Asynchronously gets a collection of entries from theCache.If the cache is configured read-through, and a future result for a key would be null because an entry is missing from the cache, the Cache's
CacheLoaderis called in an attempt to load the entry. If an entry cannot be loaded for a given key, the key will not be present in the returned Collection.- Specified by:
getEntriesAsyncin interfaceIgniteCache<K,V>- Parameters:
keys- The keys whose associated values are to be returned.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
getAllOutTx
public Map<K,V> getAllOutTx(Set<? extends K> keys)
Gets values from cache. Will bypass started transaction, if any, i.e. will not enlist entries and will not lock any keys if pessimistic transaction is started by thread.- Specified by:
getAllOutTxin interfaceIgniteCache<K,V>- Parameters:
keys- The keys whose associated values are to be returned.- Returns:
- A map of entries that were found for the given keys.
-
getAllOutTxAsync
public IgniteFuture<Map<K,V>> getAllOutTxAsync(Set<? extends K> keys)
Asynchronously gets values from cache. Will bypass started transaction, if any, i.e. will not enlist entries and will not lock any keys if pessimistic transaction is started by thread.- Specified by:
getAllOutTxAsyncin interfaceIgniteCache<K,V>- Parameters:
keys- The keys whose associated values are to be returned.- Returns:
- a Future representing pending completion of the operation.
-
containsKey
public boolean containsKey(K key) throws TransactionException
- Specified by:
containsKeyin interfacejavax.cache.Cache<K,V>- Specified by:
containsKeyin interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
loadAll
public void loadAll(Set<? extends K> keys, boolean replaceExisting, javax.cache.integration.CompletionListener completionListener)
-
containsKeyAsync
public IgniteFuture<Boolean> containsKeyAsync(K key) throws TransactionException
Asynchronously determines if theCachecontains an entry for the specified key.More formally, future result is true if and only if this cache contains a mapping for a key k such that key.equals(k). (There can be at most one such mapping.)
- Specified by:
containsKeyAsyncin interfaceIgniteCache<K,V>- Parameters:
key- Key.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
containsKeys
public boolean containsKeys(Set<? extends K> keys) throws TransactionException
Determines if theCachecontains entries for the specified keys.- Specified by:
containsKeysin interfaceIgniteCache<K,V>- Parameters:
keys- Key whose presence in this cache is to be tested.- Returns:
Trueif this cache contains a mapping for the specified keys.- Throws:
TransactionException- If operation within transaction is failed.
-
containsKeysAsync
public IgniteFuture<Boolean> containsKeysAsync(Set<? extends K> keys) throws TransactionException
Asynchronously determines if theCachecontains entries for the specified keys.- Specified by:
containsKeysAsyncin interfaceIgniteCache<K,V>- Parameters:
keys- Key whose presence in this cache is to be tested.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
put
public void put(K key, V val) throws TransactionException
- Specified by:
putin interfacejavax.cache.Cache<K,V>- Specified by:
putin interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
putAsync
public IgniteFuture<Void> putAsync(K key, V val) throws TransactionException
Asynchronously associates the specified value with the specified key in the cache.If the
Cachepreviously contained a mapping for the key, the old value is replaced by the specified value. (A cache c is said to contain a mapping for a key k if and only ifc.containsKey(k)would return true.)- Specified by:
putAsyncin interfaceIgniteCache<K,V>- Parameters:
key- Key.val- Value.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
getAndPut
public V getAndPut(K key, V val) throws TransactionException
- Specified by:
getAndPutin interfacejavax.cache.Cache<K,V>- Specified by:
getAndPutin interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
getAndPutAsync
public IgniteFuture<V> getAndPutAsync(K key, V val) throws TransactionException
Asynchronously associates the specified value with the specified key in this cache, returning an existing value if one existed as the future result.If the cache previously contained a mapping for the key, the old value is replaced by the specified value. (A cache c is said to contain a mapping for a key k if and only if
c.containsKey(k)would return true.)The previous value is returned as the future result, or future result is null if there was no value associated with the key previously.
- Specified by:
getAndPutAsyncin interfaceIgniteCache<K,V>- Parameters:
key- Key.val- Value.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
putAll
public void putAll(Map<? extends K,? extends V> map) throws TransactionException
Keys are locked in the order in which they appear in map. It is caller's responsibility to make sure keys always follow same order, such as by using
TreeMap. Using unordered map, such asHashMap, while calling this method in parallel will lead to deadlock.- Specified by:
putAllin interfacejavax.cache.Cache<K,V>- Specified by:
putAllin interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
putAllAsync
public IgniteFuture<Void> putAllAsync(Map<? extends K,? extends V> map) throws TransactionException
Asynchronously copies all of the entries from the specified map to theCache.The effect of this call is equivalent to that of calling
IgniteCache.putAsync(Object, Object)putAsync(k, v)} on this cache once for each mapping from key k to value v in the specified map.The order in which the individual puts occur is undefined.
The behavior of this operation is undefined if entries in the cache corresponding to entries in the map are modified or removed while this operation is in progress. or if map is modified while the operation is in progress.
In Default Consistency mode, individual puts occur atomically but not the entire putAll. Listeners may observe individual updates.
Keys are locked in the order in which they appear in map. It is caller's responsibility to make sure keys always follow same order, such as by using
TreeMap. Using unordered map, such asHashMap, while calling this method in parallel will lead to deadlock.- Specified by:
putAllAsyncin interfaceIgniteCache<K,V>- Parameters:
map- Map containing keys and values to put into the cache.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
putIfAbsent
public boolean putIfAbsent(K key, V val) throws TransactionException
For
CacheAtomicityMode.ATOMICreturn value on primary node crash may be incorrect because of the automatic retries. It is recommended to disable retries withIgniteCache.withNoRetries()and manually restore primary-backup consistency in case of update failure.- Specified by:
putIfAbsentin interfacejavax.cache.Cache<K,V>- Specified by:
putIfAbsentin interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
putIfAbsentAsync
public IgniteFuture<Boolean> putIfAbsentAsync(K key, V val)
Asynchronously associates the specified key with the given value if it is not already associated with a value.For
CacheAtomicityMode.ATOMICreturn value on primary node crash may be incorrect because of the automatic retries. It is recommended to disable retries withIgniteCache.withNoRetries()and manually restore primary-backup consistency in case of update failure.- Specified by:
putIfAbsentAsyncin interfaceIgniteCache<K,V>- Parameters:
key- Key.val- Value.- Returns:
- a Future representing pending completion of the operation.
-
remove
public boolean remove(K key) throws TransactionException
- Specified by:
removein interfacejavax.cache.Cache<K,V>- Specified by:
removein interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
removeAsync
public IgniteFuture<Boolean> removeAsync(K key) throws TransactionException
Asynchronously removes the mapping for a key from this cache if it is present.More formally, if this cache contains a mapping from key k to value v such that
(key==null ? k==null : key.equals(k)), that mapping is removed. (The cache can contain at most one such mapping.)A future result is true if this cache previously associated the key, or false if the cache contained no mapping for the key.
The cache will not contain a mapping for the specified key once the returned future is completed.
- Specified by:
removeAsyncin interfaceIgniteCache<K,V>- Parameters:
key- Key.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
remove
public boolean remove(K key, V oldVal) throws TransactionException
For
CacheAtomicityMode.ATOMICreturn value on primary node crash may be incorrect because of the automatic retries. It is recommended to disable retries withIgniteCache.withNoRetries()and manually restore primary-backup consistency in case of update failure.- Specified by:
removein interfacejavax.cache.Cache<K,V>- Specified by:
removein interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
removeAsync
public IgniteFuture<Boolean> removeAsync(K key, V oldVal) throws TransactionException
Asynchronously removes the mapping for a key only if currently mapped to the given value.For
CacheAtomicityMode.ATOMICreturn value on primary node crash may be incorrect because of the automatic retries. It is recommended to disable retries withIgniteCache.withNoRetries()and manually restore primary-backup consistency in case of update failure.- Specified by:
removeAsyncin interfaceIgniteCache<K,V>- Parameters:
key- Key.oldVal- Old value.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
getAndRemove
public V getAndRemove(K key) throws TransactionException
- Specified by:
getAndRemovein interfacejavax.cache.Cache<K,V>- Specified by:
getAndRemovein interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
getAndRemoveAsync
public IgniteFuture<V> getAndRemoveAsync(K key) throws TransactionException
Asynchronously removes the entry for a key only if currently mapped to some value.- Specified by:
getAndRemoveAsyncin interfaceIgniteCache<K,V>- Parameters:
key- Key.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
replace
public boolean replace(K key, V oldVal, V newVal) throws TransactionException
For
CacheAtomicityMode.ATOMICreturn value on primary node crash may be incorrect because of the automatic retries. It is recommended to disable retries withIgniteCache.withNoRetries()and manually restore primary-backup consistency in case of update failure.- Specified by:
replacein interfacejavax.cache.Cache<K,V>- Specified by:
replacein interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
replaceAsync
public IgniteFuture<Boolean> replaceAsync(K key, V oldVal, V newVal) throws TransactionException
Asynchronous version of theIgniteCache.replace(Object, Object, Object).For
CacheAtomicityMode.ATOMICreturn value on primary node crash may be incorrect because of the automatic retries. It is recommended to disable retries withIgniteCache.withNoRetries()and manually restore primary-backup consistency in case of update failure.- Specified by:
replaceAsyncin interfaceIgniteCache<K,V>- Parameters:
key- Key.oldVal- Old value.newVal- New value.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
replace
public boolean replace(K key, V val) throws TransactionException
- Specified by:
replacein interfacejavax.cache.Cache<K,V>- Specified by:
replacein interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
replaceAsync
public IgniteFuture<Boolean> replaceAsync(K key, V val) throws TransactionException
Asynchronously replaces the entry for a key only if currently mapped to a given value.- Specified by:
replaceAsyncin interfaceIgniteCache<K,V>- Parameters:
key- Key.val- Value.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
getAndReplace
public V getAndReplace(K key, V val) throws TransactionException
- Specified by:
getAndReplacein interfacejavax.cache.Cache<K,V>- Specified by:
getAndReplacein interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
getAndReplaceAsync
public IgniteFuture<V> getAndReplaceAsync(K key, V val)
Asynchronously replaces the value for a given key if and only if there is a value currently mapped by the key.- Specified by:
getAndReplaceAsyncin interfaceIgniteCache<K,V>- Parameters:
key- Key.val- Value.- Returns:
- a Future representing pending completion of the operation.
-
removeAll
public void removeAll(Set<? extends K> keys) throws TransactionException
Keys are locked in the order in which they appear in key set. It is caller's responsibility to make sure keys always follow same order, such as by using
TreeSet. Using unordered map, such asHashSet, while calling this method in parallel will lead to deadlock.- Specified by:
removeAllin interfacejavax.cache.Cache<K,V>- Specified by:
removeAllin interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
removeAllAsync
public IgniteFuture<Void> removeAllAsync(Set<? extends K> keys) throws TransactionException
Asynchronously removes entries for the specified keys.The order in which the individual entries are removed is undefined.
For every entry in the key set, the following are called:
- any registered
CacheEntryRemovedListeners - if the cache is a write-through cache, the
CacheWriter
CacheWriteris not called.Keys are locked in the order in which they appear in key set. It is caller's responsibility to make sure keys always follow same order, such as by using
TreeSet. Using unordered map, such asHashSet, while calling this method in parallel will lead to deadlock.- Specified by:
removeAllAsyncin interfaceIgniteCache<K,V>- Parameters:
keys- Keys set.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
- any registered
-
removeAll
public void removeAll()
Removes all of the mappings from this cache.The order that the individual entries are removed is undefined.
For every mapping that exists the following are called:
- any registered
CacheEntryRemovedListeners - if the cache is a write-through cache, the
CacheWriter
CacheWriteris not called.This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.
This is potentially an expensive operation as listeners are invoked. Use
IgniteCache.clear()to avoid this.- Specified by:
removeAllin interfacejavax.cache.Cache<K,V>- Specified by:
removeAllin interfaceIgniteCache<K,V>- See Also:
IgniteCache.clear(),CacheWriter.deleteAll(java.util.Collection<?>)
- any registered
-
removeAllAsync
public IgniteFuture<Void> removeAllAsync()
Asynchronously removes all of the mappings from this cache.The order that the individual entries are removed is undefined.
For every mapping that exists the following are called:
- any registered
CacheEntryRemovedListeners - if the cache is a write-through cache, the
CacheWriter
CacheWriteris not called.This is potentially an expensive operation as listeners are invoked. Use
IgniteCache.clearAsync()to avoid this.- Specified by:
removeAllAsyncin interfaceIgniteCache<K,V>- Returns:
- a Future representing pending completion of the operation.
- See Also:
IgniteCache.clearAsync(),CacheWriter.deleteAll(java.util.Collection<?>)
- any registered
-
clear
public void clear()
Clears the contents of the cache, without notifying listeners orCacheWriters. Entries are cleared only if they are not currently locked, and are not participating in a transaction. This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.
-
clearAsync
public IgniteFuture<Void> clearAsync()
Asynchronously clears the contents of the cache, without notifying listeners orCacheWriters. This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.- Specified by:
clearAsyncin interfaceIgniteCache<K,V>- Returns:
- a Future representing pending completion of the operation.
-
clear
public void clear(K key)
Clears entry from the cache and swap storage, without notifying listeners orCacheWriters. Entry is cleared only if it is not currently locked, and is not participating in a transaction. This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.- Specified by:
clearin interfaceIgniteCache<K,V>- Parameters:
key- Key to clear.
-
clearAsync
public IgniteFuture<Void> clearAsync(K key)
Asynchronously clears entry from the cache and swap storage, without notifying listeners orCacheWriters. Entry is cleared only if it is not currently locked, and is not participating in a transaction. This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.- Specified by:
clearAsyncin interfaceIgniteCache<K,V>- Parameters:
key- Key to clear.- Returns:
- a Future representing pending completion of the operation.
-
clearAll
public void clearAll(Set<? extends K> keys)
Clears entries from the cache and swap storage, without notifying listeners orCacheWriters. Entry is cleared only if it is not currently locked, and is not participating in a transaction. This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.- Specified by:
clearAllin interfaceIgniteCache<K,V>- Parameters:
keys- Keys to clear.
-
clearAllAsync
public IgniteFuture<Void> clearAllAsync(Set<? extends K> keys)
Asynchronously clears entries from the cache and swap storage, without notifying listeners orCacheWriters. Entry is cleared only if it is not currently locked, and is not participating in a transaction. This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.- Specified by:
clearAllAsyncin interfaceIgniteCache<K,V>- Parameters:
keys- Keys to clear.- Returns:
- a Future representing pending completion of the operation.
-
localClear
public void localClear(K key)
Clears entry from the cache and swap storage, without notifying listeners orCacheWriters. Entry is cleared only if it is not currently locked, and is not participating in a transaction. This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes. Note that this operation is local as it merely clears an entry from local cache, it does not remove entries from remote caches.- Specified by:
localClearin interfaceIgniteCache<K,V>- Parameters:
key- Key to clear.
-
localClearAll
public void localClearAll(Set<? extends K> keys)
Clears entries from the cache and swap storage, without notifying listeners orCacheWriters. Entry is cleared only if it is not currently locked, and is not participating in a transaction. This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes. Note that this operation is local as it merely clears an entry from local cache, it does not remove entries from remote caches.- Specified by:
localClearAllin interfaceIgniteCache<K,V>- Parameters:
keys- Keys to clear.
-
invoke
public <T> T invoke(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments) throws TransactionException
Please refer to documentation for
CacheAtomicityMode.ATOMICfor information on system behavior in crash scenarios for atomic caches.- Specified by:
invokein interfacejavax.cache.Cache<K,V>- Specified by:
invokein interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
invokeAsync
public <T> IgniteFuture<T> invokeAsync(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments) throws TransactionException
Asynchronously invokes anEntryProcessoragainst theCache.Entryspecified by the provided key. If anCache.Entrydoes not exist for the specified key, an attempt is made to load it (if a loader is configured) or a surrogateCache.Entry, consisting of the key with a null value is used instead.Please refer to documentation for
CacheAtomicityMode.ATOMICfor information on system behavior in crash scenarios for atomic caches.- Specified by:
invokeAsyncin interfaceIgniteCache<K,V>- Type Parameters:
T- Type of the cache entry processing result.- Parameters:
key- The key to the entry.entryProcessor- TheEntryProcessorto invoke.arguments- Additional arguments to pass to theEntryProcessor.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
invoke
public <T> T invoke(K key, CacheEntryProcessor<K,V,T> entryProcessor, Object... arguments) throws TransactionException
Invokes anCacheEntryProcessoragainst theCache.Entryspecified by the provided key. If anCache.Entrydoes not exist for the specified key, an attempt is made to load it (if a loader is configured) or a surrogateCache.Entry, consisting of the key with a null value is used instead.An instance of entry processor must be stateless as it may be invoked multiple times on primary and backup nodes in the cache. It is guaranteed that the value passed to the entry processor will be always the same.
Please refer to documentation for
CacheAtomicityMode.ATOMICfor information on system behavior in crash scenarios for atomic caches.- Specified by:
invokein interfaceIgniteCache<K,V>- Type Parameters:
T- Type of the cache entry processing result.- Parameters:
key- The key to the entry.entryProcessor- TheCacheEntryProcessorto invoke.arguments- Additional arguments to pass to theCacheEntryProcessor.- Returns:
- The result of the processing, if any, defined by the
CacheEntryProcessorimplementation. - Throws:
TransactionException- If operation within transaction is failed.- See Also:
CacheEntryProcessor
-
invokeAsync
public <T> IgniteFuture<T> invokeAsync(K key, CacheEntryProcessor<K,V,T> entryProcessor, Object... arguments) throws TransactionException
Asynchronously invokes anCacheEntryProcessoragainst theCache.Entryspecified by the provided key. If anCache.Entrydoes not exist for the specified key, an attempt is made to load it (if a loader is configured) or a surrogateCache.Entry, consisting of the key with a null value is used instead.An instance of entry processor must be stateless as it may be invoked multiple times on primary and backup nodes in the cache. It is guaranteed that the value passed to the entry processor will be always the same.
- Specified by:
invokeAsyncin interfaceIgniteCache<K,V>- Type Parameters:
T- Type of the cache entry processing result.- Parameters:
key- The key to the entry.entryProcessor- TheCacheEntryProcessorto invoke.arguments- Additional arguments to pass to theCacheEntryProcessor.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.- See Also:
CacheEntryProcessor
-
invokeAll
public <T> Map<K,javax.cache.processor.EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... args) throws TransactionException
Please refer to documentation for
CacheAtomicityMode.ATOMICfor information on system behavior in crash scenarios for atomic caches.Keys are locked in the order in which they appear in key set. It is caller's responsibility to make sure keys always follow same order, such as by using
TreeSet. Using unordered map, such asHashSet, while calling this method in parallel will lead to deadlock.- Specified by:
invokeAllin interfacejavax.cache.Cache<K,V>- Specified by:
invokeAllin interfaceIgniteCache<K,V>- Throws:
TransactionException- If operation within transaction is failed.
-
invokeAllAsync
public <T> IgniteFuture<Map<K,javax.cache.processor.EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... args) throws TransactionException
Asynchronously invokes anEntryProcessoragainst the set ofCache.Entrys specified by the set of keys.If an
Cache.Entrydoes not exist for the specified key, an attempt is made to load it (if a loader is configured) or a surrogateCache.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
EntryProcessorinstance to process each entry, as the case may be in a non-local cache topology.The result of executing the
EntryProcessoris returned in the future as aMapofEntryProcessorResults, one result per key. Should theEntryProcessoror Caching implementation throw an exception, the exception is wrapped and re-thrown when a call toEntryProcessorResult.get()is made.Please refer to documentation for
CacheAtomicityMode.ATOMICfor information on system behavior in crash scenarios for atomic caches.Keys are locked in the order in which they appear in key set. It is caller's responsibility to make sure keys always follow same order, such as by using
TreeSet. Using unordered map, such asHashSet, while calling this method in parallel will lead to deadlock.- Specified by:
invokeAllAsyncin interfaceIgniteCache<K,V>- Type Parameters:
T- Type of the cache entry processing result.- Parameters:
keys- The set of keys.entryProcessor- TheEntryProcessorto invoke.args- Additional arguments to pass to theEntryProcessor.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.
-
invokeAll
public <T> Map<K,javax.cache.processor.EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, CacheEntryProcessor<K,V,T> entryProcessor, Object... args) throws TransactionException
Invokes anCacheEntryProcessoragainst the set ofCache.Entrys specified by the set of keys.If an
Cache.Entrydoes not exist for the specified key, an attempt is made to load it (if a loader is configured) or a surrogateCache.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
CacheEntryProcessorinstance to process each entry, as the case may be in a non-local cache topology.The result of executing the
CacheEntryProcessoris returned as aMapofEntryProcessorResults, one result per key. Should theCacheEntryProcessoror Caching implementation throw an exception, the exception is wrapped and re-thrown when a call toEntryProcessorResult.get()is made.An instance of entry processor must be stateless as it may be invoked multiple times on primary and backup nodes in the cache. It is guaranteed that the value passed to the entry processor will be always the same.
Keys are locked in the order in which they appear in key set. It is caller's responsibility to make sure keys always follow same order, such as by using
TreeSet. Using unordered map, such asHashSet, while calling this method in parallel will lead to deadlock.- Specified by:
invokeAllin interfaceIgniteCache<K,V>- Type Parameters:
T- Type of the cache entry processing result.- Parameters:
keys- The set of keys for entries to process.entryProcessor- TheCacheEntryProcessorto invoke.args- Additional arguments to pass to theCacheEntryProcessor.- Returns:
- The map of
EntryProcessorResults of the processing per key, if any, defined by theCacheEntryProcessorimplementation. No mappings will be returned forCacheEntryProcessors that return anullvalue for a key. - Throws:
TransactionException- If operation within transaction is failed.- See Also:
CacheEntryProcessor
-
invokeAllAsync
public <T> IgniteFuture<Map<K,javax.cache.processor.EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys, CacheEntryProcessor<K,V,T> entryProcessor, Object... args) throws TransactionException
Asynchronously invokes anCacheEntryProcessoragainst the set ofCache.Entrys specified by the set of keys.If an
Cache.Entrydoes not exist for the specified key, an attempt is made to load it (if a loader is configured) or a surrogateCache.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
CacheEntryProcessorinstance to process each entry, as the case may be in a non-local cache topology.The result of executing the
CacheEntryProcessoris returned in the future as aMapofEntryProcessorResults, one result per key. Should theCacheEntryProcessoror Caching implementation throw an exception, the exception is wrapped and re-thrown when a call toEntryProcessorResult.get()is made.An instance of entry processor must be stateless as it may be invoked multiple times on primary and backup nodes in the cache. It is guaranteed that the value passed to the entry processor will be always the same.
Keys are locked in the order in which they appear in key set. It is caller's responsibility to make sure keys always follow same order, such as by using
TreeSet. Using unordered map, such asHashSet, while calling this method in parallel will lead to deadlock.- Specified by:
invokeAllAsyncin interfaceIgniteCache<K,V>- Type Parameters:
T- Type of the cache entry processing result.- Parameters:
keys- The set of keys for entries to process.entryProcessor- TheCacheEntryProcessorto invoke.args- Additional arguments to pass to theCacheEntryProcessor.- Returns:
- a Future representing pending completion of the operation.
- Throws:
TransactionException- If operation within transaction is failed.- See Also:
CacheEntryProcessor
-
unwrap
public <T> T unwrap(Class<T> clazz)
-
registerCacheEntryListener
public void registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
-
deregisterCacheEntryListener
public void deregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
-
destroy
public void destroy()
Completely deletes the cache with all its data from the system on all cluster nodes.- Specified by:
destroyin interfaceIgniteCache<K,V>
-
destroyAsync
public IgniteFuture<?> destroyAsync()
- Specified by:
destroyAsyncin interfaceIgniteCacheProxy<K,V>- Returns:
- Future that contains cache destroy operation.
-
close
public void close()
Closes this cache instance.For local cache equivalent to
IgniteCache.destroy(). For distributed caches, if called on clients, stops client cache, if called on a server node, just closes this cache instance and does not destroy cache data.After cache instance is closed another
IgniteCacheinstance for the same cache can be created usingIgnite.cache(String)method.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacejavax.cache.Cache<K,V>- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceIgniteCache<K,V>
-
closeAsync
public IgniteFuture<?> closeAsync()
- Specified by:
closeAsyncin interfaceIgniteCacheProxy<K,V>- Returns:
- Future that contains cache close operation.
-
rebalance
public IgniteFuture<Boolean> rebalance()
This cache node to re-balance its partitions. This method is usually used whenCacheConfiguration.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 of
CacheMode.PARTITIONEDcaches, 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 beforerebalanceDelayexpires. To place nodes on the same place in consistent hash ring, useIgniteConfiguration.setConsistentId(Serializable)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.- Specified by:
rebalancein interfaceIgniteCache<K,V>- Returns:
- Future that will be completed when rebalancing is finished. Future.get() returns
truewhen rebalance was successfully finished.
-
indexReadyFuture
public IgniteFuture<?> indexReadyFuture()
Returns future that will be completed when all indexes for this cache are ready to use.- Specified by:
indexReadyFuturein interfaceIgniteCache<K,V>- Returns:
- Future.
-
metrics
public CacheMetrics metrics()
Gets whole cluster snapshot metrics (statistics) for this cache.- Specified by:
metricsin interfaceIgniteCache<K,V>- Returns:
- Cache metrics.
-
metrics
public CacheMetrics metrics(ClusterGroup grp)
Gets cluster group snapshot metrics for caches in cluster group.- Specified by:
metricsin interfaceIgniteCache<K,V>- Parameters:
grp- Cluster group.- Returns:
- Cache metrics.
-
localMetrics
public CacheMetrics localMetrics()
Gets local snapshot metrics (statistics) for this cache.- Specified by:
localMetricsin interfaceIgniteCache<K,V>- Returns:
- Cache metrics.
-
lostPartitions
public Collection<Integer> lostPartitions()
Gets a collection of lost partition IDs. This method provides a facility for fine-tuned handling of lost partitions. Once all lost partitions are considered recovered (for example, after the previously failed primary and backup nodes, that stored partition data in Ignite persistence, are booted)Ignite.resetLostPartitions(Collection)can used in order to clearlostflag making all partitions fully operational.- Specified by:
lostPartitionsin interfaceIgniteCache<K,V>- Returns:
- Lost partitions.
- See Also:
PartitionLossPolicy,EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST,Ignite.resetLostPartitions(Collection)
-
enableStatistics
public void enableStatistics(boolean enabled)
Sets statistics enabled flag cluster wide for this cache.- Specified by:
enableStatisticsin interfaceIgniteCache<K,V>- Parameters:
enabled- Statistics enabled flag.
-
clearStatistics
public void clearStatistics()
Clear cluster statistics for this cache.- Specified by:
clearStatisticsin interfaceIgniteCache<K,V>
-
preloadPartition
public void preloadPartition(int part)
Efficiently preloads cache primary partition into page memory.This is useful for fast iteration over cache partition data if persistence is enabled and the data is "cold".
Preload will reduce available amount of page memory for subsequent operations and may lead to earlier page replacement.
This method is irrelevant for in-memory caches. Calling this method on an in-memory cache will result in exception.
- Specified by:
preloadPartitionin interfaceIgniteCache<K,V>- Parameters:
part- Partition.
-
preloadPartitionAsync
public IgniteFuture<Void> preloadPartitionAsync(int part)
Efficiently preloads cache partition into page memory.This is useful for fast iteration over cache partition data if persistence is enabled and the data is "cold".
Preload will reduce available amount of page memory for subsequent operations and may lead to earlier page replacement.
This method is irrelevant for in-memory caches. Calling this method on an in-memory cache will result in exception.
- Specified by:
preloadPartitionAsyncin interfaceIgniteCache<K,V>- Parameters:
part- Partition.- Returns:
- A future representing pending completion of the partition preloading.
-
localPreloadPartition
public boolean localPreloadPartition(int part)
Efficiently preloads cache partition into page memory if it exists on the local node.This is useful for fast iteration over cache partition data if persistence is enabled and the data is "cold".
Preload will reduce available amount of page memory for subsequent operations and may lead to earlier page replacement.
This method is irrelevant for in-memory caches. Calling this method on an in-memory cache will result in exception.
- Specified by:
localPreloadPartitionin interfaceIgniteCache<K,V>- Parameters:
part- Partition.- Returns:
Trueif partition was preloaded,falseif it doesn't belong to local node.
-
isProxyClosed
public boolean isProxyClosed()
- Specified by:
isProxyClosedin interfaceIgniteCacheProxy<K,V>- Returns:
Trueif proxy was closed.
-
closeProxy
public void closeProxy()
Closes this proxy instance.- Specified by:
closeProxyin interfaceIgniteCacheProxy<K,V>
-
withAsync
public IgniteCache<K,V> withAsync()
Gets instance of this component with asynchronous mode enabled.- Specified by:
withAsyncin interfaceIgniteAsyncSupport- Specified by:
withAsyncin interfaceIgniteCache<K,V>- Overrides:
withAsyncin classAsyncSupportAdapter<IgniteCache<K,V>>- Returns:
- Instance of this component with asynchronous mode enabled.
-
isAsync
public boolean isAsync()
- Specified by:
isAsyncin interfaceIgniteAsyncSupport- Overrides:
isAsyncin classAsyncSupportAdapter<IgniteCache<K,V>>- Returns:
Trueif asynchronous mode is enabled.
-
future
public <R> IgniteFuture<R> future()
Gets and resets future for previous asynchronous operation.- Specified by:
futurein interfaceIgniteAsyncSupport- Overrides:
futurein classAsyncSupportAdapter<IgniteCache<K,V>>- Type Parameters:
R- Type of the future result.- Returns:
- Future for previous asynchronous operation.
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
-