org.apache.ignite.plugin.extensions.communication

## Interface MessageWriter

-     public interface MessageWriter

  Communication message writer.

  Allows to customize the binary format of communication messages.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterInnerMessageWrite(boolean finished)` Callback called after inner message is written.
    `void` | `beforeInnerMessageWrite()` Callback called before inner message is written.
    `void` | `incrementState()` Increments state.
    `boolean` | `isHeaderWritten()`
    `void` | `onHeaderWritten()` Callback called when header of the message is written.
    `void` | `reset()` Resets this writer.
    `void` | `setBuffer(ByteBuffer buf)` Sets but buffer to write to.
    `void` | `setCurrentWriteClass(Class<? extends Message> msgCls)` Sets type of message currently written.
    `int` | `state()` Gets current message state.
    `boolean` | `writeAffinityTopologyVersion(String name, org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion val)` Writes `AffinityTopologyVersion`.
    `boolean` | `writeBitSet(String name, BitSet val)` Writes `BitSet`.
    `boolean` | `writeBoolean(String name, boolean val)` Writes `boolean` value.
    `boolean` | `writeBooleanArray(String name, boolean[] val)` Writes `boolean` array.
    `boolean` | `writeByte(String name, byte val)` Writes `byte` value.
    `boolean` | `writeByteArray(String name, byte[] val)` Writes `byte` array.
    `boolean` | `writeByteArray(String name, byte[] val, long off, int len)` Writes `byte` array.
    `boolean` | `writeChar(String name, char val)` Writes `char` value.
    `boolean` | `writeCharArray(String name, char[] val)` Writes `char` array.
    `<T> boolean` | `writeCollection(String name, Collection<T> col, MessageCollectionItemType itemType)` Writes collection.
    `boolean` | `writeDouble(String name, double val)` Writes `double` value.
    `boolean` | `writeDoubleArray(String name, double[] val)` Writes `double` array.
    `boolean` | `writeFloat(String name, float val)` Writes `float` value.
    `boolean` | `writeFloatArray(String name, float[] val)` Writes `float` array.
    `boolean` | `writeHeader(short type, byte fieldCnt)` Writes message header.
    `boolean` | `writeIgniteUuid(String name, IgniteUuid val)` Writes `IgniteUuid`.
    `boolean` | `writeInt(String name, int val)` Writes `int` value.
    `boolean` | `writeIntArray(String name, int[] val)` Writes `int` array.
    `boolean` | `writeLong(String name, long val)` Writes `long` value.
    `boolean` | `writeLongArray(String name, long[] val)` Writes `long` array.
    `boolean` | `writeLongArray(String name, long[] val, int len)` Writes `long` array.
    `<K,V> boolean` | `writeMap(String name, Map<K,V> map, MessageCollectionItemType keyType, MessageCollectionItemType valType)` Writes map.
    `boolean` | `writeMessage(String name, Message val)` Writes nested message.
    `<T> boolean` | `writeObjectArray(String name, T[] arr, MessageCollectionItemType itemType)` Writes array of objects.
    `boolean` | `writeShort(String name, short val)` Writes `short` value.
    `boolean` | `writeShortArray(String name, short[] val)` Writes `short` array.
    `boolean` | `writeString(String name, String val)` Writes `String`.
    `boolean` | `writeUuid(String name, UUID val)` Writes `UUID`.

- - ### Method Detail

    - #### setBuffer

          void setBuffer(ByteBuffer buf)

      Sets but buffer to write to.
      Parameters:
        `buf` - Byte buffer.

    - #### setCurrentWriteClass

          void setCurrentWriteClass(Class<? extends Message> msgCls)

      Sets type of message currently written.
      Parameters:
        `msgCls` - Message type.

    - #### writeHeader

          boolean writeHeader(short type,
                              byte fieldCnt)

      Writes message header.
      Parameters:
        `type` - Message type.
        `fieldCnt` - Fields count.
      Returns:
        `true` if successfully. Otherwise returns `false`.

    - #### writeByte

          boolean writeByte(String name,
                            byte val)

      Writes `byte` value.
      Parameters:
        `name` - Field name.
        `val` - `byte` value.
      Returns:
        Whether value was fully written.

    - #### writeShort

          boolean writeShort(String name,
                             short val)

      Writes `short` value.
      Parameters:
        `name` - Field name.
        `val` - `short` value.
      Returns:
        Whether value was fully written.

    - #### writeInt

          boolean writeInt(String name,
                           int val)

      Writes `int` value.
      Parameters:
        `name` - Field name.
        `val` - `int` value.
      Returns:
        Whether value was fully written.

    - #### writeLong

          boolean writeLong(String name,
                            long val)

      Writes `long` value.
      Parameters:
        `name` - Field name.
        `val` - `long` value.
      Returns:
        Whether value was fully written.

    - #### writeFloat

          boolean writeFloat(String name,
                             float val)

      Writes `float` value.
      Parameters:
        `name` - Field name.
        `val` - `float` value.
      Returns:
        Whether value was fully written.

    - #### writeDouble

          boolean writeDouble(String name,
                              double val)

      Writes `double` value.
      Parameters:
        `name` - Field name.
        `val` - `double` value.
      Returns:
        Whether value was fully written.

    - #### writeChar

          boolean writeChar(String name,
                            char val)

      Writes `char` value.
      Parameters:
        `name` - Field name.
        `val` - `char` value.
      Returns:
        Whether value was fully written.

    - #### writeBoolean

          boolean writeBoolean(String name,
                               boolean val)

      Writes `boolean` value.
      Parameters:
        `name` - Field name.
        `val` - `boolean` value.
      Returns:
        Whether value was fully written.

    - #### writeByteArray

          boolean writeByteArray(String name,
                                 byte[] val)

      Writes `byte` array.
      Parameters:
        `name` - Field name.
        `val` - `byte` array.
      Returns:
        Whether array was fully written.

    - #### writeByteArray

          boolean writeByteArray(String name,
                                 byte[] val,
                                 long off,
                                 int len)

      Writes `byte` array.
      Parameters:
        `name` - Field name.
        `val` - `byte` array.
        `off` - Offset.
        `len` - Length.
      Returns:
        Whether array was fully written.

    - #### writeShortArray

          boolean writeShortArray(String name,
                                  short[] val)

      Writes `short` array.
      Parameters:
        `name` - Field name.
        `val` - `short` array.
      Returns:
        Whether array was fully written.

    - #### writeIntArray

          boolean writeIntArray(String name,
                                int[] val)

      Writes `int` array.
      Parameters:
        `name` - Field name.
        `val` - `int` array.
      Returns:
        Whether array was fully written.

    - #### writeLongArray

          boolean writeLongArray(String name,
                                 long[] val)

      Writes `long` array.
      Parameters:
        `name` - Field name.
        `val` - `long` array.
      Returns:
        Whether array was fully written.

    - #### writeLongArray

          boolean writeLongArray(String name,
                                 long[] val,
                                 int len)

      Writes `long` array.
      Parameters:
        `name` - Field name.
        `val` - `long` array.
        `len` - Length.
      Returns:
        Whether array was fully written.

    - #### writeFloatArray

          boolean writeFloatArray(String name,
                                  float[] val)

      Writes `float` array.
      Parameters:
        `name` - Field name.
        `val` - `float` array.
      Returns:
        Whether array was fully written.

    - #### writeDoubleArray

          boolean writeDoubleArray(String name,
                                   double[] val)

      Writes `double` array.
      Parameters:
        `name` - Field name.
        `val` - `double` array.
      Returns:
        Whether array was fully written.

    - #### writeCharArray

          boolean writeCharArray(String name,
                                 char[] val)

      Writes `char` array.
      Parameters:
        `name` - Field name.
        `val` - `char` array.
      Returns:
        Whether array was fully written.

    - #### writeBooleanArray

          boolean writeBooleanArray(String name,
                                    boolean[] val)

      Writes `boolean` array.
      Parameters:
        `name` - Field name.
        `val` - `boolean` array.
      Returns:
        Whether array was fully written.

    - #### writeString

          boolean writeString(String name,
                              String val)

      Writes `String`.
      Parameters:
        `name` - Field name.
        `val` - `String`.
      Returns:
        Whether value was fully written.

    - #### writeBitSet

          boolean writeBitSet(String name,
                              BitSet val)

      Writes `BitSet`.
      Parameters:
        `name` - Field name.
        `val` - `BitSet`.
      Returns:
        Whether value was fully written.

    - #### writeUuid

          boolean writeUuid(String name,
                            UUID val)

      Writes `UUID`.
      Parameters:
        `name` - Field name.
        `val` - `UUID`.
      Returns:
        Whether value was fully written.

    - #### writeIgniteUuid

          boolean writeIgniteUuid(String name,
                                  IgniteUuid val)

      Writes `IgniteUuid`.
      Parameters:
        `name` - Field name.
        `val` - `IgniteUuid`.
      Returns:
        Whether value was fully written.

    - #### writeAffinityTopologyVersion

          boolean writeAffinityTopologyVersion(String name,
                                               org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion val)

      Writes `AffinityTopologyVersion`.
      Parameters:
        `name` - Field name.
        `val` - `AffinityTopologyVersion`.
      Returns:
        Whether value was fully written.

    - #### writeMessage

          boolean writeMessage(String name,
                               Message val)

      Writes nested message.
      Parameters:
        `name` - Field name.
        `val` - Message.
      Returns:
        Whether value was fully written.

    - #### writeObjectArray

          <T> boolean writeObjectArray(String name,
                                       T[] arr,
                                       MessageCollectionItemType itemType)

      Writes array of objects.
      Type Parameters:
        `T` - Type of the objects that array contains.
      Parameters:
        `name` - Field name.
        `arr` - Array of objects.
        `itemType` - Array component type.
      Returns:
        Whether array was fully written.

    - #### writeCollection

          <T> boolean writeCollection(String name,
                                      Collection<T> col,
                                      MessageCollectionItemType itemType)

      Writes collection.
      Type Parameters:
        `T` - Type of the objects that collection contains.
      Parameters:
        `name` - Field name.
        `col` - Collection.
        `itemType` - Collection item type.
      Returns:
        Whether value was fully written.

    - #### writeMap

          <K,V> boolean writeMap(String name,
                                 Map<K,V> map,
                                 MessageCollectionItemType keyType,
                                 MessageCollectionItemType valType)

      Writes map.
      Type Parameters:
        `K` - Initial key types of the map to write.
        `V` - Initial value types of the map to write.
      Parameters:
        `name` - Field name.
        `map` - Map.
        `keyType` - Map key type.
        `valType` - Map value type.
      Returns:
        Whether value was fully written.

    - #### isHeaderWritten

          boolean isHeaderWritten()

      Returns:
        Whether header of current message is already written.

    - #### onHeaderWritten

          void onHeaderWritten()

      Callback called when header of the message is written.

    - #### state

          int state()

      Gets current message state.
      Returns:
        State.

    - #### incrementState

          void incrementState()

      Increments state.

    - #### beforeInnerMessageWrite

          void beforeInnerMessageWrite()

      Callback called before inner message is written.

    - #### afterInnerMessageWrite

          void afterInnerMessageWrite(boolean finished)

      Callback called after inner message is written.
      Parameters:
        `finished` - Whether message was fully written.

    - #### reset

          void reset()

      Resets this writer.

${current.year} Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.15.0
Release Date | : April 25 2023