adoroszlai commented on a change in pull request #2315:
URL: https://github.com/apache/ozone/pull/2315#discussion_r650964633



##########
File path: 
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/StreamingServer.java
##########
@@ -47,35 +48,54 @@
 
   private EventLoopGroup workerGroup;
 
+  private SslContext sslContext;
+
   public StreamingServer(
-          StreamingSource source, int port
+      StreamingSource source, int port
+  ) {
+    this(source, port, null);
+  }
+
+  public StreamingServer(
+      StreamingSource source, int port, SslContext sslContext
   ) {
     this.port = port;
     this.source = source;
+    this.sslContext = sslContext;
   }
 
-  public void start() throws InterruptedException {
-    ServerBootstrap b = new ServerBootstrap();
-    bossGroup = new NioEventLoopGroup(100);
-    workerGroup = new NioEventLoopGroup(100);
-
-    b.group(bossGroup, workerGroup)
-            .channel(NioServerSocketChannel.class)
-            .option(ChannelOption.SO_BACKLOG, 100)
-            .childHandler(new ChannelInitializer<SocketChannel>() {
-              @Override
-              public void initChannel(SocketChannel ch) throws Exception {
-                ch.pipeline().addLast(
-                        new ChunkedWriteHandler(),
-                        new DirstreamServerHandler(source));
+  public void start() {
+    try {
+      ServerBootstrap b = new ServerBootstrap();
+      bossGroup = new NioEventLoopGroup(100);
+      workerGroup = new NioEventLoopGroup(100);
+
+      b.group(bossGroup, workerGroup)
+          .channel(NioServerSocketChannel.class)
+          .option(ChannelOption.SO_BACKLOG, 100)
+
+          .childHandler(new ChannelInitializer<SocketChannel>() {
+            @Override
+            public void initChannel(SocketChannel ch) throws Exception {
+              if (sslContext != null) {
+                ch.pipeline().addLast(sslContext.newHandler(ch.alloc()));
               }
-            });
+              ch.pipeline().addLast(
+                  new ChunkedWriteHandler(),
+                  new DirstreamServerHandler(source));
+
+
+            }
+          });
 
-    ChannelFuture f = b.bind(port).sync();
-    final InetSocketAddress socketAddress =
-            (InetSocketAddress) f.channel().localAddress();
-    port = socketAddress.getPort();
-    LOG.info("Started streaming server on " + port);
+      ChannelFuture f = b.bind(port).sync();
+      final InetSocketAddress socketAddress =
+          (InetSocketAddress) f.channel().localAddress();
+      port = socketAddress.getPort();
+      LOG.info("Started streaming server on " + port);
+    } catch (InterruptedException ex) {
+      throw new RuntimeException(ex);

Review comment:
       So if I understand correctly, the current patch itself does not need to 
handle `InterruptedException`, but a future change (replacing the current 
replication server implementation with the streaming one) will.  So this is in 
anticipation of the next change.
   
   If that's correct, I'm OK with converting it.




-- 
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.

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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to