This is an automated email from the ASF dual-hosted git repository.
hfutatzhanghb pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 8a4e03dc7e7 HDFS-17922. rename2 in the router asynchronous RPC is
missing an async path
8a4e03dc7e7 is described below
commit 8a4e03dc7e731b1fa553bb840161e5de9308423d
Author: Dimas Shidqi Parikesit <[email protected]>
AuthorDate: Sat May 23 08:33:03 2026 -0400
HDFS-17922. rename2 in the router asynchronous RPC is missing an async path
Contributed by dParikesit.
---
.../router/async/RouterAsyncClientProtocol.java | 1 +
.../router/TestRouterFederationRenameBase.java | 14 ++++
.../async/TestRouterAsyncFederationRename.java | 95 ++++++++++++++++++++++
3 files changed, 110 insertions(+)
diff --git
a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/async/RouterAsyncClientProtocol.java
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/async/RouterAsyncClientProtocol.java
index 78b6f8641c7..9f8558aedbb 100644
---
a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/async/RouterAsyncClientProtocol.java
+++
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/async/RouterAsyncClientProtocol.java
@@ -288,6 +288,7 @@ public void rename2(
RemoteParam dstParam = getRenameDestinations(locs, dstLocations);
if (locs.isEmpty()) {
rbfRename.routerFedRename(src, dst, srcLocations, dstLocations);
+ asyncComplete(null);
return;
}
RemoteMethod method = new RemoteMethod("rename2",
diff --git
a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterFederationRenameBase.java
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterFederationRenameBase.java
index 40464923dda..c7e25f49e86 100644
---
a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterFederationRenameBase.java
+++
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterFederationRenameBase.java
@@ -35,6 +35,8 @@
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.DFSConfigKeys;
+import
org.apache.hadoop.hdfs.server.federation.fairness.RouterAsyncRpcFairnessPolicyController;
+import
org.apache.hadoop.hdfs.server.federation.fairness.RouterRpcFairnessPolicyController;
import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster;
import org.apache.hadoop.hdfs.server.federation.MockResolver;
import org.apache.hadoop.hdfs.server.federation.RouterConfigBuilder;
@@ -64,6 +66,10 @@ public class TestRouterFederationRenameBase {
private static MiniRouterDFSCluster cluster;
public static void globalSetUp() throws Exception {
+ globalSetUp(false);
+ }
+
+ public static void globalSetUp(boolean enableAsyncRpc) throws Exception {
Configuration namenodeConf = new Configuration();
namenodeConf.setBoolean(DFSConfigKeys.HADOOP_CALLER_CONTEXT_ENABLED_KEY,
true);
@@ -98,6 +104,14 @@ public static void globalSetUp() throws Exception {
routerConf.setBoolean(DFS_PERMISSIONS_ENABLED_KEY, true);
routerConf.set(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
TestRouterFederationRename.MockGroupsMapping.class.getName());
+ if (enableAsyncRpc) {
+ routerConf.setBoolean(RBFConfigKeys.DFS_ROUTER_ASYNC_RPC_ENABLE_KEY,
true);
+ routerConf.setClass(
+ RBFConfigKeys.DFS_ROUTER_FAIRNESS_POLICY_CONTROLLER_CLASS,
+ RouterAsyncRpcFairnessPolicyController.class,
+ RouterRpcFairnessPolicyController.class);
+ routerConf.setInt(RBFConfigKeys.DFS_ROUTER_ASYNC_RPC_HANDLER_COUNT_KEY,
2);
+ }
cluster.addRouterOverrides(routerConf);
cluster.startRouters();
diff --git
a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncFederationRename.java
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncFederationRename.java
new file mode 100644
index 00000000000..27fa4c147d7
--- /dev/null
+++
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncFederationRename.java
@@ -0,0 +1,95 @@
+/**
+ * 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.hdfs.server.federation.router.async;
+
+import static
org.apache.hadoop.hdfs.server.federation.FederationTestUtils.verifyFileExists;
+import static org.apache.hadoop.test.GenericTestUtils.getMethodName;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.List;
+
+import org.apache.hadoop.fs.FileContext;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.DFSClient;
+import org.apache.hadoop.hdfs.protocol.ClientProtocol;
+import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster;
+import
org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster.RouterContext;
+import
org.apache.hadoop.hdfs.server.federation.router.TestRouterFederationRenameBase;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+
+/**
+ * Tests router federation rename with async RPC enabled.
+ */
+public class TestRouterAsyncFederationRename
+ extends TestRouterFederationRenameBase {
+
+ private RouterContext router;
+ private FileSystem routerFS;
+ private MiniRouterDFSCluster cluster;
+
+ @BeforeAll
+ public static void before() throws Exception {
+ globalSetUp(true);
+ }
+
+ @AfterAll
+ public static void after() {
+ tearDown();
+ }
+
+ @BeforeEach
+ public void testSetup() throws Exception {
+ setup();
+ router = getRouterContext();
+ routerFS = getRouterFileSystem();
+ cluster = getCluster();
+ }
+
+ @Test
+ @Timeout(value = 60)
+ public void testAsyncRbfRename2() throws Exception {
+ List<String> nss = cluster.getNameservices();
+ String ns0 = nss.get(0);
+ String ns1 = nss.get(1);
+
+ String dir = cluster.getFederatedTestDirectoryForNS(ns0) + "/"
+ + getMethodName();
+ String renamedDir = cluster.getFederatedTestDirectoryForNS(ns1) + "/"
+ + getMethodName();
+
+ createDir(routerFS, dir);
+ try {
+ DFSClient client = router.getClient();
+ ClientProtocol clientProtocol = client.getNamenode();
+ clientProtocol.rename2(dir, renamedDir);
+
+ assertFalse(verifyFileExists(routerFS, dir));
+ assertTrue(verifyFileExists(routerFS, renamedDir + "/file"));
+ } finally {
+ FileContext fileContext = router.getFileContext();
+ fileContext.delete(new Path(dir), true);
+ fileContext.delete(new Path(renamedDir), true);
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]