org.apache.ignite.internal.processors.cache

## Class GridCacheExplicitLockSpan

- java.lang.Object
- - java.util.concurrent.locks.ReentrantLock
  - - org.apache.ignite.internal.processors.cache.GridCacheExplicitLockSpan

All Implemented Interfaces:
  Serializable, Lock

    public class GridCacheExplicitLockSpan
    extends ReentrantLock

Collection of near local locks acquired by a thread on one topology version.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`GridCacheExplicitLockSpan(AffinityTopologyVersion topVer, GridCacheMvccCandidate cand)`

### Method Summary

Methods
`boolean` `addCandidate(AffinityTopologyVersion topVer, GridCacheMvccCandidate cand)` Adds candidate to a lock span.
`GridCacheMvccCandidate` `candidate(IgniteTxKey key, GridCacheVersion ver)` Gets explicit lock candidate for given key.
`boolean` `isEmpty()`
`void` `markOwned(IgniteTxKey key)` Marks all candidates added for given key as owned.
`IgniteInternalFuture<Object>` `releaseFuture()` Gets span release future.
`boolean` `removeCandidate(GridCacheMvccCandidate cand)` Removes candidate from this lock span.
`GridCacheMvccCandidate` `removeCandidate(IgniteTxKey key, GridCacheVersion ver)` Removes lock by key and optional version.
`AffinityTopologyVersion` `topologyVersion()` Gets actual topology snapshot for thread lock span.
`String` `toString()`

### Methods inherited from class java.util.concurrent.locks.ReentrantLock

`getHoldCount, getOwner, getQueuedThreads, getQueueLength, getWaitingThreads, getWaitQueueLength, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isHeldByCurrentThread, isLocked, lock, lockInterruptibly, newCondition, tryLock, tryLock, unlock`

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

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

### Constructor Detail

#### GridCacheExplicitLockSpan

    public GridCacheExplicitLockSpan(AffinityTopologyVersion topVer,
                             GridCacheMvccCandidate cand)

Parameters:
  `topVer` - Topology version.
  `cand` - Candidate.

### Method Detail

#### addCandidate

    public boolean addCandidate(AffinityTopologyVersion topVer,
                       GridCacheMvccCandidate cand)

Adds candidate to a lock span.

Parameters:
  `topVer` - Topology snapshot for which candidate is added.
  `cand` - Candidate to add.
Returns:
  `True` if candidate was added, `false` if this span is empty and new span should be created.

#### removeCandidate

    public boolean removeCandidate(GridCacheMvccCandidate cand)

Removes candidate from this lock span.

Parameters:
  `cand` - Candidate to remove.
Returns:
  `True` if span is empty and should be removed, `false` otherwise.

#### removeCandidate

    public GridCacheMvccCandidate removeCandidate(IgniteTxKey key,
                                         @Nullable
                                         GridCacheVersion ver)

Removes lock by key and optional version.

Parameters:
  `key` - Key.
  `ver` - Version (or `null` if any candidate should be removed.)
Returns:
  Removed candidate if matches given parameters.

#### isEmpty

    public boolean isEmpty()

Returns:
  `True` if span is empty and candidates cannot be added anymore.

#### markOwned

    public void markOwned(IgniteTxKey key)

Marks all candidates added for given key as owned.

Parameters:
  `key` - Key.

#### candidate

    @Nullable
    public GridCacheMvccCandidate candidate(IgniteTxKey key,
                                            @Nullable
                                            GridCacheVersion ver)

Gets explicit lock candidate for given key.

Parameters:
  `key` - Key to lookup.
  `ver` - Version to lookup (if `null` - return any).
Returns:
  Last added explicit lock candidate, if any, or `null`.

#### topologyVersion

    @Nullable
    public AffinityTopologyVersion topologyVersion()

Gets actual topology snapshot for thread lock span.

Returns:
  Topology snapshot or `null` if candidate list is empty.

#### releaseFuture

    public IgniteInternalFuture<Object> releaseFuture()

Gets span release future. Future is completed when last lock is released.

Returns:
  Release future.

#### toString

    public String toString()

Overrides:
  `toString` in class `ReentrantLock`

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.1.0
Release Date | : July 20 2017