use of org.apache.flink.shaded.netty4.io.netty.handler.codec.LengthFieldBasedFrameDecoder in project pravega by pravega.
the class AppendTest method createChannel.
static EmbeddedChannel createChannel(StreamSegmentStore store) {
ServerConnectionInboundHandler lsh = new ServerConnectionInboundHandler();
EmbeddedChannel channel = new EmbeddedChannel(new ExceptionLoggingHandler(""), new CommandEncoder(null, MetricNotifier.NO_OP_METRIC_NOTIFIER), new LengthFieldBasedFrameDecoder(MAX_WIRECOMMAND_SIZE, 4, 4), new CommandDecoder(), new AppendDecoder(), lsh);
lsh.setRequestProcessor(AppendProcessor.defaultBuilder().store(store).connection(new TrackedConnection(lsh)).nextRequestProcessor(new PravegaRequestProcessor(store, mock(TableStore.class), lsh)).build());
return channel;
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.LengthFieldBasedFrameDecoder in project Terasology by MovingBlocks.
the class TerasologyClientPipelineFactory method initChannel.
@Override
protected void initChannel(Channel ch) throws Exception {
JoinStatusImpl joinStatus = new JoinStatusImpl();
ChannelPipeline p = ch.pipeline();
p.addLast(MetricRecordingHandler.NAME, new MetricRecordingHandler());
p.addLast("inflateDecoder", new Lz4FrameDecoder());
p.addLast("lengthFrameDecoder", new LengthFieldBasedFrameDecoder(8388608, 0, 3, 0, 3));
p.addLast("protobufDecoder", new ProtobufDecoder(NetData.NetMessage.getDefaultInstance()));
p.addLast("deflateEncoder", new Lz4FrameEncoder(true));
p.addLast("frameLengthEncoder", new LengthFieldPrepender(3));
p.addLast("protobufEncoder", new ProtobufEncoder());
p.addLast("authenticationHandler", new ClientHandshakeHandler(joinStatus));
p.addLast("connectionHandler", new ClientConnectionHandler(joinStatus, networkSystem));
p.addLast("handler", new ClientHandler(networkSystem));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.LengthFieldBasedFrameDecoder in project Terasology by MovingBlocks.
the class InfoRequestPipelineFactory method initChannel.
@Override
protected void initChannel(Channel ch) throws Exception {
JoinStatusImpl joinStatus = new JoinStatusImpl();
ChannelPipeline p = ch.pipeline();
p.addLast(MetricRecordingHandler.NAME, new MetricRecordingHandler());
p.addLast("inflateDecoder", new Lz4FrameDecoder());
p.addLast("lengthFrameDecoder", new LengthFieldBasedFrameDecoder(8388608, 0, 3, 0, 3));
p.addLast("protobufDecoder", new ProtobufDecoder(NetData.NetMessage.getDefaultInstance()));
p.addLast("deflateEncoder", new Lz4FrameEncoder(true));
p.addLast("frameLengthEncoder", new LengthFieldPrepender(3));
p.addLast("protobufEncoder", new ProtobufEncoder());
p.addLast("authenticationHandler", new ClientHandshakeHandler(joinStatus));
p.addLast("connectionHandler", new ServerInfoRequestHandler());
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.LengthFieldBasedFrameDecoder in project Terasology by MovingBlocks.
the class TerasologyServerPipelineFactory method initChannel.
@Override
protected void initChannel(Channel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
p.addLast(MetricRecordingHandler.NAME, new MetricRecordingHandler());
p.addLast("inflateDecoder", new Lz4FrameDecoder());
p.addLast("lengthFrameDecoder", new LengthFieldBasedFrameDecoder(8388608, 0, 3, 0, 3));
p.addLast("protobufDecoder", new ProtobufDecoder(NetData.NetMessage.getDefaultInstance()));
p.addLast("deflateEncoder", new Lz4FrameEncoder(true));
p.addLast("frameLengthEncoder", new LengthFieldPrepender(3));
p.addLast("protobufEncoder", new ProtobufEncoder());
p.addLast("authenticationHandler", new ServerHandshakeHandler());
p.addLast("connectionHandler", new ServerConnectionHandler(networkSystem));
p.addLast("handler", new ServerHandler(networkSystem));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.LengthFieldBasedFrameDecoder in project angel by Tencent.
the class MatrixTransportServer method start.
public void start() {
Configuration conf = context.getConf();
int workerNum = conf.getInt(AngelConf.ANGEL_NETTY_MATRIXTRANSFER_SERVER_EVENTGROUP_THREADNUM, AngelConf.DEFAULT_ANGEL_NETTY_MATRIXTRANSFER_SERVER_EVENTGROUP_THREADNUM);
int sendBuffSize = conf.getInt(AngelConf.ANGEL_NETTY_MATRIXTRANSFER_SERVER_SNDBUF, AngelConf.DEFAULT_ANGEL_NETTY_MATRIXTRANSFER_SERVER_SNDBUF);
int recvBuffSize = conf.getInt(AngelConf.ANGEL_NETTY_MATRIXTRANSFER_SERVER_RCVBUF, AngelConf.DEFAULT_ANGEL_NETTY_MATRIXTRANSFER_SERVER_RCVBUF);
final int maxMessageSize = conf.getInt(AngelConf.ANGEL_NETTY_MATRIXTRANSFER_MAX_MESSAGE_SIZE, AngelConf.DEFAULT_ANGEL_NETTY_MATRIXTRANSFER_MAX_MESSAGE_SIZE);
int ioRatio = conf.getInt(AngelConf.ANGEL_NETTY_MATRIXTRANSFER_SERVER_IORATIO, AngelConf.DEFAULT_ANGEL_NETTY_MATRIXTRANSFER_SERVER_IORATIO);
String channelType = conf.get(AngelConf.ANGEL_NETTY_MATRIXTRANSFER_SERVER_CHANNEL_TYPE, AngelConf.DEFAULT_ANGEL_NETTY_MATRIXTRANSFER_SERVER_CHANNEL_TYPE);
// Use Epoll for linux
Class channelClass;
String os = System.getProperty("os.name");
if (os != null && os.toLowerCase().startsWith("linux") && channelType.equals("epoll")) {
LOG.info("Use epoll channel");
channelClass = EpollServerSocketChannel.class;
bossGroup = new EpollEventLoopGroup(1);
workerGroup = new EpollEventLoopGroup(workerNum);
((EpollEventLoopGroup) workerGroup).setIoRatio(ioRatio);
} else {
LOG.info("Use nio channel");
channelClass = NioServerSocketChannel.class;
bossGroup = new NioEventLoopGroup(1);
workerGroup = new NioEventLoopGroup(workerNum);
((NioEventLoopGroup) workerGroup).setIoRatio(70);
}
LOG.info("Server port = " + port);
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup).channel(channelClass).option(ChannelOption.SO_SNDBUF, sendBuffSize).option(ChannelOption.SO_RCVBUF, recvBuffSize).option(ChannelOption.SO_KEEPALIVE, true).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
p.addLast(new LengthFieldBasedFrameDecoder(maxMessageSize, 0, 4, 0, 4));
p.addLast(new LengthFieldPrepender(4));
p.addLast(new MatrixTransportServerHandler(context));
}
});
channelFuture = b.bind(port);
}
Aggregations