Package 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 Default Methods Deprecated Methods
    Modifier and Type | Method | 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.
    `default void` | `setBuffer​(ByteBuffer buf)` | Deprecated.
    `int` | `state()` | Gets current message state.
    `boolean` | `writeAffinityTopologyVersion​(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion val)` | Writes `AffinityTopologyVersion`.
    `boolean` | `writeBitSet​(BitSet val)` | Writes `BitSet`.
    `boolean` | `writeBoolean​(boolean val)` | Writes `boolean` value.
    `boolean` | `writeBooleanArray​(boolean[] val)` | Writes `boolean` array.
    `boolean` | `writeByte​(byte val)` | Writes `byte` value.
    `boolean` | `writeByteArray​(byte[] val)` | Writes `byte` array.
    `boolean` | `writeByteArray​(byte[] val, long off, int len)` | Writes `byte` array.
    `boolean` | `writeCacheObject​(org.apache.ignite.internal.processors.cache.CacheObject obj)` | Writes `CacheObject`.
    `boolean` | `writeChar​(char val)` | Writes `char` value.
    `boolean` | `writeCharArray​(char[] val)` | Writes `char` array.
    `<T> boolean` | `writeCollection​(Collection<T> col, MessageCollectionItemType itemType)` | Writes collection with its elements order.
    `boolean` | `writeDouble​(double val)` | Writes `double` value.
    `boolean` | `writeDoubleArray​(double[] val)` | Writes `double` array.
    `boolean` | `writeFloat​(float val)` | Writes `float` value.
    `boolean` | `writeFloatArray​(float[] val)` | Writes `float` array.
    `boolean` | `writeGridLongList​(@Nullable org.apache.ignite.internal.util.GridLongList ll)` | Writes `GridLongList`.
    `boolean` | `writeHeader​(short type)` | Writes message header.
    `boolean` | `writeIgniteUuid​(IgniteUuid val)` | Writes `IgniteUuid`.
    `boolean` | `writeInt​(int val)` | Writes `int` value.
    `boolean` | `writeIntArray​(int[] val)` | Writes `int` array.
    `boolean` | `writeKeyCacheObject​(org.apache.ignite.internal.processors.cache.KeyCacheObject obj)` | Writes `KeyCacheObject`.
    `boolean` | `writeLong​(long val)` | Writes `long` value.
    `boolean` | `writeLongArray​(long[] val)` | Writes `long` array.
    `boolean` | `writeLongArray​(long[] val, int len)` | Writes `long` array.
    `<K,​V> boolean` | `writeMap​(Map<K,​V> map, MessageCollectionItemType keyType, MessageCollectionItemType valType)` | Writes map.
    `boolean` | `writeMessage​(Message val)` | Writes nested message.
    `<T> boolean` | `writeObjectArray​(T[] arr, MessageCollectionItemType itemType)` | Writes array of objects.
    `<T> boolean` | `writeSet​(Set<T> set, MessageCollectionItemType itemType)` | Writes set with its elements order.
    `boolean` | `writeShort​(short val)` | Writes `short` value.
    `boolean` | `writeShortArray​(short[] val)` | Writes `short` array.
    `boolean` | `writeString​(String val)` | Writes `String`.
    `boolean` | `writeUuid​(UUID val)` | Writes `UUID`.

- - ### Method Detail

    - #### setBuffer

          @Deprecated
          default void setBuffer​(ByteBuffer buf)

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

    - #### writeHeader

          boolean writeHeader​(short type)

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

    - #### writeByte

          boolean writeByte​(byte val)

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

    - #### writeShort

          boolean writeShort​(short val)

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

    - #### writeInt

          boolean writeInt​(int val)

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

    - #### writeLong

          boolean writeLong​(long val)

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

    - #### writeFloat

          boolean writeFloat​(float val)

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

    - #### writeDouble

          boolean writeDouble​(double val)

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

    - #### writeChar

          boolean writeChar​(char val)

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

    - #### writeBoolean

          boolean writeBoolean​(boolean val)

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

    - #### writeByteArray

          boolean writeByteArray​(byte[] val)

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

    - #### writeByteArray

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

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

    - #### writeShortArray

          boolean writeShortArray​(short[] val)

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

    - #### writeIntArray

          boolean writeIntArray​(int[] val)

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

    - #### writeLongArray

          boolean writeLongArray​(long[] val)

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

    - #### writeLongArray

          boolean writeLongArray​(long[] val,
                                 int len)

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

    - #### writeFloatArray

          boolean writeFloatArray​(float[] val)

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

    - #### writeDoubleArray

          boolean writeDoubleArray​(double[] val)

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

    - #### writeCharArray

          boolean writeCharArray​(char[] val)

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

    - #### writeBooleanArray

          boolean writeBooleanArray​(boolean[] val)

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

    - #### writeString

          boolean writeString​(String val)

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

    - #### writeBitSet

          boolean writeBitSet​(BitSet val)

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

    - #### writeUuid

          boolean writeUuid​(UUID val)

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

    - #### writeIgniteUuid

          boolean writeIgniteUuid​(IgniteUuid val)

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

    - #### writeAffinityTopologyVersion

          boolean writeAffinityTopologyVersion​(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion val)

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

    - #### writeMessage

          boolean writeMessage​(Message val)

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

    - #### writeCacheObject

          boolean writeCacheObject​(org.apache.ignite.internal.processors.cache.CacheObject obj)

      Writes `CacheObject`.
      Parameters:
        `obj` - Cache object.
      Returns:
        Whether value was fully written.

    - #### writeKeyCacheObject

          boolean writeKeyCacheObject​(org.apache.ignite.internal.processors.cache.KeyCacheObject obj)

      Writes `KeyCacheObject`.
      Parameters:
        `obj` - Key cache object.
      Returns:
        Whether value was fully written.

    - #### writeGridLongList

          boolean writeGridLongList​(@Nullable
                                    @Nullable org.apache.ignite.internal.util.GridLongList ll)

      Writes `GridLongList`.
      Parameters:
        `ll` - Grid long list.
      Returns:
        Whether value was fully written.

    - #### writeObjectArray

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

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

    - #### writeCollection

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

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

    - #### writeSet

          <T> boolean writeSet​(Set<T> set,
                               MessageCollectionItemType itemType)

      Writes set with its elements order.
      Type Parameters:
        `T` - Type of the objects that set contains.
      Parameters:
        `set` - Set.
        `itemType` - Set item type.
      Returns:
        Whether value was fully written.

    - #### writeMap

          <K,​V> boolean writeMap​(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:
        `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.