org.apache.ignite.internal.processors.cache.transactions

## Class TxLock

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.transactions.TxLock

All Implemented Interfaces:
  Serializable, Message

    public class TxLock
    extends Object
    implements Message

Corresponds to one `GridCacheMvccCandidate` from local MVCC candidates queue. There is one exclusion: `TxLock` instance with `OWNERSHIP_REQUESTED` corresponds to lock request to remote node from near node that isn't primary node for key.

See Also:
  Serialized Form

### Field Summary

### Fields inherited from interface org.apache.ignite.plugin.extensions.communication.Message

`DIRECT_TYPE_SIZE`

### Constructor Summary

Constructors
Constructor and Description
`TxLock()` Default constructor.
`TxLock(GridCacheVersion txId, UUID nearNodeId, long threadId, byte ownership)`

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `candiate()`
`short` `directType()` Gets message type.
`byte` `fieldsCount()` Gets fields count.
`UUID` `nearNodeId()`
`void` `onAckReceived()` Method called when ack message received.
`boolean` `owner()`
`boolean` `readFrom(ByteBuffer buf, MessageReader reader)` Reads this message from provided byte buffer.
`boolean` `requested()`
`long` `threadId()`
`String` `toString()`
`GridCacheVersion` `txId()`
`boolean` `writeTo(ByteBuffer buf, MessageWriter writer)` Writes this message to provided byte buffer.

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

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

### Constructor Detail

#### TxLock

    public TxLock()

Default constructor.

#### TxLock

    public TxLock(GridCacheVersion txId,
                  UUID nearNodeId,
                  long threadId,
                  byte ownership)

Parameters:
  `txId` - Tx ID.
  `nearNodeId` - Near node ID.
  `threadId` - Thread ID.
  `ownership` - Ownership.

### Method Detail

#### nearNodeId

    public UUID nearNodeId()

Returns:
  Near node ID.

#### txId

    public GridCacheVersion txId()

Returns:
  Transaction ID.

#### threadId

    public long threadId()

Returns:
  Thread ID.

#### owner

    public boolean owner()

Returns:
  `True` if transaction hold lock on the key, otherwise `false`.

#### candiate

    public boolean candiate()

Returns:
  `True` if there is MVCC candidate for this transaction and key, otherwise `false`.

#### requested

    public boolean requested()

Returns:
  `True` if transaction requested lock for key from primary remote node but response isn't received because other transaction hold lock on the key.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### writeTo

    public boolean writeTo(ByteBuffer buf,
                           MessageWriter writer)

Writes this message to provided byte buffer.

Specified by:
  `writeTo` in interface `Message`
Parameters:
  `buf` - Byte buffer.
  `writer` - Writer.
Returns:
  Whether message was fully written.

#### readFrom

    public boolean readFrom(ByteBuffer buf,
                            MessageReader reader)

Reads this message from provided byte buffer.

Specified by:
  `readFrom` in interface `Message`
Parameters:
  `buf` - Byte buffer.
  `reader` - Reader.
Returns:
  Whether message was fully read.

#### directType

    public short directType()

Gets message type.

Specified by:
  `directType` in interface `Message`
Returns:
  Message type.

#### fieldsCount

    public byte fieldsCount()

Gets fields count.

Specified by:
  `fieldsCount` in interface `Message`
Returns:
  Fields count.

#### onAckReceived

    public void onAckReceived()

Method called when ack message received.

Specified by:
  `onAckReceived` in interface `Message`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022