This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.5 by this push:
new 241c576dc66 HBASE-29214 Typo in AsyncMasterRequestRpcRetryingCaller
which makes us fail to clear the master stub cache (#6850) (#6860)
241c576dc66 is described below
commit 241c576dc660ba6b9773307e66da39bee4a76a30
Author: Duo Zhang <[email protected]>
AuthorDate: Wed Mar 26 22:44:56 2025 +0800
HBASE-29214 Typo in AsyncMasterRequestRpcRetryingCaller which makes us fail
to clear the master stub cache (#6850) (#6860)
Signed-off-by: Nihal Jain <[email protected]>
(cherry picked from commit ff4db9099d024874c51f80f43b516cab96a8ea96)
(cherry picked from commit 7adf8f249dc157b1b7230bcc8849877fcb5b9893)
---
.../AsyncMasterRequestRpcRetryingCaller.java | 2 +-
.../client/TestAsyncAdminClearMasterStubCache.java | 88 ++++++++++++++++++++++
2 files changed, 89 insertions(+), 1 deletion(-)
diff --git
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncMasterRequestRpcRetryingCaller.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncMasterRequestRpcRetryingCaller.java
index c02b80c666a..c6407001b64 100644
---
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncMasterRequestRpcRetryingCaller.java
+++
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncMasterRequestRpcRetryingCaller.java
@@ -73,7 +73,7 @@ public class AsyncMasterRequestRpcRetryingCaller<T> extends
AsyncRpcRetryingCall
addListener(callable.call(controller, stub), (result, error2) -> {
if (error2 != null) {
onError(error2, () -> "Call to master failed",
- err -> clearMasterStubCacheOnError(stub, error2));
+ err -> clearMasterStubCacheOnError(stub, err));
return;
}
future.complete(result);
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminClearMasterStubCache.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminClearMasterStubCache.java
new file mode 100644
index 00000000000..6f73b4dec36
--- /dev/null
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminClearMasterStubCache.java
@@ -0,0 +1,88 @@
+/*
+ * 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.client;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.Socket;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.MiniHBaseCluster;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.testclassification.ClientTests;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.util.FutureUtils;
+import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+/**
+ * Testcase for HBASE-29214
+ */
+@RunWith(Parameterized.class)
+@Category({ ClientTests.class, MediumTests.class })
+public class TestAsyncAdminClearMasterStubCache extends TestAsyncAdminBase {
+
+ @ClassRule
+ public static final HBaseClassTestRule CLASS_RULE =
+ HBaseClassTestRule.forClass(TestAsyncAdminClearMasterStubCache.class);
+
+ @Before
+ public void waitMasterReady() throws Exception {
+ assertTrue(TEST_UTIL.getHBaseCluster().waitForActiveAndReadyMaster(30000));
+ }
+
+ @After
+ public void clearPortConfig() {
+ TEST_UTIL.getHBaseCluster().getConf().setInt(HConstants.MASTER_PORT, 0);
+ }
+
+ @Test
+ public void testClearMasterStubCache() throws Exception {
+ // cache master stub
+ assertNotNull(FutureUtils.get(admin.getClusterMetrics()));
+ // stop the active master
+ MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
+ MasterThread mt = cluster.getMasterThread();
+ ServerName sn = mt.getMaster().getServerName();
+ mt.getMaster().abort("for testing");
+ mt.join();
+ // wait for new active master
+ assertTrue(TEST_UTIL.getHBaseCluster().waitForActiveAndReadyMaster(30000));
+ // restart master on the same port, this is important for getting a
RemoteException
+ cluster.getConf().setInt(HConstants.MASTER_PORT, sn.getPort());
+ cluster.startMaster();
+ // make sure the master is up so we will not get a connect exception
+ TEST_UTIL.waitFor(30000, () -> {
+ try (Socket socket = new Socket(sn.getHostname(), sn.getPort())) {
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+ });
+ // we should switch to the new active master
+ assertNotNull(FutureUtils.get(admin.getClusterMetrics()));
+ }
+}