You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ay...@apache.org on 2021/10/16 09:06:41 UTC
[hadoop] branch branch-3.3 updated: HDFS-16271. RBF:
NullPointerException when setQuota through routers with quota disabled.
Contributed by Chengwei Wang.
This is an automated email from the ASF dual-hosted git repository.
ayushsaxena pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.3 by this push:
new 5b1cf17 HDFS-16271. RBF: NullPointerException when setQuota through routers with quota disabled. Contributed by Chengwei Wang.
5b1cf17 is described below
commit 5b1cf17f88c2cafcdb34432a38a3707f2d87569a
Author: Ayush Saxena <ay...@apache.org>
AuthorDate: Sat Oct 16 14:25:00 2021 +0530
HDFS-16271. RBF: NullPointerException when setQuota through routers with quota disabled. Contributed by Chengwei Wang.
---
.../hdfs/server/federation/router/Quota.java | 6 +++---
.../federation/router/TestDisableRouterQuota.java | 22 ++++++++++++++--------
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/Quota.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/Quota.java
index 9d84559..ee93865 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/Quota.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/Quota.java
@@ -80,6 +80,9 @@ public class Quota {
*/
public void setQuota(String path, long namespaceQuota, long storagespaceQuota,
StorageType type, boolean checkMountEntry) throws IOException {
+ if (!router.isQuotaEnabled()) {
+ throw new IOException("The quota system is disabled in Router.");
+ }
if (checkMountEntry && isMountEntry(path)) {
throw new AccessControlException(
"Permission denied: " + RouterRpcServer.getRemoteUser()
@@ -101,9 +104,6 @@ public class Quota {
long namespaceQuota, long storagespaceQuota, StorageType type)
throws IOException {
rpcServer.checkOperation(OperationCategory.WRITE);
- if (!router.isQuotaEnabled()) {
- throw new IOException("The quota system is disabled in Router.");
- }
// Set quota for current path and its children mount table path.
if (locations == null) {
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestDisableRouterQuota.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestDisableRouterQuota.java
index 192c807..bd3b60b 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestDisableRouterQuota.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestDisableRouterQuota.java
@@ -70,15 +70,21 @@ public class TestDisableRouterQuota {
public void testSetQuota() throws Exception {
long nsQuota = 1024;
long ssQuota = 1024;
+ Quota quotaModule = router.getRpcServer().getQuotaModule();
- try {
- Quota quotaModule = router.getRpcServer().getQuotaModule();
- quotaModule.setQuota("/test", nsQuota, ssQuota, null, false);
- fail("The setQuota call should fail.");
- } catch (IOException ioe) {
- GenericTestUtils.assertExceptionContains(
- "The quota system is disabled in Router.", ioe);
- }
+ // don't checkMountEntry called by RouterAdminServer#synchronizeQuota
+ LambdaTestUtils.intercept(
+ IOException.class,
+ "The quota system is disabled in Router.",
+ "The setQuota call should fail.",
+ () -> quotaModule.setQuota("/test", nsQuota, ssQuota, null, false));
+
+ // do checkMountEntry called by RouterClientProtocol#setQuota
+ LambdaTestUtils.intercept(
+ IOException.class,
+ "The quota system is disabled in Router.",
+ "The setQuota call should fail.",
+ () -> quotaModule.setQuota("/test", nsQuota, ssQuota, null, true));
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org