@InterfaceAudience.Public @InterfaceStability.Stable public class FilterFileSystem extends FileSystem
FilterFileSystem
contains
some other file system, which it uses as
its basic file system, possibly transforming
the data along the way or providing additional
functionality. The class FilterFileSystem
itself simply overrides all methods of
FileSystem
with versions that
pass all requests to the contained file
system. Subclasses of FilterFileSystem
may further override some of these methods
and may also provide additional methods
and fields.Modifier and Type | Field and Description |
---|---|
protected FileSystem |
fs |
protected String |
swapScheme |
DEFAULT_FS, FS_DEFAULT_NAME_KEY, SHUTDOWN_HOOK_PRIORITY, statistics, TRASH_PREFIX, USER_HOME_PREFIX
Constructor and Description |
---|
FilterFileSystem() |
FilterFileSystem(FileSystem fs) |
Modifier and Type | Method and Description |
---|---|
void |
access(Path path,
FsAction mode)
Checks if the user can access a path.
|
FSDataOutputStream |
append(Path f,
int bufferSize,
Progressable progress)
Append to an existing file (optional operation).
|
FSDataOutputStreamBuilder |
appendFile(Path path)
Create a Builder to append a file.
|
protected URI |
canonicalizeUri(URI uri)
Canonicalize the given URI.
|
protected void |
checkPath(Path path)
Check that a Path belongs to this FileSystem.
|
void |
close()
Close this FileSystem instance.
|
void |
completeLocalOutput(Path fsOutputFile,
Path tmpLocalFile)
Called when we're all done writing to the target.
|
void |
concat(Path f,
Path[] psrcs)
Concat existing files together.
|
void |
copyFromLocalFile(boolean delSrc,
boolean overwrite,
Path[] srcs,
Path dst)
The src files are on the local disk.
|
void |
copyFromLocalFile(boolean delSrc,
boolean overwrite,
Path src,
Path dst)
The src file is on the local disk.
|
void |
copyFromLocalFile(boolean delSrc,
Path src,
Path dst)
The src file is on the local disk.
|
void |
copyToLocalFile(boolean delSrc,
Path src,
Path dst)
The src file is under FS, and the dst is on the local disk.
|
FSDataOutputStream |
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.
|
FSDataOutputStream |
create(Path f,
FsPermission permission,
EnumSet<CreateFlag> flags,
int bufferSize,
short replication,
long blockSize,
Progressable progress,
org.apache.hadoop.fs.Options.ChecksumOpt checksumOpt)
Create an FSDataOutputStream at the indicated Path with a custom
checksum option.
|
FSDataOutputStreamBuilder |
createFile(Path path)
Create a new FSDataOutputStreamBuilder for the file with path.
|
FSDataOutputStream |
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.
|
protected PathHandle |
createPathHandle(FileStatus stat,
org.apache.hadoop.fs.Options.HandleOpt... opts)
Hook to implement support for
PathHandle operations. |
Path |
createSnapshot(Path path,
String snapshotName)
Create a snapshot.
|
void |
createSymlink(Path target,
Path link,
boolean createParent)
|
boolean |
delete(Path f,
boolean recursive)
Delete a file
|
void |
deleteSnapshot(Path path,
String snapshotName)
Delete a snapshot of a directory.
|
AclStatus |
getAclStatus(Path path)
Gets the ACL of a file or directory.
|
Collection<? extends BlockStoragePolicySpi> |
getAllStoragePolicies()
Retrieve all the storage policies supported by this file system.
|
protected URI |
getCanonicalUri()
Return a canonicalized form of this FileSystem's URI.
|
FileSystem[] |
getChildFileSystems()
Get all the immediate child FileSystems embedded in this FileSystem.
|
Configuration |
getConf()
Return the configuration used by this object.
|
long |
getDefaultBlockSize()
Return the number of bytes that large input files should be optimally
be split into to minimize I/O time.
|
long |
getDefaultBlockSize(Path f)
Return the number of bytes that large input files should be optimally
be split into to minimize I/O time.
|
short |
getDefaultReplication()
Get the default replication.
|
short |
getDefaultReplication(Path f)
Get the default replication for a path.
|
BlockLocation[] |
getFileBlockLocations(FileStatus file,
long start,
long len)
Return an array containing hostnames, offset and size of
portions of the given file.
|
FileChecksum |
getFileChecksum(Path f)
Get the checksum of a file, if the FS supports checksums.
|
FileChecksum |
getFileChecksum(Path f,
long length)
Get the checksum of a file, from the beginning of the file till the
specific length.
|
FileStatus |
getFileLinkStatus(Path f)
|
FileStatus |
getFileStatus(Path f)
Get file status.
|
Path |
getHomeDirectory()
Return the current user's home directory in this FileSystem.
|
protected Path |
getInitialWorkingDirectory()
Note: with the new FileContext class, getWorkingDirectory()
will be removed.
|
Path |
getLinkTarget(Path f)
|
FileSystem |
getRawFileSystem()
Get the raw file system
|
FsServerDefaults |
getServerDefaults()
Return a set of server default configuration values.
|
FsServerDefaults |
getServerDefaults(Path f)
Return a set of server default configuration values.
|
FsStatus |
getStatus(Path p)
Returns a status object describing the use and capacity of the
filesystem.
|
BlockStoragePolicySpi |
getStoragePolicy(Path src)
Query the effective storage policy ID for the given file or directory.
|
Path |
getTrashRoot(Path path)
Get the root directory of Trash for current user when the path specified
is deleted.
|
Collection<FileStatus> |
getTrashRoots(boolean allUsers)
Get all the trash roots for current user or all users.
|
URI |
getUri()
Returns a URI whose scheme and authority identify this FileSystem.
|
long |
getUsed()
Return the total size of all files in the filesystem.
|
long |
getUsed(Path path)
Return the total size of all files from a specified path.
|
Path |
getWorkingDirectory()
Get the current working directory for the given file system
|
byte[] |
getXAttr(Path path,
String name)
Get an xattr name and value for a file or directory.
|
Map<String,byte[]> |
getXAttrs(Path path)
Get all of the xattr name/value pairs for a file or directory.
|
Map<String,byte[]> |
getXAttrs(Path path,
List<String> names)
Get all of the xattrs name/value pairs for a file or directory.
|
boolean |
hasPathCapability(Path path,
String capability)
The base FileSystem implementation generally has no knowledge
of the capabilities of actual implementations.
|
void |
initialize(URI name,
Configuration conf)
Called after a new FileSystem instance is constructed.
|
org.apache.hadoop.fs.RemoteIterator<Path> |
listCorruptFileBlocks(Path path)
List corrupted file blocks.
|
org.apache.hadoop.fs.RemoteIterator<LocatedFileStatus> |
listLocatedStatus(Path f)
List files and its block locations in a directory.
|
protected org.apache.hadoop.fs.RemoteIterator<LocatedFileStatus> |
listLocatedStatus(Path f,
PathFilter filter)
List a directory.
|
FileStatus[] |
listStatus(Path f)
List files in a directory.
|
org.apache.hadoop.fs.RemoteIterator<FileStatus> |
listStatusIterator(Path f)
Return a remote iterator for listing in a directory
|
List<String> |
listXAttrs(Path path)
Get all of the xattr names for a file or directory.
|
Path |
makeQualified(Path path)
Make sure that a path specifies a FileSystem.
|
boolean |
mkdirs(Path f)
Call
FileSystem.mkdirs(Path, FsPermission) with default permission. |
boolean |
mkdirs(Path f,
FsPermission permission)
Make the given file and all non-existent parents into
directories.
|
void |
modifyAclEntries(Path path,
List<AclEntry> aclSpec)
Modifies ACL entries of files and directories.
|
void |
msync()
Synchronize client metadata state.
|
FSDataInputStream |
open(PathHandle fd,
int bufferSize)
Open an FSDataInputStream matching the PathHandle instance.
|
FSDataInputStream |
open(Path f,
int bufferSize)
Opens an FSDataInputStream at the indicated Path.
|
FutureDataInputStreamBuilder |
openFile(Path path)
Open a file for reading through a builder API.
|
FutureDataInputStreamBuilder |
openFile(PathHandle pathHandle)
Open a file for reading through a builder API.
|
protected CompletableFuture<FSDataInputStream> |
openFileWithOptions(PathHandle pathHandle,
org.apache.hadoop.fs.impl.OpenFileParameters parameters)
Execute the actual open file operation.
|
protected CompletableFuture<FSDataInputStream> |
openFileWithOptions(Path path,
org.apache.hadoop.fs.impl.OpenFileParameters parameters)
Execute the actual open file operation.
|
protected FSDataOutputStream |
primitiveCreate(Path f,
FsPermission absolutePermission,
EnumSet<CreateFlag> flag,
int bufferSize,
short replication,
long blockSize,
Progressable progress,
org.apache.hadoop.fs.Options.ChecksumOpt checksumOpt)
This create has been added to support the FileContext that processes
the permission with umask before calling this method.
|
protected boolean |
primitiveMkdir(Path f,
FsPermission abdolutePermission)
This version of the mkdirs method assumes that the permission is absolute.
|
void |
removeAcl(Path path)
Removes all but the base ACL entries of files and directories.
|
void |
removeAclEntries(Path path,
List<AclEntry> aclSpec)
Removes ACL entries from files and directories.
|
void |
removeDefaultAcl(Path path)
Removes all default ACL entries from files and directories.
|
void |
removeXAttr(Path path,
String name)
Remove an xattr of a file or directory.
|
boolean |
rename(Path src,
Path dst)
Renames Path src to Path dst.
|
protected void |
rename(Path src,
Path dst,
org.apache.hadoop.fs.Options.Rename... options)
Renames Path src to Path dst
Fails if src is a file and dst is a directory.
Fails if src is a directory and dst is a file.
Fails if the parent of dst does not exist or is a file.
|
void |
renameSnapshot(Path path,
String snapshotOldName,
String snapshotNewName)
Rename a snapshot.
|
protected Path |
resolveLink(Path f)
|
Path |
resolvePath(Path p)
Return the fully-qualified path of path, resolving the path
through any symlinks or mount point.
|
void |
satisfyStoragePolicy(Path src)
Set the source path to satisfy storage policy.
|
void |
setAcl(Path path,
List<AclEntry> aclSpec)
Fully replaces ACL of files and directories, discarding all existing
entries.
|
void |
setOwner(Path p,
String username,
String groupname)
Set owner of a path (i.e.
|
void |
setPermission(Path p,
FsPermission permission)
Set permission of a path.
|
boolean |
setReplication(Path src,
short replication)
Set replication for an existing file.
|
void |
setStoragePolicy(Path src,
String policyName)
Set the storage policy for a given file or directory.
|
void |
setTimes(Path p,
long mtime,
long atime)
Set access time of a file.
|
void |
setVerifyChecksum(boolean verifyChecksum)
Set the verify checksum flag.
|
void |
setWorkingDirectory(Path newDir)
Set the current working directory for the given file system.
|
void |
setWriteChecksum(boolean writeChecksum)
Set the write checksum flag.
|
void |
setXAttr(Path path,
String name,
byte[] value)
Set an xattr of a file or directory.
|
void |
setXAttr(Path path,
String name,
byte[] value,
EnumSet<XAttrSetFlag> flag)
Set an xattr of a file or directory.
|
Path |
startLocalOutput(Path fsOutputFile,
Path tmpLocalFile)
Returns a local File that the user can write output to.
|
boolean |
supportsSymlinks()
|
boolean |
truncate(Path f,
long newLength)
Truncate the file in the indicated path to the indicated size.
|
void |
unsetStoragePolicy(Path src)
Unset the storage policy set for a given file or directory.
|
append, append, append, append, areSymlinksEnabled, cancelDeleteOnExit, clearStatistics, closeAll, closeAllForUGI, copyFromLocalFile, copyToLocalFile, copyToLocalFile, create, create, create, create, create, create, create, create, create, create, create, createDataOutputStreamBuilder, createMultipartUploader, createNewFile, createNonRecursive, createNonRecursive, createSnapshot, delete, deleteOnExit, enableSymlinks, exists, fixRelativePart, get, get, get, getAllStatistics, getBlockSize, getCanonicalServiceName, getContentSummary, getDefaultPort, getDefaultUri, getFileBlockLocations, getFileSystemClass, getFSofPath, getGlobalStorageStatistics, getLength, getLocal, getName, getNamed, getPathHandle, getQuotaUsage, getReplication, getScheme, getStatistics, getStatistics, getStatus, getStorageStatistics, globStatus, globStatus, isDirectory, isFile, listFiles, listStatus, listStatus, listStatus, mkdirs, moveFromLocalFile, moveFromLocalFile, moveToLocalFile, newInstance, newInstance, newInstance, newInstanceLocal, open, open, primitiveMkdir, printStatistics, processDeleteOnExit, setDefaultUri, setDefaultUri, setQuota, setQuotaByStorageType
setConf
protected FileSystem fs
protected String swapScheme
public FilterFileSystem()
public FilterFileSystem(FileSystem fs)
public FileSystem getRawFileSystem()
public void initialize(URI name, Configuration conf) throws IOException
initialize
in class FileSystem
name
- a uri whose authority section names the host, port, etc.
for this FileSystemconf
- the configurationIOException
- on any failure to initialize this instance.public URI getUri()
getUri
in class FileSystem
protected URI getCanonicalUri()
FileSystem
FileSystem.canonicalizeUri(URI)
on the filesystem's own URI, so subclasses typically only need to
implement that method.getCanonicalUri
in class FileSystem
FileSystem.canonicalizeUri(URI)
protected URI canonicalizeUri(URI uri)
FileSystem
FileSystem.getDefaultPort()
returns a
default port.canonicalizeUri
in class FileSystem
uri
- url.NetUtils.getCanonicalUri(URI, int)
public Path makeQualified(Path path)
makeQualified
in class FileSystem
path
- to qualify.Path.makeQualified(URI, Path)
protected void checkPath(Path path)
checkPath
in class FileSystem
path
- to checkpublic BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len) throws IOException
FileSystem
null
is 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"})
getFileBlockLocations
in class FileSystem
file
- FilesStatus to get data fromstart
- offset into the given filelen
- length for which to get locations forIOException
- IO failurepublic Path resolvePath(Path p) throws IOException
FileSystem
resolvePath
in class FileSystem
p
- path to be resolvedFileNotFoundException
- if the path is not presentIOException
- for any other errorpublic FSDataInputStream open(Path f, int bufferSize) throws IOException
open
in class FileSystem
f
- the file name to openbufferSize
- the size of the buffer to be used.IOException
- IO failurepublic FSDataInputStream open(PathHandle fd, int bufferSize) throws IOException
FileSystem
open
in class FileSystem
fd
- PathHandle object returned by the FS authority.bufferSize
- the size of the buffer to useInvalidPathHandleException
- If PathHandle
constraints are
not satisfiedIOException
- IO failureprotected PathHandle createPathHandle(FileStatus stat, org.apache.hadoop.fs.Options.HandleOpt... opts)
FileSystem
PathHandle
operations.createPathHandle
in class FileSystem
stat
- Referent in the target FileSystemopts
- Constraints that determine the validity of the
PathHandle
reference.public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException
FileSystem
append
in class FileSystem
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.IOException
- IO failurepublic void concat(Path f, Path[] psrcs) throws IOException
FileSystem
concat
in class FileSystem
f
- the path to the target destination.psrcs
- the paths to the sources to use for the concatenation.IOException
- IO failurepublic FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException
FileSystem
create
in class FileSystem
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 reporterIOException
- IO failureFileSystem.setPermission(Path, FsPermission)
public FSDataOutputStream create(Path f, FsPermission permission, EnumSet<CreateFlag> flags, int bufferSize, short replication, long blockSize, Progressable progress, org.apache.hadoop.fs.Options.ChecksumOpt checksumOpt) throws IOException
FileSystem
create
in class FileSystem
f
- the file name to openpermission
- file permissionflags
- CreateFlag
s 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 reporterchecksumOpt
- checksum parameter. If null, the values
found in conf will be used.IOException
- IO failureFileSystem.setPermission(Path, FsPermission)
protected org.apache.hadoop.fs.RemoteIterator<LocatedFileStatus> listLocatedStatus(Path f, PathFilter filter) throws FileNotFoundException, IOException
FileSystem
listLocatedStatus
in class FileSystem
f
- a pathfilter
- a path filterFileNotFoundException
- if f
does not existIOException
- if any I/O error occurredpublic FSDataOutputStream createNonRecursive(Path f, FsPermission permission, EnumSet<CreateFlag> flags, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException
FileSystem
createNonRecursive
in class FileSystem
f
- the file name to openpermission
- file permissionflags
- CreateFlag
s 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 reporterIOException
- IO failureFileSystem.setPermission(Path, FsPermission)
public boolean setReplication(Path src, short replication) throws IOException
setReplication
in class FileSystem
src
- file namereplication
- new replicationIOException
- raised on errors performing I/O.public boolean rename(Path src, Path dst) throws IOException
rename
in class FileSystem
src
- path to be renameddst
- new path after renameIOException
- on failureprotected void rename(Path src, Path dst, org.apache.hadoop.fs.Options.Rename... options) throws IOException
FileSystem
If OVERWRITE option is not passed as an argument, rename fails if the dst already exists.
If OVERWRITE option is passed as an argument, rename overwrites the dst if it is a file or an empty directory. Rename fails if dst is a non-empty directory.
Note that atomicity of rename is dependent on the file system implementation. Please refer to the file system documentation for details. This default implementation is non atomic.This method is deprecated since it is a temporary method added to support the transition from FileSystem to FileContext for user applications.
rename
in class FileSystem
src
- path to be renameddst
- new path after renameoptions
- rename options.FileNotFoundException
- src path does not exist, or the parent
path of dst does not exist.FileAlreadyExistsException
- dest path exists and is a fileParentNotDirectoryException
- if the parent path of dest is not
a directoryIOException
- on failurepublic boolean truncate(Path f, long newLength) throws IOException
FileSystem
truncate
in class FileSystem
f
- The path to the file to be truncatednewLength
- The size the file is to be truncated totrue
if the file has been truncated to the desired
newLength
and is immediately available to be reused for
write operations such as append
, or
false
if 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.IOException
- IO failurepublic boolean delete(Path f, boolean recursive) throws IOException
delete
in class FileSystem
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.IOException
- IO failurepublic FileStatus[] listStatus(Path f) throws IOException
listStatus
in class FileSystem
f
- given pathFileNotFoundException
- when the path does not existIOException
- see specific implementationpublic org.apache.hadoop.fs.RemoteIterator<Path> listCorruptFileBlocks(Path path) throws IOException
FileSystem
listCorruptFileBlocks
in class FileSystem
path
- the path.IOException
- IO failurepublic org.apache.hadoop.fs.RemoteIterator<LocatedFileStatus> listLocatedStatus(Path f) throws IOException
listLocatedStatus
in class FileSystem
f
- is the pathFileNotFoundException
- If f
does not existIOException
- If an I/O error occurredpublic org.apache.hadoop.fs.RemoteIterator<FileStatus> listStatusIterator(Path f) throws IOException
listStatusIterator
in class FileSystem
f
- target pathFileNotFoundException
- if p
does not existIOException
- if any I/O error occurredpublic Path getHomeDirectory()
FileSystem
"/user/$USER/"
.getHomeDirectory
in class FileSystem
public void setWorkingDirectory(Path newDir)
setWorkingDirectory
in class FileSystem
newDir
- new dir.public Path getWorkingDirectory()
getWorkingDirectory
in class FileSystem
protected Path getInitialWorkingDirectory()
FileSystem
getInitialWorkingDirectory
in class FileSystem
public FsStatus getStatus(Path p) throws IOException
FileSystem
getStatus
in class FileSystem
p
- Path for which status should be obtained. null means
the default partition.IOException
- see specific implementationpublic boolean mkdirs(Path f, FsPermission permission) throws IOException
FileSystem
mkdirs
in class FileSystem
f
- path to createpermission
- to apply to fIOException
- IO failurepublic boolean mkdirs(Path f) throws IOException
FileSystem
FileSystem.mkdirs(Path, FsPermission)
with default permission.mkdirs
in class FileSystem
f
- pathIOException
- IO failurepublic void copyFromLocalFile(boolean delSrc, Path src, Path dst) throws IOException
copyFromLocalFile
in class FileSystem
delSrc
- whether to delete the srcsrc
- pathdst
- pathIOException
- IO failure.public void copyFromLocalFile(boolean delSrc, boolean overwrite, Path[] srcs, Path dst) throws IOException
copyFromLocalFile
in class FileSystem
delSrc
- whether to delete the srcoverwrite
- whether to overwrite an existing filesrcs
- array of paths which are sourcedst
- pathIOException
- IO failurepublic void copyFromLocalFile(boolean delSrc, boolean overwrite, Path src, Path dst) throws IOException
copyFromLocalFile
in class FileSystem
delSrc
- whether to delete the srcoverwrite
- whether to overwrite an existing filesrc
- pathdst
- pathIOException
- IO failurepublic void copyToLocalFile(boolean delSrc, Path src, Path dst) throws IOException
copyToLocalFile
in class FileSystem
delSrc
- whether to delete the srcsrc
- path src file in the remote filesystemdst
- path local destinationIOException
- IO failurepublic Path startLocalOutput(Path fsOutputFile, Path tmpLocalFile) throws IOException
startLocalOutput
in class FileSystem
fsOutputFile
- path of output filetmpLocalFile
- path of local tmp fileIOException
- IO failurepublic void completeLocalOutput(Path fsOutputFile, Path tmpLocalFile) throws IOException
completeLocalOutput
in class FileSystem
fsOutputFile
- path of output filetmpLocalFile
- path to local tmp fileIOException
- IO failurepublic long getUsed() throws IOException
getUsed
in class FileSystem
IOException
- IO failurepublic long getUsed(Path path) throws IOException
getUsed
in class FileSystem
path
- the path.IOException
- IO failurepublic long getDefaultBlockSize()
FileSystem
getDefaultBlockSize
in class FileSystem
public short getDefaultReplication()
FileSystem
getDefaultReplication
in class FileSystem
public FsServerDefaults getServerDefaults() throws IOException
FileSystem
getServerDefaults
in class FileSystem
IOException
- IO failurepublic long getDefaultBlockSize(Path f)
FileSystem
getDefaultBlockSize
in class FileSystem
f
- path of filepublic short getDefaultReplication(Path f)
FileSystem
getDefaultReplication
in class FileSystem
f
- of the filepublic FsServerDefaults getServerDefaults(Path f) throws IOException
FileSystem
getServerDefaults
in class FileSystem
f
- path is used to identify an FS since an FS could have
another FS that it could be delegating the call toIOException
- IO failurepublic FileStatus getFileStatus(Path f) throws IOException
getFileStatus
in class FileSystem
f
- The path we want information fromFileNotFoundException
- when the path does not existIOException
- see specific implementationpublic void msync() throws IOException, UnsupportedOperationException
FileSystem
In some FileSystem implementations such as HDFS metadata synchronization is essential to guarantee consistency of read requests particularly in HA setting.
msync
in class FileSystem
IOException
- If an I/O error occurred.UnsupportedOperationException
- if the operation is unsupported.public void access(Path path, FsAction mode) throws AccessControlException, FileNotFoundException, IOException
FileSystem
AccessControlException
.
The default implementation calls FileSystem.getFileStatus(Path)
and checks the returned permissions against the requested permissions.
Note that the FileSystem.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
.
path
- Path to checkmode
- type of access to checkAccessControlException
- if access is deniedFileNotFoundException
- if the path does not existIOException
- see specific implementationpublic void createSymlink(Path target, Path link, boolean createParent) throws AccessControlException, FileAlreadyExistsException, FileNotFoundException, ParentNotDirectoryException, UnsupportedFileSystemException, IOException
FileSystem
createSymlink
in class FileSystem
target
- target path.link
- link.createParent
- create parent.AccessControlException
- if access is denied.FileAlreadyExistsException
- when the path does not exist.FileNotFoundException
- when the path does not exist.ParentNotDirectoryException
- if the parent path of dest is not
a directory.UnsupportedFileSystemException
- if there was no known implementation
for the scheme.IOException
- raised on errors performing I/O.public FileStatus getFileLinkStatus(Path f) throws AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException
FileSystem
getFileLinkStatus
in class FileSystem
f
- the path.AccessControlException
- if access is denied.FileNotFoundException
- when the path does not exist.UnsupportedFileSystemException
- if there was no known implementation
for the scheme.IOException
- raised on errors performing I/O.public boolean supportsSymlinks()
FileSystem
supportsSymlinks
in class FileSystem
public Path getLinkTarget(Path f) throws IOException
FileSystem
getLinkTarget
in class FileSystem
f
- the path.IOException
- IO failure.protected Path resolveLink(Path f) throws IOException
FileSystem
resolveLink
in class FileSystem
f
- the path.IOException
- IO failure.public FileChecksum getFileChecksum(Path f) throws IOException
FileSystem
getFileChecksum
in class FileSystem
f
- The file pathIOException
- IO failurepublic FileChecksum getFileChecksum(Path f, long length) throws IOException
FileSystem
getFileChecksum
in class FileSystem
f
- The file pathlength
- The length of the file range for checksum calculationIOException
- IO failurepublic void setVerifyChecksum(boolean verifyChecksum)
FileSystem
setVerifyChecksum
in class FileSystem
verifyChecksum
- Verify checksum flagpublic void setWriteChecksum(boolean writeChecksum)
FileSystem
setWriteChecksum
in class FileSystem
writeChecksum
- Write checksum flagpublic Configuration getConf()
Configurable
getConf
in interface Configurable
getConf
in class Configured
public void close() throws IOException
FileSystem
FileSystem.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.close
in interface Closeable
close
in interface AutoCloseable
close
in class FileSystem
IOException
- IO failurepublic void setOwner(Path p, String username, String groupname) throws IOException
FileSystem
setOwner
in class FileSystem
p
- The pathusername
- If it is null, the original username remains unchanged.groupname
- If it is null, the original groupname remains unchanged.IOException
- IO failurepublic void setTimes(Path p, long mtime, long atime) throws IOException
FileSystem
setTimes
in class FileSystem
p
- 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.IOException
- IO failurepublic void setPermission(Path p, FsPermission permission) throws IOException
FileSystem
setPermission
in class FileSystem
p
- The pathpermission
- permissionIOException
- IO failureprotected FSDataOutputStream primitiveCreate(Path f, FsPermission absolutePermission, EnumSet<CreateFlag> flag, int bufferSize, short replication, long blockSize, Progressable progress, org.apache.hadoop.fs.Options.ChecksumOpt checksumOpt) throws IOException
FileSystem
primitiveCreate
in class FileSystem
f
- path.absolutePermission
- permission.flag
- create flag.bufferSize
- buffer size.replication
- replication.blockSize
- block size.progress
- progress.checksumOpt
- check sum opt.IOException
- IO failureprotected boolean primitiveMkdir(Path f, FsPermission abdolutePermission) throws IOException
FileSystem
primitiveMkdir
in class FileSystem
f
- pathabdolutePermission
- permissionsIOException
- IO failureFileSystem.mkdirs(Path, FsPermission)
public FileSystem[] getChildFileSystems()
FileSystem
public Path createSnapshot(Path path, String snapshotName) throws IOException
FileSystem
createSnapshot
in class FileSystem
path
- The directory where snapshots will be taken.snapshotName
- The name of the snapshotIOException
- IO failurepublic void renameSnapshot(Path path, String snapshotOldName, String snapshotNewName) throws IOException
FileSystem
renameSnapshot
in class FileSystem
path
- The directory path where the snapshot was takensnapshotOldName
- Old name of the snapshotsnapshotNewName
- New name of the snapshotIOException
- IO failurepublic void deleteSnapshot(Path path, String snapshotName) throws IOException
FileSystem
deleteSnapshot
in class FileSystem
path
- The directory that the to-be-deleted snapshot belongs tosnapshotName
- The name of the snapshotIOException
- IO failurepublic void modifyAclEntries(Path path, List<AclEntry> aclSpec) throws IOException
FileSystem
modifyAclEntries
in class FileSystem
path
- Path to modifyaclSpec
- List<AclEntry> describing modificationsIOException
- if an ACL could not be modifiedpublic void removeAclEntries(Path path, List<AclEntry> aclSpec) throws IOException
FileSystem
removeAclEntries
in class FileSystem
path
- Path to modifyaclSpec
- List describing entries to removeIOException
- if an ACL could not be modifiedpublic void removeDefaultAcl(Path path) throws IOException
FileSystem
removeDefaultAcl
in class FileSystem
path
- Path to modifyIOException
- if an ACL could not be modifiedpublic void removeAcl(Path path) throws IOException
FileSystem
removeAcl
in class FileSystem
path
- Path to modifyIOException
- if an ACL could not be removedpublic void setAcl(Path path, List<AclEntry> aclSpec) throws IOException
FileSystem
setAcl
in class FileSystem
path
- Path to modifyaclSpec
- List describing modifications, which must include entries
for user, group, and others for compatibility with permission bits.IOException
- if an ACL could not be modifiedpublic AclStatus getAclStatus(Path path) throws IOException
FileSystem
getAclStatus
in class FileSystem
path
- Path to getIOException
- if an ACL could not be readpublic void setXAttr(Path path, String name, byte[] value) throws IOException
FileSystem
Refer to the HDFS extended attributes user documentation for details.
setXAttr
in class FileSystem
path
- Path to modifyname
- xattr name.value
- xattr value.IOException
- IO failurepublic void setXAttr(Path path, String name, byte[] value, EnumSet<XAttrSetFlag> flag) throws IOException
FileSystem
Refer to the HDFS extended attributes user documentation for details.
setXAttr
in class FileSystem
path
- Path to modifyname
- xattr name.value
- xattr value.flag
- xattr set flagIOException
- IO failurepublic byte[] getXAttr(Path path, String name) throws IOException
FileSystem
Refer to the HDFS extended attributes user documentation for details.
getXAttr
in class FileSystem
path
- Path to get extended attributename
- xattr name.IOException
- IO failurepublic Map<String,byte[]> getXAttrs(Path path) throws IOException
FileSystem
Refer to the HDFS extended attributes user documentation for details.
getXAttrs
in class FileSystem
path
- Path to get extended attributesIOException
- IO failurepublic Map<String,byte[]> getXAttrs(Path path, List<String> names) throws IOException
FileSystem
Refer to the HDFS extended attributes user documentation for details.
getXAttrs
in class FileSystem
path
- Path to get extended attributesnames
- XAttr names.IOException
- IO failurepublic List<String> listXAttrs(Path path) throws IOException
FileSystem
Refer to the HDFS extended attributes user documentation for details.
listXAttrs
in class FileSystem
path
- Path to get extended attributesIOException
- IO failurepublic void removeXAttr(Path path, String name) throws IOException
FileSystem
Refer to the HDFS extended attributes user documentation for details.
removeXAttr
in class FileSystem
path
- Path to remove extended attributename
- xattr nameIOException
- IO failurepublic void satisfyStoragePolicy(Path src) throws IOException
FileSystem
satisfyStoragePolicy
in class FileSystem
src
- The source path referring to either a directory or a file.IOException
- If an I/O error occurred.public void setStoragePolicy(Path src, String policyName) throws IOException
FileSystem
setStoragePolicy
in class FileSystem
src
- file or directory path.policyName
- the name of the target storage policy. The list
of supported Storage policies can be retrieved
via FileSystem.getAllStoragePolicies()
.IOException
- IO failurepublic void unsetStoragePolicy(Path src) throws IOException
FileSystem
unsetStoragePolicy
in class FileSystem
src
- file or directory path.IOException
- IO failurepublic BlockStoragePolicySpi getStoragePolicy(Path src) throws IOException
FileSystem
getStoragePolicy
in class FileSystem
src
- file or directory path.IOException
- IO failurepublic Collection<? extends BlockStoragePolicySpi> getAllStoragePolicies() throws IOException
FileSystem
getAllStoragePolicies
in class FileSystem
IOException
- IO failurepublic Path getTrashRoot(Path path)
FileSystem
getTrashRoot
in class FileSystem
path
- the trash root of the path to be determined./user/$USER/.Trash
public Collection<FileStatus> getTrashRoots(boolean allUsers)
FileSystem
getTrashRoots
in class FileSystem
allUsers
- return trash roots for all users if true./user/$USER/.Trash
exists.public FSDataOutputStreamBuilder createFile(Path path)
FileSystem
createFile
in class FileSystem
path
- file pathpublic FSDataOutputStreamBuilder appendFile(Path path)
FileSystem
appendFile
in class FileSystem
path
- file path.FSDataOutputStreamBuilder
to build file append request.public FutureDataInputStreamBuilder openFile(Path path) throws IOException, UnsupportedOperationException
FileSystem
FileSystem.open(Path, int)
unless a subclass
executes the open command differently.
The semantics of this call are therefore the same as that of
FileSystem.open(Path, int)
with one special point: it is in
FSDataInputStreamBuilder.build()
in which the open operation
takes place -it is there where all preconditions to the operation
are checked.openFile
in class FileSystem
path
- file pathIOException
- if some early checks cause IO failures.UnsupportedOperationException
- if support is checked early.public FutureDataInputStreamBuilder openFile(PathHandle pathHandle) throws IOException, UnsupportedOperationException
FileSystem
FileSystem.open(PathHandle, int)
unless a subclass
executes the open command differently.
If PathHandles are unsupported, this may fail in the
FSDataInputStreamBuilder.build()
command,
rather than in this openFile()
operation.openFile
in class FileSystem
pathHandle
- path handle.IOException
- if some early checks cause IO failures.UnsupportedOperationException
- if support is checked early.protected CompletableFuture<FSDataInputStream> openFileWithOptions(Path path, org.apache.hadoop.fs.impl.OpenFileParameters parameters) throws IOException
FileSystem
FSDataInputStreamBuilder.build()
and from DelegateToFileSystem
and is where
the action of opening the file should begin.
The base implementation performs a blocking
call to FileSystem.open(Path, int)
in this call;
the actual outcome is in the returned CompletableFuture
.
This avoids having to create some thread pool, while still
setting up the expectation that the get()
call
is needed to evaluate the result.openFileWithOptions
in class FileSystem
path
- path to the fileparameters
- open file parameters from the builder.IOException
- failure to resolve the link.protected CompletableFuture<FSDataInputStream> openFileWithOptions(PathHandle pathHandle, org.apache.hadoop.fs.impl.OpenFileParameters parameters) throws IOException
FileSystem
FileSystem.open(Path, int)
in this call;
the actual outcome is in the returned CompletableFuture
.
This avoids having to create some thread pool, while still
setting up the expectation that the get()
call
is needed to evaluate the result.openFileWithOptions
in class FileSystem
pathHandle
- path to the fileparameters
- open file parameters from the builder.IOException
- failure to resolve the link.public boolean hasPathCapability(Path path, String capability) throws IOException
FileSystem
true
, this instance is explicitly
declaring that the capability is available.
If the function returns false
, it can mean one of:
Implementors: PathCapabilitiesSupport
can be used to help implement this method.
hasPathCapability
in interface org.apache.hadoop.fs.PathCapabilities
hasPathCapability
in class FileSystem
path
- path to query the capability of.capability
- non-null, non-empty string to query the path for support.IOException
- this should not be raised, except on problems
resolving paths or relaying the call.Copyright © 2023 Apache Software Foundation. All rights reserved.