pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] ambition119 commented on a change in pull request #3336: Added HTTP Support
Date Thu, 10 Jan 2019 01:28:51 GMT
ambition119 commented on a change in pull request #3336: Added HTTP Support
URL: https://github.com/apache/pulsar/pull/3336#discussion_r246610401
 
 

 ##########
 File path: pulsar-io/netty/src/main/java/org/apache/pulsar/io/netty/server/NettyServer.java
 ##########
 @@ -108,6 +116,22 @@ private void runTcp() throws InterruptedException {
         channelFuture.channel().closeFuture().sync();
     }
 
+    private void runHttp() throws InterruptedException {
+        bossGroup = new NioEventLoopGroup(this.numberOfThreads);
+        workerGroup = new NioEventLoopGroup(this.numberOfThreads);
+
+        ServerBootstrap serverBootstrap = new ServerBootstrap();
+        serverBootstrap.group(bossGroup, workerGroup)
+                .channel(NioServerSocketChannel.class)
+                .childHandler(new NettyHttpChannelInitializer(new NettyHttpServerHandler(this.nettySource),
null))
+                .option(ChannelOption.SO_BACKLOG, 1024)
+                .childOption(ChannelOption.SO_KEEPALIVE, true);
+
+        ChannelFuture channelFuture = serverBootstrap.bind(this.host, this.port).sync();
+        channelFuture.channel().closeFuture().sync();
+    }
+
 
 Review comment:
   > Actually the runUDP method uses the Bootstrap class while the other two use the ServerBootstrap
class. I am not sure why that is the case, but it does make the above suggestion a bit more
tricky
   
   The proposal is that runTcp and runHttp use the getServerBootstrap method, not including
runUdp. 
   ```java
   private void runTcp() throws InterruptedException {
           ServerBootstrap serverBootstrap = getServerBootstrap(new NettyChannelInitializer(new
NettyServerHandler(this.nettySource)));
   
           ChannelFuture channelFuture = serverBootstrap.bind(this.host, this.port).sync();
           channelFuture.channel().closeFuture().sync();
   }
   
   private void runHttp() throws InterruptedException {
           ServerBootstrap serverBootstrap = getServerBootstrap(new NettyHttpChannelInitializer(new
NettyHttpServerHandler(this.nettySource), null));
   
           ChannelFuture channelFuture = serverBootstrap.bind(this.host, this.port).sync();
           channelFuture.channel().closeFuture().sync();
   }
   
   private ServerBootstrap getServerBootstrap(ChannelHandler childHandler) {
           bossGroup = new NioEventLoopGroup(this.numberOfThreads);
           workerGroup = new NioEventLoopGroup(this.numberOfThreads);
           ServerBootstrap serverBootstrap = new ServerBootstrap();
           serverBootstrap.group(bossGroup, workerGroup);
           serverBootstrap.channel(NioServerSocketChannel.class);
           serverBootstrap.childHandler(childHandler)
                   .option(ChannelOption.SO_BACKLOG, 1024)
                   .childOption(ChannelOption.SO_KEEPALIVE, true);
   
           return serverBootstrap;
   }
   
   ```
   @david-streamlio If my comments lead you to close this PR, I'm sorry.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message