org.apache.hadoop.hdfs.server.protocol
Interface DatanodeProtocol

All Superinterfaces:
org.apache.hadoop.ipc.VersionedProtocol
All Known Subinterfaces:
NamenodeProtocols
All Known Implementing Classes:
BackupNode, NameNode

@InterfaceAudience.Private
public interface DatanodeProtocol
extends org.apache.hadoop.ipc.VersionedProtocol

Protocol that a DFS datanode uses to communicate with the NameNode. It's used to upload current load information and block reports. The only way a NameNode can communicate with a DataNode is by returning values from these functions.


Field Summary
static int DISK_ERROR
           
static int DNA_ACCESSKEYUPDATE
           
static int DNA_FINALIZE
           
static int DNA_INVALIDATE
           
static int DNA_RECOVERBLOCK
           
static int DNA_REGISTER
           
static int DNA_SHUTDOWN
           
static int DNA_TRANSFER
           
static int DNA_UNKNOWN
          Determines actions that data node should perform when receiving a datanode command.
static int FATAL_DISK_ERROR
           
static int INVALID_BLOCK
           
static int NOTIFY
           
static long versionID
          24: register() renamed registerDatanode()
 
Method Summary
 void blockReceived(DatanodeRegistration registration, Block[] blocks, String[] delHints)
          blockReceived() allows the DataNode to tell the NameNode about recently-received block data, with a hint for pereferred replica to be deleted when there is any excessive blocks.
 DatanodeCommand blockReport(DatanodeRegistration registration, long[] blocks)
          blockReport() tells the NameNode about all the locally-stored blocks.
 void commitBlockSynchronization(Block block, long newgenerationstamp, long newlength, boolean closeFile, boolean deleteblock, DatanodeID[] newtargets)
          Commit block synchronization in lease recovery
 void errorReport(DatanodeRegistration registration, int errorCode, String msg)
          errorReport() tells the NameNode about something that has gone awry.
 UpgradeCommand processUpgradeCommand(UpgradeCommand comm)
          This is a very general way to send a command to the name-node during distributed upgrade process.
 DatanodeRegistration registerDatanode(DatanodeRegistration registration)
          Register Datanode.
 void reportBadBlocks(LocatedBlock[] blocks)
          same as ClientProtocol.reportBadBlocks(LocatedBlock[]) }
 DatanodeCommand[] sendHeartbeat(DatanodeRegistration registration, long capacity, long dfsUsed, long remaining, int xmitsInProgress, int xceiverCount)
          sendHeartbeat() tells the NameNode that the DataNode is still alive and well.
 NamespaceInfo versionRequest()
           
 
Methods inherited from interface org.apache.hadoop.ipc.VersionedProtocol
getProtocolVersion
 

Field Detail

versionID

static final long versionID
24: register() renamed registerDatanode()

See Also:
Constant Field Values

NOTIFY

static final int NOTIFY
See Also:
Constant Field Values

DISK_ERROR

static final int DISK_ERROR
See Also:
Constant Field Values

INVALID_BLOCK

static final int INVALID_BLOCK
See Also:
Constant Field Values

FATAL_DISK_ERROR

static final int FATAL_DISK_ERROR
See Also:
Constant Field Values

DNA_UNKNOWN

static final int DNA_UNKNOWN
Determines actions that data node should perform when receiving a datanode command.

See Also:
Constant Field Values

DNA_TRANSFER

static final int DNA_TRANSFER
See Also:
Constant Field Values

DNA_INVALIDATE

static final int DNA_INVALIDATE
See Also:
Constant Field Values

DNA_SHUTDOWN

static final int DNA_SHUTDOWN
See Also:
Constant Field Values

DNA_REGISTER

static final int DNA_REGISTER
See Also:
Constant Field Values

DNA_FINALIZE

static final int DNA_FINALIZE
See Also:
Constant Field Values

DNA_RECOVERBLOCK

static final int DNA_RECOVERBLOCK
See Also:
Constant Field Values

DNA_ACCESSKEYUPDATE

static final int DNA_ACCESSKEYUPDATE
See Also:
Constant Field Values
Method Detail

registerDatanode

DatanodeRegistration registerDatanode(DatanodeRegistration registration)
                                      throws IOException
Register Datanode.

Returns:
updated DatanodeRegistration, which contains new storageID if the datanode did not have one and registration ID for further communication.
Throws:
IOException
See Also:
DataNode.dnRegistration, FSNamesystem.registerDatanode(DatanodeRegistration)

sendHeartbeat

@Nullable
DatanodeCommand[] sendHeartbeat(DatanodeRegistration registration,
                                         long capacity,
                                         long dfsUsed,
                                         long remaining,
                                         int xmitsInProgress,
                                         int xceiverCount)
                                throws IOException
sendHeartbeat() tells the NameNode that the DataNode is still alive and well. Includes some status info, too. It also gives the NameNode a chance to return an array of "DatanodeCommand" objects. A DatanodeCommand tells the DataNode to invalidate local block(s), or to copy them to other DataNodes, etc.

Throws:
IOException

blockReport

DatanodeCommand blockReport(DatanodeRegistration registration,
                            long[] blocks)
                            throws IOException
blockReport() tells the NameNode about all the locally-stored blocks. The NameNode returns an array of Blocks that have become obsolete and should be deleted. This function is meant to upload *all* the locally-stored blocks. It's invoked upon startup and then infrequently afterwards.

Parameters:
registration -
blocks - - the block list as an array of longs. Each block is represented as 2 longs. This is done instead of Block[] to reduce memory used by block reports.
Returns:
- the next command for DN to process.
Throws:
IOException

blockReceived

void blockReceived(DatanodeRegistration registration,
                   Block[] blocks,
                   String[] delHints)
                   throws IOException
blockReceived() allows the DataNode to tell the NameNode about recently-received block data, with a hint for pereferred replica to be deleted when there is any excessive blocks. For example, whenever client code writes a new Block here, or another DataNode copies a Block to this DataNode, it will call blockReceived().

Throws:
IOException

errorReport

void errorReport(DatanodeRegistration registration,
                 int errorCode,
                 String msg)
                 throws IOException
errorReport() tells the NameNode about something that has gone awry. Useful for debugging.

Throws:
IOException

versionRequest

NamespaceInfo versionRequest()
                             throws IOException
Throws:
IOException

processUpgradeCommand

UpgradeCommand processUpgradeCommand(UpgradeCommand comm)
                                     throws IOException
This is a very general way to send a command to the name-node during distributed upgrade process. The generosity is because the variety of upgrade commands is unpredictable. The reply from the name-node is also received in the form of an upgrade command.

Returns:
a reply in the form of an upgrade command
Throws:
IOException

reportBadBlocks

void reportBadBlocks(LocatedBlock[] blocks)
                     throws IOException
same as ClientProtocol.reportBadBlocks(LocatedBlock[]) }

Throws:
IOException

commitBlockSynchronization

void commitBlockSynchronization(Block block,
                                long newgenerationstamp,
                                long newlength,
                                boolean closeFile,
                                boolean deleteblock,
                                DatanodeID[] newtargets)
                                throws IOException
Commit block synchronization in lease recovery

Throws:
IOException


Copyright © 2009 The Apache Software Foundation