org.apache.ignite.internal.processors.cache

## Class GridCacheMvccManager

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter
  - - org.apache.ignite.internal.processors.cache.GridCacheMvccManager

All Implemented Interfaces:
  GridCacheSharedManager

    public class GridCacheMvccManager
    extends GridCacheSharedManagerAdapter

Manages lock order within a thread.

### Field Summary

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

`cctx, log`

### Constructor Summary

Constructors
Constructor and Description
`GridCacheMvccManager()`

### Method Summary

Methods
`void` `addAtomicFuture(GridCacheVersion futVer, GridCacheAtomicFuture<?> fut)`
`void` `addExplicitLock(long threadId, GridCacheMvccCandidate cand, GridDiscoveryTopologySnapshot snapshot)` Adds candidate to the list of near local candidates.
`boolean` `addFuture(GridCacheFuture<?> fut)` Adds future.
`boolean` `addLocal(GridCacheMvccCandidate cand)`
`boolean` `addNext(GridCacheContext cacheCtx, GridCacheMvccCandidate cand)`
`boolean` `addRemoved(GridCacheContext cacheCtx, GridCacheVersion ver)`
`IgniteInternalFuture<?>` `atomicFuture(GridCacheVersion futVer)` Gets future by given future ID.
`Collection<GridCacheAtomicFuture<?>>` `atomicFutures()`
`GridCacheMvccCallback` `callback()`
`void` `cancelClientFutures()` Cancels all client futures.
`void` `contextReset()` Reset MVCC context.
`GridCacheMvccCandidate` `explicitLock(KeyCacheObject key, GridCacheVersion ver)` Gets explicit lock candidate added by any thread by given key and lock version.
`GridCacheMvccCandidate` `explicitLock(long threadId, KeyCacheObject key)` Gets last added explicit lock candidate by thread id and key.
`IgniteInternalFuture<?>` `finishAtomicUpdates(long topVer)`
`IgniteInternalFuture<?>` `finishExplicitLocks(long topVer)` Creates a future that will wait for all explicit locks acquired on given topology version to be released.
`IgniteInternalFuture<?>` `finishKeys(Collection<KeyCacheObject> keys, long topVer)`
`IgniteInternalFuture<?>` `finishLocks(long topVer)`
`<T> GridCacheFuture<T>` `future(GridCacheVersion ver, IgniteUuid futId)` Gets future for given future ID and lock ID.
`<T> Collection<? extends IgniteInternalFuture<T>>` `futures(GridCacheVersion ver)` Gets all futures for given lock version, possibly empty collection.
`boolean` `hasFuture(GridCacheFuture<?> fut)`
`boolean` `isLockedByThread(KeyCacheObject key, long threadId)` Checks if given key is locked by thread with given id or any thread.
`boolean` `isRemoved(GridCacheContext cacheCtx, GridCacheVersion ver)`
`GridDiscoveryTopologySnapshot` `lastExplicitLockTopologySnapshot(long threadId)`
`Collection<GridCacheMvccCandidate>` `localCandidates()` This method has poor performance, so use with care.
`Collection<GridCacheVersion>` `localDhtPendingVersions(Collection<KeyCacheObject> keys, GridCacheVersion base)`
`GridCacheVersion` `mappedVersion(GridCacheVersion from)`
`void` `mapVersion(GridCacheVersion from, GridCacheVersion to)`
`void` `markExplicitOwner(KeyCacheObject key, long threadId)` Marks candidates for given thread and given key as owned.
`void` `onKernalStart0()`
`void` `onKernalStop0(boolean cancel)`
`void` `printMemoryStats()` Prints memory statistics (sizes of internal data structures, etc.).
`void` `recheckPendingLocks()`
`Collection<GridCacheMvccCandidate>` `remoteCandidates()` This method has poor performance, so use with care.
`IgniteInternalFuture<?>` `removeAtomicFuture(GridCacheVersion futVer)`
`void` `removeExplicitLock(GridCacheMvccCandidate cand)` Removes candidate from the list of near local candidates.
`GridCacheMvccCandidate` `removeExplicitLock(long threadId, KeyCacheObject key, GridCacheVersion ver)` Removes explicit lock for given thread id, key and optional version.
`boolean` `removeFuture(GridCacheFuture<?> fut)`
`boolean` `removeLocal(GridCacheMvccCandidate cand)`
`protected void` `start0()`
`GridCacheVersion` `unmapVersion(GridCacheVersion from)`

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

`context, kernalStartInfo, kernalStopInfo, log, onKernalStart, onKernalStop, start, startInfo, stop, stop0, stopInfo, toString`

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

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

### Constructor Detail

#### GridCacheMvccManager

    public GridCacheMvccManager()

### Method Detail

#### start0

    protected void start0()
                   throws IgniteCheckedException

Overrides:
  `start0` in class `GridCacheSharedManagerAdapter`
Throws:
  `IgniteCheckedException` - If failed.

#### onKernalStart0

    public void onKernalStart0()
                        throws IgniteCheckedException

Overrides:
  `onKernalStart0` in class `GridCacheSharedManagerAdapter`
Throws:
  `IgniteCheckedException` - If failed.

#### onKernalStop0

    public void onKernalStop0(boolean cancel)

Overrides:
  `onKernalStop0` in class `GridCacheSharedManagerAdapter`
Parameters:
  `cancel` - Cancel flag.

#### callback

    public GridCacheMvccCallback callback()

Returns:
  MVCC callback.

#### mapVersion

    public void mapVersion(GridCacheVersion from,
                  GridCacheVersion to)

Parameters:
  `from` - From version.
  `to` - To version.

#### mappedVersion

    public GridCacheVersion mappedVersion(GridCacheVersion from)

Parameters:
  `from` - Near version.
Returns:
  DHT version.

#### cancelClientFutures

    public void cancelClientFutures()

Cancels all client futures.

#### unmapVersion

    public GridCacheVersion unmapVersion(GridCacheVersion from)

Parameters:
  `from` - From version.
Returns:
  To version.

#### hasFuture

    public boolean hasFuture(GridCacheFuture<?> fut)

Parameters:
  `fut` - Future to check.
Returns:
  `True` if future is registered.

#### addAtomicFuture

    public void addAtomicFuture(GridCacheVersion futVer,
                       GridCacheAtomicFuture<?> fut)

Parameters:
  `futVer` - Future ID.
  `fut` - Future.

#### atomicFutures

    public Collection<GridCacheAtomicFuture<?>> atomicFutures()

Returns:
  Collection of pending atomic futures.

#### atomicFuture

    @Nullable
    public IgniteInternalFuture<?> atomicFuture(GridCacheVersion futVer)

Gets future by given future ID.

Parameters:
  `futVer` - Future ID.
Returns:
  Future.

#### removeAtomicFuture

    @Nullable
    public IgniteInternalFuture<?> removeAtomicFuture(GridCacheVersion futVer)

Parameters:
  `futVer` - Future ID.
Returns:
  Removed future.

#### addFuture

    public boolean addFuture(GridCacheFuture<?> fut)

Adds future.

Parameters:
  `fut` - Future.
Returns:
  `True` if added.

#### removeFuture

    public boolean removeFuture(GridCacheFuture<?> fut)

Parameters:
  `fut` - Future to remove.
Returns:
  `True` if removed.

#### future

    @Nullable
    public <T> GridCacheFuture<T> future(GridCacheVersion ver,
                                         IgniteUuid futId)

Gets future for given future ID and lock ID.

Parameters:
  `ver` - Lock ID.
  `futId` - Future ID.
Returns:
  Future.

#### futures

    public <T> Collection<? extends IgniteInternalFuture<T>> futures(GridCacheVersion ver)

Gets all futures for given lock version, possibly empty collection.

Parameters:
  `ver` - Version.
Returns:
  All futures for given lock version.

#### isRemoved

    public boolean isRemoved(GridCacheContext cacheCtx,
                    GridCacheVersion ver)

Parameters:
  `ver` - Lock version to check.
Returns:
  `True` if lock had been removed.

#### addRemoved

    public boolean addRemoved(GridCacheContext cacheCtx,
                     GridCacheVersion ver)

Parameters:
  `ver` - Obsolete entry version.
Returns:
  `True` if added.

#### remoteCandidates

    public Collection<GridCacheMvccCandidate> remoteCandidates()

This method has poor performance, so use with care. It is currently only used by `DGC`.

Returns:
  Remote candidates.

#### localCandidates

    public Collection<GridCacheMvccCandidate> localCandidates()

This method has poor performance, so use with care. It is currently only used by `DGC`.

Returns:
  Local candidates.

#### addLocal

    public boolean addLocal(GridCacheMvccCandidate cand)

Parameters:
  `cand` - Local lock.
Returns:
  `True` if added.

#### removeLocal

    public boolean removeLocal(GridCacheMvccCandidate cand)

Parameters:
  `cand` - Local candidate to remove.
Returns:
  `True` if removed.

#### localDhtPendingVersions

    public Collection<GridCacheVersion> localDhtPendingVersions(Collection<KeyCacheObject> keys,
                                                       GridCacheVersion base)

Parameters:
  `keys` - Keys.
  `base` - Base version.
Returns:
  Versions that are less than `base` whose keys are in the `keys` collection.

#### addNext

    public boolean addNext(GridCacheContext cacheCtx,
                  GridCacheMvccCandidate cand)

Parameters:
  `cand` - Cache lock candidate to add.
Returns:
  `True` if added as a result of this operation, `false` if was previously added.

#### contextReset

    public void contextReset()

Reset MVCC context.

#### addExplicitLock

    public void addExplicitLock(long threadId,
                       GridCacheMvccCandidate cand,
                       GridDiscoveryTopologySnapshot snapshot)

Adds candidate to the list of near local candidates.

Parameters:
  `threadId` - Thread ID.
  `cand` - Candidate to add.
  `snapshot` - Topology snapshot.

#### removeExplicitLock

    public void removeExplicitLock(GridCacheMvccCandidate cand)

Removes candidate from the list of near local candidates.

Parameters:
  `cand` - Candidate to remove.

#### isLockedByThread

    public boolean isLockedByThread(KeyCacheObject key,
                           long threadId)

Checks if given key is locked by thread with given id or any thread.

Parameters:
  `key` - Key to check.
  `threadId` - Thread id. If -1, all threads will be checked.
Returns:
  `True` if locked by any or given thread (depending on `threadId` value).

#### markExplicitOwner

    public void markExplicitOwner(KeyCacheObject key,
                         long threadId)

Marks candidates for given thread and given key as owned.

Parameters:
  `key` - Key.
  `threadId` - Thread id.

#### removeExplicitLock

    public GridCacheMvccCandidate removeExplicitLock(long threadId,
                                            KeyCacheObject key,
                                            @Nullable
                                            GridCacheVersion ver)

Removes explicit lock for given thread id, key and optional version.

Parameters:
  `threadId` - Thread id.
  `key` - Key.
  `ver` - Optional version.
Returns:
  Candidate.

#### explicitLock

    @Nullable
    public GridCacheMvccCandidate explicitLock(long threadId,
                                               KeyCacheObject key)

Gets last added explicit lock candidate by thread id and key.

Parameters:
  `threadId` - Thread id.
  `key` - Key to look up.
Returns:
  Last added explicit lock candidate for given thread id and key or `null` if no such candidate.

#### explicitLock

    @Nullable
    public GridCacheMvccCandidate explicitLock(KeyCacheObject key,
                                               @Nullable
                                               GridCacheVersion ver)

Gets explicit lock candidate added by any thread by given key and lock version.

Parameters:
  `key` - Key.
  `ver` - Version.
Returns:
  Lock candidate that satisfies given criteria or `null` if no such candidate.

#### lastExplicitLockTopologySnapshot

    @Nullable
    public GridDiscoveryTopologySnapshot lastExplicitLockTopologySnapshot(long threadId)

Parameters:
  `threadId` - Thread ID.
Returns:
  Topology snapshot for last acquired and not released lock.

#### printMemoryStats

    public void printMemoryStats()

Prints memory statistics (sizes of internal data structures, etc.). NOTE: this method is for testing and profiling purposes only.

Specified by:
  `printMemoryStats` in interface `GridCacheSharedManager`
Overrides:
  `printMemoryStats` in class `GridCacheSharedManagerAdapter`

#### finishLocks

    public IgniteInternalFuture<?> finishLocks(long topVer)

Parameters:
  `topVer` - Topology version.
Returns:
  Future that signals when all locks for given partitions are released.

#### finishExplicitLocks

    public IgniteInternalFuture<?> finishExplicitLocks(long topVer)

Creates a future that will wait for all explicit locks acquired on given topology version to be released.

Parameters:
  `topVer` - Topology version to wait for.
Returns:
  Explicit locks release future.

#### finishAtomicUpdates

    public IgniteInternalFuture<?> finishAtomicUpdates(long topVer)

Parameters:
  `topVer` - Topology version to finish.
Returns:
  Finish update future.

#### finishKeys

    public IgniteInternalFuture<?> finishKeys(Collection<KeyCacheObject> keys,
                                     long topVer)

Parameters:
  `keys` - Key for which locks should be released.
  `topVer` - Topology version.
Returns:
  Future that signals when all locks for given keys are released.

#### recheckPendingLocks

    public void recheckPendingLocks()

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC3
Release Date | : March 24 2015