[ 
https://issues.apache.org/jira/browse/HDFS-17214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17771299#comment-17771299
 ] 

ASF GitHub Bot commented on HDFS-17214:
---------------------------------------

xiaojunxiang2023 commented on code in PR #6135:
URL: https://github.com/apache/hadoop/pull/6135#discussion_r1343269884


##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterQuota.java:
##########
@@ -1168,6 +1170,32 @@ public void testQuotaUpdateWhenDestinationNotPresent() 
throws Exception {
     assertEquals(0, quotaUsage.getSpaceConsumed());
   }
 
+  @Test
+  public void testAndByStorageType() {
+    long[] typeQuota = new long[StorageType.values().length];
+    Arrays.fill(typeQuota, HdfsConstants.QUOTA_DONT_SET);
+
+    Predicate<StorageType> predicate = new Predicate<StorageType>() {
+      @Override
+      public boolean test(StorageType storageType) {
+        return typeQuota[storageType.ordinal()] == 
HdfsConstants.QUOTA_DONT_SET;
+      }
+    };
+
+    assertTrue(Quota.andByStorageType(predicate));
+
+    typeQuota[0] = 2023;
+    assertFalse(Quota.andByStorageType(predicate));
+
+    Arrays.fill(typeQuota, HdfsConstants.QUOTA_DONT_SET);
+    typeQuota[1] = 2023;
+    assertFalse(Quota.andByStorageType(predicate));
+
+    Arrays.fill(typeQuota, HdfsConstants.QUOTA_DONT_SET);
+    typeQuota[typeQuota.length-1] = 2023;
+    assertFalse(Quota.andByStorageType(predicate));

Review Comment:
   Ok, I've fixed it and added some necessary comments and I'm waiting for it 
to be recompiled, please review it later
   
   
![image](https://github.com/apache/hadoop/assets/65019264/a4de2978-c348-438c-84c7-af61e0e7d0f9)
   





> The Quata class's andByStorageType method res has an incorrect initial value
> ----------------------------------------------------------------------------
>
>                 Key: HDFS-17214
>                 URL: https://issues.apache.org/jira/browse/HDFS-17214
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: rbf
>    Affects Versions: 3.3.4
>            Reporter: xiaojunxiang
>            Priority: Major
>              Labels: pull-request-available
>
> The Quata class's andByStorageType method is intended to apply bitwise and to 
> each bit of StorageType.values( ) (the converted value), returning true only 
> if all the values are true.
> So the initial value of res should be true and then loop through the array to 
> perform the bitwise and operation. 
> However, since res starts with fasle, the bitwise and always evaluates to 
> false, so we should fix res to start with true.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to