Hexiaoqiao commented on code in PR #7409: URL: https://github.com/apache/hadoop/pull/7409#discussion_r1969229062
########## hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestAsyncRouterAdmin.java: ########## @@ -0,0 +1,119 @@ +/** + * 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 org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.ha.HAServiceProtocol; +import org.apache.hadoop.hdfs.protocol.HdfsFileStatus; +import org.apache.hadoop.hdfs.server.federation.RouterConfigBuilder; +import org.apache.hadoop.hdfs.server.federation.StateStoreDFSCluster; +import org.apache.hadoop.hdfs.server.federation.resolver.ActiveNamenodeResolver; +import org.apache.hadoop.hdfs.server.federation.resolver.RemoteLocation; +import org.apache.hadoop.hdfs.server.federation.router.RemoteMethod; +import org.apache.hadoop.hdfs.server.federation.router.Router; +import org.apache.hadoop.hdfs.server.federation.router.RouterRpcServer; +import org.apache.hadoop.hdfs.server.federation.router.TestRouterAdmin; +import org.apache.hadoop.hdfs.server.federation.router.async.utils.AsyncUtil; +import org.apache.hadoop.util.Lists; +import org.junit.BeforeClass; +import org.mockito.Mockito; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import static org.apache.hadoop.hdfs.server.federation.FederationTestUtils.createNamenodeReport; +import static org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys.DFS_ROUTER_ADMIN_MOUNT_CHECK_ENABLE; +import static org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys.DFS_ROUTER_ASYNC_RPC_ENABLE_KEY; + +public class TestAsyncRouterAdmin extends TestRouterAdmin { + + @BeforeClass + public static void globalSetUp() throws Exception { + cluster = new StateStoreDFSCluster(false, 1); + // Build and start a router with State Store + admin + RPC + Configuration conf = new RouterConfigBuilder() + .stateStore() + .admin() + .rpc() + .build(); + conf.setBoolean(DFS_ROUTER_ADMIN_MOUNT_CHECK_ENABLE, true); + conf.setBoolean(DFS_ROUTER_ASYNC_RPC_ENABLE_KEY, true); + + cluster.addRouterOverrides(conf); + cluster.startRouters(); + routerContext = cluster.getRandomRouter(); + mockMountTable = cluster.generateMockMountTable(); + Router router = routerContext.getRouter(); + stateStore = router.getStateStore(); + + // Add two name services for testing disabling + ActiveNamenodeResolver membership = router.getNamenodeResolver(); + membership.registerNamenode( + createNamenodeReport("ns0", "nn1", HAServiceProtocol.HAServiceState.ACTIVE)); + membership.registerNamenode( + createNamenodeReport("ns1", "nn1", HAServiceProtocol.HAServiceState.ACTIVE)); + stateStore.refreshCaches(true); + + setUpMocks(); + } + + private static void setUpMocks() + throws IOException, NoSuchFieldException, IllegalAccessException { + RouterRpcServer spyRpcServer = + Mockito.spy(routerContext.getRouter().createRpcServer()); + //Used reflection to set the 'rpcServer field' Review Comment: codestyle: Please keep the same style about annotation, a. leave one space between slash and the first letter. b. Start with uppercase and end with period. (Include L84.) Thanks. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
