-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HDFS-16008. RBF: Tool to initialize ViewFS Mapping to Router #2981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ef407a8
HDFS-16008. Initialize the ViewFS Maping tool to the Router
9a7c9f1
Address comments and add unit tests
e0b806f
Address comments and add doc
7fa083a
fix checkstyle of blanks
3be7673
Address comments
c33ba43
Address comments: support for all clusters
698a3a9
Address comments
3370147
Address comments
93dbc90
Address comments
0204cdc
Fix doc formatting errors
bc5089e
fix checkstyle
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,10 @@ | |
| import org.apache.hadoop.fs.CommonConfigurationKeys; | ||
| import org.apache.hadoop.fs.StorageType; | ||
| import org.apache.hadoop.fs.permission.FsPermission; | ||
| import org.apache.hadoop.fs.viewfs.Constants; | ||
| import org.apache.hadoop.fs.Path; | ||
| import org.apache.hadoop.fs.FileSystem; | ||
| import org.apache.hadoop.fs.FileStatus; | ||
| import org.apache.hadoop.hdfs.DFSConfigKeys; | ||
| import org.apache.hadoop.hdfs.HdfsConfiguration; | ||
| import org.apache.hadoop.hdfs.protocol.HdfsConstants; | ||
|
|
@@ -132,7 +136,7 @@ private String getUsage(String cmd) { | |
| {"-add", "-update", "-rm", "-ls", "-getDestination", "-setQuota", | ||
| "-setStorageTypeQuota", "-clrQuota", "-clrStorageTypeQuota", | ||
| "-safemode", "-nameservice", "-getDisabledNameservices", | ||
| "-refresh", "-refreshRouterArgs", | ||
| "-refresh", "-initViewFsToMountTable", "-refreshRouterArgs", | ||
| "-refreshSuperUserGroupsConfiguration"}; | ||
| StringBuilder usage = new StringBuilder(); | ||
| usage.append("Usage: hdfs dfsrouteradmin :\n"); | ||
|
|
@@ -171,7 +175,10 @@ private String getUsage(String cmd) { | |
| return "\t[-clrQuota <path>]"; | ||
| } else if (cmd.equals("-clrStorageTypeQuota")) { | ||
| return "\t[-clrStorageTypeQuota <path>]"; | ||
| } else if (cmd.equals("-safemode")) { | ||
| } else if (cmd.equals("-initViewFsToMountTable")) { | ||
| return "\t[-initViewFsToMountTable <clusterName>," + | ||
| "-initViewFsToMountTable ClusterX]"; | ||
| }else if (cmd.equals("-safemode")) { | ||
| return "\t[-safemode enter | leave | get]"; | ||
| } else if (cmd.equals("-nameservice")) { | ||
| return "\t[-nameservice enable | disable <nameservice>]"; | ||
|
|
@@ -384,7 +391,14 @@ public int run(String[] argv) throws Exception { | |
| getDisabledNameservices(); | ||
| } else if ("-refresh".equals(cmd)) { | ||
| refresh(address); | ||
| } else if ("-refreshRouterArgs".equals(cmd)) { | ||
| } else if ("-initViewFsToMountTable".equals(cmd)) { | ||
| if (initViewFsToMountTable(argv, i)) { | ||
zhuxiangyi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| System.out.println("Successfully init ViewFs mapping to router " + argv[i]); | ||
| } else { | ||
zhuxiangyi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| exitCode = -1; | ||
| } | ||
| } | ||
| else if ("-refreshRouterArgs".equals(cmd)) { | ||
| exitCode = genericRefresh(argv, i); | ||
| } else if ("-refreshSuperUserGroupsConfiguration".equals(cmd)) { | ||
| exitCode = refreshSuperUserGroupsConfiguration(); | ||
|
|
@@ -1035,7 +1049,56 @@ private boolean updateQuota(String mount, long nsQuota, long ssQuota) | |
| .updateMountTableEntry(updateRequest); | ||
| return updateResponse.getStatus(); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * initViewFsToMountTable. | ||
zhuxiangyi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * @param parameters The specified cluster to initialize. | ||
| * @param i Index in the parameters | ||
| * @return If the quota was updated. | ||
| * @throws IOException Error adding the mount point. | ||
| */ | ||
| public boolean initViewFsToMountTable(String[] parameters, int i) throws IOException { | ||
zhuxiangyi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| String clusterName = parameters[i++]; | ||
| if (clusterName == null) { | ||
| System.out.println("Please enter the cluster name."); | ||
| return false; | ||
| } | ||
| final String mountTablePrefix = | ||
zhuxiangyi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Constants.CONFIG_VIEWFS_PREFIX + "." + clusterName + "." + | ||
| Constants.CONFIG_VIEWFS_LINK + "./"; | ||
| Map<String, String> viewFsMap = getConf().getValByRegex(mountTablePrefix); | ||
| if (viewFsMap.size() == 0) { | ||
zhuxiangyi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| System.out.println("Please check the cluster name and veiwfs " + | ||
zhuxiangyi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "configuration."); | ||
| } | ||
| for (String key : viewFsMap.keySet()) { | ||
zhuxiangyi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Path path = new Path(viewFsMap.get(key)); | ||
| String owner = null; | ||
zhuxiangyi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 (Exception e) { | ||
| LOG.warn("Exception encountered", e); | ||
zhuxiangyi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| DestinationOrder order = DestinationOrder.HASH; | ||
| String mount = | ||
| key.split(clusterName + "." + Constants.CONFIG_VIEWFS_LINK + ".")[1]; | ||
| String dest = path.toUri().getPath(); | ||
|
||
| String[] nss = new String[]{path.toUri().getAuthority()}; | ||
| addMount(mount, nss, dest, false, false, order, | ||
zhuxiangyi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| new ACLEntity(owner, group, mode)); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| /** | ||
| * Update storage type quota of specified mount table. | ||
| * | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.