java.lang.Object org.apache.hadoop.conf.Configured org.apache.hadoop.fs.FileSystem
public abstract class FileSystem
An abstract base class for a fairly generic filesystem. It may be implemented as a distributed filesystem, or as a "local" one that reflects the locally-connected disk. The local version exists for small Hadoop instances and for testing.
All user code that may potentially use the Hadoop Distributed File System should be written to use a FileSystem object. The Hadoop DFS is a multi-machine system that appears as a single disk. It's useful because of its fault tolerance and potentially very large capacity.
The local implementation is LocalFileSystem
and distributed implementation is DistributedFileSystem.
static void
addFileSystemForTesting(URI uri, Configuration conf, FileSystem fs)
FSDataOutputStream
append(Path f)
FSDataOutputStream
append(Path f, int bufferSize)
abstract FSDataOutputStream
append(Path f, int bufferSize, Progressable progress)
protected void
checkPath(Path path)
static void
clearStatistics()
void
close()
static void
closeAll()
static void
closeAllForUGI(UserGroupInformation ugi)
void
completeLocalOutput(Path fsOutputFile, Path tmpLocalFile)
void
concat(Path trg, Path[] srcs)
void
copyFromLocalFile(boolean delSrc, boolean overwrite, Path[] srcs, Path dst)
void
copyFromLocalFile(boolean delSrc, boolean overwrite, Path src, Path dst)
void
copyFromLocalFile(boolean delSrc, Path src, Path dst)
void
copyFromLocalFile(Path src, Path dst)
void
copyToLocalFile(boolean delSrc, Path src, Path dst)
void
copyToLocalFile(Path src, Path dst)
static FSDataOutputStream
create(FileSystem fs, Path file, FsPermission permission)
FSDataOutputStream
create(Path f)
FSDataOutputStream
create(Path f, boolean overwrite)
FSDataOutputStream
create(Path f, boolean overwrite, int bufferSize)
FSDataOutputStream
create(Path f, boolean overwrite, int bufferSize, Progressable progress)
FSDataOutputStream
create(Path f, boolean overwrite, int bufferSize, short replication, long blockSize)
FSDataOutputStream
create(Path f, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress)
abstract FSDataOutputStream
create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress)
FSDataOutputStream
create(Path f, Progressable progress)
FSDataOutputStream
create(Path f, short replication)
FSDataOutputStream
create(Path f, short replication, Progressable progress)
boolean
createNewFile(Path f)
FSDataOutputStream
createNonRecursive(Path f, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress)
FSDataOutputStream
createNonRecursive(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress)
abstract boolean
delete(Path f)
abstract boolean
delete(Path f, boolean recursive)
boolean
deleteOnExit(Path f)
boolean
exists(Path f)
static FileSystem
get(Configuration conf)
static FileSystem
get(URI uri, Configuration conf)
static FileSystem
get(URI uri, Configuration conf, String user)
static List<FileSystem.Statistics>
getAllStatistics()
long
getBlockSize(Path f)
static int
getCacheSize()
String
getCanonicalServiceName()
protected URI
getCanonicalUri()
ContentSummary
getContentSummary(Path f)
ContentSummary
of a given Path
. long
getDefaultBlockSize()
getDefaultBlockSize(Path)
instead long
getDefaultBlockSize(Path f)
protected int
getDefaultPort()
short
getDefaultReplication()
getDefaultReplication(Path)
instead short
getDefaultReplication(Path path)
static URI
getDefaultUri(Configuration conf)
Token<?>
getDelegationToken(String renewer)
BlockLocation[]
getFileBlockLocations(FileStatus file, long start, long len)
FileChecksum
getFileChecksum(Path f)
abstract FileStatus
getFileStatus(Path f)
Path
getHomeDirectory()
long
getLength(Path f)
static LocalFileSystem
getLocal(Configuration conf)
String
getName()
static FileSystem
getNamed(String name, Configuration conf)
short
getReplication(Path src)
static Map<String,FileSystem.Statistics>
getStatistics()
getAllStatistics()
instead static FileSystem.Statistics
getStatistics(String scheme, Class<? extends FileSystem> cls)
abstract URI
getUri()
long
getUsed()
abstract Path
getWorkingDirectory()
FileStatus[]
globStatus(Path pathPattern)
FileStatus[]
globStatus(Path pathPattern, PathFilter filter)
void
initialize(URI name, Configuration conf)
boolean
isDirectory(Path f)
boolean
isFile(Path f)
abstract FileStatus[]
listStatus(Path f)
FileStatus[]
listStatus(Path[] files)
FileStatus[]
listStatus(Path[] files, PathFilter filter)
FileStatus[]
listStatus(Path f, PathFilter filter)
Path
makeQualified(Path path)
static boolean
mkdirs(FileSystem fs, Path dir, FsPermission permission)
boolean
mkdirs(Path f)
mkdirs(Path, FsPermission)
with default permission. abstract boolean
mkdirs(Path f, FsPermission permission)
void
moveFromLocalFile(Path[] srcs, Path dst)
void
moveFromLocalFile(Path src, Path dst)
void
moveToLocalFile(Path src, Path dst)
FSDataInputStream
open(Path f)
abstract FSDataInputStream
open(Path f, int bufferSize)
static void
printStatistics()
protected void
processDeleteOnExit()
abstract boolean
rename(Path src, Path dst)
static void
setDefaultUri(Configuration conf, String uri)
static void
setDefaultUri(Configuration conf, URI uri)
void
setOwner(Path p, String username, String groupname)
void
setPermission(Path p, FsPermission permission)
boolean
setReplication(Path src, short replication)
void
setTimes(Path p, long mtime, long atime)
void
setVerifyChecksum(boolean verifyChecksum)
abstract void
setWorkingDirectory(Path new_dir)
Path
startLocalOutput(Path fsOutputFile, Path tmpLocalFile)
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
FS_DEFAULT_NAME_KEY
public static final String FS_DEFAULT_NAME_KEY
public static final org.apache.commons.logging.Log LOG
protected FileSystem.Statistics statistics
protected FileSystem()
public static void addFileSystemForTesting(URI uri, Configuration conf, FileSystem fs) throws IOException
uri
- the uri to store it under
conf
- the configuration to store it under
fs
- the file system to store
IOException
public static FileSystem get(URI uri, Configuration conf, String user) throws IOException, InterruptedException
IOException
InterruptedException
public static FileSystem get(Configuration conf) throws IOException
IOException
public static URI getDefaultUri(Configuration conf)
conf
- the configuration to access
public static void setDefaultUri(Configuration conf, URI uri)
conf
- the configuration to alter
uri
- the new default filesystem uri
public static void setDefaultUri(Configuration conf, String uri)
conf
- the configuration to alter
uri
- the new default filesystem uri
@InterfaceAudience.Private public static int getCacheSize()
public void initialize(URI name, Configuration conf) throws IOException
name
- a uri whose authority section names the host, port, etc. for this FileSystem
conf
- the configuration
IOException
public abstract URI getUri()
protected URI getCanonicalUri()
NetUtils.getCanonicalUri(URI, int)
protected int getDefaultPort()
public String getCanonicalServiceName()
SecurityUtil.buildDTServiceName(URI, int)
public String getName()
public static FileSystem getNamed(String name, Configuration conf) throws IOException
IOException
public static LocalFileSystem getLocal(Configuration conf) throws IOException
conf
- the configuration to configure the file system with
IOException
public static FileSystem get(URI uri, Configuration conf) throws IOException
IOException
public static void closeAll() throws IOException
IOException
public static void closeAllForUGI(UserGroupInformation ugi) throws IOException
ugi
-
IOException
public Path makeQualified(Path path)
public static FSDataOutputStream create(FileSystem fs, Path file, FsPermission permission) throws IOException
fs
- file system handle
file
- the name of the file to be created
permission
- the permission of the file
IOException
public static boolean mkdirs(FileSystem fs, Path dir, FsPermission permission) throws IOException
fs
- file system handle
dir
- the name of the directory to be created
permission
- the permission of the directory
IOException
create(FileSystem, Path, FsPermission)
protected void checkPath(Path path)
public BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len) throws IOException
IOException
public abstract FSDataInputStream open(Path f, int bufferSize) throws IOException
f
- the file name to open
bufferSize
- the size of the buffer to be used.
IOException
public FSDataInputStream open(Path f) throws IOException
f
- the file to open
IOException
public FSDataOutputStream create(Path f) throws IOException
IOException
public FSDataOutputStream create(Path f, boolean overwrite) throws IOException
IOException
public FSDataOutputStream create(Path f, Progressable progress) throws IOException
IOException
public FSDataOutputStream create(Path f, short replication) throws IOException
IOException
public FSDataOutputStream create(Path f, short replication, Progressable progress) throws IOException
IOException
public FSDataOutputStream create(Path f, boolean overwrite, int bufferSize) throws IOException
f
- the file name to open
overwrite
- 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.
IOException
public FSDataOutputStream create(Path f, boolean overwrite, int bufferSize, Progressable progress) throws IOException
f
- the file name to open
overwrite
- 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.
IOException
public FSDataOutputStream create(Path f, boolean overwrite, int bufferSize, short replication, long blockSize) throws IOException
f
- the file name to open
overwrite
- 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
public FSDataOutputStream create(Path f, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException
f
- the file name to open
overwrite
- 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
public abstract FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException
f
- the file name to open
permission
-
overwrite
- 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
-
progress
-
IOException
setPermission(Path, FsPermission)
@Deprecated public FSDataOutputStream createNonRecursive(Path f, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException
f
- the file name to open
overwrite
- 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
-
progress
-
IOException
setPermission(Path, FsPermission)
@Deprecated public FSDataOutputStream createNonRecursive(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException
f
- the file name to open
permission
-
overwrite
- 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
-
progress
-
IOException
setPermission(Path, FsPermission)
public boolean createNewFile(Path f) throws IOException
IOException
public FSDataOutputStream append(Path f) throws IOException
f
- the existing file to be appended.
IOException
public FSDataOutputStream append(Path f, int bufferSize) throws IOException
f
- the existing file to be appended.
bufferSize
- the size of the buffer to be used.
IOException
public abstract FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException
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 void concat(Path trg, Path[] srcs) throws IOException
trg
- the path to the target destination.
psrcs
- the paths to the sources to use for the concatenation.
IOException
@Deprecated public short getReplication(Path src) throws IOException
src
- file name
IOException
public boolean setReplication(Path src, short replication) throws IOException
src
- file name
replication
- new replication
IOException
public abstract boolean rename(Path src, Path dst) throws IOException
IOException
@Deprecated public abstract boolean delete(Path f) throws IOException
IOException
public abstract boolean delete(Path f, boolean recursive) throws IOException
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 boolean deleteOnExit(Path f) throws IOException
f
- the path to delete.
IOException
protected void processDeleteOnExit()
public boolean exists(Path f) throws IOException
f
- source file
IOException
@Deprecated public boolean isDirectory(Path f) throws IOException
IOException
public boolean isFile(Path f) throws IOException
IOException
@Deprecated public long getLength(Path f) throws IOException
IOException
public ContentSummary getContentSummary(Path f) throws IOException
ContentSummary
of a given Path
.
IOException
public abstract FileStatus[] listStatus(Path f) throws IOException
f
- given path
IOException
public FileStatus[] listStatus(Path f, PathFilter filter) throws IOException
f
- a path name
filter
- the user-supplied path filter
IOException
- if encounter any problem while fetching the status
public FileStatus[] listStatus(Path[] files) throws IOException
files
- a list of paths
IOException
public FileStatus[] listStatus(Path[] files, PathFilter filter) throws IOException
files
- a list of paths
filter
- the user-supplied path filter
IOException
public FileStatus[] globStatus(Path pathPattern) throws IOException
Return all the files that match filePattern and are not checksum files. Results are sorted by their names.
A filename pattern is composed of regular characters and special pattern matching characters, which are:
pathPattern
- a regular expression specifying a pth pattern
IOException
public FileStatus[] globStatus(Path pathPattern, PathFilter filter) throws IOException
pathPattern
- a regular expression specifying the path pattern
filter
- a user-supplied path filter
IOException
- if any I/O error occurs when fetching file status
public Path getHomeDirectory()
public Token<?> getDelegationToken(String renewer) throws IOException
renewer
- the account name that is allowed to renew the token.
IOException
public abstract void setWorkingDirectory(Path new_dir)
new_dir
-
public abstract Path getWorkingDirectory()
public boolean mkdirs(Path f) throws IOException
mkdirs(Path, FsPermission)
with default permission.
IOException
public abstract boolean mkdirs(Path f, FsPermission permission) throws IOException
IOException
public void copyFromLocalFile(Path src, Path dst) throws IOException
IOException
public void moveFromLocalFile(Path[] srcs, Path dst) throws IOException
IOException
public void moveFromLocalFile(Path src, Path dst) throws IOException
IOException
public void copyFromLocalFile(boolean delSrc, Path src, Path dst) throws IOException
IOException
public void copyFromLocalFile(boolean delSrc, boolean overwrite, Path[] srcs, Path dst) throws IOException
IOException
public void copyFromLocalFile(boolean delSrc, boolean overwrite, Path src, Path dst) throws IOException
IOException
public void copyToLocalFile(Path src, Path dst) throws IOException
IOException
public void moveToLocalFile(Path src, Path dst) throws IOException
IOException
public void copyToLocalFile(boolean delSrc, Path src, Path dst) throws IOException
IOException
public Path startLocalOutput(Path fsOutputFile, Path tmpLocalFile) throws IOException
IOException
public void completeLocalOutput(Path fsOutputFile, Path tmpLocalFile) throws IOException
IOException
public void close() throws IOException
close
in interface Closeable
IOException
public long getUsed() throws IOException
IOException
@Deprecated public long getBlockSize(Path f) throws IOException
IOException
@Deprecated public long getDefaultBlockSize()
getDefaultBlockSize(Path)
instead
public long getDefaultBlockSize(Path f)
f
- path of file
@Deprecated public short getDefaultReplication()
getDefaultReplication(Path)
instead
public short getDefaultReplication(Path path)
path
- of the file
public abstract FileStatus getFileStatus(Path f) throws IOException
f
- The path we want information from
FileNotFoundException
- when the path does not exist; IOException see specific implementation
IOException
public FileChecksum getFileChecksum(Path f) throws IOException
f
- The file path
IOException
public void setVerifyChecksum(boolean verifyChecksum)
verifyChecksum
-
public void setPermission(Path p, FsPermission permission) throws IOException
p
-
permission
-
IOException
public void setOwner(Path p, String username, String groupname) throws IOException
p
- The path
username
- 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
p
- The path
mtime
- 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 static Map<String,FileSystem.Statistics> getStatistics()
getAllStatistics()
instead
public static List<FileSystem.Statistics> getAllStatistics()
public static FileSystem.Statistics getStatistics(String scheme, Class<? extends FileSystem> cls)
cls
- the class to lookup
public static void clearStatistics()
public static void printStatistics() throws IOException
IOException
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4