com.hazelcast.nio.tcp

## Class PacketDecoder

- java.lang.Object
- - com.hazelcast.internal.networking.ChannelHandler<com.hazelcast.internal.networking.InboundHandler,S,D>
  - - com.hazelcast.internal.networking.InboundHandler<S,D>
    - - com.hazelcast.internal.networking.nio.InboundHandlerWithCounters<ByteBuffer,Consumer<Packet>>
      - - com.hazelcast.nio.tcp.PacketDecoder

-     public class PacketDecoder
      extends com.hazelcast.internal.networking.nio.InboundHandlerWithCounters<ByteBuffer,Consumer<Packet>>

  The `InboundHandler` for member to member communication. It reads as many packets from the src `ByteBuffer` as possible, and each of the Packets is send to the destination.
  See Also:
    `Consumer`, `PacketEncoder`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected TcpIpConnection` | `connection`

    - ### Fields inherited from class com.hazelcast.internal.networking.nio.InboundHandlerWithCounters

      `normalPacketsRead, priorityPacketsRead`

    - ### Fields inherited from class com.hazelcast.internal.networking.ChannelHandler

      `channel, dst, src`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PacketDecoder(TcpIpConnection connection, Consumer<Packet> dst)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `handlerAdded()` Gets called when this ChannelHandler is added to the pipeline.
    `protected void` | `onPacketComplete(Packet packet)`
    `com.hazelcast.internal.networking.HandlerStatus` | `onRead()` A callback to indicate that data is available in the src to be processed.

    - ### Methods inherited from class com.hazelcast.internal.networking.nio.InboundHandlerWithCounters

      `setNormalPacketsRead, setPriorityPacketsRead`

    - ### Methods inherited from class com.hazelcast.internal.networking.InboundHandler

      `initSrcBuffer, initSrcBuffer`

    - ### Methods inherited from class com.hazelcast.internal.networking.ChannelHandler

      `dst, dst, interceptError, setChannel, src, src`

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

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

- - ### Field Detail

    - #### connection

          protected final TcpIpConnection connection

  - ### Constructor Detail

    - #### PacketDecoder

          public PacketDecoder(TcpIpConnection connection,
                               Consumer<Packet> dst)

  - ### Method Detail

    - #### handlerAdded

          public void handlerAdded()

      Description copied from class: `com.hazelcast.internal.networking.ChannelHandler`
      Gets called when this ChannelHandler is added to the pipeline. This method should execute very quickly because it could be executed on an io thread. Will be called from a thread owning this handler.
      Overrides:
        `handlerAdded` in class `com.hazelcast.internal.networking.ChannelHandler<com.hazelcast.internal.networking.InboundHandler,ByteBuffer,Consumer<Packet>>`

    - #### onRead

          public com.hazelcast.internal.networking.HandlerStatus onRead()
                                                                 throws Exception

      Description copied from class: `com.hazelcast.internal.networking.InboundHandler`
      A callback to indicate that data is available in the src to be processed. InboundHandlers should be able to deal with spurious onReads (so a read even though there is nothing to be processed).
      Specified by:
        `onRead` in class `com.hazelcast.internal.networking.InboundHandler<ByteBuffer,Consumer<Packet>>`
      Returns:
        HandlerStatus the status of the handler after processing the src.
      Throws:
        `Exception` - if something fails while reading data from the src or processing the data (e.g. when a Packet fails to get processed). When an exception is thrown, the `ChannelErrorHandler` is called.

    - #### onPacketComplete

          protected void onPacketComplete(Packet packet)

Copyright © 2019. All rights reserved.