欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > java >内容正文

java

HDFS剩余空间大小的Java接口,java api获取hdfs索引大小

发布时间:2025/3/12 java 25 豆豆
生活随笔 收集整理的这篇文章主要介绍了 HDFS剩余空间大小的Java接口,java api获取hdfs索引大小 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

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

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());

总结

以上是生活随笔为你收集整理的HDFS剩余空间大小的Java接口,java api获取hdfs索引大小的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。