use of com.baidu.hugegraph.computer.core.network.netty.codec.PreciseFrameDecoder in project hugegraph-computer by hugegraph.
the class NettyProtocol method initializeServerPipeline.
/**
* Initialize the server channel handlers.
*
* <pre>
* +----------------------+
* | 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) |
* +-------------------------------------------------------------------+
* </pre>
*/
protected void initializeServerPipeline(Channel channel, MessageHandler handler) {
ChannelPipeline pipeline = channel.pipeline();
pipeline.addLast("encoder", MessageEncoder.INSTANCE);
if (this.conf.recvBufferFileMode()) {
pipeline.addLast("frameDecoder", new PreciseFrameDecoder());
pipeline.addLast("decoder", MessageDecoder.INSTANCE_FILE_REGION);
} else {
pipeline.addLast("frameDecoder", new FrameDecoder());
pipeline.addLast("decoder", MessageDecoder.INSTANCE_MEMORY_BUFFER);
}
pipeline.addLast("serverIdleStateHandler", this.newServerIdleStateHandler());
// NOTE: The heartbeatHandler can reuse of a server
pipeline.addLast("serverIdleHandler", SERVER_IDLE_HANDLER);
pipeline.addLast(SERVER_HANDLER_NAME, this.newNettyServerHandler(handler));
}
Aggregations