org.apache.ignite.internal.processors.cache.version

## Class GridCacheVersion

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.version.GridCacheVersion

All Implemented Interfaces:
  Externalizable, Serializable, Comparable<CacheEntryVersion>, CacheEntryVersion, Message

Direct Known Subclasses:
  GridCacheVersionEx

    public class GridCacheVersion
    extends Object
    implements Message, Externalizable, CacheEntryVersion

Grid unique version.

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
`GridCacheVersion()` Empty constructor required by `Externalizable`.
`GridCacheVersion(int topVer, int nodeOrderDrId, long order)`
`GridCacheVersion(int topVer, long order, int nodeOrder, int dataCenterId)`

### Method Summary

All Methods Instance Methods Concrete Methods
`IgniteUuid` `asIgniteUuid()`
`byte` `clusterId()` Cluster id is a value to distinguish updates in case user wants to aggregate and sort updates from several Ignite clusters.
`int` `compareTo(CacheEntryVersion other)`
`GridCacheVersion` `conflictVersion()`
`byte` `dataCenterId()`
`short` `directType()` Gets message type.
`boolean` `equals(Object o)`
`byte` `fieldsCount()` Gets fields count.
`int` `hashCode()`
`boolean` `isGreater(GridCacheVersion ver)`
`boolean` `isGreaterEqual(GridCacheVersion ver)`
`boolean` `isLess(GridCacheVersion ver)`
`boolean` `isLessEqual(GridCacheVersion ver)`
`int` `nodeOrder()`
`int` `nodeOrderAndDrIdRaw()` Gets combined node order and DR ID.
`void` `onAckReceived()` Method called when ack message received.
`long` `order()` Order of the update.
`CacheEntryVersion` `otherClusterVersion()` If source of the update is "local" cluster then `null` will be returned.
`void` `readExternal(ObjectInput in)`
`boolean` `readFrom(ByteBuffer buf, MessageReader reader)` Reads this message from provided byte buffer.
`int` `topologyVersion()`
`String` `toString()`
`void` `writeExternal(ObjectOutput out)`
`boolean` `writeTo(ByteBuffer buf, MessageWriter writer)` Writes this message to provided byte buffer.

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

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

### Constructor Detail

#### GridCacheVersion

    public GridCacheVersion()

Empty constructor required by `Externalizable`.

#### GridCacheVersion

    public GridCacheVersion(int topVer,
                            long order,
                            int nodeOrder,
                            int dataCenterId)

Parameters:
  `topVer` - Topology version plus number of seconds from the start time of the first grid node.
  `order` - Version order.
  `nodeOrder` - Node order.
  `dataCenterId` - Replication data center ID.

#### GridCacheVersion

    public GridCacheVersion(int topVer,
                            int nodeOrderDrId,
                            long order)

Parameters:
  `topVer` - Topology version plus number of seconds from the start time of the first grid node.
  `nodeOrderDrId` - Node order and DR ID.
  `order` - Version order.

### Method Detail

#### topologyVersion

    public int topologyVersion()

Specified by:
  `topologyVersion` in interface `CacheEntryVersion`
Returns:
  Topology version plus number of seconds from the start time of the first grid node.

#### nodeOrderAndDrIdRaw

    public int nodeOrderAndDrIdRaw()

Gets combined node order and DR ID.

Returns:
  Combined integer for node order and DR ID.

#### order

    public long order()

Description copied from interface: `CacheEntryVersion`
Order of the update. Value is an incremental counter value. Scope of counter is node.

Specified by:
  `order` in interface `CacheEntryVersion`
Returns:
  Version order.

#### otherClusterVersion

    public CacheEntryVersion otherClusterVersion()

If source of the update is "local" cluster then `null` will be returned. If updated comes from the other cluster using `IgniteInternalCache.putAllConflict(Map)` then entry version for other cluster.

Specified by:
  `otherClusterVersion` in interface `CacheEntryVersion`
Returns:
  Replication version.
See Also:
  `IgniteInternalCache.putAllConflict(Map)`, `IgniteInternalCache.removeAllConflict(Map)`

#### nodeOrder

    public int nodeOrder()

Specified by:
  `nodeOrder` in interface `CacheEntryVersion`
Returns:
  Node order on which this version was assigned.

#### clusterId

    public byte clusterId()

Cluster id is a value to distinguish updates in case user wants to aggregate and sort updates from several Ignite clusters. `clusterId` id can be set for the node using `GridCacheVersionManager.dataCenterId(byte)`.

Specified by:
  `clusterId` in interface `CacheEntryVersion`
Returns:
  Cluster id.

#### dataCenterId

    public byte dataCenterId()

Returns:
  DR mask.

#### conflictVersion

    public GridCacheVersion conflictVersion()

Returns:
  Conflict version.

#### isGreater

    public boolean isGreater(GridCacheVersion ver)

Parameters:
  `ver` - Version.
Returns:
  `True` if this version is greater.

#### isGreaterEqual

    public boolean isGreaterEqual(GridCacheVersion ver)

Parameters:
  `ver` - Version.
Returns:
  `True` if this version is greater or equal.

#### isLess

    public boolean isLess(GridCacheVersion ver)

Parameters:
  `ver` - Version.
Returns:
  `True` if this version is less.

#### isLessEqual

    public boolean isLessEqual(GridCacheVersion ver)

Parameters:
  `ver` - Version.
Returns:
  `True` if this version is less or equal.

#### asIgniteUuid

    public IgniteUuid asIgniteUuid()

Returns:
  Version represented as `IgniteUuid`

#### onAckReceived

    public void onAckReceived()

Method called when ack message received.

Specified by:
  `onAckReceived` in interface `Message`

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

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

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException

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

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### compareTo

    public int compareTo(CacheEntryVersion other)

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

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

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.14.0
Release Date | : September 29 2022