Skip to content

Commit 10cbb16

Browse files
committed
HDFS-17751. [ARR] Add unit tests using asynchronous router rpc for all in org.apache.hadoop.hdfs.server.federation.router.
1 parent 4452980 commit 10cbb16

File tree

9 files changed

+779
-165
lines changed

9 files changed

+779
-165
lines changed

hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,10 +2004,11 @@ private static boolean isReadCall(Method method) {
20042004
* Checks and sets last refresh time for a namespace's stateId.
20052005
* Returns true if refresh time is newer than threshold.
20062006
* Otherwise, return false and call should be handled by active namenode.
2007-
* @param nsId namespaceID
2007+
* @param nsId namespaceID.
2008+
* @return true if refresh time is newer than threshold. Otherwise, return false.
20082009
*/
20092010
@VisibleForTesting
2010-
boolean isNamespaceStateIdFresh(String nsId) {
2011+
public boolean isNamespaceStateIdFresh(String nsId) {
20112012
if (activeNNStateIdRefreshPeriodMs < 0) {
20122013
return true;
20132014
}

hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterStateIdContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class RouterStateIdContext implements AlignmentContext {
6464
/** Nameservice specific overrides of the default setting for enabling observer reads. */
6565
private HashSet<String> observerReadEnabledOverrides = new HashSet<>();
6666

67-
RouterStateIdContext(Configuration conf) {
67+
public RouterStateIdContext(Configuration conf) {
6868
this.coordinatedMethods = new HashSet<>();
6969
// For now, only ClientProtocol methods can be coordinated, so only checking
7070
// against ClientProtocol.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.hadoop.hdfs.server.federation.router;
20+
21+
public final class TestRouterConstants {
22+
23+
private TestRouterConstants() {
24+
25+
}
26+
27+
public static final String ASYNC_MODE = "ASYNC";
28+
public static final String SYNC_MODE = "SYNC";
29+
}

hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterNetworkTopologyServlet.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
import java.util.Map;
4242

4343
import static org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys.DFS_ROUTER_HTTP_ENABLE;
44+
import static org.apache.hadoop.hdfs.server.federation.router.TestRouterConstants.ASYNC_MODE;
45+
import static org.apache.hadoop.hdfs.server.federation.router.TestRouterConstants.SYNC_MODE;
4446
import static org.junit.jupiter.api.Assertions.assertEquals;
4547
import static org.junit.jupiter.api.Assertions.assertTrue;
4648
import static org.apache.hadoop.hdfs.server.federation.router.TestRouterNetworkTopologyServlet.clusterNoDatanodes;
@@ -53,16 +55,13 @@ public class TestRouterNetworkTopologyServlet {
5355
public static StateStoreDFSCluster clusterWithDatanodes;
5456
public static StateStoreDFSCluster clusterNoDatanodes;
5557

56-
public static final String ASYNC_MODE = "ASYNC";
57-
public static final String SYNC_MODE = "SYNC";
58-
5958
public static void setUp(String rpcMode) throws Exception {
6059
// Builder configuration.
6160
Configuration routerConf =
6261
new RouterConfigBuilder().stateStore().admin().quota().rpc().build();
6362
routerConf.set(DFS_ROUTER_HTTP_ENABLE, "true");
6463
// Use async router rpc.
65-
if (rpcMode.equals("ASYNC")) {
64+
if (rpcMode.equals(ASYNC_MODE)) {
6665
routerConf.setBoolean(RBFConfigKeys.DFS_ROUTER_ASYNC_RPC_ENABLE_KEY, true);
6766
}
6867
Configuration hdfsConf = new Configuration(false);

0 commit comments

Comments
 (0)