public class DistributedFileSystem extends FileSystem
限定符和类型 | 类和说明 |
---|---|
static class |
DistributedFileSystem.DiskStatus |
FileSystem.Statistics
FS_DEFAULT_NAME_KEY, LOG, statistics
构造器和说明 |
---|
DistributedFileSystem() |
DistributedFileSystem(InetSocketAddress namenode,
Configuration conf)
已过时。
|
限定符和类型 | 方法和说明 |
---|---|
FSDataOutputStream |
append(Path f,
int bufferSize,
Progressable progress)
This optional operation is not yet supported.
|
void |
cancelDelegationToken(Token<DelegationTokenIdentifier> token)
已过时。
Use Token.cancel instead.
|
void |
close()
No more filesystem operations are needed.
|
void |
concat(Path trg,
Path[] psrcs)
Move blocks from srcs to trg and delete srcs afterwards.
|
FSDataOutputStream |
create(Path f,
FsPermission permission,
boolean overwrite,
int bufferSize,
short replication,
long blockSize,
Progressable progress)
Opens an FSDataOutputStream at the indicated Path with write-progress
reporting.
|
FSDataOutputStream |
createNonRecursive(Path f,
FsPermission permission,
boolean overwrite,
int bufferSize,
short replication,
long blockSize,
Progressable progress)
Same as create(), except fails if parent directory doesn't already exist.
|
boolean |
delete(Path f)
已过时。
|
boolean |
delete(Path f,
boolean recursive)
requires a boolean check to delete a non
empty directory recursively.
|
UpgradeStatusReport |
distributedUpgradeProgress(FSConstants.UpgradeAction action) |
void |
finalizeUpgrade()
Finalize previously upgraded files system state.
|
DFSClient |
getClient() |
ContentSummary |
getContentSummary(Path f)
Return the
ContentSummary of a given Path . |
long |
getCorruptBlocksCount()
Returns count of blocks with at least one replica marked corrupt.
|
DatanodeInfo[] |
getDataNodeStats()
Return statistics for each datanode.
|
long |
getDefaultBlockSize()
Return the number of bytes that large input files should be optimally
be split into to minimize i/o time.
|
protected int |
getDefaultPort()
Get the default port for this file system.
|
short |
getDefaultReplication()
Get the default replication.
|
Token<DelegationTokenIdentifier> |
getDelegationToken(String renewer)
Get a new delegation token for this file system.
|
Token<DelegationTokenIdentifier> |
getDelegationToken(Text renewer)
已过时。
|
DistributedFileSystem.DiskStatus |
getDiskStatus()
Return the disk usage of the filesystem, including total capacity,
used space, and remaining space
|
BlockLocation[] |
getFileBlockLocations(FileStatus file,
long start,
long len)
Return an array containing hostnames, offset and size of
portions of the given file.
|
MD5MD5CRC32FileChecksum |
getFileChecksum(Path f)
Get the checksum of a file.
|
FileStatus |
getFileStatus(Path f)
Returns the stat information about the file.
|
Path |
getHomeDirectory()
Return the current user's home directory in this filesystem.
|
long |
getMissingBlocksCount()
Returns count of blocks with no good replicas left.
|
String |
getName()
已过时。
|
long |
getRawCapacity()
Return the total raw capacity of the filesystem, disregarding
replication .
|
long |
getRawUsed()
Return the total raw used space in the filesystem, disregarding
replication .
|
long |
getUnderReplicatedBlocksCount()
Returns count of blocks with one of more replica missing.
|
URI |
getUri()
Returns a URI whose scheme and authority identify this FileSystem.
|
Path |
getWorkingDirectory()
Get the current working directory for the given file system
|
void |
initialize(URI uri,
Configuration conf)
Called after a new FileSystem instance is constructed.
|
boolean |
isFileClosed(Path src)
Get the close status of a file
|
static boolean |
isHealthy(URI uri)
Is the HDFS healthy?
|
FileStatus[] |
listStatus(Path p)
List all the entries of a directory
Note that this operation is not atomic for a large directory.
|
void |
metaSave(String pathname) |
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.
|
boolean |
recoverLease(Path f)
Start the lease recovery of a file
|
void |
refreshNodes()
Refreshes the list of hosts and excluded hosts from the configured
files.
|
boolean |
rename(Path src,
Path dst)
Rename files/dirs
|
long |
renewDelegationToken(Token<DelegationTokenIdentifier> token)
已过时。
Use Token.renew instead.
|
boolean |
reportChecksumFailure(Path f,
FSDataInputStream in,
long inPos,
FSDataInputStream sums,
long sumsPos)
We need to find the blocks that didn't match.
|
void |
saveNamespace()
Save namespace image.
|
void |
setBalancerBandwidth(long bandwidth)
Requests the namenode to tell all datanodes to use a new, non-persistent
bandwidth value for dfs.balance.bandwidthPerSec.
|
void |
setOwner(Path p,
String username,
String groupname)
Set owner of a path (i.e. a file or a directory).
|
void |
setPermission(Path p,
FsPermission permission)
Set permission of a path.
|
void |
setQuota(Path src,
long namespaceQuota,
long diskspaceQuota)
Set a directory's quotas
|
boolean |
setReplication(Path src,
short replication)
Set replication for an existing file.
|
boolean |
setSafeMode(FSConstants.SafeModeAction action)
Enter, leave or get safe mode.
|
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 dir)
Set the current working directory for the given file system.
|
String |
toString() |
addFileSystemForTesting, append, append, checkPath, clearStatistics, closeAll, closeAllForUGI, completeLocalOutput, copyFromLocalFile, copyFromLocalFile, copyFromLocalFile, copyFromLocalFile, copyToLocalFile, copyToLocalFile, create, create, create, create, create, create, create, create, create, create, createNewFile, createNonRecursive, deleteOnExit, exists, get, get, get, getAllStatistics, getBlockSize, getCacheSize, getCanonicalServiceName, getCanonicalUri, getDefaultBlockSize, getDefaultReplication, getDefaultUri, getLength, getLocal, getNamed, getReplication, getStatistics, getStatistics, getUsed, globStatus, globStatus, isDirectory, isFile, listStatus, listStatus, listStatus, makeQualified, mkdirs, mkdirs, moveFromLocalFile, moveFromLocalFile, moveToLocalFile, open, printStatistics, processDeleteOnExit, setDefaultUri, setDefaultUri, startLocalOutput
getConf, setConf
public DistributedFileSystem()
public DistributedFileSystem(InetSocketAddress namenode, Configuration conf) throws IOException
IOException
public String getName()
getName
在类中 FileSystem
public URI getUri()
FileSystem
getUri
在类中 FileSystem
public void initialize(URI uri, Configuration conf) throws IOException
FileSystem
initialize
在类中 FileSystem
uri
- a uri whose authority section names the host, port, etc.
for this FileSystemconf
- the configurationIOException
public Path getWorkingDirectory()
FileSystem
getWorkingDirectory
在类中 FileSystem
public long getDefaultBlockSize()
FileSystem
getDefaultBlockSize
在类中 FileSystem
public short getDefaultReplication()
FileSystem
getDefaultReplication
在类中 FileSystem
public void setWorkingDirectory(Path dir)
FileSystem
setWorkingDirectory
在类中 FileSystem
public Path getHomeDirectory()
getHomeDirectory
在类中 FileSystem
public BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len) throws IOException
FileSystem
getFileBlockLocations
在类中 FileSystem
IOException
public void setVerifyChecksum(boolean verifyChecksum)
FileSystem
setVerifyChecksum
在类中 FileSystem
public FSDataInputStream open(Path f, int bufferSize) throws IOException
FileSystem
open
在类中 FileSystem
f
- the file name to openbufferSize
- the size of the buffer to be used.IOException
public boolean isFileClosed(Path src) throws IOException
src
- The path to the fileFileNotFoundException
- if the file does not exist.IOException
- If an I/O error occurredpublic boolean recoverLease(Path f) throws IOException
f
- a fileIOException
- if an error occurspublic FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException
append
在类中 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
FileSystem
create
在类中 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 FSDataOutputStream createNonRecursive(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException
createNonRecursive
在类中 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
create(Path, FsPermission, boolean, int, short, long, Progressable)
public boolean setReplication(Path src, short replication) throws IOException
FileSystem
setReplication
在类中 FileSystem
src
- file namereplication
- new replicationIOException
public void concat(Path trg, Path[] psrcs) throws IOException
concat
在类中 FileSystem
trg
- existing file to append topsrcs
- list of files (same block size, same replication)IOException
public boolean rename(Path src, Path dst) throws IOException
rename
在类中 FileSystem
IOException
@Deprecated public boolean delete(Path f) throws IOException
delete
在类中 FileSystem
IOException
public boolean delete(Path f, boolean recursive) throws IOException
delete
在类中 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 ContentSummary getContentSummary(Path f) throws IOException
ContentSummary
of a given Path
.getContentSummary
在类中 FileSystem
IOException
public void setQuota(Path src, long namespaceQuota, long diskspaceQuota) throws IOException
public FileStatus[] listStatus(Path p) throws IOException
listStatus
在类中 FileSystem
p
- given pathIOException
public boolean mkdirs(Path f, FsPermission permission) throws IOException
FileSystem
mkdirs
在类中 FileSystem
IOException
public void close() throws IOException
close
在接口中 Closeable
close
在接口中 AutoCloseable
close
在类中 FileSystem
IOException
public DFSClient getClient()
public DistributedFileSystem.DiskStatus getDiskStatus() throws IOException
IOException
public long getRawCapacity() throws IOException
IOException
public long getRawUsed() throws IOException
IOException
public long getMissingBlocksCount() throws IOException
IOException
public long getUnderReplicatedBlocksCount() throws IOException
IOException
public long getCorruptBlocksCount() throws IOException
IOException
public DatanodeInfo[] getDataNodeStats() throws IOException
IOException
public boolean setSafeMode(FSConstants.SafeModeAction action) throws IOException
public void saveNamespace() throws AccessControlException, IOException
public void refreshNodes() throws IOException
IOException
public void finalizeUpgrade() throws IOException
IOException
public UpgradeStatusReport distributedUpgradeProgress(FSConstants.UpgradeAction action) throws IOException
IOException
public void metaSave(String pathname) throws IOException
IOException
public boolean reportChecksumFailure(Path f, FSDataInputStream in, long inPos, FSDataInputStream sums, long sumsPos)
public FileStatus getFileStatus(Path f) throws IOException
getFileStatus
在类中 FileSystem
f
- The path we want information fromFileNotFoundException
- if the file does not exist.IOException
public MD5MD5CRC32FileChecksum getFileChecksum(Path f) throws IOException
getFileChecksum
在类中 FileSystem
f
- The file pathIOException
public void setPermission(Path p, FsPermission permission) throws IOException
setPermission
在类中 FileSystem
IOException
public void setOwner(Path p, String username, String groupname) throws IOException
setOwner
在类中 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
在类中 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
protected int getDefaultPort()
FileSystem
getDefaultPort
在类中 FileSystem
public Token<DelegationTokenIdentifier> getDelegationToken(String renewer) throws IOException
FileSystem
getDelegationToken
在类中 FileSystem
renewer
- the account name that is allowed to renew the token.IOException
@Deprecated public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer) throws IOException
renewer
- Name of the designated renewer for the tokenIOException
public long renewDelegationToken(Token<DelegationTokenIdentifier> token) throws SecretManager.InvalidToken, IOException
token
- delegation token obtained earlierIOException
SecretManager.InvalidToken
public void cancelDelegationToken(Token<DelegationTokenIdentifier> token) throws IOException
token
- delegation tokenIOException
public void setBalancerBandwidth(long bandwidth) throws IOException
bandwidth
- Blanacer bandwidth in bytes per second for all datanodes.IOException
public static boolean isHealthy(URI uri)
uri
- the HDFS URI. Note that the URI path is ignored.Copyright © 2009 The Apache Software Foundation