org.apache.ignite.internal.processors.cache

## Class GridCacheMvccCandidate

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate

All Implemented Interfaces:
  Externalizable, Serializable, Comparable<GridCacheMvccCandidate>, CacheLockCandidates

    public class GridCacheMvccCandidate
    extends Object
    implements Externalizable, Comparable<GridCacheMvccCandidate>, CacheLockCandidates

Lock candidate.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`GridCacheMvccCandidate()` Empty constructor required by `Externalizable`.
`GridCacheMvccCandidate(GridCacheEntryEx parent, UUID nodeId, @Nullable UUID otherNodeId, @Nullable GridCacheVersion otherVer, long threadId, GridCacheVersion ver, boolean loc, boolean reentry, boolean tx, boolean singleImplicit, boolean nearLoc, boolean dhtLoc, @Nullable GridCacheVersion serOrder, boolean read)`

### Method Summary

All Methods Instance Methods Concrete Methods
`GridCacheMvccCandidate` `candidate(int idx)`
`int` `compareTo(GridCacheMvccCandidate o)`
`boolean` `dhtLocal()`
`boolean` `equals(Object o)`
`short` `flags()`
`boolean` `hasCandidate(GridCacheVersion ver)`
`int` `hashCode()`
`boolean` `hasSameHolderAs(GridCacheMvccCandidate other)` Lock has the same holder as other lock.
`boolean` `isHeldByThread(long threadId)` Is lock held by the thread.
`boolean` `isHeldByThreadOrVer(long threadId, GridCacheVersion ver)` Is lock held by the thread or cache version.
`IgniteTxKey` `key()`
`boolean` `local()`
`Collection<ClusterNode>` `mappedDhtNodes()`
`Collection<ClusterNode>` `mappedNearNodes()`
`void` `mappedNodeIds(Collection<ClusterNode> mappedDhtNodes, Collection<ClusterNode> mappedNearNodes)`
`boolean` `nearLocal()`
`GridCacheMvccCandidate` `next()`
`void` `next(GridCacheMvccCandidate next)`
`UUID` `nodeId()`
`UUID` `otherNodeId()`
`void` `otherNodeId(UUID otherNodeId)`
`GridCacheVersion` `otherVersion()`
`boolean` `otherVersion(GridCacheVersion otherVer)` Sets mapped version for candidate.
`boolean` `owner()`
`@Nullable GridCacheVersion` `ownerVersion()`
`boolean` `ownerVersion(GridCacheVersion ownerVer)` Sets owned version for proper lock ordering when remote candidate is added.
`<V> GridCacheEntryEx` `parent()`
`void` `parent(GridCacheEntryEx parent)`
`@Nullable GridCacheMvccCandidate` `previous()`
`void` `previous(GridCacheMvccCandidate prev)`
`boolean` `read()`
`void` `readExternal(ObjectInput in)`
`boolean` `ready()`
`GridCacheMvccCandidate` `reenter()`
`boolean` `reentry()`
`boolean` `removed()`
`void` `removeMappedNode(ClusterNode node)`
`boolean` `serializable()`
`@Nullable GridCacheVersion` `serializableOrder()`
`void` `setOwner()` Sets owner flag.
`void` `setReady()` Sets ready flag.
`void` `setReentry()` Sets reentry flag.
`void` `setRemoved()` Sets removed flag.
`void` `setUsed()` Sets used flag.
`boolean` `singleImplicit()`
`int` `size()`
`long` `threadId()`
`AffinityTopologyVersion` `topologyVersion()`
`void` `topologyVersion(AffinityTopologyVersion topVer)`
`String` `toString()`
`boolean` `tx()`
`@Nullable GridCacheMvccCandidate` `unenter()`
`boolean` `used()`
`GridCacheVersion` `version()`
`void` `writeExternal(ObjectOutput out)`

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

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

### Constructor Detail

#### GridCacheMvccCandidate

    public GridCacheMvccCandidate()

Empty constructor required by `Externalizable`.

#### GridCacheMvccCandidate

    public GridCacheMvccCandidate(GridCacheEntryEx parent,
                                  UUID nodeId,
                                  @Nullable
                                  @Nullable UUID otherNodeId,
                                  @Nullable
                                  @Nullable GridCacheVersion otherVer,
                                  long threadId,
                                  GridCacheVersion ver,
                                  boolean loc,
                                  boolean reentry,
                                  boolean tx,
                                  boolean singleImplicit,
                                  boolean nearLoc,
                                  boolean dhtLoc,
                                  @Nullable
                                  @Nullable GridCacheVersion serOrder,
                                  boolean read)

Parameters:
  `parent` - Parent entry.
  `nodeId` - Requesting node ID.
  `otherNodeId` - Near node ID.
  `otherVer` - Other version.
  `threadId` - Requesting thread ID.
  `ver` - Cache version.
  `loc` - `True` if the lock is local.
  `reentry` - `True` if candidate is for reentry.
  `tx` - Transaction flag.
  `singleImplicit` - Single-key-implicit-transaction flag.
  `nearLoc` - Near-local flag.
  `dhtLoc` - DHT local flag.
  `serOrder` - Version for serializable transactions ordering.
  `read` - Read lock flag.

### Method Detail

#### flags

    public short flags()

Returns:
  Flags.

#### parent

    public <V> GridCacheEntryEx parent()

Returns:
  Parent entry.

#### topologyVersion

    public AffinityTopologyVersion topologyVersion()

Returns:
  Topology for which this lock was acquired.

#### topologyVersion

    public void topologyVersion(AffinityTopologyVersion topVer)

Parameters:
  `topVer` - Topology version.

#### reenter

    public GridCacheMvccCandidate reenter()

Returns:
  Reentry candidate.

#### unenter

    @Nullable
    public @Nullable GridCacheMvccCandidate unenter()

Returns:
  Removed reentry candidate or `null`.

#### parent

    public void parent(GridCacheEntryEx parent)

Parameters:
  `parent` - Sets locks parent entry.

#### nodeId

    public UUID nodeId()

Returns:
  Node ID.

#### otherNodeId

    public UUID otherNodeId()

Returns:
  Near or DHT node ID.

#### otherNodeId

    public void otherNodeId(UUID otherNodeId)

Parameters:
  `otherNodeId` - Near or DHT node ID.

#### mappedDhtNodes

    public Collection<ClusterNode> mappedDhtNodes()

Returns:
  Mapped node IDs.

#### mappedNearNodes

    public Collection<ClusterNode> mappedNearNodes()

Returns:
  Mapped node IDs.

#### mappedNodeIds

    public void mappedNodeIds(Collection<ClusterNode> mappedDhtNodes,
                              Collection<ClusterNode> mappedNearNodes)

Parameters:
  `mappedDhtNodes` - Mapped DHT node IDs.

#### removeMappedNode

    public void removeMappedNode(ClusterNode node)

Parameters:
  `node` - Node to remove.

#### otherVersion

    public GridCacheVersion otherVersion()

Returns:
  Near version.

#### otherVersion

    public boolean otherVersion(GridCacheVersion otherVer)

Sets mapped version for candidate. For dht local candidates `otherVer` is near local candidate version. For near local candidates `otherVer` is dht mapped candidate version.

Parameters:
  `otherVer` - Alternative candidate version.
Returns:
  `True` if other version was set, `false` if other version is already set.

#### ownerVersion

    public boolean ownerVersion(GridCacheVersion ownerVer)

Sets owned version for proper lock ordering when remote candidate is added.

Parameters:
  `ownerVer` - Version of owned candidate by the moment this candidate was added.
Returns:
  `True` if owned version was set, `false` otherwise.

#### ownerVersion

    @Nullable
    public @Nullable GridCacheVersion ownerVersion()

Returns:
  Version of owned candidate by the time this candidate was added, or `null` if there were no owned candidates.

#### threadId

    public long threadId()

Returns:
  Thread ID. Can be outdated for explicit transactions.
See Also:
  `Thread.getId()`

#### isHeldByThread

    public boolean isHeldByThread(long threadId)

Is lock held by the thread.

Parameters:
  `threadId` - Thread id.

#### isHeldByThreadOrVer

    public boolean isHeldByThreadOrVer(long threadId,
                                       GridCacheVersion ver)

Is lock held by the thread or cache version.

Parameters:
  `threadId` - Thread id.
  `ver` - Version.

#### hasSameHolderAs

    public boolean hasSameHolderAs(GridCacheMvccCandidate other)

Lock has the same holder as other lock.

Parameters:
  `other` - Other lock.

#### version

    public GridCacheVersion version()

Returns:
  Lock version.

#### local

    public boolean local()

Returns:
  `True` if lock is local.

#### tx

    public boolean tx()

Returns:
  `True` if transaction flag is set.

#### singleImplicit

    public boolean singleImplicit()

Returns:
  `True` if implicit transaction.

#### nearLocal

    public boolean nearLocal()

Returns:
  Near local flag.

#### dhtLocal

    public boolean dhtLocal()

Returns:
  Near local flag.

#### serializable

    public boolean serializable()

Returns:
  Serializable transaction flag.

#### serializableOrder

    @Nullable
    public @Nullable GridCacheVersion serializableOrder()

Returns:
  Version for serializable transactions ordering.

#### read

    public boolean read()

Returns:
  Read lock flag.

#### reentry

    public boolean reentry()

Returns:
  `True` if this candidate is a reentry.

#### setReentry

    public void setReentry()

Sets reentry flag.

#### ready

    public boolean ready()

Returns:
  Ready flag.

#### setReady

    public void setReady()

Sets ready flag.

#### used

    public boolean used()

Returns:
  `True` if lock was released.

#### setUsed

    public void setUsed()

Sets used flag.

#### removed

    public boolean removed()

Returns:
  Removed flag.

#### setRemoved

    public void setRemoved()

Sets removed flag.

#### owner

    public boolean owner()

Returns:
  `True` if is or was an owner.

#### setOwner

    public void setOwner()

Sets owner flag.

#### previous

    @Nullable
    public @Nullable GridCacheMvccCandidate previous()

Returns:
  Lock that comes before in the same thread, possibly `null`.

#### previous

    public void previous(GridCacheMvccCandidate prev)

Parameters:
  `prev` - Lock that comes before in the same thread.

#### next

    public GridCacheMvccCandidate next()

Returns:
  Gets next candidate in this thread.

#### next

    public void next(GridCacheMvccCandidate next)

Parameters:
  `next` - Next candidate in this thread.

#### key

    public IgniteTxKey key()

Returns:
  Key.

#### candidate

    public GridCacheMvccCandidate candidate(int idx)

Specified by:
  `candidate` in interface `CacheLockCandidates`
Parameters:
  `idx` - Candidate index.
Returns:
  Candidate.

#### size

    public int size()

Specified by:
  `size` in interface `CacheLockCandidates`
Returns:
  Number of candidates.

#### hasCandidate

    public boolean hasCandidate(GridCacheVersion ver)

Specified by:
  `hasCandidate` in interface `CacheLockCandidates`
Parameters:
  `ver` - Candidate version.
Returns:
  `True` if contains candidate with given version.

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

Specified by:
  `writeExternal` in interface `Externalizable`
Throws:
  `IOException`

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

Specified by:
  `readExternal` in interface `Externalizable`
Throws:
  `IOException`
  `ClassNotFoundException`

#### compareTo

    public int compareTo(GridCacheMvccCandidate o)

Specified by:
  `compareTo` in interface `Comparable<GridCacheMvccCandidate>`

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.8.1
Release Date | : May 21 2020