goiri commented on a change in pull request #2266:
URL: https://github.com/apache/hadoop/pull/2266#discussion_r481458397
##########
File path:
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdmin.java
##########
@@ -128,7 +166,6 @@ public void testAddMountTable() throws IOException {
MountTable newEntry = MountTable.newInstance(
"/testpath", Collections.singletonMap("ns0", "/testdir"),
Time.now(), Time.now());
-
Review comment:
Avoid
##########
File path:
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdmin.java
##########
@@ -103,11 +113,39 @@ public static void globalSetUp() throws Exception {
createNamenodeReport("ns1", "nn1", HAServiceState.ACTIVE));
stateStore.refreshCaches(true);
+ setUpMocks();
+ }
+
+ private static void setUpMocks() throws IOException {
RouterRpcServer spyRpcServer =
Mockito.spy(routerContext.getRouter().createRpcServer());
Whitebox
.setInternalState(routerContext.getRouter(), "rpcServer",
spyRpcServer);
Mockito.doReturn(null).when(spyRpcServer).getFileInfo(Mockito.anyString());
+
+ mockRpcClient = Mockito.spy(spyRpcServer.getRPCClient());
Review comment:
Add a comment highlighting what this part does.
##########
File path:
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdmin.java
##########
@@ -103,11 +113,39 @@ public static void globalSetUp() throws Exception {
createNamenodeReport("ns1", "nn1", HAServiceState.ACTIVE));
stateStore.refreshCaches(true);
+ setUpMocks();
+ }
+
+ private static void setUpMocks() throws IOException {
RouterRpcServer spyRpcServer =
Mockito.spy(routerContext.getRouter().createRpcServer());
Whitebox
.setInternalState(routerContext.getRouter(), "rpcServer",
spyRpcServer);
Mockito.doReturn(null).when(spyRpcServer).getFileInfo(Mockito.anyString());
+
+ mockRpcClient = Mockito.spy(spyRpcServer.getRPCClient());
+ Whitebox
Review comment:
I think whitebox needed to be deprecated.
##########
File path:
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdmin.java
##########
@@ -103,11 +113,39 @@ public static void globalSetUp() throws Exception {
createNamenodeReport("ns1", "nn1", HAServiceState.ACTIVE));
stateStore.refreshCaches(true);
+ setUpMocks();
+ }
+
+ private static void setUpMocks() throws IOException {
Review comment:
Add javadoc
##########
File path:
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdmin.java
##########
@@ -103,11 +113,39 @@ public static void globalSetUp() throws Exception {
createNamenodeReport("ns1", "nn1", HAServiceState.ACTIVE));
stateStore.refreshCaches(true);
+ setUpMocks();
+ }
+
+ private static void setUpMocks() throws IOException {
RouterRpcServer spyRpcServer =
Mockito.spy(routerContext.getRouter().createRpcServer());
Whitebox
.setInternalState(routerContext.getRouter(), "rpcServer",
spyRpcServer);
Mockito.doReturn(null).when(spyRpcServer).getFileInfo(Mockito.anyString());
+
+ mockRpcClient = Mockito.spy(spyRpcServer.getRPCClient());
+ Whitebox
+ .setInternalState(spyRpcServer, "rpcClient", mockRpcClient);
+ RemoteLocation remoteLocation0 = new RemoteLocation("ns0", "/testdir",
null);
+ RemoteLocation remoteLocation1 = new RemoteLocation("ns1", "/", null);
+ mockResponse0.put(remoteLocation0,
+ new HdfsFileStatus.Builder().build());
+ Mockito.doReturn(mockResponse0).when(mockRpcClient).invokeConcurrent(
+ Mockito.eq(Lists.newArrayList(remoteLocation0)),
+ Mockito.any(RemoteMethod.class),
+ Mockito.eq(false),
+ Mockito.eq(false),
+ Mockito.eq(HdfsFileStatus.class)
+ );
+ mockResponse1.put(remoteLocation1,
+ new HdfsFileStatus.Builder().build());
+ Mockito.doReturn(mockResponse1).when(mockRpcClient).invokeConcurrent(
Review comment:
What are we doing with this? Is there a test actually using it?
##########
File path:
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterAdminServer.java
##########
@@ -562,11 +595,35 @@ public GetDestinationResponse getDestination(
LOG.error("Cannot get location for {}: {}",
src, ioe.getMessage());
}
- if (nsIds.isEmpty() && !locations.isEmpty()) {
- String nsId = locations.get(0).getNameserviceId();
- nsIds.add(nsId);
+ return nsIds;
+ }
+
+ /**
+ * Verify the file exists in destination nameservices to avoid dangling
+ * mount points.
+ *
+ * @param entry the new mount points added, could be from add or update.
+ * @return destination nameservices where the file doesn't exist.
+ * @throws IOException
Review comment:
Add exception reasons
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]