public interface ClientProtocol extends VersionedProtocol
DistributedFileSystem
class to communicate
with the NameNode. User code can manipulate the directory namespace,
as well as open/close file streams, etc.限定符和类型 | 字段和说明 |
---|---|
static int |
GET_STATS_CAPACITY_IDX |
static int |
GET_STATS_CORRUPT_BLOCKS_IDX |
static int |
GET_STATS_MISSING_BLOCKS_IDX |
static int |
GET_STATS_REMAINING_IDX |
static int |
GET_STATS_UNDER_REPLICATED_IDX |
static int |
GET_STATS_USED_IDX |
static long |
versionID
Compared to the previous version the following changes have been introduced:
(Only the latest change is reflected.
|
限定符和类型 | 方法和说明 |
---|---|
void |
abandonBlock(Block b,
String src,
String holder)
The client can give up on a blcok by calling abandonBlock().
|
LocatedBlock |
addBlock(String src,
String clientName)
已过时。
use the 3-arg form below
|
LocatedBlock |
addBlock(String src,
String clientName,
DatanodeInfo[] excludedNodes)
A client that wants to write an additional block to the
indicated filename (which must currently be open for writing)
should call addBlock().
|
LocatedBlock |
append(String src,
String clientName)
Append to the end of the file.
|
void |
cancelDelegationToken(Token<DelegationTokenIdentifier> token)
Cancel an existing delegation token.
|
boolean |
complete(String src,
String clientName)
The client is done writing data to the given filename, and would
like to complete it.
|
void |
concat(String trg,
String[] srcs)
Moves blocks from srcs to trg and delete srcs
|
void |
create(String src,
FsPermission masked,
String clientName,
boolean overwrite,
boolean createParent,
short replication,
long blockSize)
Create a new file entry in the namespace.
|
void |
create(String src,
FsPermission masked,
String clientName,
boolean overwrite,
short replication,
long blockSize)
Create a new file entry in the namespace.
|
boolean |
delete(String src)
Delete the given file or directory from the file system.
|
boolean |
delete(String src,
boolean recursive)
Delete the given file or directory from the file system.
|
UpgradeStatusReport |
distributedUpgradeProgress(FSConstants.UpgradeAction action)
Report distributed upgrade progress or force current upgrade to proceed.
|
void |
finalizeUpgrade()
Finalize previous upgrade.
|
void |
fsync(String src,
String client)
Write all metadata for this file into persistent storage.
|
LocatedBlocks |
getBlockLocations(String src,
long offset,
long length)
Get locations of the blocks of the specified file within the specified range.
|
ContentSummary |
getContentSummary(String path)
Get
ContentSummary rooted at the specified directory. |
DatanodeInfo[] |
getDatanodeReport(FSConstants.DatanodeReportType type)
Get a report on the system's current datanodes.
|
Token<DelegationTokenIdentifier> |
getDelegationToken(Text renewer)
Get a valid Delegation Token.
|
HdfsFileStatus |
getFileInfo(String src)
Get the file info for a specific file or directory.
|
DirectoryListing |
getListing(String src,
byte[] startAfter)
Get a partial listing of the indicated directory
|
long |
getPreferredBlockSize(String filename)
Get the block size for the given file.
|
long[] |
getStats()
Get a set of statistics about the filesystem.
|
boolean |
isFileClosed(String src)
Get the close status of a file
|
void |
metaSave(String filename)
Dumps namenode data structures into specified file.
|
boolean |
mkdirs(String src,
FsPermission masked)
Create a directory (or hierarchy of directories) with the given
name and permission.
|
boolean |
recoverLease(String src,
String clientName)
Start lease recovery
|
void |
refreshNodes()
Tells the namenode to reread the hosts and exclude files.
|
boolean |
rename(String src,
String dst)
Rename an item in the file system namespace.
|
long |
renewDelegationToken(Token<DelegationTokenIdentifier> token)
Renew an existing delegation token.
|
void |
renewLease(String clientName)
Client programs can cause stateful changes in the NameNode
that affect other clients.
|
void |
reportBadBlocks(LocatedBlock[] blocks)
The client wants to report corrupted blocks (blocks with specified
locations on datanodes).
|
void |
saveNamespace()
Save namespace image.
|
void |
setBalancerBandwidth(long bandwidth)
Tell all datanodes to use a new, non-persistent bandwidth value for
dfs.balance.bandwidthPerSec.
|
void |
setOwner(String src,
String username,
String groupname)
Set owner of a path (i.e. a file or a directory).
|
void |
setPermission(String src,
FsPermission permission)
Set permissions for an existing file/directory.
|
void |
setQuota(String path,
long namespaceQuota,
long diskspaceQuota)
Set the quota for a 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)
Sets the modification and access time of the file to the specified time.
|
getProtocolVersion
static final long versionID
static final int GET_STATS_CAPACITY_IDX
static final int GET_STATS_USED_IDX
static final int GET_STATS_REMAINING_IDX
static final int GET_STATS_UNDER_REPLICATED_IDX
static final int GET_STATS_CORRUPT_BLOCKS_IDX
static final int GET_STATS_MISSING_BLOCKS_IDX
LocatedBlocks getBlockLocations(String src, long offset, long length) throws IOException
Return LocatedBlocks
which contains
file length, blocks and their locations.
DataNode locations for each block are sorted by
the distance to the client's address.
The client will then have to contact one of the indicated DataNodes to obtain the actual data.
src
- file nameoffset
- range start offsetlength
- range lengthIOException
void create(String src, FsPermission masked, String clientName, boolean overwrite, boolean createParent, short replication, long blockSize) throws IOException
This will create an empty file specified by the source path. The path should reflect a full path originated at the root. The name-node does not have a notion of "current" directory for a client.
Once created, the file is visible and available for read to other clients.
Although, other clients cannot delete(String)
, re-create or
rename(String, String)
it until the file is completed
or explicitly as a result of lease expiration.
Blocks have a maximum size. Clients that intend to
create multi-block files must also use addBlock(String, String)
.
src
- path of the file being created.masked
- masked permission.clientName
- name of the current client.overwrite
- indicates whether the file should be
overwritten if it already exists.createParent
- create missing parent directory if truereplication
- block replication factor.blockSize
- maximum block size.AccessControlException
- if permission to create file is
denied by the system. As usually on the client side the exception will
be wrapped into RemoteException
.QuotaExceededException
- if the file creation violates
any quota restrictionIOException
- if other errors occur.void create(String src, FsPermission masked, String clientName, boolean overwrite, short replication, long blockSize) throws IOException
IOException
LocatedBlock append(String src, String clientName) throws IOException
src
- path of the file being created.clientName
- name of the current client.AccessControlException
- if permission to append file is
denied by the system. As usually on the client side the exception will
be wrapped into RemoteException
.
Allows appending to an existing file if the server is
configured with the parameter dfs.support.broken.append set to true, otherwise
throws an IOException.IOException
- if other errors occur.boolean recoverLease(String src, String clientName) throws IOException
src
- path of the file to start lease recoveryclientName
- name of the current clientIOException
boolean isFileClosed(String src) throws AccessControlException, FileNotFoundException, IOException
src
- The string representation of the path to the fileAccessControlException
- permission deniedFileNotFoundException
- file src
is not foundIOException
- If an I/O error occurredboolean setReplication(String src, short replication) throws IOException
The NameNode sets replication to the new value and returns. The actual block replication is not expected to be performed during this method call. The blocks will be populated or removed in the background as the result of the routine block maintenance procedures.
src
- file namereplication
- new replicationIOException
void setPermission(String src, FsPermission permission) throws IOException
IOException
void setOwner(String src, String username, String groupname) throws IOException
src
- username
- If it is null, the original username remains unchanged.groupname
- If it is null, the original groupname remains unchanged.IOException
void abandonBlock(Block b, String src, String holder) throws IOException
IOException
LocatedBlock addBlock(String src, String clientName) throws IOException
IOException
LocatedBlock addBlock(String src, String clientName, DatanodeInfo[] excludedNodes) throws IOException
excludedNodes
- a list of nodes that should not be allocatedIOException
boolean complete(String src, String clientName) throws IOException
IOException
void reportBadBlocks(LocatedBlock[] blocks) throws IOException
blocks
- Array of located blocks to reportIOException
boolean rename(String src, String dst) throws IOException
src
- existing file or directory name.dst
- new name.IOException
- if the new name is invalid.QuotaExceededException
- if the rename would violate
any quota restrictionvoid concat(String trg, String[] srcs) throws IOException
trg
- existing filesrcs
- - list of existing files (same block size, same replication)IOException
- if some arguments are invalidboolean delete(String src) throws IOException
Any blocks belonging to the deleted files will be garbage-collected.
src
- existing name.IOException
boolean delete(String src, boolean recursive) throws IOException
same as delete but provides a way to avoid accidentally deleting non empty directories programmatically.
src
- existing namerecursive
- if true deletes a non empty directory recursively,
else throws an exception.IOException
boolean mkdirs(String src, FsPermission masked) throws IOException
src
- The path of the directory being createdmasked
- The masked permission of the directory being created{@link
- AccessControlException} if permission to create file is
denied by the system. As usually on the client side the exception will
be wraped into RemoteException
.QuotaExceededException
- if the operation would violate
any quota restriction.IOException
DirectoryListing getListing(String src, byte[] startAfter) throws IOException
src
- the directory namestartAfter
- the name of the last entry received by the clientIOException
void renewLease(String clientName) throws IOException
So, the NameNode will revoke the locks and live file-creates for clients that it thinks have died. A client tells the NameNode that it is still alive by periodically calling renewLease(). If a certain amount of time passes since the last call to renewLease(), the NameNode assumes the client has died.
IOException
long[] getStats() throws IOException
GET_STATS_CAPACITY_IDX
in place of
actual numbers to index into the array.IOException
DatanodeInfo[] getDatanodeReport(FSConstants.DatanodeReportType type) throws IOException
IOException
long getPreferredBlockSize(String filename) throws IOException
filename
- The name of the fileIOException
boolean setSafeMode(FSConstants.SafeModeAction action) throws IOException
Safe mode is a name node state when it
Safe mode is entered automatically at name node startup.
Safe mode can also be entered manually using
setSafeMode(SafeModeAction.SAFEMODE_GET)
.
At startup the name node accepts data node reports collecting information about block locations. In order to leave safe mode it needs to collect a configurable percentage called threshold of blocks, which satisfy the minimal replication condition. The minimal replication condition is that each block must have at least dfs.replication.min replicas. When the threshold is reached the name node extends safe mode for a configurable amount of time to let the remaining data nodes to check in before it will start replicating missing blocks. Then the name node leaves safe mode.
If safe mode is turned on manually using
setSafeMode(SafeModeAction.SAFEMODE_ENTER)
then the name node stays in safe mode until it is manually turned off
using setSafeMode(SafeModeAction.SAFEMODE_LEAVE)
.
Current state of the name node can be verified using
setSafeMode(SafeModeAction.SAFEMODE_GET)
action
- IOException
void saveNamespace() throws IOException
Saves current namespace into storage directories and reset edits log. Requires superuser privilege and safe mode.
AccessControlException
- if the superuser privilege is violated.IOException
- if image creation failed.void refreshNodes() throws IOException
IOException
void finalizeUpgrade() throws IOException
IOException
UpgradeStatusReport distributedUpgradeProgress(FSConstants.UpgradeAction action) throws IOException
action
- FSConstants.UpgradeAction
to performIOException
void metaSave(String filename) throws IOException
IOException
void setBalancerBandwidth(long bandwidth) throws IOException
bandwidth
- Blanacer bandwidth in bytes per second for this datanode.IOException
HdfsFileStatus getFileInfo(String src) throws IOException
src
- The string representation of the path to the fileIOException
- if permission to access file is denied by the systemContentSummary getContentSummary(String path) throws IOException
ContentSummary
rooted at the specified directory.path
- The string representation of the pathIOException
void setQuota(String path, long namespaceQuota, long diskspaceQuota) throws IOException
path
- The string representation of the path to the directorynamespaceQuota
- Limit on the number of names in the tree rooted
at the directorydiskspaceQuota
- Limit on disk space occupied all the files under
this directory.
FSConstants.QUOTA_DONT_SET
implies
the quota will not be changed, and (3) FSConstants.QUOTA_RESET
implies the quota will be reset. Any other value is a runtime error.FileNotFoundException
- if the path is a file or
does not existQuotaExceededException
- if the directory size
is greater than the given quotaIOException
void fsync(String src, String client) throws IOException
src
- The string representation of the pathclient
- The string representation of the clientIOException
void setTimes(String src, long mtime, long atime) throws IOException
src
- The string representation of the pathmtime
- The number of milliseconds since Jan 1, 1970.
Setting mtime to -1 means that modification time should not be set
by this call.atime
- The number of milliseconds since Jan 1, 1970.
Setting atime to -1 means that access time should not be set
by this call.IOException
Token<DelegationTokenIdentifier> getDelegationToken(Text renewer) throws IOException
renewer
- the designated renewer for the tokenIOException
long renewDelegationToken(Token<DelegationTokenIdentifier> token) throws IOException
token
- delegation token obtained earlierIOException
void cancelDelegationToken(Token<DelegationTokenIdentifier> token) throws IOException
token
- delegation tokenIOException
Copyright © 2009 The Apache Software Foundation