use of org.apache.flink.shaded.netty4.io.netty.handler.codec.LengthFieldBasedFrameDecoder in project iris by chicc999.
the class NettyTransport method handler.
protected ChannelHandler handler() {
return new ChannelInitializer() {
@Override
protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(config.getFrameMaxSize(), 0, 4, 0, 4));
ch.pipeline().addLast(new CommandDecoder());
ch.pipeline().addLast(new CommandEncoder());
ch.pipeline().addLast(new IdleStateHandler(0, 0, config.getChannelMaxIdleTime(), TimeUnit.MILLISECONDS));
ch.pipeline().addLast(dispatcherHandler);
ch.pipeline().addLast(connectionHandler);
}
};
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.LengthFieldBasedFrameDecoder in project netty by netty.
the class LengthFieldBasedFrameDecoderTest method testFailFastTooLongFrameRecovery.
@Test
public void testFailFastTooLongFrameRecovery() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new LengthFieldBasedFrameDecoder(5, 0, 4, 0, 4));
for (int i = 0; i < 2; i++) {
try {
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 2 })));
fail(DecoderException.class.getSimpleName() + " must be raised.");
} catch (TooLongFrameException e) {
// Expected
}
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 0, 0, 1, 'A' }));
ByteBuf buf = ch.readInbound();
assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
buf.release();
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.LengthFieldBasedFrameDecoder in project zipkin by openzipkin.
the class NettyScribeServer method start.
void start() {
bossGroup = EventLoopGroups.newEventLoopGroup(1);
EventLoopGroup workerGroup = CommonPools.workerGroup();
ServerBootstrap b = new ServerBootstrap();
try {
channel = b.group(bossGroup, workerGroup).channel(EventLoopGroups.serverChannelType(bossGroup)).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4)).addLast(new ScribeInboundHandler(scribe));
}
}).bind(port).syncUninterruptibly().channel();
} catch (Throwable t) {
propagateIfFatal(t);
throw new RuntimeException("Could not start scribe server.", t);
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.LengthFieldBasedFrameDecoder in project pravega by pravega.
the class PravegaConnectionListener method createEncodingStack.
@Override
public List<ChannelHandler> createEncodingStack(String connectionName) {
List<ChannelHandler> stack = new ArrayList<>();
stack.add(new ExceptionLoggingHandler(connectionName));
stack.add(new CommandEncoder(null, NO_OP_METRIC_NOTIFIER));
stack.add(new LengthFieldBasedFrameDecoder(MAX_WIRECOMMAND_SIZE, 4, 4));
stack.add(new CommandDecoder());
stack.add(new AppendDecoder());
return stack;
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.LengthFieldBasedFrameDecoder in project pravega by pravega.
the class AdminConnectionListener method createEncodingStack.
@Override
public List<ChannelHandler> createEncodingStack(String connectionName) {
List<ChannelHandler> stack = new ArrayList<>();
stack.add(new ExceptionLoggingHandler(connectionName));
stack.add(new CommandEncoder(null, NO_OP_METRIC_NOTIFIER));
stack.add(new LengthFieldBasedFrameDecoder(MAX_WIRECOMMAND_SIZE, 4, 4));
stack.add(new CommandDecoder());
return stack;
}
Aggregations