Package org.apache.hadoop.fs.viewfs
Class InodeTree<T>
java.lang.Object
org.apache.hadoop.fs.viewfs.InodeTree<T>
- Type Parameters:
T- is AbstractFileSystem or FileSystem The two main methods areInodeTree(Configuration, String, URI, boolean)// constructorresolve(String, boolean)
InodeTree implements a mount-table as a tree of inodes.
It is used to implement ViewFs and ViewFileSystem.
In order to use it the caller must subclass it and implement
the abstract methods
getTargetFileSystem(INodeDir), etc.
The mountable is initialized from the config variables as
specified in ViewFs-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn internal class to represent a mount link.static classstatic classResolve returns ResolveResult. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInodeTree(Configuration config, String viewName, URI theUri, boolean initingUriAsFallbackOnNoMounts) Create Inode Tree from the specified mount-table specified in Config. -
Method Summary
Modifier and TypeMethodDescriptionprotected InodeTree.ResolveResult<T>buildResolveResultForRegexMountPoint(org.apache.hadoop.fs.viewfs.InodeTree.ResultKind resultKind, String resolvedPathStr, String targetOfResolvedPathStr, Path remainingPath) Build resolve result.protected abstract TgetTargetFileSystem(String settings, URI[] mergeFsURIs) protected abstract TgetTargetFileSystem(org.apache.hadoop.fs.viewfs.InodeTree.INodeDir<T> dir) The user of this class must subclass and implement the following 3 abstract methods.booleanResolve the pathname p relative to root InodeDir.protected InodeTree.ResolveResult<T>tryResolveInRegexMountpoint(String srcPath, boolean resolveLastComponent) Walk through all regex mount points to see whether the path match any regex expressions.
-
Constructor Details
-
InodeTree
protected InodeTree(Configuration config, String viewName, URI theUri, boolean initingUriAsFallbackOnNoMounts) throws UnsupportedFileSystemException, URISyntaxException, FileAlreadyExistsException, IOException Create Inode Tree from the specified mount-table specified in Config.- Parameters:
config- the mount table keys are prefixed with FsConstants.CONFIG_VIEWFS_PREFIX.viewName- the name of the mount table if null use defaultMT name.theUri- heUri.initingUriAsFallbackOnNoMounts- initingUriAsFallbackOnNoMounts.- Throws:
UnsupportedFileSystemException- file system foruriis not found.URISyntaxException- if the URI does not have an authority it is badly formed.FileAlreadyExistsException- there is a file at the path specified or is discovered on one of its ancestors.IOException- raised on errors performing I/O.
-
-
Method Details
-
initAndGetTargetFs
The user of this class must subclass and implement the following 3 abstract methods.- Returns:
- Function.
-
getTargetFileSystem
protected abstract T getTargetFileSystem(org.apache.hadoop.fs.viewfs.InodeTree.INodeDir<T> dir) throws URISyntaxException, IOException - Throws:
URISyntaxExceptionIOException
-
getTargetFileSystem
protected abstract T getTargetFileSystem(String settings, URI[] mergeFsURIs) throws UnsupportedFileSystemException, URISyntaxException, IOException -
isRootInternalDir
public boolean isRootInternalDir()- Returns:
- true if the root represented as internalDir. In LinkMergeSlash, there will be root to root mapping. So, root does not represent as internalDir.
-
getRootFallbackLink
-
resolve
public InodeTree.ResolveResult<T> resolve(String p, boolean resolveLastComponent) throws IOException Resolve the pathname p relative to root InodeDir.- Parameters:
p- - input pathresolveLastComponent- resolveLastComponent.- Returns:
- ResolveResult which allows further resolution of the remaining path
- Throws:
IOException- raised on errors performing I/O.
-
tryResolveInRegexMountpoint
protected InodeTree.ResolveResult<T> tryResolveInRegexMountpoint(String srcPath, boolean resolveLastComponent) Walk through all regex mount points to see whether the path match any regex expressions. E.g. link: ^/user/(?<username>\\w+) => s3://$user.apache.com/_${user} srcPath: is /user/hadoop/dir1 resolveLastComponent: true then return value is s3://hadoop.apache.com/_hadoop- Parameters:
srcPath- srcPath.resolveLastComponent- resolveLastComponent.- Returns:
- ResolveResult.
-
buildResolveResultForRegexMountPoint
protected InodeTree.ResolveResult<T> buildResolveResultForRegexMountPoint(org.apache.hadoop.fs.viewfs.InodeTree.ResultKind resultKind, String resolvedPathStr, String targetOfResolvedPathStr, Path remainingPath) Build resolve result. Here's an example Mountpoint: fs.viewfs.mounttable.mt .linkRegex.replaceresolveddstpath:_:-#.^/user/(??<username>\w+) Value: /targetTestRoot/$username Dir path to test: viewfs://mt/user/hadoop_user1/hadoop_dir1 Expect path: /targetTestRoot/hadoop-user1/hadoop_dir1 resolvedPathStr: /user/hadoop_user1 targetOfResolvedPathStr: /targetTestRoot/hadoop-user1 remainingPath: /hadoop_dir1- Parameters:
resultKind- resultKind.resolvedPathStr- resolvedPathStr.targetOfResolvedPathStr- targetOfResolvedPathStr.remainingPath- remainingPath.- Returns:
- targetFileSystem or null on exceptions.
-
getMountPoints
-
getHomeDirPrefixValue
- Returns:
- home dir value from mount table; null if no config value was found.
-