public class DFSClient extends Object implements FSConstants, Closeable
限定符和类型 | 类和说明 |
---|---|
static class |
DFSClient.DFSDataInputStream
The Hdfs implementation of
FSDataInputStream |
class |
DFSClient.DFSInputStream
DFSInputStream provides bytes from a named file.
|
static class |
DFSClient.RemoteBlockReader
This is a wrapper around connection to datadone
and understands checksum, offset etc
|
static class |
DFSClient.Renewer |
FSConstants.DatanodeReportType, FSConstants.SafeModeAction, FSConstants.UpgradeAction
限定符和类型 | 字段和说明 |
---|---|
static org.apache.commons.logging.Log |
LOG |
static int |
MAX_BLOCK_ACQUIRE_FAILURES |
ClientProtocol |
namenode |
BLOCKREPORT_INITIAL_DELAY, BLOCKREPORT_INTERVAL, BUFFER_SIZE, DEFAULT_BLOCK_SIZE, DEFAULT_DATA_SOCKET_SIZE, HEARTBEAT_INTERVAL, LAYOUT_VERSION, LEASE_HARDLIMIT_PERIOD, LEASE_RECOVER_PERIOD, LEASE_SOFTLIMIT_PERIOD, MAX_PATH_DEPTH, MAX_PATH_LENGTH, MIN_BLOCKS_FOR_WRITE, QUOTA_DONT_SET, QUOTA_RESET, SIZE_OF_INTEGER, SMALL_BUFFER_SIZE
构造器和说明 |
---|
DFSClient(Configuration conf)
Same as this(NameNode.getAddress(conf), conf);
|
DFSClient(InetSocketAddress nameNodeAddr,
Configuration conf)
Same as this(nameNodeAddr, conf, null);
|
DFSClient(InetSocketAddress nameNodeAddr,
Configuration conf,
FileSystem.Statistics stats)
Same as this(nameNodeAddr, null, conf, stats);
|
限定符和类型 | 方法和说明 |
---|---|
FSDataOutputStream |
append(String src,
int buffersize,
Progressable progress,
FileSystem.Statistics statistics)
Append to an existing HDFS file.
|
void |
cancelDelegationToken(Token<DelegationTokenIdentifier> token)
已过时。
Use Token.cancel instead.
|
void |
close()
Close the file system, abandoning all of the leases and files being
created and close connections to the namenode.
|
void |
concat(String trg,
String[] srcs)
Move blocks from src to trg and delete src
See
ClientProtocol.concat(String, String []) . |
OutputStream |
create(String src,
boolean overwrite)
Create a new dfs file and return an output stream for writing into it.
|
OutputStream |
create(String src,
boolean overwrite,
Progressable progress)
Create a new dfs file and return an output stream for writing into it
with write-progress reporting.
|
OutputStream |
create(String src,
boolean overwrite,
short replication,
long blockSize)
Create a new dfs file with the specified block replication
and return an output stream for writing into the file.
|
OutputStream |
create(String src,
boolean overwrite,
short replication,
long blockSize,
Progressable progress)
Create a new dfs file with the specified block replication
with write-progress reporting and return an output stream for writing
into the file.
|
OutputStream |
create(String src,
boolean overwrite,
short replication,
long blockSize,
Progressable progress,
int buffersize)
Call
create(String,FsPermission,boolean,short,long,Progressable,int)
with default permission. |
OutputStream |
create(String src,
FsPermission permission,
boolean overwrite,
boolean createParent,
short replication,
long blockSize,
Progressable progress,
int buffersize)
Create a new dfs file with the specified block replication
with write-progress reporting and return an output stream for writing
into the file.
|
OutputStream |
create(String src,
FsPermission permission,
boolean overwrite,
short replication,
long blockSize,
Progressable progress,
int buffersize)
Call
create(String,FsPermission,boolean,boolean,short,long,Progressable,int)
with createParent set to true. |
static ClientProtocol |
createNamenode(Configuration conf)
Create a
NameNode proxy |
static ClientProtocol |
createNamenode(InetSocketAddress nameNodeAddr,
Configuration conf) |
DatanodeInfo[] |
datanodeReport(FSConstants.DatanodeReportType type) |
boolean |
delete(String src)
已过时。
|
boolean |
delete(String src,
boolean recursive)
delete file or directory.
|
UpgradeStatusReport |
distributedUpgradeProgress(FSConstants.UpgradeAction action) |
boolean |
exists(String src)
Implemented using getFileInfo(src)
|
void |
finalizeUpgrade() |
BlockLocation[] |
getBlockLocations(String src,
long start,
long length)
Get block location info about file
getBlockLocations() returns a list of hostnames that store
data for a specific file region.
|
long |
getBlockSize(String f) |
long |
getCorruptBlocksCount()
Returns count of blocks with at least one replica marked corrupt.
|
long |
getDefaultBlockSize()
Get the default block size for this cluster
|
short |
getDefaultReplication() |
Token<DelegationTokenIdentifier> |
getDelegationToken(Text renewer) |
DistributedFileSystem.DiskStatus |
getDiskStatus() |
MD5MD5CRC32FileChecksum |
getFileChecksum(String src)
Get the checksum of a file.
|
static MD5MD5CRC32FileChecksum |
getFileChecksum(String src,
ClientProtocol namenode,
SocketFactory socketFactory,
int socketTimeout)
Get the checksum of a file.
|
HdfsFileStatus |
getFileInfo(String src) |
String[][] |
getHints(String src,
long start,
long length)
已过时。
Use getBlockLocations instead
Get hints about the location of the indicated block(s).
getHints() returns a list of hostnames that store data for
a specific file region. It returns a set of hostnames for
every block within the indicated region.
This function is very useful when writing code that considers
data-placement when performing operations. For example, the
MapReduce system tries to schedule tasks on the same machines
as the data-block the task processes.
|
org.apache.hadoop.hdfs.LeaseRenewer |
getLeaseRenewer()
Return the lease renewer instance.
|
long |
getMissingBlocksCount()
Returns count of blocks with no good replicas left.
|
long |
getUnderReplicatedBlocksCount()
Returns count of blocks with one of more replica missing.
|
boolean |
isDirectory(String src)
已过时。
Use getHdfsFileStatus() instead
|
boolean |
isFileClosed(String src)
Close status of a file
|
DirectoryListing |
listPaths(String src,
byte[] startAfter)
Get a partial listing of the indicated directory
Recommend to use HdfsFileStatus.EMPTY_NAME as startAfter
if the application wants to fetch a listing starting from
the first entry in the directory
|
void |
metaSave(String pathname)
Dumps DFS data structures into specified file.
|
boolean |
mkdirs(String src) |
boolean |
mkdirs(String src,
FsPermission permission)
Create a directory (or hierarchy of directories) with the given
name and permission.
|
DFSClient.DFSInputStream |
open(String src) |
DFSClient.DFSInputStream |
open(String src,
int buffersize,
boolean verifyChecksum,
FileSystem.Statistics stats)
Create an input stream that obtains a nodelist from the
namenode, and then reads from all the right places.
|
void |
refreshNodes()
Refresh the hosts and exclude files.
|
boolean |
rename(String src,
String dst)
Rename file or directory.
|
long |
renewDelegationToken(Token<DelegationTokenIdentifier> token)
已过时。
Use Token.renew instead.
|
void |
reportBadBlocks(LocatedBlock[] blocks)
Report corrupt blocks that were discovered by the client.
|
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(String src,
String username,
String groupname)
Set file or directory owner.
|
void |
setPermission(String src,
FsPermission permission)
Set permissions to a file or directory.
|
boolean |
setReplication(String src,
short replication)
Set replication for an existing file.
|
boolean |
setSafeMode(FSConstants.SafeModeAction action)
Enter, leave or get safe mode.
|
void |
setTimes(String src,
long mtime,
long atime)
set the modification and access time of a file
|
static String |
stringifyToken(Token<DelegationTokenIdentifier> token)
A test method for printing out tokens
|
String |
toString() |
long |
totalRawCapacity() |
long |
totalRawUsed() |
public static final org.apache.commons.logging.Log LOG
public static final int MAX_BLOCK_ACQUIRE_FAILURES
public final ClientProtocol namenode
public DFSClient(Configuration conf) throws IOException
public DFSClient(InetSocketAddress nameNodeAddr, Configuration conf) throws IOException
public DFSClient(InetSocketAddress nameNodeAddr, Configuration conf, FileSystem.Statistics stats) throws IOException
public static ClientProtocol createNamenode(Configuration conf) throws IOException
NameNode
proxyIOException
public static ClientProtocol createNamenode(InetSocketAddress nameNodeAddr, Configuration conf) throws IOException
IOException
public org.apache.hadoop.hdfs.LeaseRenewer getLeaseRenewer() throws IOException
IOException
public void close() throws IOException
close
在接口中 Closeable
close
在接口中 AutoCloseable
IOException
public long getDefaultBlockSize()
public long getBlockSize(String f) throws IOException
IOException
public static String stringifyToken(Token<DelegationTokenIdentifier> token) throws IOException
IOException
public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer) throws IOException
IOException
public long renewDelegationToken(Token<DelegationTokenIdentifier> token) throws SecretManager.InvalidToken, IOException
token
- the token to renewSecretManager.InvalidToken
IOException
public void cancelDelegationToken(Token<DelegationTokenIdentifier> token) throws SecretManager.InvalidToken, IOException
token
- the token to cancelSecretManager.InvalidToken
IOException
public void reportBadBlocks(LocatedBlock[] blocks) throws IOException
IOException
public short getDefaultReplication()
@Deprecated public String[][] getHints(String src, long start, long length) throws IOException
IOException
public BlockLocation[] getBlockLocations(String src, long start, long length) throws IOException
IOException
public DFSClient.DFSInputStream open(String src) throws IOException
IOException
public DFSClient.DFSInputStream open(String src, int buffersize, boolean verifyChecksum, FileSystem.Statistics stats) throws IOException
IOException
public OutputStream create(String src, boolean overwrite) throws IOException
src
- stream nameoverwrite
- do not check for file existence if trueIOException
public OutputStream create(String src, boolean overwrite, Progressable progress) throws IOException
src
- stream nameoverwrite
- do not check for file existence if trueIOException
public OutputStream create(String src, boolean overwrite, short replication, long blockSize) throws IOException
src
- stream nameoverwrite
- do not check for file existence if truereplication
- block replicationIOException
public OutputStream create(String src, boolean overwrite, short replication, long blockSize, Progressable progress) throws IOException
src
- stream nameoverwrite
- do not check for file existence if truereplication
- block replicationIOException
public OutputStream create(String src, boolean overwrite, short replication, long blockSize, Progressable progress, int buffersize) throws IOException
create(String,FsPermission,boolean,short,long,Progressable,int)
with default permission.IOException
FsPermission.getDefault()
public OutputStream create(String src, FsPermission permission, boolean overwrite, short replication, long blockSize, Progressable progress, int buffersize) throws IOException
create(String,FsPermission,boolean,boolean,short,long,Progressable,int)
with createParent set to true.IOException
public OutputStream create(String src, FsPermission permission, boolean overwrite, boolean createParent, short replication, long blockSize, Progressable progress, int buffersize) throws IOException
src
- stream namepermission
- The permission of the directory being created.
If permission == null, use FsPermission.getDefault()
.overwrite
- do not check for file existence if truecreateParent
- create missing parent directory if truereplication
- block replicationIOException
ClientProtocol.create(String, FsPermission, String, boolean, short, long)
public boolean isFileClosed(String src) throws IOException
IOException
public FSDataOutputStream append(String src, int buffersize, Progressable progress, FileSystem.Statistics statistics) throws IOException
src
- file namebuffersize
- buffer sizeprogress
- for reporting write-progress; null is acceptable.statistics
- file system statistics; null is acceptable.IOException
ClientProtocol.append(String, String)
public boolean setReplication(String src, short replication) throws IOException
replication
- IOException
ClientProtocol.setReplication(String, short)
public void concat(String trg, String[] srcs) throws IOException
ClientProtocol.concat(String, String [])
.IOException
public boolean rename(String src, String dst) throws IOException
ClientProtocol.rename(String, String)
.IOException
@Deprecated public boolean delete(String src) throws IOException
ClientProtocol.delete(String)
.IOException
public boolean delete(String src, boolean recursive) throws IOException
IOException
public boolean exists(String src) throws IOException
IOException
@Deprecated public boolean isDirectory(String src) throws IOException
IOException
public DirectoryListing listPaths(String src, byte[] startAfter) throws IOException
src
- the directory namestartAfter
- the name to start listing afterIOException
public HdfsFileStatus getFileInfo(String src) throws IOException
IOException
public MD5MD5CRC32FileChecksum getFileChecksum(String src) throws IOException
src
- The file pathIOException
DistributedFileSystem.getFileChecksum(Path)
public static MD5MD5CRC32FileChecksum getFileChecksum(String src, ClientProtocol namenode, SocketFactory socketFactory, int socketTimeout) throws IOException
src
- The file pathIOException
public void setPermission(String src, FsPermission permission) throws IOException
src
- path name.permission
- FileNotFoundException
- is file does not exist.IOException
public void setOwner(String src, String username, String groupname) throws IOException
src
- path name.username
- user id.groupname
- user group.FileNotFoundException
- is file does not exist.IOException
public DistributedFileSystem.DiskStatus getDiskStatus() throws IOException
IOException
public long totalRawCapacity() throws IOException
IOException
public long totalRawUsed() throws IOException
IOException
public long getMissingBlocksCount() throws IOException
IOException
public long getUnderReplicatedBlocksCount() throws IOException
IOException
public long getCorruptBlocksCount() throws IOException
IOException
public DatanodeInfo[] datanodeReport(FSConstants.DatanodeReportType type) throws IOException
IOException
public boolean setSafeMode(FSConstants.SafeModeAction action) throws IOException
ClientProtocol.setSafeMode(FSConstants.SafeModeAction)
for more details.public void refreshNodes() throws IOException
ClientProtocol.refreshNodes()
for more details.public void metaSave(String pathname) throws IOException
ClientProtocol.metaSave(String)
for more details.public void setBalancerBandwidth(long bandwidth) throws IOException
ClientProtocol.setBalancerBandwidth(long)
for more details.public void finalizeUpgrade() throws IOException
public UpgradeStatusReport distributedUpgradeProgress(FSConstants.UpgradeAction action) throws IOException
public boolean mkdirs(String src) throws IOException
IOException
public boolean mkdirs(String src, FsPermission permission) throws IOException
src
- The path of the directory being createdpermission
- The permission of the directory being created.
If permission == null, use FsPermission.getDefault()
.IOException
ClientProtocol.mkdirs(String, FsPermission)
public void setTimes(String src, long mtime, long atime) throws IOException
FileNotFoundException
- if the path is not a fileIOException
Copyright © 2009 The Apache Software Foundation