欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

查找某個(gè)文件在HDFS集群中的位置

系統(tǒng) 3073 0

? ? ?通過" FileSystem.getFileBlockLocation(FileStatus file,long start,long len) "可查找指定文件在HDFS集群上的位置,其中file為文件的完整路徑,start和len來標(biāo)識(shí)查找文件的路徑。

以下是java代碼的實(shí)現(xiàn):

package com.njupt.hadoop;


import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.BlockLocation;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.DistributedFileSystem;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;


public class FindFileOnHDFS {


public static void main(String[] args) throws Exception{
getHDFSNodes();
getFileLocal();
}


public static void getFileLocal() throws Exception {


Configuration conf = new Configuration();
FileSystem hdfs = FileSystem.get(conf);
Path fpath = new Path("/user/root/20120722/word.txt");

FileStatus fileStatus = hdfs.getFileStatus(fpath);
? ?BlockLocation[] blkLocations = hdfs.getFileBlockLocations(fileStatus, 0, fileStatus.getLen());

? ?int blockLen = blkLocations.length;
? ?
? ?for(int i = 0 ; i < blockLen ; ++i ){
? ?String[] hosts = blkLocations[i].getHosts();
? ?System.out.println("block_"+i + "_location:" + hosts[i]);
? ?}
}


public static void getHDFSNodes() throws Exception{
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
DistributedFileSystem hdfs = (DistributedFileSystem)fs;
DatanodeInfo[] dataNodeStats = hdfs.getDataNodeStats();

for( int i = 0 ; i < dataNodeStats.length ; ++i ){
System.out.println("DataNode_" + i + "_Node:" + dataNodeStats[i].getHostName());
}
}
}

?

查找某個(gè)文件在HDFS集群中的位置


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 成人在线免费网站 | 日本人毛片 | 亚洲九九| 91天堂网| 天天色天天操天天射 | 亚洲视频在线一区 | 久久福利青草精品免费 | 国产精品久久久久久久久久久久 | 高清男女性高爱潮免费 | 国产精品久久久久久无码人妻 | 亚洲在线视频播放 | 日韩一区不卡 | 99久久国产综合精品女小说 | 成人国产精品免费观看视频 | 国产免费观看视频 | 韩日美无码精品无码 | 我和我的祖国电影在线观看免费版高清 | 成人国内精品久久久久影 | 久久精精 | 成人欧美在线观看 | 日本大人吃奶视频xxxx | 日本不卡高清免费 | 嗯啊你轻点好深啊hh在线播放 | 亚洲欧美精品一中文字幕 | 欧美大码毛片在线播放 | 日本在线视频观看 | 青草草在线观看免费视频 | 天天爽夜夜爽 | 午夜在线免费观看 | 午夜视频一区二区三区 | 色网站视频 | 欧美大香线蕉线伊人久久 | 精品国产一区二区三区香蕉沈先生 | 一区在线免费观看 | 色婷婷精品国产一区二区三区 | 日韩福利在线观看 | 亚洲黄网视频 | 日本一区二区视频在线 | 大片在线免费观看 | 夜色视频网 | 亚洲国产品综合人成综合网站 |