org.apache.ignite.internal.processors.cache.binary

## Class MetadataUpdateProposedMessage

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.binary.MetadataUpdateProposedMessage

All Implemented Interfaces:
  Serializable, DiscoveryCustomMessage

    public final class MetadataUpdateProposedMessage
    extends Object
    implements DiscoveryCustomMessage

MetadataUpdateProposedMessage and `MetadataUpdateAcceptedMessage` messages make a basis for discovery-based protocol for exchanging `metadata` describing objects in binary format stored in Ignite caches. All interactions with binary metadata are performed through `BinaryMetadataHandler` interface implemented in `CacheObjectBinaryProcessorImpl` processor. Protocol works as follows:

1. Each thread aiming to add/update metadata sends MetadataUpdateProposedMessage and blocks until receiving acknowledge or reject for proposed update.
2. Coordinator node checks whether proposed update is in conflict with current version of metadata for the same typeId. In case of conflict initial MetadataUpdateProposedMessage is marked rejected and sent to initiator.
3. If there are no conflicts on coordinator, pending version for metadata of this typeId is bumped up by one; MetadataUpdateProposedMessage with pending version information is sent across the cluster.
4. Each node on receiving non-rejected MetadataUpdateProposedMessage updates pending version for the typeId in metadata local cache.
5. When MetadataUpdateProposedMessage finishes pass, `ack` is sent. Ack has the same accepted version as pending version of initial MetadataUpdateProposedMessage message.
6. Each node on receiving MetadataUpdateAcceptedMessage updates accepted version for the typeId. All threads waiting for arrival of ack with this accepted version are unblocked.

If a thread on some node decides to read metadata which has ongoing update (with pending version strictly greater than accepted version) it gets blocked until `MetadataUpdateAcceptedMessage` arrives with accepted version equals to pending version of this metadata to the moment when is was initially read by the thread.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`MetadataUpdateProposedMessage(BinaryMetadata metadata, UUID origNodeId)`

### Method Summary

All Methods Instance Methods Concrete Methods
`@Nullable DiscoveryCustomMessage` `ackMessage()` Called when custom message has been handled by all nodes.
`@Nullable DiscoCache` `createDiscoCache(GridDiscoveryManager mgr, AffinityTopologyVersion topVer, DiscoCache discoCache)` Creates new discovery cache if message caused topology version change.
`IgniteUuid` `id()`
`boolean` `isMutable()`
`BinaryMetadata` `metadata()`
`void` `metadata(BinaryMetadata metadata)`
`String` `toString()`
`int` `typeId()`

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

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

### Constructor Detail

#### MetadataUpdateProposedMessage

    public MetadataUpdateProposedMessage(BinaryMetadata metadata,
                                         UUID origNodeId)

Parameters:
  `metadata` - `BinaryMetadata` requested to be updated.
  `origNodeId` - ID of node requested update.

### Method Detail

#### id

    public IgniteUuid id()

Specified by:
  `id` in interface `DiscoveryCustomMessage`
Returns:
  Unique custom message ID.

#### ackMessage

    @Nullable
    public @Nullable DiscoveryCustomMessage ackMessage()

Called when custom message has been handled by all nodes.

Specified by:
  `ackMessage` in interface `DiscoveryCustomMessage`
Returns:
  Ack message or `null` if ack is not required.

#### isMutable

    public boolean isMutable()

Specified by:
  `isMutable` in interface `DiscoveryCustomMessage`
Returns:
  `True` if message can be modified during listener notification. Changes will be sent to next nodes.

#### createDiscoCache

    @Nullable
    public @Nullable DiscoCache createDiscoCache(GridDiscoveryManager mgr,
                                                           AffinityTopologyVersion topVer,
                                                           DiscoCache discoCache)

Creates new discovery cache if message caused topology version change.

Specified by:
  `createDiscoCache` in interface `DiscoveryCustomMessage`
Parameters:
  `mgr` - Discovery manager.
  `topVer` - New topology version.
  `discoCache` - Current discovery cache.
Returns:
  Reused discovery cache.

#### metadata

    public BinaryMetadata metadata()

#### metadata

    public void metadata(BinaryMetadata metadata)

Parameters:
  `metadata` - Metadata.

#### typeId

    public int typeId()

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.11.0
Release Date | : September 11 2021