Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8053297
  • 博文数量: 594
  • 博客积分: 13065
  • 博客等级: 上将
  • 技术积分: 10324
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-26 16:44
个人简介

推荐: blog.csdn.net/aquester https://github.com/eyjian https://www.cnblogs.com/aquester http://blog.chinaunix.net/uid/20682147.html

文章分类

全部博文(594)

分类: HADOOP

2017-05-19 09:29:25

详情请参见DatanodeUtil.java中的函数idToBlockDir(File root, long blockId)。
如果block文件没有放在正确的目录下,则DataNode会出现“expected block file path”日志。

// g++ -g -o block2dir block2dir.cpp
#include
#include

int main(int argc, char* argv[])
{
    if (argc != 2)
    {
        fprintf(stderr, "usage: block2dir block_id, example: block2dir 1075840138\n");
        exit(1);
    }

    const long block_id = atol(argv[1]);
    const int d1 = (int) ((block_id >> 16) & 0x1F);
    const int d2 = (int) ((block_id >> 8) & 0x1F);
    fprintf(stderr, "subdir%d/subdir%d\n", d1, d2);

    return 0;
}

运行示例:
$ ./block2dir 1075840138
subdir0/subdir4

/**
* @return the meta name given the block name and generation stamp.
*/
public static String getMetaName(String blockName, long generationStamp) {
    return blockName + "_" + generationStamp + Block.METADATA_EXTENSION; 
}
阅读(3867) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~