sunchao commented on a change in pull request #1253: HDFS-8631. WebHDFS :
Support setQuota
URL: https://github.com/apache/hadoop/pull/1253#discussion_r312329673
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFS.java
##########
@@ -1129,9 +1129,88 @@ public void testQuotaUsage() throws Exception {
cluster.shutdown();
}
}
+ }
+
+ @Test
+ public void testSetQuota() throws Exception {
+ MiniDFSCluster cluster = null;
+ final Configuration conf = WebHdfsTestUtil.createConf();
+ final Path path = new Path("/TestDir");
+ try {
+ cluster = new MiniDFSCluster.Builder(conf).numDataNodes(3).build();
+ final WebHdfsFileSystem webHdfs = WebHdfsTestUtil.getWebHdfsFileSystem(
+ conf, WebHdfsConstants.WEBHDFS_SCHEME);
+ final DistributedFileSystem dfs = cluster.getFileSystem();
+ final long nsQuota = 100;
+ final long spaceQuota = 1024;
+
+ webHdfs.mkdirs(path);
+
+ webHdfs.setQuota(path, nsQuota, spaceQuota);
+ QuotaUsage quotaUsage = dfs.getQuotaUsage(path);
+ assertEquals(nsQuota, quotaUsage.getQuota());
+ assertEquals(spaceQuota, quotaUsage.getSpaceQuota());
+
+ webHdfs.setQuota(path,
+ HdfsConstants.QUOTA_RESET, HdfsConstants.QUOTA_RESET);
+ quotaUsage = dfs.getQuotaUsage(path);
+ assertEquals(HdfsConstants.QUOTA_RESET, quotaUsage.getQuota());
+ assertEquals(HdfsConstants.QUOTA_RESET, quotaUsage.getSpaceQuota());
+
+ webHdfs.setQuotaByStorageType(path, StorageType.DISK, spaceQuota);
+ webHdfs.setQuotaByStorageType(path, StorageType.ARCHIVE, spaceQuota);
+ webHdfs.setQuotaByStorageType(path, StorageType.SSD, spaceQuota);
+ quotaUsage = dfs.getQuotaUsage(path);
+ assertEquals(spaceQuota, quotaUsage.getTypeQuota(StorageType.DISK));
+ assertEquals(spaceQuota, quotaUsage.getTypeQuota(StorageType.ARCHIVE));
+ assertEquals(spaceQuota, quotaUsage.getTypeQuota(StorageType.SSD));
+
+ // Test invalid parameters
+
+ try {
+ webHdfs.setQuota(path, -100, 100);
+ fail("Should have thrown exception");
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().contains("Invalid values for quota"));
Review comment:
Thanks. I was searching for this but forgot what it is called. Will replace.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]