BewareMyPower commented on a change in pull request #12917:
URL: https://github.com/apache/pulsar/pull/12917#discussion_r754171520



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -385,16 +385,25 @@ public void startProtocolHandlers(
     private void startProtocolHandler(String protocol,
                                       SocketAddress address,
                                       ChannelInitializer<SocketChannel> 
initializer) throws IOException {
-        ServerBootstrap bootstrap = defaultServerBootstrap.clone();
+
         ServiceConfiguration configuration = pulsar.getConfiguration();
         boolean useSeparateThreadPool = 
configuration.isUseSeparateThreadPoolForProtocolHandlers();
+        ServerBootstrap bootstrap;
         if (useSeparateThreadPool) {
+            bootstrap = new ServerBootstrap();
+            bootstrap.childOption(ChannelOption.ALLOCATOR, 
PulsarByteBufAllocator.DEFAULT);
+            bootstrap.childOption(ChannelOption.TCP_NODELAY, true);
+            bootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR,
+                    new AdaptiveRecvByteBufAllocator(1024, 16 * 1024, 1 * 1024 
* 1024));
+            EventLoopUtil.enableTriggeredMode(bootstrap);

Review comment:
       Could we add the repeat logic into 
`BrokerService#defaultServerBootstrap()`? I think the only difference is the 
second argument of `ServerBootstrap#group`.
   
   For example,
   
   ```java
       private ServerBootstrap defaultServerBootstrap() {
           return defaultServerBootstrap(workerGroup);
       }
   
       private ServerBootstrap defaultServerBootstrap(EventLoopGroup 
workerGroup) {
           ServerBootstrap bootstrap = new ServerBootstrap();
           bootstrap.childOption(ChannelOption.ALLOCATOR, 
PulsarByteBufAllocator.DEFAULT);
           bootstrap.group(acceptorGroup, workerGroup);
           bootstrap.childOption(ChannelOption.TCP_NODELAY, true);
           bootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR,
               new AdaptiveRecvByteBufAllocator(1024, 16 * 1024, 1 * 1024 * 
1024));
           
bootstrap.channel(EventLoopUtil.getServerSocketChannelClass(workerGroup));
           EventLoopUtil.enableTriggeredMode(bootstrap);
           return bootstrap;
       }
   ```
   
   And call `bootstrap = defaultServerBootstrap(dedicatedWorkerGroup);` here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to