shardul-cr7 commented on a change in pull request #572: HBASE-22012 Space 
Quota: DisableTableViolationPolicy will cause cycles of enable/disable table
URL: https://github.com/apache/hbase/pull/572#discussion_r326858236
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java
 ##########
 @@ -702,15 +703,53 @@ int pruneEntriesOlderThan(long timeToPruneBefore) {
     Iterator<Entry<RegionInfo,SizeSnapshotWithTimestamp>> iterator =
         regionSizes.entrySet().iterator();
     while (iterator.hasNext()) {
-      long currentEntryTime = iterator.next().getValue().getTime();
-      if (currentEntryTime < timeToPruneBefore) {
+      RegionInfo regionInfo = iterator.next().getKey();
+      long currentEntryTime = regionSizes.get(regionInfo).getTime();
+      boolean isInViolationAndPolicyDisable = 
isInViolationAndPolicyDisable(regionInfo.getTable());
+      // do not prune the entries if table is in violation and
+      // violation policy is disable.prune entries older than time.
+      if (currentEntryTime < timeToPruneBefore && 
!isInViolationAndPolicyDisable) {
         iterator.remove();
         numEntriesRemoved++;
       }
     }
     return numEntriesRemoved;
   }
 
+  /**
+   * Method to check if a table is in violation and policy set on table is 
DISABLE.
+   *
+   * @param tableName tableName to check.
+   * @return returns true if table is in violation and policy is disable else 
false.
+   */
+  private boolean isInViolationAndPolicyDisable(TableName tableName) {
+    boolean isInViolationAtTable = false;
+    boolean isInViolationAndPolicyDisable = false;
+    SpaceViolationPolicy policy = null;
+    try {
+      if (QuotaUtil.isQuotaEnabled(masterServices.getConfiguration())) {
+        // Get Current Snapshot for the given table
+        SpaceQuotaSnapshot spaceQuotaSnapshot =
+            
QuotaUtil.getCurrentSnapshotFromQuotaTable(masterServices.getConnection(), 
tableName);
+        if (spaceQuotaSnapshot != null) {
+          // check if table in violation
+          isInViolationAtTable = 
spaceQuotaSnapshot.getQuotaStatus().isInViolation();
+          Optional<SpaceViolationPolicy> policyAtNamespace =
 
 Review comment:
   done

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to