public static Server startServer(AvroSourceProtocol handler, int port, boolean enableCompression) {
Responder responder = new SpecificResponder(AvroSourceProtocol.class,
handler);
Server server;
if (enableCompression) {
server = new NettyServer(responder,
new InetSocketAddress(localhost, port),
new NioServerSocketChannelFactory
(Executors .newCachedThreadPool(), Executors.newCachedThreadPool()),
new CompressionChannelPipelineFactory(), null);
} else {
server = new NettyServer(responder,
new InetSocketAddress(localhost, port));
}
server.start();
logger.info("Server started on hostname: {}, port: {}",
new Object[] { localhost, Integer.toString(server.getPort()) });