use of org.neo4j.helpers.PortBindException in project neo4j by neo4j.
the class NettyServer method start.
@Override
public void start() throws Throwable {
// The boss thread accepts new incoming connections and chooses a worker thread to be responsible for the
// IO of the new connection. We expect new connections to be (comparatively) rare, so we allocate a single
// thread for this.
// TODO: In fact, dedicating a whole thread to sit and spin in #select for new connections may be a waste of
// time, we could have the same event loop groups for both handling new connections and for handling events
// on existing connections
bossGroup = new NioEventLoopGroup(1, tf);
// These threads handle live channels. Each thread has a set of channels it is responsible for, and it will
// continuously run a #select() loop to react to new events on these channels.
selectorGroup = new NioEventLoopGroup(NUM_SELECTOR_THREADS, tf);
for (ProtocolInitializer initializer : bootstrappers) {
try {
new ServerBootstrap().option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT).group(bossGroup, selectorGroup).channel(NioServerSocketChannel.class).childHandler(initializer.channelInitializer()).bind(initializer.address().socketAddress()).sync();
} catch (Throwable e) {
// In any case, we do all this just in order to throw a more helpful bind exception, oh, and here's that part coming right now!
if (e instanceof BindException) {
throw new PortBindException(initializer.address(), (BindException) e);
}
throw e;
}
}
}
Aggregations