Save This Page
Home » hadoop-0.14.4 » org.apache » hadoop » dfs » [javadoc | source]
org.apache.hadoop.dfs
public class: DataNode [javadoc | source]
java.lang.Object
   org.apache.hadoop.dfs.DataNode

All Implemented Interfaces:
    Runnable, FSConstants

DataNode is a class (and program) that stores a set of blocks for a DFS deployment. A single deployment can have one or many DataNodes. Each DataNode communicates regularly with a single NameNode. It also communicates with client code and other DataNodes from time to time. DataNodes store a series of named blocks. The DataNode allows client code to read these blocks, or to write new block data. The DataNode may also, in response to instructions from its NameNode, delete blocks or copy blocks to/from other DataNodes. The DataNode maintains just one critical table: block-> stream of bytes (of BLOCK_SIZE or less) This info is stored on a local disk. The DataNode reports the table's contents to the NameNode upon startup and every so often afterwards. DataNodes spend their lives in an endless loop of asking the NameNode for something to do. A NameNode cannot connect to a DataNode directly; a NameNode simply returns values from functions invoked by a DataNode. DataNodes maintain an open server socket so that client code or other DataNodes can read/write data. The host/port for this server is reported to the NameNode, which then sends that information to clients or other DataNodes that might be interested.
Nested Class Summary:
class  DataNode.DataXceiveServer  Server used for receiving/sending a block of data. This is created to listen for requests from clients or other DataNodes. This small server does not use the Hadoop IPC mechanism. 
class  DataNode.DataXceiver  Thread for processing incoming/outgoing data stream 
class  DataNode.DataTransfer  Used for transferring a block of data. This class sends a piece of data to another DataNode. 
Field Summary
public static final  Log LOG     
 DatanodeProtocol namenode     
 FSDataset data     
 DatanodeRegistration dnRegistration     
volatile  boolean shouldRun     
 LinkedList receivedBlockList     
 int xmitsInProgress     
 Daemon dataXceiveServer     
 long blockReportInterval     
 long lastBlockReport     
 long lastHeartbeat     
 long heartBeatInterval     
 String machineName     
 int defaultBytesPerChecksum     
 DataNode.Count xceiverCount     
 UpgradeManagerDatanode upgradeManager     
Constructor:
 DataNode(Configuration conf,
    AbstractList dataDirs) throws IOException 
    Create the DataNode given a configuration and an array of dataDirs. 'dataDirs' is where the blocks are stored.
Method from org.apache.hadoop.dfs.DataNode Summary:
createDataNode,   createSocketAddr,   getDataNode,   getNameNodeAddr,   getNamenode,   getStartupOption,   join,   main,   makeInstance,   offerService,   run,   run,   sendBlock,   shutdown,   startDataNode,   toString
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.hadoop.dfs.DataNode Detail:
 static DataNode createDataNode(String[] args,
    Configuration conf) throws IOException 
    Start a single datanode daemon and wait for it to finish. If this thread is specifically interrupted, it will stop waiting.
 public static InetSocketAddress createSocketAddr(String target) throws IOException 
    Util method to build socket addr from either: : ://:/
 public static DataNode getDataNode() 
    Return the DataNode object
 public InetSocketAddress getNameNodeAddr() 
 public String getNamenode() 
    Return the namenode's identifier
 static StartupOption getStartupOption(Configuration conf) 
  void join() 
 public static  void main(String[] args) 
 static DataNode makeInstance(String[] dataDirs,
    Configuration conf) throws IOException 
    Make an instance of DataNode after ensuring that at least one of the given data directories (and their parent directories, if necessary) can be created.
 public  void offerService() throws Exception 
    Main loop for the DataNode. Runs until shutdown, forever calling remote NameNode functions.
 public  void run() 
    No matter what kind of exception we get, keep retrying to offerService(). That's the loop that connects to the NameNode and provides basic DataNode functionality. Only stop when "shouldRun" is turned off (which can only happen at shutdown).
 public static DataNode run(Configuration conf) throws IOException 
    Start datanode daemon.
 long sendBlock(Socket sock,
    Block block,
    long startOffset,
    long length,
    DatanodeInfo[] targets) throws IOException 
    sendBlock() is used to read block and its metadata and stream the data to either a client or to another datanode. If argument targets is null, then it is assumed to be replying to a client request (OP_BLOCK_READ). Otherwise, we are replicating to another datanode. returns total bytes reads, including crc.
 public  void shutdown() 
    Shut down this instance of the datanode. Returns only after shutdown is complete.
  void startDataNode(Configuration conf,
    AbstractList dataDirs) throws IOException 
 public String toString()