joshelser 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_r325833344
 
 

 ##########
 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);
 
 Review comment:
   Can you use `QuotaObserverChore#getTableQuotaSnapshot(TableName)` instead? 
This is going to hit `hbase:quota` every time which might be costly.
   
   Since we're inside the master already, we should be able to safely pull from 
the in-memory state in `QuotaObserverChore` instead.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to