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

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


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

commit beb7c6d490497e45f229bb168275f0c449d9a926
Author: Duo Zhang <[email protected]>
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 <[email protected]
    Signed-off-by: GeorryHuang <[email protected]>
    (cherry picked from commit 5919b30b6d9e905130033461efc37fae60bab947)
---
 .../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 950a8f715f5..c03e45c5f77 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
@@ -241,7 +241,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
@@ -250,7 +250,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 4c13bd1425a..a96eec6a47e 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());
   }
 
   /**

Reply via email to