Skip to content

Commit

Permalink
review commits
Browse files Browse the repository at this point in the history
  • Loading branch information
witgo committed Jun 25, 2017
1 parent adc9ce2 commit e5a444f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public NettyServer(InetSocketAddress addr, Configuration conf) {
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline()
.addLast("encoder", NettyFrameEncoder.INSTANCE)
.addLast(TransportFrameDecoder.HANDLER_NAME, NettyUtils.createFrameDecoder())
.addLast("frameDecoder", NettyUtils.createFrameDecoder())
.addLast("decoder", NettyFrameDecoder.INSTANCE)
.addLast("handler", new NettyServerMLHandler());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public NettyTransceiver(
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline()
.addLast("encoder", NettyFrameEncoder.INSTANCE)
.addLast(TransportFrameDecoder.HANDLER_NAME, NettyUtils.createFrameDecoder())
.addLast("frameDecoder", NettyUtils.createFrameDecoder())
.addLast("decoder", NettyFrameDecoder.INSTANCE)
.addLast(
"readTimeout",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.util.concurrent.DefaultThreadFactory;
import io.netty.util.internal.PlatformDependent;

Expand Down Expand Up @@ -84,8 +86,13 @@ public static Class<? extends ServerChannel> getServerChannelClass(IOMode mode)
* Creates a LengthFieldBasedFrameDecoder where the first 8 bytes are the length of the frame.
* This is used before all decoders.
*/
public static TransportFrameDecoder createFrameDecoder() {
return new TransportFrameDecoder();
public static ByteToMessageDecoder createFrameDecoder() {
// maxFrameLength = 2G
// lengthFieldOffset = 0
// lengthFieldLength = 8
// lengthAdjustment = -8, i.e. exclude the 8 byte length itself
// initialBytesToStrip = 8, i.e. strip out the length field itself
return new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 8, -8, 8);
}

/** Returns the remote address on the channel or "&lt;unknown remote&gt;" if none exists. */
Expand Down

This file was deleted.

0 comments on commit e5a444f

Please sign in to comment.