You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2022/08/09 08:18:29 UTC

[hbase] branch master updated: HBASE-27283 Use readTO instead of hard coded RpcClient.DEFAULT_SOCKET_TIMEOUT_READ when creating ReadTimeoutHandler in NettyRpcConnection (#4685)

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/master by this push:
     new 5919b30b6d9 HBASE-27283 Use readTO instead of hard coded RpcClient.DEFAULT_SOCKET_TIMEOUT_READ when creating ReadTimeoutHandler in NettyRpcConnection (#4685)
5919b30b6d9 is described below

commit 5919b30b6d9e905130033461efc37fae60bab947
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Tue Aug 9 16:18:23 2022 +0800

    HBASE-27283 Use readTO instead of hard coded RpcClient.DEFAULT_SOCKET_TIMEOUT_READ when creating ReadTimeoutHandler in NettyRpcConnection (#4685)
    
    Signed-off-by: Xin Sun <ddupgs@gmail.com
    Signed-off-by: GeorryHuang <hu...@apache.org>
---
 .../hadoop/hbase/ipc/NettyRpcConnection.java       |  4 +--
 .../hadoop/hbase/security/TestSecureIPC.java       | 34 +++++++++++-----------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcConnection.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcConnection.java
index cd12c7d2073..e7ef0825973 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcConnection.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcConnection.java
@@ -240,7 +240,7 @@ class NettyRpcConnection extends RpcConnection {
             // because of the different configuration in client side and server side
             final String readTimeoutHandlerName = "ReadTimeout";
             p.addBefore(BufferCallBeforeInitHandler.NAME, readTimeoutHandlerName,
-              new ReadTimeoutHandler(RpcClient.DEFAULT_SOCKET_TIMEOUT_READ, TimeUnit.MILLISECONDS))
+              new ReadTimeoutHandler(rpcClient.readTO, TimeUnit.MILLISECONDS))
               .addBefore(BufferCallBeforeInitHandler.NAME, null, chHandler);
             NettyFutureUtils.addListener(connectionHeaderPromise, new FutureListener<Boolean>() {
               @Override
@@ -249,7 +249,7 @@ class NettyRpcConnection extends RpcConnection {
                   ChannelPipeline p = ch.pipeline();
                   p.remove(readTimeoutHandlerName);
                   p.remove(NettyHBaseRpcConnectionHeaderHandler.class);
-                  // don't send connection header, NettyHbaseRpcConnectionHeaderHandler
+                  // don't send connection header, NettyHBaseRpcConnectionHeaderHandler
                   // sent it already
                   established(ch);
                 } else {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestSecureIPC.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestSecureIPC.java
index 1e7cf32238f..4b44141e40e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestSecureIPC.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestSecureIPC.java
@@ -21,11 +21,12 @@ import static org.apache.hadoop.hbase.ipc.TestProtobufRpcServiceImpl.SERVICE;
 import static org.apache.hadoop.hbase.ipc.TestProtobufRpcServiceImpl.newBlockingStub;
 import static org.apache.hadoop.hbase.security.HBaseKerberosUtils.getKeytabFileForTesting;
 import static org.apache.hadoop.hbase.security.HBaseKerberosUtils.getPrincipalForTesting;
-import static org.apache.hadoop.hbase.security.HBaseKerberosUtils.getSecuredConfiguration;
+import static org.apache.hadoop.hbase.security.HBaseKerberosUtils.setSecuredConfiguration;
 import static org.apache.hadoop.hbase.security.provider.SaslClientAuthenticationProviders.SELECTOR_KEY;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.fail;
 
 import java.io.File;
@@ -73,10 +74,8 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
-import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
-import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameter;
@@ -107,14 +106,11 @@ public class TestSecureIPC {
   private static String HOST = "localhost";
   private static String PRINCIPAL;
 
-  String krbKeytab;
-  String krbPrincipal;
-  UserGroupInformation ugi;
-  Configuration clientConf;
-  Configuration serverConf;
-
-  @Rule
-  public ExpectedException exception = ExpectedException.none();
+  private String krbKeytab;
+  private String krbPrincipal;
+  private UserGroupInformation ugi;
+  private Configuration clientConf;
+  private Configuration serverConf;
 
   @Parameters(name = "{index}: rpcClientImpl={0}, rpcServerImpl={1}")
   public static Collection<Object[]> parameters() {
@@ -143,6 +139,9 @@ public class TestSecureIPC {
     PRINCIPAL = "hbase/" + HOST;
     KDC.createPrincipal(KEYTAB_FILE, PRINCIPAL);
     HBaseKerberosUtils.setPrincipalForTesting(PRINCIPAL + "@" + KDC.getRealm());
+    // set a smaller timeout and retry to speed up tests
+    TEST_UTIL.getConfiguration().setInt(RpcClient.SOCKET_TIMEOUT_READ, 2000);
+    TEST_UTIL.getConfiguration().setInt("hbase.security.relogin.maxretries", 1);
   }
 
   @AfterClass
@@ -158,9 +157,11 @@ public class TestSecureIPC {
     krbKeytab = getKeytabFileForTesting();
     krbPrincipal = getPrincipalForTesting();
     ugi = loginKerberosPrincipal(krbKeytab, krbPrincipal);
-    clientConf = getSecuredConfiguration();
+    clientConf = new Configuration(TEST_UTIL.getConfiguration());
+    setSecuredConfiguration(clientConf);
     clientConf.set(RpcClientFactory.CUSTOM_RPC_CLIENT_IMPL_CONF_KEY, rpcClientImpl);
-    serverConf = getSecuredConfiguration();
+    serverConf = new Configuration(TEST_UTIL.getConfiguration());
+    setSecuredConfiguration(serverConf);
     serverConf.set(RpcServerFactory.CUSTOM_RPC_SERVER_IMPL_CONF_KEY, rpcServerImpl);
   }
 
@@ -303,7 +304,7 @@ public class TestSecureIPC {
     callRpcService(User.create(clientUgi));
   }
 
-  void setRpcProtection(String clientProtection, String serverProtection) {
+  private void setRpcProtection(String clientProtection, String serverProtection) {
     clientConf.set("hbase.rpc.protection", clientProtection);
     serverConf.set("hbase.rpc.protection", serverProtection);
   }
@@ -331,10 +332,9 @@ public class TestSecureIPC {
 
   @Test
   public void testSaslNoCommonQop() throws Exception {
-    exception.expect(SaslException.class);
-    exception.expectMessage("No common protection layer between client and server");
     setRpcProtection("integrity", "privacy");
-    callRpcService(User.create(ugi));
+    SaslException se = assertThrows(SaslException.class, () -> callRpcService(User.create(ugi)));
+    assertEquals("No common protection layer between client and server", se.getMessage());
   }
 
   /**