[
https://issues.apache.org/jira/browse/HDFS-16008?focusedWorklogId=593116&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-593116
]
ASF GitHub Bot logged work on HDFS-16008:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 07/May/21 02:34
Start Date: 07/May/21 02:34
Worklog Time Spent: 10m
Work Description: zhuxiangyi commented on a change in pull request #2981:
URL: https://github.com/apache/hadoop/pull/2981#discussion_r627882834
##########
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:
I think it fails to get FileStatus and can continue to use the default
ACLEntity to add mapping.
--
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 593116)
Remaining Estimate: 0h
Time Spent: 10m
> RBF: Tool to initialize ViewFS Mapping to Router
> ------------------------------------------------
>
> Key: HDFS-16008
> URL: https://issues.apache.org/jira/browse/HDFS-16008
> Project: Hadoop HDFS
> Issue Type: Improvement
> Components: rbf
> Affects Versions: 3.3.1
> Reporter: zhu
> Assignee: zhu
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> This is a tool for initializing ViewFS Mapping to Router.
> Some companies are currently migrating from viewfs to router, I think they
> need this tool.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]