joshelser commented on a change in pull request #4125:
URL: https://github.com/apache/hbase/pull/4125#discussion_r835650139
##########
File path:
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcConnection.java
##########
@@ -114,47 +107,42 @@
@Override
protected void callTimeout(Call call) {
- execute(eventLoop, () -> {
- if (channel != null) {
- channel.pipeline().fireUserEventTriggered(new CallEvent(TIMEOUT,
call));
- }
- });
+ Channel channel = channelRef.get();
+ if (channel != null) {
+ channel.pipeline().fireUserEventTriggered(new CallEvent(TIMEOUT, call));
+ }
}
@Override
public boolean isActive() {
- return channel != null;
+ return channelRef.get() != null;
}
private void shutdown0() {
- assert eventLoop.inEventLoop();
+ Channel channel = channelRef.getAndSet(null);
if (channel != null) {
channel.close();
- channel = null;
}
}
@Override
public void shutdown() {
- execute(eventLoop, this::shutdown0);
+ this.shutdown0();
}
Review comment:
Can consolidate `shutdown()` and `shutdown0()` since we aren't running
on the EventLoop
##########
File path:
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/X509Util.java
##########
@@ -0,0 +1,324 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.io.crypto.tls;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.security.GeneralSecurityException;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.NoSuchAlgorithmException;
+import java.security.Security;
+import java.security.cert.PKIXBuilderParameters;
+import java.security.cert.X509CertSelector;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.net.ssl.CertPathTrustManagerParameters;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509ExtendedTrustManager;
+import javax.net.ssl.X509KeyManager;
+import javax.net.ssl.X509TrustManager;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.exceptions.X509Exception;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Utility code for X509 handling
+ *
+ * Default cipher suites:
+ *
+ * Performance testing done by Facebook engineers shows that on Intel x86_64
machines,
+ * Java9 performs better with GCM and Java8 performs better with CBC, so
these seem like
+ * reasonable defaults.
+ */
[email protected]
+public class X509Util {
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(X509Util.class);
+
+ // Config
+ static final String CONFIG_PREFIX = "hbase.security.tls.";
Review comment:
nit: `hbase.rpc.tls` instead of `hbase.security.tls` please. Since this
is specific to RPC (our `hbase.security` configs tend to be higher-level stuff,
hbase auth'n or auth'z)
##########
File path:
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcConnection.java
##########
@@ -321,31 +320,39 @@ public void run(boolean cancelled) throws IOException {
} else {
Channel channel = channelRef.get();
if (channel == null) {
- try {
- Channel newChannel = connect();
- if (!channelRef.compareAndSet(null, newChannel)) {
- newChannel.close();
+ connect().addListener(new ChannelFutureListener() {
+ @Override public void operationComplete(ChannelFuture
channelFuture) {
+ Channel ch = channelFuture.channel();
+ if (channelFuture.isSuccess()) {
+ if (!channelRef.compareAndSet(null, ch)) {
+ ch.close();
+ ch = channelRef.get();
+ }
+ writeAndFlushToChannel(call, ch);
Review comment:
Definitely can benefit from a comment here :). I had to read this a
couple of times.
Essentially, if we have a non-null channel already set on the reference,
close the channel we just opened via from the Future, and then write our call
to the channel which was already open.
Crazy question: is it possible that `ch` and `channelRef.get()` refer the
same Channel object in this code?
--
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]