ayushtkn commented on a change in pull request #3634:
URL: https://github.com/apache/hadoop/pull/3634#discussion_r747676443



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/Quota.java
##########
@@ -50,7 +50,7 @@ public static Counts newInstance() {
    * The quota is violated if quota is set and usage > quota.
    */
   public static boolean isViolated(final long quota, final long usage) {
-    return quota >= 0 && usage > quota;
+    return quota >= 0 && usage >= quota;

Review comment:
       I think the method is correct only, It is used for LOGS in core HDFS 
parts, and Quota is said to be violated when the count is more than the value 
set, if the fileAndDirCount is 5 and quota is also 5, then quota isn't said to 
be violated.
   The javadoc also tells that.
   
   Regarding RBF, I think you need to change the call here to pass the delta, 
while verifying  :
   
https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUsage.java#L99
   
   Rather than the method which you tweaked use the below one with proper delta:
   ```
     static boolean isViolated(final long quota, final long usage,
         final long delta) {
       return quota >= 0 && delta > 0 && usage > quota - delta;
     }
   ```
   That I think should solve the problem here. Not sure how things will work in 
case of storage quota though....
   
   Wrote a UT in **TestRouterRPCMultipleDestinationMountTableResolver** , to 
check this, putting it up here as well in case anyone wants to try, might save 
some efforts.
   
   ```
     @Test
     public void testQuotaMultiDest() throws Exception {
       // NS-Quota as 4
       long nsQuota = 4;
       Path path = new Path("/test10");
       nnFs0.mkdirs(path);
       nnFs1.mkdirs(path);
       Map<String, String> destMap = new HashMap<>();
       destMap.put("ns0", "/test10");
       destMap.put("ns1", "/test10");
       MountTable addEntry = MountTable.newInstance("/test10", destMap);
       assertTrue(addMountTable(addEntry));
       RouterQuotaUpdateService updateService =
           routerContext.getRouter().getQuotaCacheUpdateService();
       updateService.periodicInvoke();
   
       // Set NS-Quota as 4
       RouterAdmin admin = getRouterAdmin();
       String[] argv = new String[] {"-setQuota", path.toString(), "-nsQuota",
           String.valueOf(nsQuota)};
       assertEquals(0, ToolRunner.run(admin, argv));
       updateService.periodicInvoke();
       resolver.loadCache(true);
   
       // Touch two files under ns-fed/tes10
   
       routerFs.create(new Path("/test10/file1")).close();
       routerFs.create(new Path("/test10/file2")).close();
   
       updateService.periodicInvoke();
   
       // This should have thrown exception since 2 target directories & 2 
files: total 4 & Quota is 4
       routerFs.create(new Path("/test10/file3")).close();
     }
   ```
   




-- 
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.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to