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
`Collection<GridCacheExplicitLockSpan>` `activeExplicitLocks()`
`Collection<GridCacheFuture<?>>` `activeFutures()`
`boolean` `addAtomicFuture(GridCacheVersion futVer, GridCacheAtomicFuture<?> fut)`
`void` `addExplicitLock(long threadId, GridCacheMvccCandidate cand, AffinityTopologyVersion topVer)` Adds candidate to the list of near local candidates.
`void` `addFuture(GridCacheFuture<?> fut, IgniteUuid futId)`
`boolean` `addFuture(GridCacheMvccFuture<?> fut)` Adds future.
`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` `contextReset()` Reset MVCC context.
`GridCacheMvccCandidate` `explicitLock(IgniteTxKey key, GridCacheVersion ver)` Gets explicit lock candidate added by any thread by given key and lock version.
`GridCacheMvccCandidate` `explicitLock(long threadId, IgniteTxKey key)` Gets last added explicit lock candidate by thread id and key.
`IgniteInternalFuture<?>` `finishAtomicUpdates(AffinityTopologyVersion topVer)`
`IgniteInternalFuture<?>` `finishExplicitLocks(AffinityTopologyVersion topVer)` Creates a future that will wait for all explicit locks acquired on given topology version to be released.
`IgniteInternalFuture<?>` `finishKeys(Collection<KeyCacheObject> keys, int cacheId, AffinityTopologyVersion topVer)`
`IgniteInternalFuture<?>` `finishLocks(AffinityTopologyVersion topVer)`
`GridCacheFuture` `future(IgniteUuid futId)`
`boolean` `isLockedByThread(IgniteTxKey key, long threadId)` Checks if given key is locked by thread with given id or any thread.
`boolean` `isRemoved(GridCacheContext cacheCtx, GridCacheVersion ver)`
`AffinityTopologyVersion` `lastExplicitLockTopologyVersion(long threadId)`
`Collection<GridCacheMvccCandidate>` `localCandidates()` This method has poor performance, so use with care.
`Collection<IgniteTxKey>` `lockedKeys()`
`GridCacheVersion` `mappedVersion(GridCacheVersion from)`
`void` `mapVersion(GridCacheVersion from, GridCacheVersion to)`
`void` `markExplicitOwner(IgniteTxKey key, long threadId)` Marks candidates for given thread and given key as owned.
`GridCacheMvccFuture<?>` `mvccFuture(GridCacheVersion ver, IgniteUuid futId)` Gets future for given future ID and lock ID.
`Collection<GridCacheMvccFuture<?>>` `mvccFutures(GridCacheVersion ver)` Gets futures for given lock ID.
`Collection<IgniteTxKey>` `nearLockedKeys()`
`void` `onDisconnected(IgniteFuture reconnectFut)`
`protected void` `onKernalStart0(boolean reconnect)`
`void` `onKernalStop0(boolean cancel)`
`void` `onStop()` Cancels all client futures.
`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, IgniteTxKey key, GridCacheVersion ver)` Removes explicit lock for given thread id, key and optional version.
`void` `removeExplicitNodeLocks(UUID leftNodeId, AffinityTopologyVersion topVer)`
`void` `removeFuture(IgniteUuid futId)`
`boolean` `removeMvccFuture(GridCacheMvccFuture<?> fut)`
`protected void` `start0()`
`Map<IgniteTxKey,Collection<GridCacheMvccCandidate>>` `unfinishedLocks(AffinityTopologyVersion topVer)`
`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

    protected void onKernalStart0(boolean reconnect)
                           throws IgniteCheckedException

Overrides:
  `onKernalStart0` in class `GridCacheSharedManagerAdapter`
Parameters:
  `reconnect` - `True` if manager restarted after client reconnect.
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.

#### activeExplicitLocks

    public Collection<GridCacheExplicitLockSpan> activeExplicitLocks()

Returns:
  Collection of pending explicit locks.

#### activeFutures

    public Collection<GridCacheFuture<?>> activeFutures()

Returns:
  Collection of active futures.

#### removeExplicitNodeLocks

    public void removeExplicitNodeLocks(UUID leftNodeId,
                               AffinityTopologyVersion topVer)

Parameters:
  `leftNodeId` - Left node ID.
  `topVer` - Topology version.

#### 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.

#### onStop

    public void onStop()

Cancels all client futures.

#### onDisconnected

    public void onDisconnected(IgniteFuture reconnectFut)

Specified by:
  `onDisconnected` in interface `GridCacheSharedManager`
Overrides:
  `onDisconnected` in class `GridCacheSharedManagerAdapter`
Parameters:
  `reconnectFut` - Reconnect future.

#### unmapVersion

    public GridCacheVersion unmapVersion(GridCacheVersion from)

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

#### addAtomicFuture

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

Parameters:
  `futVer` - Future ID.
  `fut` - Future.
Returns:
  `False` if future was forcibly completed with error.

#### 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 void addFuture(GridCacheFuture<?> fut,
                 IgniteUuid futId)

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

#### addFuture

    public boolean addFuture(GridCacheMvccFuture<?> fut)

Adds future.

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

#### removeFuture

    public void removeFuture(IgniteUuid futId)

Parameters:
  `futId` - Future ID.

#### removeMvccFuture

    public boolean removeMvccFuture(GridCacheMvccFuture<?> fut)

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

#### mvccFuture

    @Nullable
    public GridCacheMvccFuture<?> mvccFuture(GridCacheVersion ver,
                                             IgniteUuid futId)

Gets future for given future ID and lock ID.

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

#### mvccFutures

    @Nullable
    public Collection<GridCacheMvccFuture<?>> mvccFutures(GridCacheVersion ver)

Gets futures for given lock ID.

Parameters:
  `ver` - Lock ID.
Returns:
  Futures.

#### future

    @Nullable
    public GridCacheFuture future(IgniteUuid futId)

Parameters:
  `futId` - Future ID.
Returns:
  Found future.

#### isRemoved

    public boolean isRemoved(GridCacheContext cacheCtx,
                    GridCacheVersion ver)

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

#### addRemoved

    public boolean addRemoved(GridCacheContext cacheCtx,
                     GridCacheVersion ver)

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

#### lockedKeys

    public Collection<IgniteTxKey> lockedKeys()

Returns:
  Locked keys.

#### nearLockedKeys

    public Collection<IgniteTxKey> nearLockedKeys()

Returns:
  Locked near keys.

#### 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.

#### addNext

    public boolean addNext(GridCacheContext cacheCtx,
                  GridCacheMvccCandidate cand)

Parameters:
  `cacheCtx` - Cache context.
  `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,
                       AffinityTopologyVersion topVer)

Adds candidate to the list of near local candidates.

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

#### removeExplicitLock

    public void removeExplicitLock(GridCacheMvccCandidate cand)

Removes candidate from the list of near local candidates.

Parameters:
  `cand` - Candidate to remove.

#### isLockedByThread

    public boolean isLockedByThread(IgniteTxKey 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(IgniteTxKey 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,
                                            IgniteTxKey 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,
                                               IgniteTxKey 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(IgniteTxKey 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.

#### lastExplicitLockTopologyVersion

    @Nullable
    public AffinityTopologyVersion lastExplicitLockTopologyVersion(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(AffinityTopologyVersion topVer)

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

#### unfinishedLocks

    public Map<IgniteTxKey,Collection<GridCacheMvccCandidate>> unfinishedLocks(AffinityTopologyVersion topVer)

Parameters:
  `topVer` - Topology version.
Returns:
  Locked keys.

#### finishExplicitLocks

    public IgniteInternalFuture<?> finishExplicitLocks(AffinityTopologyVersion 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(AffinityTopologyVersion topVer)

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

#### finishKeys

    public IgniteInternalFuture<?> finishKeys(Collection<KeyCacheObject> keys,
                                     int cacheId,
                                     AffinityTopologyVersion topVer)

Parameters:
  `keys` - Key for which locks should be released.
  `cacheId` - Cache ID.
  `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.6.0
Release Date | : May 18 2016