Starting from protocol Versionedprotocol 2--clientdatanodeprotocol and Interdatanodeprotocol

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.