use of io.pravega.shared.protocol.netty.ExceptionLoggingHandler in project pravega by pravega.
the class PravegaConnectionListener method startListening.
// endregion
public void startListening() {
// Configure SSL.
final SslContext sslCtx;
if (ssl) {
try {
sslCtx = SslContextBuilder.forServer(new File(this.certFile), new File(this.keyFile)).build();
} catch (SSLException e) {
throw new RuntimeException(e);
}
} else {
sslCtx = null;
}
boolean nio = false;
try {
bossGroup = new EpollEventLoopGroup(1);
workerGroup = new EpollEventLoopGroup();
} catch (ExceptionInInitializerError | UnsatisfiedLinkError | NoClassDefFoundError e) {
nio = true;
bossGroup = new NioEventLoopGroup(1);
workerGroup = new NioEventLoopGroup();
}
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup).channel(nio ? NioServerSocketChannel.class : EpollServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, 100).handler(new LoggingHandler(LogLevel.INFO)).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
if (sslCtx != null) {
SslHandler handler = sslCtx.newHandler(ch.alloc());
p.addLast(handler);
}
ServerConnectionInboundHandler lsh = new ServerConnectionInboundHandler();
// p.addLast(new LoggingHandler(LogLevel.INFO));
p.addLast(new ExceptionLoggingHandler(ch.remoteAddress().toString()), new CommandEncoder(null), new LengthFieldBasedFrameDecoder(MAX_WIRECOMMAND_SIZE, 4, 4), new CommandDecoder(), new AppendDecoder(), lsh);
lsh.setRequestProcessor(new AppendProcessor(store, lsh, new PravegaRequestProcessor(store, lsh, statsRecorder, tokenVerifier), statsRecorder, tokenVerifier));
}
});
// Start the server.
serverChannel = b.bind(host, port).awaitUninterruptibly().channel();
}
use of io.pravega.shared.protocol.netty.ExceptionLoggingHandler in project pravega by pravega.
the class AdminConnectionListenerTest method testCreateEncodingStack.
@Test
public void testCreateEncodingStack() {
@Cleanup AdminConnectionListener listener = new AdminConnectionListener(false, false, "localhost", 6622, mock(StreamSegmentStore.class), mock(TableStore.class), new PassingTokenVerifier(), null, null, SecurityConfigDefaults.TLS_PROTOCOL_VERSION);
List<ChannelHandler> stack = listener.createEncodingStack("connection");
// Check that the order of encoders is the right one.
Assert.assertTrue(stack.get(0) instanceof ExceptionLoggingHandler);
Assert.assertTrue(stack.get(1) instanceof CommandEncoder);
Assert.assertTrue(stack.get(2) instanceof LengthFieldBasedFrameDecoder);
Assert.assertTrue(stack.get(3) instanceof CommandDecoder);
}
Aggregations