use of org.neo4j.causalclustering.messaging.marshalling.RaftMessageDecoder in project neo4j by neo4j.
the class RaftServer method startNettyServer.
private void startNettyServer() {
workerGroup = new NioEventLoopGroup(0, threadFactory);
log.info("Starting server at: " + listenAddress);
ServerBootstrap bootstrap = new ServerBootstrap().group(workerGroup).channel(NioServerSocketChannel.class).option(ChannelOption.SO_REUSEADDR, true).localAddress(listenAddress.socketAddress()).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4));
pipeline.addLast(new LengthFieldPrepender(4));
pipeline.addLast(new VersionDecoder(logProvider));
pipeline.addLast(new VersionPrepender());
pipeline.addLast(new RaftMessageDecoder(marshal));
pipeline.addLast(new RaftMessageHandler());
pipeline.addLast(new ExceptionLoggingHandler(log));
pipeline.addLast(new ExceptionMonitoringHandler(monitors.newMonitor(ExceptionMonitoringHandler.Monitor.class, RaftServer.class)));
pipeline.addLast(new ExceptionSwallowingHandler());
}
});
try {
channel = bootstrap.bind().syncUninterruptibly().channel();
} catch (Exception e) {
//noinspection ConstantConditions
if (e instanceof BindException) {
userLog.error("Address is already bound for setting: " + setting + " with value: " + listenAddress);
log.error("Address is already bound for setting: " + setting + " with value: " + listenAddress, e);
throw e;
}
}
}
Aggregations