设置hdfs磁盘配额
来源:互联网 发布:淘宝商城舞蹈鞋 编辑:程序博客网 时间:2024/05/18 14:25
设置磁盘配额
命令行:
hdfs dfsadmin -setQuota 5 /tmp
超额的错误提示为:
put: The NameSpacequota (directories and files) of directory /tmp is exceeded: quota=5 filecount=8
java代码:
public static void main(String[] args) { FileSystem hdfs = null; Configuration conf = new Configuration(); try { hdfs = FileSystem.get(new URI("hdfs://192.xxx.xx.xx:9000"),conf,"username"); } catch (Exception e) { e.printStackTrace(); } Path filenamePath = new Path("/test/input"); try { //会根据集群的配置输出,例如我这里输出3G System.out.println("SIZE OF THE HDFS DIRECTORY : " + hdfs.getContentSummary(filenamePath).getSpaceConsumed()); // 显示实际的输出,例如这里显示 1G System.out.println("SIZE OF THE HDFS DIRECTORY : " + hdfs.getContentSummary(filenamePath).getLength()); } catch (IOException e) { e.printStackTrace(); } }
jni代码:
int64_t hdfsa::getSpaceConsumed(hdfsFS dfs, const char* file_path) { JNIEnv* envJNI = getJNIEnv(); if (envJNI == NULL) { Throw(Exception::ServerException, "Can't get JNIEnv from current thread", LIBHDFS_ERROR); } RAIIJObject_Path hdfsPath(envJNI, file_path); if (hdfsPath.jerror()) { Throw( Exception::ServerException, hdfsPath.jerrorStackTrace("Failed to construct a HDFS Path object"), LIBHDFS_ERROR); } // get class ContentSummary jvalue jContentSummary; jthrowable jthr = invokeMethod( envJNI, &jContentSummary, INSTANCE, (jobject)dfs, "org/apache/hadoop/hdfs/DistributedFileSystem", "getContentSummary", "(Lorg/apache/hadoop/fs/Path;)Lorg/apache/hadoop/fs/ContentSummary;", hdfsPath.get()); checkAndThrow(jthr, "getContentSummary"); // get the disk space usage jvalue jSpaceConsumed; jthr = invokeMethod( envJNI, &jSpaceConsumed, INSTANCE, jContentSummary.l, "org/apache/hadoop/fs/ContentSummary", "getSpaceConsumed", "()J"); checkAndThrow(jthr, "getSpaceConsumed"); return jSpaceConsumed.j;}
阅读全文
0 0
- 设置hdfs磁盘配额
- debian设置磁盘配额
- HDFS配额设置和测试
- Linux下磁盘配额设置
- 设置磁盘配额(第二版)
- linux实现磁盘配额设置
- 浅析Windows磁盘配额设置方法
- Linux磁盘配额的设置与检测
- linux中的磁盘配额设置详解
- linux批量设置用户磁盘配额
- Windows Server 2003设置磁盘配额
- linux批量设置用户磁盘配额
- 磁盘配额
- 磁盘配额
- 磁盘配额
- 磁盘配额
- 磁盘配额
- 磁盘配额
- Maven步步为营(一)概述
- block
- Android 常用的语言代码与国家地区对照表
- IOS异常笔记
- Maven步步为营(二)POm
- 设置hdfs磁盘配额
- MapReduce原理篇
- Maven步步为营(三)命令
- IOS零散知识笔记
- HDU 2923-Einbahnstrasse
- LaTex(PART II)一些常用关键字
- 【LeetCode】C# 96、Unique Binary Search Trees
- IOS 图片放大缩小移动,使用block精简代码
- Maven步步为营(四)其他