Class NettyProtocol


  • public class NettyProtocol
    extends java.lang.Object
    Defines the server and client channel handlers, i.e. the protocol.
    • Field Detail

      • CLIENT_HANDLER_NAME

        protected static final java.lang.String CLIENT_HANDLER_NAME
        See Also:
        Constant Field Values
      • SERVER_HANDLER_NAME

        protected static final java.lang.String SERVER_HANDLER_NAME
        See Also:
        Constant Field Values
    • Constructor Detail

    • Method Detail

      • initializeServerPipeline

        protected void initializeServerPipeline​(io.netty.channel.Channel channel,
                                                MessageHandler handler)
        Initialize the server channel handlers.
             +----------------------+
             | File / Local Buffer  |
             +-----------+----------+
                        /|\ (2) zero-copy
         +---------------+---------------------------------------------------+
         |               |        SERVER CHANNEL PIPELINE                    |
         |               |                                                   |
         |    +----------+----------+ (3)write ack +----------------------+  |
         |    | ServerHandler       |------------->| MessageEncoder       |  |
         |    +----------+----------+              +-----------+----------+  |
         |              /|\                                 \|/              |
         |               |                                   |               |
         |    +----------+----------+                        |               |
         |    | MessageDecoder      |                        |               |
         |    +----------+----------+                        |               |
         |              /|\                                  |               |
         |               |                                   |               |
         |   +-----------+-----------+                       |               |
         |   | PreciseFrameDecoder   |                       |               |
         |   +-----------+-----------+                       |               |
         |              /|\                                  |               |
         +---------------+-----------------------------------+---------------+
         |               | (1) read request                 \|/              |
         +---------------+-----------------------------------+---------------+
         |               |                                   |               |
         |       [ Socket.read() ]                    [ Socket.write() ]     |
         |                                                                   |
         |  Netty Internal I/O Threads (Transport Implementation)            |
         +-------------------------------------------------------------------+
         
      • initializeClientPipeline

        protected void initializeClientPipeline​(io.netty.channel.Channel channel)
        Initialize the client channel handlers.
                                                 +----------------------+
                                                 | request client       |
                                                 +-----------+----------+
                                                             | (1) send message
         +-------------------------------------------------------------------+
         |                        CLIENT CHANNEL PIPELINE    |               |
         |                                                  \|/              |
         |    +---------------------+            +----------------------+    |
         |    | ClientHandler       |            | MessageEncoder       |    |
         |    +----------+----------+            +-----------+----------+    |
         |              /|\                                 \|/              |
         |               |                                   |               |
         |    +----------+----------+                        |               |
         |    | MessageDecoder      |                        |               |
         |    +----------+----------+                        |               |
         |              /|\                                  |               |
         |               |                                   |               |
         |   +-----------+-----------+                       |               |
         |   | FrameDecoder          |                       |               |
         |   +-----------+-----------+                       |               |
         |              /|\                                  |               |
         +---------------+-----------------------------------+---------------+
         |               | (3) server response              \|/ (2) client request
         +---------------+-----------------------------------+---------------+
         |               |                                   |               |
         |       [ Socket.read() ]                    [ Socket.write() ]     |
         |                                                                   |
         |  Netty Internal I/O Threads (Transport Implementation)            |
         +-------------------------------------------------------------------+
         
      • replaceClientHandler

        protected void replaceClientHandler​(io.netty.channel.Channel channel,
                                            NettyTransportClient client)