HDFS-16271. RBF: NullPointerException when setQuota through routers with quota disabled. Contributed by Chengwei Wang.
This commit is contained in:
parent
af920f138b
commit
5b1cf17f88
@ -80,6 +80,9 @@ public Quota(Router router, RouterRpcServer server) {
|
|||||||
*/
|
*/
|
||||||
public void setQuota(String path, long namespaceQuota, long storagespaceQuota,
|
public void setQuota(String path, long namespaceQuota, long storagespaceQuota,
|
||||||
StorageType type, boolean checkMountEntry) throws IOException {
|
StorageType type, boolean checkMountEntry) throws IOException {
|
||||||
|
if (!router.isQuotaEnabled()) {
|
||||||
|
throw new IOException("The quota system is disabled in Router.");
|
||||||
|
}
|
||||||
if (checkMountEntry && isMountEntry(path)) {
|
if (checkMountEntry && isMountEntry(path)) {
|
||||||
throw new AccessControlException(
|
throw new AccessControlException(
|
||||||
"Permission denied: " + RouterRpcServer.getRemoteUser()
|
"Permission denied: " + RouterRpcServer.getRemoteUser()
|
||||||
@ -101,9 +104,6 @@ void setQuotaInternal(String path, List<RemoteLocation> locations,
|
|||||||
long namespaceQuota, long storagespaceQuota, StorageType type)
|
long namespaceQuota, long storagespaceQuota, StorageType type)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
rpcServer.checkOperation(OperationCategory.WRITE);
|
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.
|
// Set quota for current path and its children mount table path.
|
||||||
if (locations == null) {
|
if (locations == null) {
|
||||||
|
@ -70,15 +70,21 @@ public void checkDisableQuota() {
|
|||||||
public void testSetQuota() throws Exception {
|
public void testSetQuota() throws Exception {
|
||||||
long nsQuota = 1024;
|
long nsQuota = 1024;
|
||||||
long ssQuota = 1024;
|
long ssQuota = 1024;
|
||||||
|
|
||||||
try {
|
|
||||||
Quota quotaModule = router.getRpcServer().getQuotaModule();
|
Quota quotaModule = router.getRpcServer().getQuotaModule();
|
||||||
quotaModule.setQuota("/test", nsQuota, ssQuota, null, false);
|
|
||||||
fail("The setQuota call should fail.");
|
// don't checkMountEntry called by RouterAdminServer#synchronizeQuota
|
||||||
} catch (IOException ioe) {
|
LambdaTestUtils.intercept(
|
||||||
GenericTestUtils.assertExceptionContains(
|
IOException.class,
|
||||||
"The quota system is disabled in Router.", ioe);
|
"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
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user