1. First of all, I'm looking at hadoop1.2.1
This inside, a little strange clientdatanodeprotocol VersionID is 4, but Interdatanodeprotocol's VersionID is 3,
And these two are no longer under the same package, Interdatanodeprotocol is located under Org.apache.hadoop.hdfs.server.protocol, while Clientdatanodeprotocol is located under Org.apache.hadoop.hdfs.protocol
2, Clientdatanodeprotocol inside of the three methods
Locatedblock Recoverblock (Block block, Boolean keeplength,
Datanodeinfo[] targets) throws IOException;
Block Getblockinfo (block block) throws IOException;
Blocklocalpathinfo Getblocklocalpathinfo (Block block,
Token<blocktokenidentifier> token) throws IOException;
Recoverblock,getblockinfo,getblocklocalpathinfo
3, Interdatanodeprotocol inside of the three methods
Blockmetadatainfo Getblockmetadatainfo (block block) throws IOException;
Blockrecoveryinfo startblockrecovery (block block) throws IOException;
void Updateblock (Block Oldblock, Block Newblock, Boolean finalize) throws IOException;
Getblockmetadatainfo,startblockrecovery,updatablock
4, it is clear that two protocols can be restored block, can get some information block
The difference is that the information obtained by Clientdatanodeprotocol is for download, and the information obtained in Interdatanodeprotocol is for synchronization, that is Updatablock
5, Blockmetadatainfo inherit to block,
Add only one attribute to the private long lastscantime;
6, Blockrecoveryinfo This class is also very simple
Private block Block;
Private Boolean Wasrecoveredonstartup;
7, it seems to see, can not open a class, which class? Block
This class is also
Private long Blockid;
Private long numbytes;
Private long Generationstamp;
Three core attributes, ID, size, timestamp generated
There are two ways to do this.
/**
* Determine if it is a block name
*/
public static Boolean isblockfilename (File f) {
String name = F.getname ();
if (Name.startswith ("Blk_") &&
Name.indexof ('. ') < 0) {
return true;
} else {
return false;
}
}
Static long Filename2id (String name) {
Return Long.parselong (name.substring ("Blk_". Length ()));
}
That's what you'll see, why the files behind the scenes are starting with Blk_.
Starting from protocol Versionedprotocol 2--clientdatanodeprotocol and Interdatanodeprotocol