com.hazelcast.nio.tcp

## Class UnifiedProtocolDecoder

- java.lang.Object
- - com.hazelcast.internal.networking.ChannelHandler<com.hazelcast.internal.networking.InboundHandler,S,D>
  - - com.hazelcast.internal.networking.InboundHandler<ByteBuffer,Void>
    - - com.hazelcast.nio.tcp.UnifiedProtocolDecoder

-     public class UnifiedProtocolDecoder
      extends com.hazelcast.internal.networking.InboundHandler<ByteBuffer,Void>

  A `InboundHandler` that reads the protocol bytes `Protocols` and based on the protocol it creates the appropriate handlers. The ProtocolDecoder doesn't forward to the dst; it replaces itself once the protocol bytes are known. So that is why the Void type for dst.

- - ### Field Summary

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

      `channel, dst, src`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UnifiedProtocolDecoder(IOService ioService, UnifiedProtocolEncoder protocolEncoder)`

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

- - ### Constructor Detail

    - #### UnifiedProtocolDecoder

          public UnifiedProtocolDecoder(IOService ioService,
                                        UnifiedProtocolEncoder protocolEncoder)

  - ### 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,Void>`

    - #### 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,Void>`
      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.

Copyright © 2019. All rights reserved.