virajjasani commented on code in PR #4990:
URL: https://github.com/apache/hadoop/pull/4990#discussion_r1230000973
##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterAdminServer.java:
##########
@@ -425,6 +428,20 @@ private void verifyFileExistenceInDest(MountTable
mountTable) throws IOException
}
}
+ /** Return true if the input mountTable exists, else return false.
+ *
+ * @param mountTable mountTable needs to be checked
+ */
Review Comment:
javadoc missing `@throws`?
##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdminCLI.java:
##########
@@ -1925,6 +1925,99 @@ public void testAddMultipleMountPointsFailure() throws
Exception {
err.toString().contains("Cannot add mount points:
[/testAddMultiMountPoints-01"));
}
+ @Test
+ public void testAddMultipleDestinations() throws Exception {
+ System.setOut(new PrintStream(out));
+ System.setErr(new PrintStream(err));
+
+ assertNotNull(router.getNamenodeResolver()
+ .getNamenodesForNameserviceId("ns0", false));
+ assertNotNull(router.getNamenodeResolver()
+ .getNamenodesForNameserviceId("ns1", false));
+
+ stateStore.loadCache(MountTableStoreImpl.class, true);
+ String[] argv = new String[] {"-add", "/addMultipleDestination",
"ns01,ns02", "/tmp0"};
+ assertEquals(0, ToolRunner.run(admin, argv));
+ err.reset();
+
+ stateStore.loadCache(MountTableStoreImpl.class, true);
+ argv = new String[] {"-add", "/addMultipleDestination1", "ns01,ns02",
"/tmp1,/tmp2"};
+ assertEquals(0, ToolRunner.run(admin, argv));
+ err.reset();
+
+ stateStore.loadCache(MountTableStoreImpl.class, true);
+ argv = new String[] {"-add", "/addMultipleDestination", "ns01,ns02",
"/tmp3,/tmp4"};
+ assertEquals(-1, ToolRunner.run(admin, argv));
+ assertTrue(err.toString().contains("MountTable
entry:/addMultipleDestination already exists."));
+ err.reset();
+
+ argv = new String[] {"-add", "/addMultipleDestination2", "ns01",
"/tmp5,/tmp6"};
+ assertEquals(-1, ToolRunner.run(admin, argv));
+ assertTrue(err.toString().contains("Invalid number of namespaces and
destinations"));
+ err.reset();
+
+ argv = new String[] {"-add", "/addMultipleDestination2", "ns01,ns02",
"/tmp7,/tmp8,/tmp9"};
+ assertEquals(-1, ToolRunner.run(admin, argv));
+ assertTrue(err.toString().contains("Invalid number of namespaces and
destinations"));
+ err.reset();
+ }
+
+ @Test
+ public void testUpdateMultipleDestinations() throws Exception {
+ System.setOut(new PrintStream(out));
+ System.setErr(new PrintStream(err));
+
+ assertNotNull(router.getNamenodeResolver()
+ .getNamenodesForNameserviceId("ns0", false));
+ assertNotNull(router.getNamenodeResolver()
+ .getNamenodesForNameserviceId("ns1", false));
+
+ stateStore.loadCache(MountTableStoreImpl.class, true);
+ String[] argv = new String[] {"-add", "/updateMultipleDestination0",
"ns01,ns02", "/tmp0"};
+ assertEquals(0, ToolRunner.run(admin, argv));
+ err.reset();
+
+ stateStore.loadCache(MountTableStoreImpl.class, true);
+ argv = new String[] {"-update", "/updateMultipleDestination0", "ns0,ns1",
"/tmp0_1,/tmp0_2"};
+ assertEquals(0, ToolRunner.run(admin, argv));
+ err.reset();
+
+ stateStore.loadCache(MountTableStoreImpl.class, true);
+ argv = new String[] {"-update", "/updateMultipleDestination0",
"ns01,ns02", "/tmp1"};
+ assertEquals(0, ToolRunner.run(admin, argv));
+ err.reset();
+
+ stateStore.loadCache(MountTableStoreImpl.class, true);
+ argv = new String[] {"-update", "/updateMultipleDestination0", "ns01,ns02",
+ "/tmp1,/tmp2,/tmp3"};
+ assertEquals(-1, ToolRunner.run(admin, argv));
+ assertTrue(err.toString().contains("Invalid number of namespaces and
destinations"));
+ err.reset();
+ }
+
+ @Test
+ public void testAddAllMultipleDestinations() throws Exception {
+ System.setOut(new PrintStream(out));
+ System.setErr(new PrintStream(err));
+
+ assertNotNull(router.getNamenodeResolver()
+ .getNamenodesForNameserviceId("ns0", false));
+ assertNotNull(router.getNamenodeResolver()
+ .getNamenodesForNameserviceId("ns1", false));
+
+ stateStore.loadCache(MountTableStoreImpl.class, true);
+ String[] argv = new String[] {"-addAll", "/addAllMultipleDestination3",
"ns01,ns02",
+ "/tmp3_1,/tmp3_2", ",", "/multipleDestination4", "ns01,ns02",
"/tmp4_1"};
+ assertEquals(0, ToolRunner.run(admin, argv));
+ err.reset();
+
+ argv = new String[] {"-addAll", "/addAllMultipleDestination5",
"ns01,ns02", "/tmp5_1,/tmp5_2",
+ ",", "/multipleDestination6", "ns01,ns02", "/tmp6_1,/tmp6_2,/tmp6_3"};
+ assertEquals(-1, ToolRunner.run(admin, argv));
+ assertTrue(err.toString().contains("Invalid number of namespaces and
destinations"));
+ err.reset();
Review Comment:
`out.reset()` as well?
--
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]