@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_FILTER, DEFAULT_FS, FS_DEFAULT_NAME_KEY, LOG, SHUTDOWN_HOOK_PRIORITY, statistics
Constructor and Description |
---|
FilterFileSystem() |
FilterFileSystem(FileSystem fs) |
Modifier and Type | Method and Description |
---|---|
FSDataOutputStream |
append(Path f,
int bufferSize,
Progressable progress)
Append to an existing file (optional operation).
|
protected void |
checkPath(Path path)
Check that a Path belongs to this FileSystem.
|
void |
close()
No more filesystem operations are needed.
|
void |
completeLocalOutput(Path fsOutputFile,
Path tmpLocalFile)
Called when we're all done writing to the target.
|
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.
|
boolean |
delete(Path f,
boolean recursive)
Delete a file
|
protected URI |
getCanonicalUri()
Returns a qualified URI whose scheme and authority identify this
FileSystem.
|
FileSystem[] |
getChildFileSystems()
Get all the immediate child FileSystems embedded in this FileSystem.
|
Configuration |
getConf()
Return the configuration used by this object.
|
ContentSummary |
getContentSummary(Path f)
Return the
ContentSummary of a given Path . |
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.
|
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 FilesContext class, getWorkingDirectory()
will be removed.
|
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
file system.
|
URI |
getUri()
Returns a URI whose scheme and authority identify this FileSystem.
|
long |
getUsed()
Return the total size of all files in the filesystem.
|
Path |
getWorkingDirectory()
Get the current working directory for the given file system
|
void |
initialize(URI name,
Configuration conf)
Called after a new FileSystem instance is constructed.
|
org.apache.hadoop.fs.RemoteIterator<Path> |
listCorruptFileBlocks(Path path) |
org.apache.hadoop.fs.RemoteIterator<LocatedFileStatus> |
listLocatedStatus(Path f)
List files and its block locations in a directory.
|
FileStatus[] |
listStatus(Path f)
List files in a directory.
|
Path |
makeQualified(Path path)
Make sure that a path specifies a FileSystem.
|
boolean |
mkdirs(Path f,
FsPermission permission)
Make the given file and all non-existent parents into
directories.
|
FSDataInputStream |
open(Path f,
int bufferSize)
Opens an FSDataInputStream at the indicated Path.
|
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) |
protected boolean |
primitiveMkdir(Path f,
FsPermission abdolutePermission)
This version of the mkdirs method assumes that the permission is absolute.
|
boolean |
rename(Path src,
Path dst)
Renames Path src to Path dst.
|
Path |
resolvePath(Path p)
Return the fully-qualified path of path f resolving the path
through any symlinks or mount point
|
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 |
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.
|
Path |
startLocalOutput(Path fsOutputFile,
Path tmpLocalFile)
Returns a local File that the user can write output to.
|
append, append, cancelDeleteOnExit, clearStatistics, closeAll, closeAllForUGI, copyFromLocalFile, copyToLocalFile, copyToLocalFile, create, create, create, create, create, create, create, create, create, create, create, createNewFile, createNonRecursive, createNonRecursive, delete, deleteOnExit, exists, get, get, get, getAllStatistics, getBlockSize, getDefaultPort, getDefaultUri, getFileBlockLocations, getLength, getLocal, getName, getNamed, getReplication, getStatistics, getStatistics, getStatus, globStatus, globStatus, isDirectory, isFile, listFiles, listLocatedStatus, listStatus, listStatus, listStatus, mkdirs, mkdirs, moveFromLocalFile, moveFromLocalFile, moveToLocalFile, newInstance, newInstance, newInstance, newInstanceLocal, open, primitiveMkdir, printStatistics, processDeleteOnExit, rename, setDefaultUri, setDefaultUri
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
public URI getUri()
getUri
in class FileSystem
protected URI getCanonicalUri()
getCanonicalUri
in class FileSystem
NetUtils.getCanonicalUri(URI, int)
public Path makeQualified(Path path)
makeQualified
in class FileSystem
path
- to useprotected void checkPath(Path path)
checkPath
in class FileSystem
path
- to checkpublic BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len) throws IOException
FileSystem
getFileBlockLocations
in class FileSystem
file
- FilesStatus to get data fromstart
- offset into the given filelen
- length for which to get locations forIOException
public Path resolvePath(Path p) throws IOException
FileSystem
resolvePath
in class FileSystem
p
- path to be resolvedFileNotFoundException
IOException
public 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
public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException
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
public FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException
create
in class FileSystem
f
- the file name to openoverwrite
- 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.IOException
FileSystem.setPermission(Path, FsPermission)
public boolean setReplication(Path src, short replication) throws IOException
setReplication
in class FileSystem
src
- file namereplication
- new replicationIOException
public boolean rename(Path src, Path dst) throws IOException
rename
in class FileSystem
src
- path to be renameddst
- new path after renameIOException
- on 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
public FileStatus[] listStatus(Path f) throws IOException
listStatus
in class FileSystem
f
- given pathFileNotFoundException
- when the path does not exist;
IOException see specific implementationIOException
public org.apache.hadoop.fs.RemoteIterator<Path> listCorruptFileBlocks(Path path) throws IOException
listCorruptFileBlocks
in class FileSystem
IOException
public 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 Path getHomeDirectory()
FileSystem
getHomeDirectory
in class FileSystem
public void setWorkingDirectory(Path newDir)
setWorkingDirectory
in class FileSystem
newDir
- public Path getWorkingDirectory()
getWorkingDirectory
in class FileSystem
protected Path getInitialWorkingDirectory()
FileSystem
getInitialWorkingDirectory
in class FileSystem
public FsStatus getStatus(Path p) throws IOException
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
mkdirs
in class FileSystem
f
- path to createpermission
- to apply to fIOException
public void copyFromLocalFile(boolean delSrc, Path src, Path dst) throws IOException
copyFromLocalFile
in class FileSystem
delSrc
- whether to delete the srcsrc
- pathdst
- pathIOException
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
public 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
public void copyToLocalFile(boolean delSrc, Path src, Path dst) throws IOException
copyToLocalFile
in class FileSystem
delSrc
- whether to delete the srcsrc
- pathdst
- pathIOException
public Path startLocalOutput(Path fsOutputFile, Path tmpLocalFile) throws IOException
startLocalOutput
in class FileSystem
fsOutputFile
- path of output filetmpLocalFile
- path of local tmp fileIOException
public void completeLocalOutput(Path fsOutputFile, Path tmpLocalFile) throws IOException
completeLocalOutput
in class FileSystem
fsOutputFile
- path of output filetmpLocalFile
- path to local tmp fileIOException
public long getUsed() throws IOException
getUsed
in class FileSystem
IOException
public 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
public ContentSummary getContentSummary(Path f) throws IOException
FileSystem
ContentSummary
of a given Path
.getContentSummary
in class FileSystem
f
- path to useIOException
public 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
public FileStatus getFileStatus(Path f) throws IOException
getFileStatus
in class FileSystem
f
- The path we want information fromFileNotFoundException
- when the path does not exist;
IOException see specific implementationIOException
public FileChecksum getFileChecksum(Path f) throws IOException
getFileChecksum
in class FileSystem
f
- The file pathIOException
public void setVerifyChecksum(boolean verifyChecksum)
setVerifyChecksum
in class FileSystem
public void setWriteChecksum(boolean writeChecksum)
FileSystem
setWriteChecksum
in class FileSystem
public Configuration getConf()
Configurable
getConf
in interface Configurable
getConf
in class Configured
public void close() throws IOException
FileSystem
close
in interface Closeable
close
in interface AutoCloseable
close
in class FileSystem
IOException
public void setOwner(Path p, String username, String groupname) throws IOException
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
public void setTimes(Path p, long mtime, long atime) throws IOException
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
public void setPermission(Path p, FsPermission permission) throws IOException
setPermission
in class FileSystem
IOException
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) throws IOException
primitiveCreate
in class FileSystem
IOException
protected boolean primitiveMkdir(Path f, FsPermission abdolutePermission) throws IOException
FileSystem
primitiveMkdir
in class FileSystem
IOException
public FileSystem[] getChildFileSystems()
FileSystem
Copyright © 2014 Apache Software Foundation. All Rights Reserved.