Class ViewFileSystemOverloadScheme
- All Implemented Interfaces:
Closeable,AutoCloseable,Configurable,BulkDeleteSource,PathCapabilities,DelegationTokenIssuer
This class is extended from the ViewFileSystem for the overloaded scheme file system. Mount link configurations and in-memory mount table building behaviors are inherited from ViewFileSystem. Unlike ViewFileSystem scheme (viewfs://), the users would be able to use any scheme.
To use this class, the following configurations need to be added in
core-site.xml file.
1) fs.<scheme>.impl
= org.apache.hadoop.fs.viewfs.ViewFileSystemOverloadScheme
2) fs.viewfs.overload.scheme.target.<scheme>.impl
= <hadoop compatible file system implementation class name
for the <scheme>>
Here <scheme> can be any scheme, but with that scheme there should be a hadoop compatible file system available. Second configuration value should be the respective scheme's file system implementation class. Example: if scheme is configured with "hdfs", then the 2nd configuration class name will be org.apache.hadoop.hdfs.DistributedFileSystem. if scheme is configured with "s3a", then the 2nd configuration class name will be org.apache.hadoop.fs.s3a.S3AFileSystem.
Use Case 1:
===========
If users want some of their existing cluster (hdfs://Cluster)
data to mount with other hdfs and object store clusters(hdfs://NN1,
o3fs://bucket1.volume1/, s3a://bucket1/)
fs.viewfs.mounttable.Cluster.link./user = hdfs://NN1/user
fs.viewfs.mounttable.Cluster.link./data = o3fs://bucket1.volume1/data
fs.viewfs.mounttable.Cluster.link./backup = s3a://bucket1/backup/
Op1: Create file hdfs://Cluster/user/fileA will go to hdfs://NN1/user/fileA
Op2: Create file hdfs://Cluster/data/datafile will go to
o3fs://bucket1.volume1/data/datafile
Op3: Create file hdfs://Cluster/backup/data.zip will go to
s3a://bucket1/backup/data.zip
Use Case 2:
===========
If users want some of their existing cluster (s3a://bucketA/)
data to mount with other hdfs and object store clusters
(hdfs://NN1, o3fs://bucket1.volume1/)
fs.viewfs.mounttable.bucketA.link./user = hdfs://NN1/user
fs.viewfs.mounttable.bucketA.link./data = o3fs://bucket1.volume1/data
fs.viewfs.mounttable.bucketA.link./salesDB = s3a://bucketA/salesDB/
Op1: Create file s3a://bucketA/user/fileA will go to hdfs://NN1/user/fileA
Op2: Create file s3a://bucketA/data/datafile will go to
o3fs://bucket1.volume1/data/datafile
Op3: Create file s3a://bucketA/salesDB/dbfile will go to
s3a://bucketA/salesDB/dbfile
Note:
(1) In ViewFileSystemOverloadScheme, by default the mount links will be
represented as non-symlinks. If you want to change this behavior, please see
ViewFileSystem.listStatus(Path)
(2) In ViewFileSystemOverloadScheme, only the initialized uri's hostname will
be considered as the mount table name. When the passed uri has hostname:port,
it will simply ignore the port number and only hostname will be considered as
the mount table name.
(3) If there are no mount links configured with the initializing uri's
hostname as the mount table name, then it will automatically consider the
current uri as fallback( ex:
fs.viewfs.mounttable.<mycluster>.linkFallback) target fs uri.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA class to maintain the target file system and a path to pass to the target file system.Nested classes/interfaces inherited from class org.apache.hadoop.fs.viewfs.ViewFileSystem
ViewFileSystem.MountPointNested classes/interfaces inherited from class org.apache.hadoop.fs.FileSystem
FileSystem.DirectoryEntries, FileSystem.DirListingIterator<T extends FileStatus>, FileSystem.Statistics -
Field Summary
Fields inherited from class org.apache.hadoop.fs.FileSystem
DEFAULT_FS, FS_DEFAULT_NAME_KEY, LOG, SHUTDOWN_HOOK_PRIORITY, statistics, TRASH_PREFIX, USER_HOME_PREFIXFields inherited from interface org.apache.hadoop.security.token.DelegationTokenIssuer
TOKEN_LOG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncanonicalizeUri(URI uri) Canonicalize the given URI.protected FsGetterfsGetter()This method is overridden because in ViewFileSystemOverloadScheme if overloaded scheme matches with mounted target fs scheme, file system should be created without going into fs.<scheme>.impl based resolution.getMountPathInfo(Path path, Configuration conf) Gets the mount path info, which contains the target file system and remaining path to pass to the target file system.getRawFileSystem(Path path, Configuration conf) This is an admin only API to give access to its child raw file system, if the path is link.Return the protocol scheme for the FileSystem.voidinitialize(URI theUri, Configuration conf) Called after a new FileSystem instance is constructed.voidsetSupportAutoAddingFallbackOnNoMounts(boolean addAutoFallbackOnNoMounts) Sets whether to add fallback automatically when no mount points found.booleanBy default returns false as ViewFileSystemOverloadScheme supports auto adding fallback on no mounts.Methods inherited from class org.apache.hadoop.fs.viewfs.ViewFileSystem
access, append, close, create, createNonRecursive, createSnapshot, delete, delete, deleteSnapshot, getAclStatus, getAllStoragePolicies, getChildFileSystems, getContentSummary, getDefaultBlockSize, getDefaultBlockSize, getDefaultReplication, getDefaultReplication, getEnclosingRoot, getFileBlockLocations, getFileChecksum, getFileChecksum, getFileStatus, getHomeDirectory, getLinkTarget, getMountPoints, getQuotaUsage, getServerDefaults, getServerDefaults, getStatus, getStatus, getStoragePolicy, getTrashRoot, getTrashRoots, getUri, getUsed, getWorkingDirectory, getXAttr, getXAttrs, getXAttrs, hasPathCapability, listLocatedStatus, listStatus, listXAttrs, mkdirs, mkdirs, modifyAclEntries, open, removeAcl, removeAclEntries, removeDefaultAcl, removeXAttr, rename, renameSnapshot, resolvePath, satisfyStoragePolicy, setAcl, setOwner, setPermission, setReplication, setStoragePolicy, setTimes, setVerifyChecksum, setWorkingDirectory, setWriteChecksum, setXAttr, truncate, unsetStoragePolicyMethods inherited from class org.apache.hadoop.fs.FileSystem
append, append, append, append, appendFile, areSymlinksEnabled, cancelDeleteOnExit, checkPath, clearStatistics, closeAll, closeAllForUGI, completeLocalOutput, concat, copyFromLocalFile, copyFromLocalFile, copyFromLocalFile, copyFromLocalFile, copyToLocalFile, copyToLocalFile, copyToLocalFile, create, create, create, create, create, create, create, create, create, create, create, create, createBulkDelete, createDataInputStreamBuilder, createDataInputStreamBuilder, createDataOutputStreamBuilder, createFile, createMultipartUploader, createNewFile, createNonRecursive, createNonRecursive, createPathHandle, createSnapshot, createSymlink, deleteOnExit, enableSymlinks, exists, fixRelativePart, get, get, get, getAdditionalTokenIssuers, getAllStatistics, getBlockSize, getCanonicalServiceName, getCanonicalUri, getDefaultPort, getDefaultUri, getDelegationToken, getFileBlockLocations, getFileLinkStatus, getFileSystemClass, getFSofPath, getGlobalStorageStatistics, getInitialWorkingDirectory, getLength, getLocal, getName, getNamed, getPathHandle, getReplication, getStatistics, getStatistics, getStorageStatistics, getUsed, globStatus, globStatus, isDirectory, isFile, listCorruptFileBlocks, listFiles, listLocatedStatus, listStatus, listStatus, listStatus, listStatusBatch, listStatusIterator, makeQualified, mkdirs, moveFromLocalFile, moveFromLocalFile, moveToLocalFile, msync, newInstance, newInstance, newInstance, newInstanceLocal, open, open, open, openFile, openFile, openFileWithOptions, openFileWithOptions, primitiveCreate, primitiveMkdir, primitiveMkdir, printStatistics, processDeleteOnExit, rename, resolveLink, setDefaultUri, setDefaultUri, setQuota, setQuotaByStorageType, setXAttr, startLocalOutput, supportsSymlinksMethods inherited from class org.apache.hadoop.conf.Configured
getConf, setConfMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.security.token.DelegationTokenIssuer
addDelegationTokens
-
Constructor Details
-
ViewFileSystemOverloadScheme
- Throws:
IOException
-
-
Method Details
-
getScheme
Description copied from class:ViewFileSystemReturn the protocol scheme for the FileSystem.- Overrides:
getSchemein classViewFileSystem- Returns:
viewfs
-
supportAutoAddingFallbackOnNoMounts
public boolean supportAutoAddingFallbackOnNoMounts()By default returns false as ViewFileSystemOverloadScheme supports auto adding fallback on no mounts. -
setSupportAutoAddingFallbackOnNoMounts
public void setSupportAutoAddingFallbackOnNoMounts(boolean addAutoFallbackOnNoMounts) Sets whether to add fallback automatically when no mount points found.- Parameters:
addAutoFallbackOnNoMounts- addAutoFallbackOnNoMounts.
-
initialize
Description copied from class:ViewFileSystemCalled after a new FileSystem instance is constructed.- Overrides:
initializein classViewFileSystem- Parameters:
theUri- a uri whose authority section names the host, port, etc. for this FileSystemconf- the configuration- Throws:
IOException- on any failure to initialize this instance.
-
fsGetter
This method is overridden because in ViewFileSystemOverloadScheme if overloaded scheme matches with mounted target fs scheme, file system should be created without going into fs.<scheme>.impl based resolution. Otherwise it will end up in an infinite loop as the target will be resolved again to ViewFileSystemOverloadScheme as fs.<scheme>.impl points to ViewFileSystemOverloadScheme. So, below method will initialize the fs.viewfs.overload.scheme.target.<scheme>.impl. Other schemes can follow fs.newInstance- Overrides:
fsGetterin classViewFileSystem- Returns:
- fs getter.
-
getRawFileSystem
This is an admin only API to give access to its child raw file system, if the path is link. If the given path is an internal directory(path is from mount paths tree), it will initialize the file system of given path uri directly. If path cannot be resolved to any internal directory or link, it will throw NotInMountpointException. Please note, this API will not return chrooted file system. Instead, this API will get actual raw file system instances.- Parameters:
path- - fs uri pathconf- - configuration- Returns:
- file system.
- Throws:
IOException- raised on errors performing I/O.
-
getMountPathInfo
public ViewFileSystemOverloadScheme.MountPathInfo<FileSystem> getMountPathInfo(Path path, Configuration conf) throws IOException Gets the mount path info, which contains the target file system and remaining path to pass to the target file system.- Parameters:
path- the path.conf- configuration.- Returns:
- mount path info.
- Throws:
IOException- raised on errors performing I/O.
-
getFallbackFileSystem
- Returns:
- Gets the fallback file system configured. Usually, this will be the default cluster.
-
canonicalizeUri
Description copied from class:FileSystemCanonicalize the given URI. This is implementation-dependent, and may for example consist of canonicalizing the hostname using DNS and adding the default port if not specified. The default implementation simply fills in the default port if not specified and ifFileSystem.getDefaultPort()returns a default port.- Overrides:
canonicalizeUriin classFileSystem- Parameters:
uri- url.- Returns:
- URI
- See Also:
-