Class ViewFileSystem
- All Implemented Interfaces:
Closeable,AutoCloseable,Configurable,BulkDeleteSource,org.apache.hadoop.fs.PathCapabilities,org.apache.hadoop.security.token.DelegationTokenIssuer
ViewFs.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classorg.apache.hadoop.fs.viewfs.ViewFileSystem.MountPointMountPoint representation built from the configuration.Nested classes/interfaces inherited from class org.apache.hadoop.fs.FileSystem
org.apache.hadoop.fs.FileSystem.DirectoryEntries, org.apache.hadoop.fs.FileSystem.DirListingIterator<T extends FileStatus>, org.apache.hadoop.fs.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
ConstructorsConstructorDescriptionThis is the constructor with the signature needed byFileSystem.createFileSystem(URI, Configuration)After this constructor is called initialize() is called.ViewFileSystem(Configuration conf) Convenience Constructor for apps to call directly. -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks if the user can access a path.append(Path f, int bufferSize, Progressable progress) Append to an existing file (optional operation).voidclose()Close this FileSystem instance.create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) Create an FSDataOutputStream at the indicated Path with write-progress reporting.createNonRecursive(Path f, FsPermission permission, EnumSet<CreateFlag> flags, int bufferSize, short replication, long blockSize, Progressable progress) Opens an FSDataOutputStream at the indicated Path with write-progress reporting.createSnapshot(Path path, String snapshotName) Create a snapshot.booleanDelete a file/directory.booleanDelete a file.voiddeleteSnapshot(Path path, String snapshotName) Delete a snapshot of a directory.protected org.apache.hadoop.fs.viewfs.FsGetterfsGetter()Gets file system creator instance.getAclStatus(Path path) Gets the ACL of a file or directory.Collection<? extends BlockStoragePolicySpi>Retrieve all the storage policies supported by this file system.Get all the immediate child FileSystems embedded in this FileSystem.Return theContentSummaryof a givenPath.longReturn the number of bytes that large input files should be optimally be split into to minimize I/O time.longReturn the number of bytes that large input files should be optimally be split into to minimize I/O time.shortGet the default replication.shortGet the default replication for a path.getEnclosingRoot(Path path) Return path of the enclosing root for a given path.getFileBlockLocations(FileStatus fs, long start, long len) Return an array containing hostnames, offset and size of portions of the given file.Get the checksum of a file, if the FS supports checksums.getFileChecksum(Path f, long length) Get the checksum of a file, from the beginning of the file till the specific length.Return a file status object that represents the path.Return the current user's home directory in this FileSystem.getLinkTarget(Path path) org.apache.hadoop.fs.viewfs.ViewFileSystem.MountPoint[]Return theQuotaUsageof a givenPath.Return the protocol scheme for the FileSystem.Return a set of server default configuration values.Return a set of server default configuration values.Returns a status object describing the use and capacity of the filesystem.Returns a status object describing the use and capacity of the filesystem.getStoragePolicy(Path src) Query the effective storage policy ID for the given file or directory.getTrashRoot(Path path) Get the trash root directory for current user when the path specified is deleted.getTrashRoots(boolean allUsers) Get all the trash roots for current user or all users.getUri()Returns a URI which identifies this FileSystem.longgetUsed()Return the total size of all files under "/", ifConstants.CONFIG_VIEWFS_LINK_MERGE_SLASHis supported and is a valid mount point.Get the current working directory for the given FileSystembyte[]Get an xattr name and value for a file or directory.Get all of the xattr name/value pairs for a file or directory.Get all of the xattrs name/value pairs for a file or directory.booleanhasPathCapability(Path path, String capability) Reject the concat operation; forward the rest to the viewed FS.voidinitialize(URI theUri, Configuration conf) Called after a new FileSystem instance is constructed.org.apache.hadoop.fs.RemoteIterator<LocatedFileStatus>listLocatedStatus(Path f, PathFilter filter) List a directory.listStatus(Path f) List the statuses of the files/directories in the given path if the path is a directory.listXAttrs(Path path) Get all of the xattr names for a file or directory.booleanCallFileSystem.mkdirs(Path, FsPermission)with default permission.booleanmkdirs(Path dir, FsPermission permission) Make the given file and all non-existent parents into directories.voidmodifyAclEntries(Path path, List<AclEntry> aclSpec) Modifies ACL entries of files and directories.Opens an FSDataInputStream at the indicated Path.voidRemoves all but the base ACL entries of files and directories.voidremoveAclEntries(Path path, List<AclEntry> aclSpec) Removes ACL entries from files and directories.voidremoveDefaultAcl(Path path) Removes all default ACL entries from files and directories.voidremoveXAttr(Path path, String name) Remove an xattr of a file or directory.booleanRenames Path src to Path dst.voidrenameSnapshot(Path path, String snapshotOldName, String snapshotNewName) Rename a snapshot.resolvePath(Path f) Return the fully-qualified path of path, resolving the path through any symlinks or mount point.voidsatisfyStoragePolicy(Path src) Set the source path to satisfy storage policy.voidFully replaces ACL of files and directories, discarding all existing entries.voidSet owner of a path (i.e. a file or a directory).voidsetPermission(Path f, FsPermission permission) Set permission of a path.booleansetReplication(Path f, short replication) Set the replication for an existing file.voidsetStoragePolicy(Path src, String policyName) Set the storage policy for a given file or directory.voidSet access time of a file.voidsetVerifyChecksum(boolean verifyChecksum) Set the verify checksum flag.voidsetWorkingDirectory(Path new_dir) Set the current working directory for the given FileSystem.voidsetWriteChecksum(boolean writeChecksum) Set the write checksum flag.voidsetXAttr(Path path, String name, byte[] value, EnumSet<XAttrSetFlag> flag) Set an xattr of a file or directory.booleanTruncate the file in the indicated path to the indicated size.voidunsetStoragePolicy(Path src) Unset the storage policy set for a given file or directory.Methods inherited from class org.apache.hadoop.fs.FileSystem
append, append, append, append, appendFile, areSymlinksEnabled, cancelDeleteOnExit, canonicalizeUri, 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
-
ViewFileSystem
This is the constructor with the signature needed byFileSystem.createFileSystem(URI, Configuration)After this constructor is called initialize() is called.- Throws:
IOException- raised on errors performing I/O.
-
ViewFileSystem
Convenience Constructor for apps to call directly.- Parameters:
conf- configuration.- Throws:
IOException- raised on errors performing I/O.
-
-
Method Details
-
fsGetter
protected org.apache.hadoop.fs.viewfs.FsGetter fsGetter()Gets file system creator instance.- Returns:
- fs getter.
-
getScheme
Return the protocol scheme for the FileSystem.- Overrides:
getSchemein classFileSystem- Returns:
viewfs
-
initialize
Called after a new FileSystem instance is constructed.- Overrides:
initializein classFileSystem- 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.
-
getUri
Description copied from class:FileSystemReturns a URI which identifies this FileSystem.- Specified by:
getUriin classFileSystem- Returns:
- the URI of this filesystem.
-
resolvePath
Description copied from class:FileSystemReturn the fully-qualified path of path, resolving the path through any symlinks or mount point.- Overrides:
resolvePathin classFileSystem- Parameters:
f- path to be resolved- Returns:
- fully qualified path
- Throws:
FileNotFoundException- if the path is not presentIOException- for any other error
-
getHomeDirectory
Description copied from class:FileSystemReturn the current user's home directory in this FileSystem. The default implementation returns"/user/$USER/".- Overrides:
getHomeDirectoryin classFileSystem- Returns:
- the path.
-
getWorkingDirectory
Description copied from class:FileSystemGet the current working directory for the given FileSystem- Specified by:
getWorkingDirectoryin classFileSystem- Returns:
- the directory pathname
-
setWorkingDirectory
Description copied from class:FileSystemSet the current working directory for the given FileSystem. All relative paths will be resolved relative to it.- Specified by:
setWorkingDirectoryin classFileSystem- Parameters:
new_dir- Path of new working directory
-
append
Description copied from class:FileSystemAppend to an existing file (optional operation).- Specified by:
appendin classFileSystem- Parameters:
f- the existing file to be appended.bufferSize- the size of the buffer to be used.progress- for reporting progress if it is not null.- Returns:
- output stream.
- Throws:
IOException- IO failure
-
createNonRecursive
public FSDataOutputStream createNonRecursive(Path f, FsPermission permission, EnumSet<CreateFlag> flags, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException Description copied from class:FileSystemOpens an FSDataOutputStream at the indicated Path with write-progress reporting. Same as create(), except fails if parent directory doesn't already exist.- Overrides:
createNonRecursivein classFileSystem- Parameters:
f- the file name to openpermission- file permissionflags-CreateFlags to use for this stream.bufferSize- the size of the buffer to be used.replication- required block replication for the file.blockSize- block sizeprogress- the progress reporter- Returns:
- output stream.
- Throws:
IOException- IO failure- See Also:
-
create
public FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException Description copied from class:FileSystemCreate an FSDataOutputStream at the indicated Path with write-progress reporting.- Specified by:
createin classFileSystem- Parameters:
f- the file name to openpermission- file permissionoverwrite- if a file with this name already exists, then if true, the file will be overwritten, and if false an error will be thrown.bufferSize- the size of the buffer to be used.replication- required block replication for the file.blockSize- block sizeprogress- the progress reporter- Returns:
- output stream.
- Throws:
IOException- IO failure- See Also:
-
delete
public boolean delete(Path f, boolean recursive) throws AccessControlException, FileNotFoundException, IOException Description copied from class:FileSystemDelete a file.- Specified by:
deletein classFileSystem- Parameters:
f- the path to delete.recursive- if path is a directory and set to true, the directory is deleted else throws an exception. In case of a file the recursive can be set to either true or false.- Returns:
- true if delete is successful else false.
- Throws:
IOException- IO failureAccessControlExceptionFileNotFoundException
-
delete
Description copied from class:FileSystemDelete a file/directory.- Overrides:
deletein classFileSystem- Parameters:
f- the path.- Returns:
- if delete success true, not false.
- Throws:
IOException- IO failure.AccessControlExceptionFileNotFoundException
-
getFileBlockLocations
public BlockLocation[] getFileBlockLocations(FileStatus fs, long start, long len) throws IOException Description copied from class:FileSystemReturn an array containing hostnames, offset and size of portions of the given file. For nonexistent file or regions,nullis returned.if f == null : result = null elif f.getLen() <= start: result = [] else result = [ locations(FS, b) for b in blocks(FS, p, s, s+l)]This call is most helpful with and distributed filesystem where the hostnames of machines that contain blocks of the given file can be determined. The default implementation returns an array containing one element:BlockLocation( { "localhost:9866" }, { "localhost" }, 0, file.getLen())In HDFS, if file is three-replicated, the returned array contains elements like:BlockLocation(offset: 0, length: BLOCK_SIZE, hosts: {"host1:9866", "host2:9866, host3:9866"}) BlockLocation(offset: BLOCK_SIZE, length: BLOCK_SIZE, hosts: {"host2:9866", "host3:9866, host4:9866"})And if a file is erasure-coded, the returned BlockLocation are logical block groups. Suppose we have a RS_3_2 coded file (3 data units and 2 parity units). 1. If the file size is less than one stripe size, say 2 * CELL_SIZE, then there will be one BlockLocation returned, with 0 offset, actual file size and 4 hosts (2 data blocks and 2 parity blocks) hosting the actual blocks. 3. If the file size is less than one group size but greater than one stripe size, then there will be one BlockLocation returned, with 0 offset, actual file size with 5 hosts (3 data blocks and 2 parity blocks) hosting the actual blocks. 4. If the file size is greater than one group size, 3 * BLOCK_SIZE + 123 for example, then the result will be like:BlockLocation(offset: 0, length: 3 * BLOCK_SIZE, hosts: {"host1:9866", "host2:9866","host3:9866","host4:9866","host5:9866"}) BlockLocation(offset: 3 * BLOCK_SIZE, length: 123, hosts: {"host1:9866", "host4:9866", "host5:9866"})- Overrides:
getFileBlockLocationsin classFileSystem- Parameters:
fs- FilesStatus to get data fromstart- offset into the given filelen- length for which to get locations for- Returns:
- block location array.
- Throws:
IOException- IO failure
-
getFileChecksum
public FileChecksum getFileChecksum(Path f) throws AccessControlException, FileNotFoundException, IOException Description copied from class:FileSystemGet the checksum of a file, if the FS supports checksums.- Overrides:
getFileChecksumin classFileSystem- Parameters:
f- The file path- Returns:
- The file checksum. The default return value is null, which indicates that no checksum algorithm is implemented in the corresponding FileSystem.
- Throws:
IOException- IO failureAccessControlExceptionFileNotFoundException
-
getFileChecksum
public FileChecksum getFileChecksum(Path f, long length) throws AccessControlException, FileNotFoundException, IOException Description copied from class:FileSystemGet the checksum of a file, from the beginning of the file till the specific length.- Overrides:
getFileChecksumin classFileSystem- Parameters:
f- The file pathlength- The length of the file range for checksum calculation- Returns:
- The file checksum or null if checksums are not supported.
- Throws:
IOException- IO failureAccessControlExceptionFileNotFoundException
-
getFileStatus
public FileStatus getFileStatus(Path f) throws AccessControlException, FileNotFoundException, IOException Return a file status object that represents the path. If the given path is a symlink(mount link), the path will be resolved to a target path and it will get the resolved path's FileStatus object. It will not be represented as a symlink and isDirectory API returns true if the resolved path is a directory, false otherwise.- Specified by:
getFileStatusin classFileSystem- Parameters:
f- The path we want information from- Returns:
- a FileStatus object
- Throws:
FileNotFoundException- when the path does not existIOException- see specific implementationAccessControlException
-
access
public void access(Path path, FsAction mode) throws AccessControlException, FileNotFoundException, IOException Description copied from class:FileSystemChecks if the user can access a path. The mode specifies which access checks to perform. If the requested permissions are granted, then the method returns normally. If access is denied, then the method throws anAccessControlException.The default implementation calls
FileSystem.getFileStatus(Path)and checks the returned permissions against the requested permissions. Note that theFileSystem.getFileStatus(Path)call will be subject to authorization checks. Typically, this requires search (execute) permissions on each directory in the path's prefix, but this is implementation-defined. Any file system that provides a richer authorization model (such as ACLs) may override the default implementation so that it checks against that model instead.In general, applications should avoid using this method, due to the risk of time-of-check/time-of-use race conditions. The permissions on a file may change immediately after the access call returns. Most applications should prefer running specific file system actions as the desired user represented by a
UserGroupInformation.- Parameters:
path- Path to checkmode- type of access to check- Throws:
AccessControlException- if access is deniedFileNotFoundException- if the path does not existIOException- see specific implementation
-
listStatus
public FileStatus[] listStatus(Path f) throws AccessControlException, FileNotFoundException, IOException List the statuses of the files/directories in the given path if the path is a directory.Does not guarantee to return the List of files/directories status in a sorted order.
Will not return null. Expect IOException upon access error. Note: listStatus considers listing from fallbackLink if available. If the same directory path is present in configured mount path as well as in fallback fs, then only the fallback path will be listed in the returned result except for link. If any of the the immediate children of the given path f is a symlink(mount link), the returned FileStatus object of that children would be represented as a symlink. It will not be resolved to the target path and will not get the target path FileStatus object. The target path will be available via getSymlink on that children's FileStatus object. Since it represents as symlink, isDirectory on that children's FileStatus will return false. This behavior can be changed by setting an advanced configuration fs.viewfs.mount.links.as.symlinks to false. In this case, mount points will be represented as non-symlinks and all the file/directory attributes like permissions, isDirectory etc will be assigned from it's resolved target directory/file. If you want to get the FileStatus of target path for that children, you may want to use GetFileStatus API with that children's symlink path. Please see
getFileStatus(Path f)Note: In ViewFileSystem, by default the mount links are represented as symlinks.- Specified by:
listStatusin classFileSystem- Parameters:
f- given path- Returns:
- the statuses of the files/directories in the given patch
- Throws:
FileNotFoundException- when the path does not existIOException- see specific implementationAccessControlException
-
listLocatedStatus
public org.apache.hadoop.fs.RemoteIterator<LocatedFileStatus> listLocatedStatus(Path f, PathFilter filter) throws FileNotFoundException, IOException Description copied from class:FileSystemList a directory. The returned results include its block location if it is a file The results are filtered by the given path filter- Overrides:
listLocatedStatusin classFileSystem- Parameters:
f- a pathfilter- a path filter- Returns:
- an iterator that traverses statuses of the files/directories in the given path
- Throws:
FileNotFoundException- iffdoes not existIOException- if any I/O error occurred
-
mkdirs
Description copied from class:FileSystemCallFileSystem.mkdirs(Path, FsPermission)with default permission.- Overrides:
mkdirsin classFileSystem- Parameters:
dir- path- Returns:
- true if the directory was created
- Throws:
IOException- IO failure
-
mkdirs
Description copied from class:FileSystemMake the given file and all non-existent parents into directories. Has roughly the semantics of Unix @{code mkdir -p}. Existence of the directory hierarchy is not an error.- Specified by:
mkdirsin classFileSystem- Parameters:
dir- path to createpermission- to apply to f- Returns:
- if mkdir success true, not false.
- Throws:
IOException- IO failure
-
open
public FSDataInputStream open(Path f, int bufferSize) throws AccessControlException, FileNotFoundException, IOException Description copied from class:FileSystemOpens an FSDataInputStream at the indicated Path.- Specified by:
openin classFileSystem- Parameters:
f- the file name to openbufferSize- the size of the buffer to be used.- Returns:
- input stream.
- Throws:
IOException- IO failureAccessControlExceptionFileNotFoundException
-
rename
Description copied from class:FileSystemRenames Path src to Path dst.- Specified by:
renamein classFileSystem- Parameters:
src- path to be renameddst- new path after rename- Returns:
- true if rename is successful
- Throws:
IOException- on failure
-
truncate
Description copied from class:FileSystemTruncate the file in the indicated path to the indicated size.- Fails if path is a directory.
- Fails if path does not exist.
- Fails if path is not closed.
- Fails if new size is greater than current size.
- Overrides:
truncatein classFileSystem- Parameters:
f- The path to the file to be truncatednewLength- The size the file is to be truncated to- Returns:
trueif the file has been truncated to the desirednewLengthand is immediately available to be reused for write operations such asappend, orfalseif a background process of adjusting the length of the last block has been started, and clients should wait for it to complete before proceeding with further file updates.- Throws:
IOException- IO failure
-
setOwner
public void setOwner(Path f, String username, String groupname) throws AccessControlException, FileNotFoundException, IOException Description copied from class:FileSystemSet owner of a path (i.e. a file or a directory). The parameters username and groupname cannot both be null.- Overrides:
setOwnerin classFileSystem- Parameters:
f- The pathusername- If it is null, the original username remains unchanged.groupname- If it is null, the original groupname remains unchanged.- Throws:
IOException- IO failureAccessControlExceptionFileNotFoundException
-
setPermission
public void setPermission(Path f, FsPermission permission) throws AccessControlException, FileNotFoundException, IOException Description copied from class:FileSystemSet permission of a path.- Overrides:
setPermissionin classFileSystem- Parameters:
f- The pathpermission- permission- Throws:
IOException- IO failureAccessControlExceptionFileNotFoundException
-
setReplication
public boolean setReplication(Path f, short replication) throws AccessControlException, FileNotFoundException, IOException Description copied from class:FileSystemSet the replication for an existing file. If a filesystem does not support replication, it will always return true: the check for a file existing may be bypassed. This is the default behavior.- Overrides:
setReplicationin classFileSystem- Parameters:
f- file namereplication- new replication- Returns:
- true if successful, or the feature in unsupported; false if replication is supported but the file does not exist, or is a directory
- Throws:
IOException- an IO failure.AccessControlExceptionFileNotFoundException
-
setTimes
public void setTimes(Path f, long mtime, long atime) throws AccessControlException, FileNotFoundException, IOException Description copied from class:FileSystemSet access time of a file.- Overrides:
setTimesin classFileSystem- Parameters:
f- The pathmtime- Set the modification time of this file. The number of milliseconds since Jan 1, 1970. A value of -1 means that this call should not set modification time.atime- Set the access time of this file. The number of milliseconds since Jan 1, 1970. A value of -1 means that this call should not set access time.- Throws:
IOException- IO failureAccessControlExceptionFileNotFoundException
-
modifyAclEntries
Description copied from class:FileSystemModifies ACL entries of files and directories. This method can add new ACL entries or modify the permissions on existing ACL entries. All existing ACL entries that are not specified in this call are retained without changes. (Modifications are merged into the current ACL.)- Overrides:
modifyAclEntriesin classFileSystem- Parameters:
path- Path to modifyaclSpec- List<AclEntry> describing modifications- Throws:
IOException- if an ACL could not be modified
-
removeAclEntries
Description copied from class:FileSystemRemoves ACL entries from files and directories. Other ACL entries are retained.- Overrides:
removeAclEntriesin classFileSystem- Parameters:
path- Path to modifyaclSpec- List describing entries to remove- Throws:
IOException- if an ACL could not be modified
-
removeDefaultAcl
Description copied from class:FileSystemRemoves all default ACL entries from files and directories.- Overrides:
removeDefaultAclin classFileSystem- Parameters:
path- Path to modify- Throws:
IOException- if an ACL could not be modified
-
removeAcl
Description copied from class:FileSystemRemoves all but the base ACL entries of files and directories. The entries for user, group, and others are retained for compatibility with permission bits.- Overrides:
removeAclin classFileSystem- Parameters:
path- Path to modify- Throws:
IOException- if an ACL could not be removed
-
setAcl
Description copied from class:FileSystemFully replaces ACL of files and directories, discarding all existing entries.- Overrides:
setAclin classFileSystem- Parameters:
path- Path to modifyaclSpec- List describing modifications, which must include entries for user, group, and others for compatibility with permission bits.- Throws:
IOException- if an ACL could not be modified
-
getAclStatus
Description copied from class:FileSystemGets the ACL of a file or directory.- Overrides:
getAclStatusin classFileSystem- Parameters:
path- Path to get- Returns:
- AclStatus describing the ACL of the file or directory
- Throws:
IOException- if an ACL could not be read
-
setXAttr
public void setXAttr(Path path, String name, byte[] value, EnumSet<XAttrSetFlag> flag) throws IOException Description copied from class:FileSystemSet an xattr of a file or directory. The name must be prefixed with the namespace followed by ".". For example, "user.attr".Refer to the HDFS extended attributes user documentation for details.
- Overrides:
setXAttrin classFileSystem- Parameters:
path- Path to modifyname- xattr name.value- xattr value.flag- xattr set flag- Throws:
IOException- IO failure
-
getXAttr
Description copied from class:FileSystemGet an xattr name and value for a file or directory. The name must be prefixed with the namespace followed by ".". For example, "user.attr".Refer to the HDFS extended attributes user documentation for details.
- Overrides:
getXAttrin classFileSystem- Parameters:
path- Path to get extended attributename- xattr name.- Returns:
- byte[] xattr value.
- Throws:
IOException- IO failure
-
getXAttrs
Description copied from class:FileSystemGet all of the xattr name/value pairs for a file or directory. Only those xattrs which the logged-in user has permissions to view are returned.Refer to the HDFS extended attributes user documentation for details.
- Overrides:
getXAttrsin classFileSystem- Parameters:
path- Path to get extended attributes- Returns:
- Map describing the XAttrs of the file or directory
- Throws:
IOException- IO failure
-
getXAttrs
Description copied from class:FileSystemGet all of the xattrs name/value pairs for a file or directory. Only those xattrs which the logged-in user has permissions to view are returned.Refer to the HDFS extended attributes user documentation for details.
- Overrides:
getXAttrsin classFileSystem- Parameters:
path- Path to get extended attributesnames- XAttr names.- Returns:
- Map describing the XAttrs of the file or directory
- Throws:
IOException- IO failure
-
listXAttrs
Description copied from class:FileSystemGet all of the xattr names for a file or directory. Only those xattr names which the logged-in user has permissions to view are returned.Refer to the HDFS extended attributes user documentation for details.
- Overrides:
listXAttrsin classFileSystem- Parameters:
path- Path to get extended attributes- Returns:
- List<String> of the XAttr names of the file or directory
- Throws:
IOException- IO failure
-
removeXAttr
Description copied from class:FileSystemRemove an xattr of a file or directory. The name must be prefixed with the namespace followed by ".". For example, "user.attr".Refer to the HDFS extended attributes user documentation for details.
- Overrides:
removeXAttrin classFileSystem- Parameters:
path- Path to remove extended attributename- xattr name- Throws:
IOException- IO failure
-
setVerifyChecksum
public void setVerifyChecksum(boolean verifyChecksum) Description copied from class:FileSystemSet the verify checksum flag. This is only applicable if the corresponding filesystem supports checksums. By default doesn't do anything.- Overrides:
setVerifyChecksumin classFileSystem- Parameters:
verifyChecksum- Verify checksum flag
-
getDefaultBlockSize
public long getDefaultBlockSize()Description copied from class:FileSystemReturn the number of bytes that large input files should be optimally be split into to minimize I/O time.- Overrides:
getDefaultBlockSizein classFileSystem- Returns:
- default block size.
-
getDefaultReplication
public short getDefaultReplication()Description copied from class:FileSystemGet the default replication.- Overrides:
getDefaultReplicationin classFileSystem- Returns:
- the replication; the default value is "1".
-
getServerDefaults
Description copied from class:FileSystemReturn a set of server default configuration values.- Overrides:
getServerDefaultsin classFileSystem- Returns:
- server default configuration values
- Throws:
IOException- IO failure
-
getDefaultBlockSize
Description copied from class:FileSystemReturn the number of bytes that large input files should be optimally be split into to minimize I/O time. The given path will be used to locate the actual filesystem. The full path does not have to exist.- Overrides:
getDefaultBlockSizein classFileSystem- Parameters:
f- path of file- Returns:
- the default block size for the path's filesystem
-
getDefaultReplication
Description copied from class:FileSystemGet the default replication for a path. The given path will be used to locate the actual FileSystem to query. The full path does not have to exist.- Overrides:
getDefaultReplicationin classFileSystem- Parameters:
f- of the file- Returns:
- default replication for the path's filesystem
-
getServerDefaults
Description copied from class:FileSystemReturn a set of server default configuration values.- Overrides:
getServerDefaultsin classFileSystem- Parameters:
f- path is used to identify an FS since an FS could have another FS that it could be delegating the call to- Returns:
- server default configuration values
- Throws:
IOException- IO failure
-
getContentSummary
Description copied from class:FileSystemReturn theContentSummaryof a givenPath.- Overrides:
getContentSummaryin classFileSystem- Parameters:
f- path to use- Returns:
- content summary.
- Throws:
FileNotFoundException- if the path does not resolveIOException- IO failure
-
getQuotaUsage
Description copied from class:FileSystemReturn theQuotaUsageof a givenPath.- Overrides:
getQuotaUsagein classFileSystem- Parameters:
f- path to use- Returns:
- the quota usage
- Throws:
IOException- IO failure
-
setWriteChecksum
public void setWriteChecksum(boolean writeChecksum) Description copied from class:FileSystemSet the write checksum flag. This is only applicable if the corresponding filesystem supports checksums. By default doesn't do anything.- Overrides:
setWriteChecksumin classFileSystem- Parameters:
writeChecksum- Write checksum flag
-
getChildFileSystems
Description copied from class:FileSystemGet all the immediate child FileSystems embedded in this FileSystem. It does not recurse and get grand children. If a FileSystem has multiple child FileSystems, then it must return a unique list of those FileSystems. Default is to return null to signify no children.- Returns:
- FileSystems that are direct children of this FileSystem, or null for "no children"
-
getMountPoints
public org.apache.hadoop.fs.viewfs.ViewFileSystem.MountPoint[] getMountPoints() -
createSnapshot
Description copied from class:FileSystemCreate a snapshot.- Overrides:
createSnapshotin classFileSystem- Parameters:
path- The directory where snapshots will be taken.snapshotName- The name of the snapshot- Returns:
- the snapshot path.
- Throws:
IOException- IO failure
-
renameSnapshot
public void renameSnapshot(Path path, String snapshotOldName, String snapshotNewName) throws IOException Description copied from class:FileSystemRename a snapshot.- Overrides:
renameSnapshotin classFileSystem- Parameters:
path- The directory path where the snapshot was takensnapshotOldName- Old name of the snapshotsnapshotNewName- New name of the snapshot- Throws:
IOException- IO failure
-
deleteSnapshot
Description copied from class:FileSystemDelete a snapshot of a directory.- Overrides:
deleteSnapshotin classFileSystem- Parameters:
path- The directory that the to-be-deleted snapshot belongs tosnapshotName- The name of the snapshot- Throws:
IOException- IO failure
-
satisfyStoragePolicy
Description copied from class:FileSystemSet the source path to satisfy storage policy.- Overrides:
satisfyStoragePolicyin classFileSystem- Parameters:
src- The source path referring to either a directory or a file.- Throws:
IOException- If an I/O error occurred.
-
setStoragePolicy
Description copied from class:FileSystemSet the storage policy for a given file or directory.- Overrides:
setStoragePolicyin classFileSystem- Parameters:
src- file or directory path.policyName- the name of the target storage policy. The list of supported Storage policies can be retrieved viaFileSystem.getAllStoragePolicies().- Throws:
IOException- IO failure
-
unsetStoragePolicy
Description copied from class:FileSystemUnset the storage policy set for a given file or directory.- Overrides:
unsetStoragePolicyin classFileSystem- Parameters:
src- file or directory path.- Throws:
IOException- IO failure
-
getStoragePolicy
Description copied from class:FileSystemQuery the effective storage policy ID for the given file or directory.- Overrides:
getStoragePolicyin classFileSystem- Parameters:
src- file or directory path.- Returns:
- storage policy for give file.
- Throws:
IOException- IO failure
-
getAllStoragePolicies
Description copied from class:FileSystemRetrieve all the storage policies supported by this file system.- Overrides:
getAllStoragePoliciesin classFileSystem- Returns:
- all storage policies supported by this filesystem.
- Throws:
IOException- IO failure
-
getTrashRoot
Get the trash root directory for current user when the path specified is deleted. If FORCE_INSIDE_MOUNT_POINT flag is not set, return the default trash root from targetFS. When FORCE_INSIDE_MOUNT_POINT is set to true,-
If the trash root for path p is in the same mount point as path p,
and one of:
- The mount point isn't at the top of the target fs.
- The resolved path of path is root (in fallback FS).
- The trash isn't in user's target fs home directory get the corresponding viewFS path for the trash root and return it.
- else, return the trash root under the root of the mount point (/{mntpoint}/.Trash/{user}).
- File systems may need to have more local trash roots, such as encryption zones or snapshot roots.
- The fallback mount should use the user's home directory.
- Cloud storage systems should not use trash in an implicity defined home directory, per a container, unless it is the fallback fs.
- Overrides:
getTrashRootin classFileSystem- Parameters:
path- the trash root of the path to be determined.- Returns:
- the trash root path.
-
If the trash root for path p is in the same mount point as path p,
and one of:
-
getTrashRoots
Get all the trash roots for current user or all users. When FORCE_INSIDE_MOUNT_POINT is set to true, we also return trash roots under the root of each mount point, with their viewFS paths.- Overrides:
getTrashRootsin classFileSystem- Parameters:
allUsers- return trash roots for all users if true.- Returns:
- all Trash root directories.
-
getStatus
Description copied from class:FileSystemReturns a status object describing the use and capacity of the filesystem. If the filesystem has multiple partitions, the use and capacity of the root partition is reflected.- Overrides:
getStatusin classFileSystem- Returns:
- a FsStatus object
- Throws:
IOException- see specific implementation
-
getStatus
Description copied from class:FileSystemReturns a status object describing the use and capacity of the filesystem. If the filesystem has multiple partitions, the use and capacity of the partition pointed to by the specified path is reflected.- Overrides:
getStatusin classFileSystem- Parameters:
p- Path for which status should be obtained. null means the default partition.- Returns:
- a FsStatus object
- Throws:
IOException- see specific implementation
-
getUsed
Return the total size of all files under "/", ifConstants.CONFIG_VIEWFS_LINK_MERGE_SLASHis supported and is a valid mount point. Else, throw NotInMountpointException.- Overrides:
getUsedin classFileSystem- Returns:
- the number of path used.
- Throws:
IOException- raised on errors performing I/O.
-
getLinkTarget
Description copied from class:FileSystem- Overrides:
getLinkTargetin classFileSystem- Parameters:
path- the path.- Returns:
- the path.
- Throws:
IOException- IO failure.
-
hasPathCapability
Reject the concat operation; forward the rest to the viewed FS.- Specified by:
hasPathCapabilityin interfaceorg.apache.hadoop.fs.PathCapabilities- Overrides:
hasPathCapabilityin classFileSystem- Parameters:
path- path to query the capability of.capability- string to query the stream support for.- Returns:
- the capability
- Throws:
IOException- if there is no resolved FS, or it raises an IOE.
-
getEnclosingRoot
Description copied from class:FileSystemReturn path of the enclosing root for a given path. The enclosing root path is a common ancestor that should be used for temp and staging dirs as well as within encryption zones and other restricted directories. Call makeQualified on the param path to ensure its part of the correct filesystem.- Overrides:
getEnclosingRootin classFileSystem- Parameters:
path- file path to find the enclosing root path for- Returns:
- a path to the enclosing root
- Throws:
IOException- early checks like failure to resolve path cause IO failures
-
close
Description copied from class:FileSystemClose this FileSystem instance. Will release any held locks, delete all files queued for deletion through calls toFileSystem.deleteOnExit(Path), and remove this FS instance from the cache, if cached. After this operation, the outcome of any method call on this FileSystem instance, or any input/output stream created by it is undefined.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFileSystem- Throws:
IOException- IO failure
-