[ 
https://issues.apache.org/jira/browse/HDFS-13507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17732679#comment-17732679
 ] 

ASF GitHub Bot commented on HDFS-13507:
---------------------------------------

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?





> RBF: Remove update functionality from routeradmin's add cmd
> -----------------------------------------------------------
>
>                 Key: HDFS-13507
>                 URL: https://issues.apache.org/jira/browse/HDFS-13507
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>            Reporter: Wei Yan
>            Assignee: Gang Li
>            Priority: Minor
>              Labels: incompatible, pull-request-available
>         Attachments: HDFS-13507-HDFS-13891.003.patch, 
> HDFS-13507-HDFS-13891.004.patch, HDFS-13507.000.patch, HDFS-13507.001.patch, 
> HDFS-13507.002.patch, HDFS-13507.003.patch
>
>
> Follow up the discussion in HDFS-13326. We should remove the "update" 
> functionality from routeradmin's add cmd, to make it consistent with RPC 
> calls.
> Note that: this is an incompatible change.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to