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

## Class GridDhtLockFuture<K,V>

- java.lang.Object
- - java.util.concurrent.locks.AbstractOwnableSynchronizer
  - - java.util.concurrent.locks.AbstractQueuedSynchronizer
    - - org.apache.ignite.internal.util.future.GridFutureAdapter<R>
      - - org.apache.ignite.internal.util.future.GridCompoundFuture<T,T>
        - - org.apache.ignite.internal.util.future.GridCompoundIdentityFuture<Boolean>
          - - org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockFuture<K,V>

All Implemented Interfaces:
  Serializable, IgniteInternalFuture<Boolean>, GridDhtFuture<Boolean>, GridCacheMappedVersion, GridCacheFuture<Boolean>, GridCacheMvccFuture<Boolean>

    public final class GridDhtLockFuture<K,V>
    extends GridCompoundIdentityFuture<Boolean>
    implements GridCacheMvccFuture<Boolean>, GridDhtFuture<Boolean>, GridCacheMappedVersion

Cache lock future.

See Also:
  Serialized Form

### Nested Class Summary

### Nested classes/interfaces inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer

`AbstractQueuedSynchronizer.ConditionObject`

### Constructor Summary

Constructors
Constructor and Description
`GridDhtLockFuture(GridCacheContext<K,V> cctx, UUID nearNodeId, GridCacheVersion nearLockVer, long topVer, int cnt, boolean read, long timeout, GridDhtTxLocalAdapter tx, long threadId, long accessTtl, CacheEntryPredicate[] filter)`

### Method Summary

Methods
`GridCacheMvccCandidate` `addEntry(GridDhtCacheEntry entry)` Adds entry to future.
`boolean` `cancel()` Default no-op implementation that always returns `false`.
`Collection<GridDhtCacheEntry>` `entries()`
`Collection<GridDhtCacheEntry>` `entriesCopy()`
`IgniteUuid` `futureId()`
`int` `hashCode()`
`Collection<Integer>` `invalidPartitions()` Node that future should be able to provide keys to retry before it completes, so it's not necessary to wait till future is done to get retry keys.
`void` `map()`
`GridCacheVersion` `mappedVersion()` Mapping should occur only if this interface returns a non-null value.
`void` `markNotTrackable()` Marks this future as non-trackable.
`GridCacheVersion` `nearLockVersion()`
`Collection<? extends ClusterNode>` `nodes()`
`boolean` `onDone(Boolean success, Throwable err)` Callback to notify that future is finished.
`void` `onError(GridDistributedLockCancelledException e)`
`void` `onError(Throwable t)`
`boolean` `onNodeLeft(UUID nodeId)` Callback for when node left.
`boolean` `onOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner)` Callback for whenever entry lock ownership changes.
`String` `toString()`
`boolean` `trackable()`
`GridCacheVersion` `version()`

### Methods inherited from class org.apache.ignite.internal.util.future.GridCompoundFuture

`add, addAll, addAll, futures, hasPending, ignoreChildFailures, initialized, markInitialized, pending, reducer, reducer`

### Methods inherited from class org.apache.ignite.internal.util.future.GridFutureAdapter

`chain, duration, endTime, error, get, get, get, get0, isCancelled, isDone, isFailed, listen, onCancelled, onDone, onDone, onDone, result, startTime, tryAcquireShared, tryReleaseShared`

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

`acquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedPredecessors, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, tryAcquire, tryAcquireNanos, tryAcquireSharedNanos, tryRelease`

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

`getExclusiveOwnerThread, setExclusiveOwnerThread`

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

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

### Methods inherited from interface org.apache.ignite.internal.IgniteInternalFuture

`chain, duration, error, get, get, get, isCancelled, isDone, listen, result, startTime`

### Constructor Detail

#### GridDhtLockFuture

    public GridDhtLockFuture(GridCacheContext<K,V> cctx,
                     UUID nearNodeId,
                     GridCacheVersion nearLockVer,
                     long topVer,
                     int cnt,
                     boolean read,
                     long timeout,
                     GridDhtTxLocalAdapter tx,
                     long threadId,
                     long accessTtl,
                     CacheEntryPredicate[] filter)

Parameters:
  `cctx` - Cache context.
  `nearNodeId` - Near node ID.
  `nearLockVer` - Near lock version.
  `topVer` - Topology version.
  `cnt` - Number of keys to lock.
  `read` - Read flag.
  `timeout` - Lock acquisition timeout.
  `tx` - Transaction.
  `threadId` - Thread ID.
  `accessTtl` - TTL for read operation.
  `filter` - Filter.

### Method Detail

#### invalidPartitions

    public Collection<Integer> invalidPartitions()

Node that future should be able to provide keys to retry before it completes, so it's not necessary to wait till future is done to get retry keys.

Specified by:
  `invalidPartitions` in interface `GridDhtFuture<Boolean>`
Returns:
  Keys to retry because this node is no longer a primary or backup.

#### nodes

    public Collection<? extends ClusterNode> nodes()

Specified by:
  `nodes` in interface `GridCacheFuture<Boolean>`
Returns:
  Participating nodes.

#### version

    public GridCacheVersion version()

Specified by:
  `version` in interface `GridCacheFuture<Boolean>`
Returns:
  Future version.

#### trackable

    public boolean trackable()

Specified by:
  `trackable` in interface `GridCacheFuture<Boolean>`
Returns:
  `True` if future should be tracked.

#### markNotTrackable

    public void markNotTrackable()

Marks this future as non-trackable.

Specified by:
  `markNotTrackable` in interface `GridCacheFuture<Boolean>`

#### entries

    public Collection<GridDhtCacheEntry> entries()

Returns:
  Entries.

#### entriesCopy

    public Collection<GridDhtCacheEntry> entriesCopy()

Returns:
  Entries.

#### futureId

    public IgniteUuid futureId()

Specified by:
  `futureId` in interface `GridCacheFuture<Boolean>`
Returns:
  Future ID.

#### nearLockVersion

    public GridCacheVersion nearLockVersion()

Returns:
  Near lock version.

#### mappedVersion

    @Nullable
    public GridCacheVersion mappedVersion()

Mapping should occur only if this interface returns a non-null value.

Specified by:
  `mappedVersion` in interface `GridCacheMappedVersion`
Returns:
  Mapped version.

#### addEntry

    @Nullable
    public GridCacheMvccCandidate addEntry(GridDhtCacheEntry entry)
                                    throws GridCacheEntryRemovedException,
                                           GridDistributedLockCancelledException

Adds entry to future.

Parameters:
  `entry` - Entry to add.
Returns:
  Lock candidate.
Throws:
  `GridCacheEntryRemovedException` - If entry was removed.
  `GridDistributedLockCancelledException` - If lock is canceled.

#### onNodeLeft

    public boolean onNodeLeft(UUID nodeId)

Description copied from interface: `GridCacheFuture`
Callback for when node left.

Specified by:
  `onNodeLeft` in interface `GridCacheFuture<Boolean>`
Parameters:
  `nodeId` - Left node ID
Returns:
  `True` if node was in the list.

#### onError

    public void onError(GridDistributedLockCancelledException e)

Parameters:
  `e` - Error.

#### onError

    public void onError(Throwable t)

Parameters:
  `t` - Error.

#### onOwnerChanged

    public boolean onOwnerChanged(GridCacheEntryEx entry,
                         GridCacheMvccCandidate owner)

Callback for whenever entry lock ownership changes.

Specified by:
  `onOwnerChanged` in interface `GridCacheMvccFuture<Boolean>`
Parameters:
  `entry` - Entry whose lock ownership changed.
  `owner` - Owner.
Returns:
  `True` if future cares about this entry.

#### cancel

    public boolean cancel()

Default no-op implementation that always returns `false`. Futures that do support cancellation should override this method and call `GridFutureAdapter.onCancelled()` callback explicitly if cancellation indeed did happen.

Specified by:
  `cancel` in interface `IgniteInternalFuture<Boolean>`
Overrides:
  `cancel` in class `GridCompoundFuture<Boolean,Boolean>`
Returns:
  `True` if future was canceled (i.e. was not finished prior to this call).

#### onDone

    public boolean onDone(@Nullable
                 Boolean success,
                 @Nullable
                 Throwable err)

Callback to notify that future is finished. Note that if non-`null` exception is passed in the result value will be ignored.

Overrides:
  `onDone` in class `GridFutureAdapter<Boolean>`
Parameters:
  `success` - Optional result.
  `err` - Optional error.
Returns:
  `True` if result was set by this call.

#### map

    public void map()

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `GridCompoundIdentityFuture<Boolean>`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

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