private void test() throws Exception{
// 初始化hdfs
Configuration conf = new Configuration();
conf.addResource(new FileInputStream("/xxxxx/hive-conf/core-site.xml"));
conf.addResource(new FileInputStream("/xxxxx/hive-conf/hdfs-site.xml"));
UserGroupInformation.setConfiguration(conf);
UserGroupInformation.loginUserFromKeytab("hdfs_admin", "/xxxx/hdfs_admin.keytab");
FileSystem fs = FileSystem.get(conf);
// 获取根路径下的配额
QuotaUsage quota = fs.getQuotaUsage(new Path("/"));
// 查询配额大小
long spaceQuota = quota.getSpaceQuota();
// 查询已使用大小
long used = quota.getSpaceConsumed();
// 查询HDFS磁盘总容量
DistributedFileSystem dfs = (DistributedFileSystem )fs;
long capacity = dfs.getStatus().getCapacity();
}