Skip to content

Instantly share code, notes, and snippets.

@olivermt
Created October 29, 2014 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olivermt/338ef9d4ec7487d83916 to your computer and use it in GitHub Desktop.
Save olivermt/338ef9d4ec7487d83916 to your computer and use it in GitHub Desktop.
EventLoopGroup group = new NioEventLoopGroup();
try {
for(UdpLoadBalancerConfig config : configList) {
System.out.println("Started load balancer on port: " + config.port + " and with servers: " + java.util.Arrays.toString(config.servers));
Bootstrap b = new Bootstrap();
b.group(group)
.channel(NioDatagramChannel.class)
.option(ChannelOption.SO_BROADCAST, true)
.handler(new UdpLoadBalancerHandler(config.servers, debug));
b.bind(config.port).sync().channel().closeFuture().await();
}
} finally {
group.shutdownGracefully();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment