vnhive commented on a change in pull request #3966:
URL: https://github.com/apache/hadoop/pull/3966#discussion_r813515195
##########
File path:
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java
##########
@@ -1957,4 +1969,261 @@ public void close() {
IOUtils.closeStream(in);
}
}
+
+ static class NioIpcStreams extends IpcStreams {
+ NioIpcStreams(Socket socket) throws IOException {
+ setInputStream(
+ new BufferedInputStream(NetUtils.getInputStream(socket)));
+ setOutputStream(
+ new BufferedOutputStream(NetUtils.getOutputStream(socket)));
+ }
+ @Override
+ Future<?> submit(Runnable call) {
+ return Client.getClientExecutor().submit(call);
+ }
+ }
+
+ static class NettyIpcStreams extends IpcStreams {
+ private final EventLoopGroup group;
+ private io.netty.channel.Channel channel;
+ private int soTimeout;
+ private IOException channelIOE;
+
+ NettyIpcStreams(Socket socket) throws IOException {
+ soTimeout = socket.getSoTimeout();
+ if (!LOG.isDebugEnabled()) {
+ ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED);
+ }
+ channel = new NioSocketChannel(socket.getChannel());
+ channel.config().setAutoRead(false);
+
+ SslContext sslCtx = null;
+
+ try {
+ sslCtx = SslContextBuilder.forClient()
+ .trustManager(InsecureTrustManagerFactory.INSTANCE).build();
+ } catch (SSLException e) {
+ throw new IOException("Exception while building SSL Context", e);
+ }
+
+ SslHandler sslHandler = sslCtx.newHandler(channel.alloc());
+
+ if (sslHandler != null) {
+ sslHandler.handshakeFuture().addListener(
+ new
GenericFutureListener<io.netty.util.concurrent.Future<Channel>>() {
+ @Override
+ public void operationComplete(
+ final io.netty.util.concurrent.Future<Channel> handshakeFuture)
+ throws Exception {
+ if (handshakeFuture.isSuccess()) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("TLS handshake success");
+ }
+ } else {
+ throw new IOException("TLS handshake failed." +
handshakeFuture.cause());
+ }
+ }
+ });
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Adding the SSLHandler to the pipeline");
+ }
+ channel.pipeline().addLast("SSL", sslHandler);
+
+ RpcChannelHandler handler = new RpcChannelHandler();
+ setInputStream(new BufferedInputStream(handler.getInputStream()));
+ setOutputStream(new BufferedOutputStream(handler.getOutputStream()));
+ channel.pipeline().addLast(handler);
+ group = new NioEventLoopGroup(1);
Review comment:
will look into this. I will try to update my next PR with this change,
or maybe subsequent PRs. If I am doing it in subsequent PRs, I will create a
JIRA issue for follow up.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]