从Java获取HDFS的文件夹大小 [英] Get Folder size of HDFS from java

查看:85
本文介绍了从Java获取HDFS的文件夹大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用具有Java子目录的HDFS文件夹大小.

I have to HDFS folder size which is having sub directories from java.

在命令行中,我们可以使用-dus选项,但是任何人都可以帮助我了解如何使用Java来获取相同的信息.

From command line we can use -dus option, But anyone can help me on how to get the same using java.

推荐答案

ContentSummary 类中的 getSpaceConsumed()函数将返回文件/目录占用的实际空间在群集中,即它考虑了为群集设置的复制因子.

The getSpaceConsumed() function in the ContentSummary class will return the actual space the file/directory occupies in the cluster i.e. it takes into account the replication factor set for the cluster.

例如,如果hadoop群集中的复制因子设置为3,并且目录大小为1.5GB,则 getSpaceConsumed()函数将返回值为4.5GB.

For instance, if the replication factor in the hadoop cluster is set to 3 and the directory size is 1.5GB, the getSpaceConsumed() function will return the value as 4.5GB.

使用 < ContentSummary 类中的code> getLength() 函数将返回您的实际文件/目录大小.

Using getLength() function in the ContentSummary class will return you the actual file/directory size.

这篇关于从Java获取HDFS的文件夹大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆