Github user jackylk commented on a diff in the pull request:

    
https://github.com/apache/incubator-carbondata/pull/605#discussion_r102363743
  
    --- Diff: 
core/src/main/java/org/apache/carbondata/core/dictionary/server/DictionaryServer.java
 ---
    @@ -42,38 +38,40 @@
       private static final LogService LOGGER =
               
LogServiceFactory.getLogService(DictionaryServer.class.getName());
     
    -  private ServerBootstrap bootstrap;
    -
       private DictionaryServerHandler dictionaryServerHandler;
     
    +  private EventLoopGroup boss;
    +  private EventLoopGroup worker;
    +
       /**
        * start dictionary server
        *
        * @param port
        * @throws Exception
        */
       public void startServer(int port) {
    -    bootstrap = new ServerBootstrap();
         dictionaryServerHandler = new DictionaryServerHandler();
    +    boss = new NioEventLoopGroup();
    +    worker = new NioEventLoopGroup();
    +    // Configure the server.
    +    try {
    +      ServerBootstrap bootstrap = new ServerBootstrap();
    +      bootstrap.group(boss, worker);
    +      bootstrap.channel(NioServerSocketChannel.class);
     
    -    ExecutorService boss = Executors.newCachedThreadPool();
    -    ExecutorService worker = Executors.newCachedThreadPool();
    -
    -    bootstrap.setFactory(new NioServerSocketChannelFactory(boss, worker));
    +      bootstrap.childHandler(new ChannelInitializer<SocketChannel>() {
    +        @Override public void initChannel(SocketChannel ch) throws 
Exception {
    +          ChannelPipeline pipeline = ch.pipeline();
    +          pipeline.addLast("DictionaryServerHandler", 
dictionaryServerHandler);
    +        }
    +      });
    +      bootstrap.bind(port).sync();
    --- End diff --
    
    I think SO_KEEPALIVE is needed, and please log the port it is listening:
    ```
        bootstrap.childOption(ChannelOption.SO_KEEPALIVE, true);
    
        // bind server address
        bindFuture = bootstrap.bind(new 
InetSocketAddress(port)).syncUninterruptibly();
        localAddr = (InetSocketAddress) bindFuture.channel().localAddress();
    
        long endTime = System.currentTimeMillis();
        LOGGER.info("Dictionary Server started! Time spent " + (endTime - 
startTime) +
            ", listening on " + localAddr);
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to