首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

java api获取hdfs索引大小

2012-09-01 
java api获取hdfs目录大小1. hadoop fs -dus 的源码:?public static void dus(String src,Configuration c

java api获取hdfs目录大小

1. hadoop fs -dus 的源码:

?

public static void dus(String src,Configuration conf) throws IOException {    Path srcPath = new Path(src);    FileSystem srcFs = srcPath.getFileSystem(conf);    FileStatus status[] = srcFs.globStatus(new Path(src));    if (status==null || status.length==0) {      throw new FileNotFoundException("Cannot access " + src +           ": No such file or directory.");    }    for(int i=0; i<status.length; i++) {      long totalSize = srcFs.getContentSummary(status[i].getPath()).getLength();      String pathStr = status[i].getPath().toString();      System.out.println(("".equals(pathStr)?".":pathStr) + "\t" + totalSize);    }  }

?

2.

FileSystem fs = new Path(s).getFileSystem(conf);System.out.println(fs.getContentSummary(new Path(s)).getLength());
?

热点排行