HDFS-14209. RBF: setQuota() through router is working for only the mount Points under the Source column in MountTable. Contributed by Shubham Dewan.

This commit is contained in:
Yiqun Lin 2019-01-23 22:59:43 +08:00 committed by Brahma Reddy Battula
parent b9e0b02a6c
commit 6b5f63c25b
2 changed files with 37 additions and 2 deletions

View File

@ -216,6 +216,11 @@ public class Quota {
locations.addAll(rpcServer.getLocationsForPath(childPath, true, false));
}
}
return locations;
if (locations.size() >= 1) {
return locations;
} else {
locations.addAll(rpcServer.getLocationsForPath(path, true, false));
return locations;
}
}
}

View File

@ -755,4 +755,34 @@ public class TestRouterQuota {
assertEquals(HdfsConstants.QUOTA_RESET, subClusterQuota.getQuota());
assertEquals(HdfsConstants.QUOTA_RESET, subClusterQuota.getSpaceQuota());
}
}
@Test
public void testSetQuotaNotMountTable() throws Exception {
long nsQuota = 5;
long ssQuota = 100;
final FileSystem nnFs1 = nnContext1.getFileSystem();
// setQuota should run for any directory
MountTable mountTable1 = MountTable.newInstance("/setquotanmt",
Collections.singletonMap("ns0", "/testdir16"));
addMountTable(mountTable1);
// Add a directory not present in mount table.
nnFs1.mkdirs(new Path("/testdir16/testdir17"));
routerContext.getRouter().getRpcServer().setQuota("/setquotanmt/testdir17",
nsQuota, ssQuota, null);
RouterQuotaUpdateService updateService = routerContext.getRouter()
.getQuotaCacheUpdateService();
// ensure setQuota RPC call was invoked
updateService.periodicInvoke();
ClientProtocol client1 = nnContext1.getClient().getNamenode();
final QuotaUsage quota1 = client1.getQuotaUsage("/testdir16/testdir17");
assertEquals(nsQuota, quota1.getQuota());
assertEquals(ssQuota, quota1.getSpaceQuota());
}
}