org.apache.ignite.internal.processors.cache.distributed

## Class GridDistributedCacheAdapter<K,V>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheAdapter<K,V>
  - - org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheAdapter<K,V>

All Implemented Interfaces:
  Externalizable, Serializable, Iterable<javax.cache.Cache.Entry<K,V>>, GridCache<K,V>, CacheProjection<K,V>, GridCacheProjectionEx<K,V>

Direct Known Subclasses:
  GridDhtCacheAdapter, GridNearCacheAdapter

    public abstract class GridDistributedCacheAdapter<K,V>
    extends GridCacheAdapter<K,V>

Distributed cache implementation.

See Also:
  Serialized Form

### Nested Class Summary

### Nested classes/interfaces inherited from class org.apache.ignite.internal.processors.cache.GridCacheAdapter

`GridCacheAdapter.AsyncOp<T>, GridCacheAdapter.CacheExpiryPolicy, GridCacheAdapter.FutureHolder, GridCacheAdapter.UpdateGetTimeStatClosure<T>, GridCacheAdapter.UpdatePutAndGetTimeStatClosure<T>, GridCacheAdapter.UpdatePutTimeStatClosure<T>, GridCacheAdapter.UpdateRemoveTimeStatClosure<T>, GridCacheAdapter.UpdateTimeStatClosure<T>`

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.cache.GridCacheAdapter

`cacheCfg, CLEAR_ALL_SPLIT_THRESHOLD, ctx, gridCfg, keyCheck, lastFut, locNodeId, log, map, metrics, mxBean`

### Constructor Summary

Constructors
`protected` `GridDistributedCacheAdapter()` Empty constructor required by `Externalizable`.
`protected` `GridDistributedCacheAdapter(GridCacheContext<K,V> ctx, GridCacheConcurrentMap<K,V> map)`
`protected` `GridDistributedCacheAdapter(GridCacheContext<K,V> ctx, int startSize)`

### Method Summary

Methods
`IgniteInternalFuture<Boolean>` `lockAllAsync(Collection<? extends K> keys, long timeout, IgnitePredicate<javax.cache.Cache.Entry<K,V>>... filter)` All or nothing synchronous lock for passed in keys.
`protected abstract IgniteInternalFuture<Boolean>` `lockAllAsync(Collection<? extends K> keys, long timeout, IgniteTxLocalEx<K,V> tx, boolean isInvalidate, boolean isRead, boolean retval, TransactionIsolation isolation, long accessTtl, IgnitePredicate<javax.cache.Cache.Entry<K,V>>[] filter)`
`void` `removeAll()` Removes mappings from cache for entries for which the optionally passed in filters do pass.
`IgniteInternalFuture<?>` `removeAllAsync()`
`void` `removeVersionedEntry(K key, GridCacheVersion ver)`
`String` `toString()`
`IgniteInternalFuture<Boolean>` `txLockAsync(Collection<? extends K> keys, long timeout, IgniteTxLocalEx<K,V> tx, boolean isRead, boolean retval, TransactionIsolation isolation, boolean isInvalidate, long accessTtl, IgnitePredicate<javax.cache.Cache.Entry<K,V>>[] filter)`

### Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheAdapter

`affinity, allEntries, asyncOp, asyncOpAcquire, asyncOpRelease, awaitLastFut, cache, checkJta, clear, clear, clearAsync, clearLocally, clearLocally, clearLocally, clearLocally0, clearLocally0, commitTxAsync, compact, compact, compactAll, compactAll, configuration, containsKey, containsKeyAsync, containsKeys, containsKeysAsync, containsValue, context, entries, entry, entryEx, entryEx, entryEx, entryExSafe, entrySet, entrySet, entrySet, entrySet, entrySetx, evict, evict, evictAll, evictAll, evictAll, expiry, expiryPolicy, flags, flagsOff, flagsOn, forAll, forceRepartition, forEach, forSubjectId, get, get, get, getAll, getAll, getAllAsync, getAllAsync, getAllAsync, getAllAsync, getAllOutTx, getAllOutTxAsync, getAsync, getAsync, getForcePrimary, getForcePrimaryAsync, globalPrimarySize, globalSize, gridProjection, igfsDataSpaceMax, igfsDataSpaceUsed, igniteIterator, init, invoke, invokeAll, invokeAll, invokeAllAsync, invokeAllAsync, invokeAsync, isColocated, isDht, isDhtAtomic, isEmpty, isIgfsDataCache, isLocal, isLocked, isLockedByThread, isMongoDataCache, isMongoMetaCache, isNear, iterator, iterator, keepPortable, keepPortable0, keySet, keySet, loadAll, loadCache, loadCacheAsync, localEntries, localLoad, localPeek, localSize, lock, lockAll, lockAsync, log, map, metrics, metrics0, mxBean, name, nearSize, offHeapAllocatedSize, offHeapEntriesCount, offHeapIterator, onDeferredDelete, onIgfsDataSizeChanged, onKernalStart, onKernalStop, onUndeploy, overflowSize, peek, peek, peek, peek0, peek0, peek0, peekAll, peekAll0, peekAll0, peekEx, predicate, preloader, primaryEntrySet, primaryEntrySet, primaryEntrySetx, primaryKeySet, primaryKeySet, primarySize, primaryValues, primaryValues, printMemoryStats, projection, projection, projection, promote, promote, promoteAll, put, put, putAll, putAllAsync, putAllDr, putAllDrAsync, putAsync, putAsync, putIfAbsent, putIfAbsentAsync, putx, putx, putxAsync, putxAsync, putxIfAbsent, putxIfAbsentAsync, queries, randomEntry, readExternal, readResolve, readThroughAllAsync, reload, reloadAll, reloadAll, reloadAll, reloadAllAsync, reloadAllAsync, reloadAllAsync, reloadAsync, remove, remove, remove, removeAll, removeAllAsync, removeAllAsync, removeAllDr, removeAllDrAsync, removeAsync, removeAsync, removeAsync, removeEntry, removeIfObsolete, removex, removex, removex, removexAsync, removexAsync, removexAsync, replace, replace, replaceAsync, replaceAsync, replacex, replacex, replacexAsync, replacexAsync, saveFuture, size, size, sizeAsync, splitClearLocally, start, startInfo, stop, stopInfo, swapIterator, swapKeys, swapSize, toMap, tx, txStart, txStart, txStart, txStartEx, txSynchronizations, txSynchronize, txUnsynchronize, unlock, validateCacheKey, validateCacheKeys, values, values, withExpiryPolicy, writeExternal`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.apache.ignite.internal.processors.cache.CacheProjection

`unlockAll`

### Constructor Detail

#### GridDistributedCacheAdapter

    protected GridDistributedCacheAdapter()

Empty constructor required by `Externalizable`.

#### GridDistributedCacheAdapter

    protected GridDistributedCacheAdapter(GridCacheContext<K,V> ctx,
                               int startSize)

Parameters:
  `ctx` - Cache registry.
  `startSize` - Start size.

#### GridDistributedCacheAdapter

    protected GridDistributedCacheAdapter(GridCacheContext<K,V> ctx,
                               GridCacheConcurrentMap<K,V> map)

Parameters:
  `ctx` - Cache context.
  `map` - Cache map.

### Method Detail

#### txLockAsync

    public IgniteInternalFuture<Boolean> txLockAsync(Collection<? extends K> keys,
                                            long timeout,
                                            IgniteTxLocalEx<K,V> tx,
                                            boolean isRead,
                                            boolean retval,
                                            TransactionIsolation isolation,
                                            boolean isInvalidate,
                                            long accessTtl,
                                            IgnitePredicate<javax.cache.Cache.Entry<K,V>>[] filter)

Specified by:
  `txLockAsync` in class `GridCacheAdapter<K,V>`
Parameters:
  `keys` - Keys to lock.
  `timeout` - Lock timeout.
  `tx` - Transaction.
  `isRead` - `True` for read operations.
  `retval` - Flag to return value.
  `isolation` - Transaction isolation.
  `isInvalidate` - Invalidate flag.
  `accessTtl` - TTL for read operation.
  `filter` - Optional filter.
Returns:
  Locks future.

#### lockAllAsync

    public IgniteInternalFuture<Boolean> lockAllAsync(Collection<? extends K> keys,
                                             long timeout,
                                             IgnitePredicate<javax.cache.Cache.Entry<K,V>>... filter)

All or nothing synchronous lock for passed in keys. This method together with filter check will be executed as one atomic operation. If at least one filter validation failed, no locks will be acquired.

## Transactions

Locks are not transactional and should not be used from within transactions. If you do need explicit locking within transaction, then you should use `TransactionConcurrency.PESSIMISTIC` concurrency control for transaction which will acquire explicit locks for relevant cache operations.

## Cache Flags

This method is not available if any of the following flags are set on projection: `CacheFlag.LOCAL`, `CacheFlag.READ`.

Parameters:
  `keys` - Keys to lock.
  `timeout` - Timeout in milliseconds to wait for lock to be acquired (`'0'` for no expiration).
  `filter` - Optional filter that needs to atomically pass in order for the locks to be acquired.
Returns:
  Future for the collection of locks. The future will return `true` if all filters passed and locks were acquired before timeout has expired, `false` otherwise.

#### lockAllAsync

    protected abstract IgniteInternalFuture<Boolean> lockAllAsync(Collection<? extends K> keys,
                                             long timeout,
                                             @Nullable
                                             IgniteTxLocalEx<K,V> tx,
                                             boolean isInvalidate,
                                             boolean isRead,
                                             boolean retval,
                                             @Nullable
                                             TransactionIsolation isolation,
                                             long accessTtl,
                                             IgnitePredicate<javax.cache.Cache.Entry<K,V>>[] filter)

Parameters:
  `keys` - Keys to lock.
  `timeout` - Timeout.
  `tx` - Transaction
  `isInvalidate` - Invalidation flag.
  `isRead` - Indicates whether value is read or written.
  `retval` - Flag to return value.
  `isolation` - Transaction isolation.
  `accessTtl` - TTL for read operation.
  `filter` - Optional filter.
Returns:
  Future for locks.

#### removeVersionedEntry

    public void removeVersionedEntry(K key,
                            GridCacheVersion ver)

Parameters:
  `key` - Key to remove.
  `ver` - Version to remove.

#### removeAll

    public void removeAll()
                   throws IgniteCheckedException

Removes mappings from cache for entries for which the optionally passed in filters do pass. If passed in filters are `null`, then all entries in cache will be enrolled into transaction.

USE WITH CARE - if your cache has many entries that pass through the filter or if filter is empty, then transaction will quickly become very heavy and slow. Also, locks are acquired in undefined order, so it may cause a deadlock when used with other concurrent transactional updates.

If write-through is enabled, the values will be removed from `CacheStore` via `CacheStore#removeAll(Transaction, Collection)` method.

## Transactions

This method is transactional and will enlist the entry into ongoing transaction if there is one.

## Cache Flags

This method is not available if any of the following flags are set on projection: `CacheFlag.LOCAL`, `CacheFlag.READ`.

Throws:
  `IgniteCheckedException` - If remove failed.

#### removeAllAsync

    public IgniteInternalFuture<?> removeAllAsync()

Returns:
  Remove future.

#### toString

    public String toString()

Overrides:
  `toString` in class `GridCacheAdapter<K,V>`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC1
Release Date | : February 17 2015