goiri commented on a change in pull request #2981:
URL: https://github.com/apache/hadoop/pull/2981#discussion_r627891890



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/tools/federation/RouterAdmin.java
##########
@@ -1035,6 +1054,65 @@ private boolean updateQuota(String mount, long nsQuota, 
long ssQuota)
         .updateMountTableEntry(updateRequest);
     return updateResponse.getStatus();
   }
+  
+  /**
+   * initViewFsToMountTable.
+   * @param clusterName The specified cluster to initialize.
+   * @return If the quota was updated.
+   * @throws IOException Error adding the mount point.
+   */
+  public boolean initViewFsToMountTable(String clusterName)
+      throws IOException {
+    // fs.viewfs.mounttable.ClusterX.link./data
+    final String mountTablePrefix =
+        Constants.CONFIG_VIEWFS_PREFIX + "." + clusterName + "." +
+            Constants.CONFIG_VIEWFS_LINK + "./";
+    Map<String, String> viewFsMap = getConf().getValByRegex(mountTablePrefix);
+    if (viewFsMap.isEmpty()) {
+      System.out.println("There is no ViewFs mapping to initialize.");
+      return true;
+    }
+    for (Entry<String, String> entry : viewFsMap.entrySet()) {
+      Path path = new Path(entry.getValue());
+      DestinationOrder order = DestinationOrder.HASH;
+      String[] mount = entry.getKey().split(
+              clusterName + "." + Constants.CONFIG_VIEWFS_LINK + ".");
+      if (mount.length < 2) {
+        System.out.println("Added Mount Point failed " + entry.getKey());
+        continue;
+      }
+      String[] nss = new String[]{path.toUri().getAuthority()};
+      boolean added = addMount(
+          mount[1], nss, path.toUri().getPath(), false,
+          false, order, getACLEntityFormHdfsPath(path));
+      if (added) {
+        System.out.println("added mount point " + mount[1]);
+      }
+    }
+    return true;
+  }
+
+  /**
+   * Returns ACLEntity according to a HDFS pat.
+   * @param path A path of HDFS.
+   */
+  public ACLEntity getACLEntityFormHdfsPath(Path path){
+    String owner = null;
+    String group = null;
+    FsPermission mode = null;
+    try {
+      FileSystem fs = path.getFileSystem(getConf());
+      if (fs.exists(path)) {
+        FileStatus fileStatus = fs.getFileStatus(path);
+        owner = fileStatus.getOwner();
+        group = fileStatus.getGroup();
+        mode = fileStatus.getPermission();
+      }
+    } catch (IOException e) {
+      System.out.println("Exception encountered " + e);

Review comment:
       Yes, but it should go to System.err not System.out, right?




-- 
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to