You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ps...@apache.org on 2022/11/25 15:01:41 UTC

[hbase] branch branch-2.5 updated: HBASE-27506 Optionally disable sorting directories by size in CleanerChore (#4896)

This is an automated email from the ASF dual-hosted git repository.

psomogyi pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.5 by this push:
     new b68dcf46e9e HBASE-27506 Optionally disable sorting directories by size in CleanerChore (#4896)
b68dcf46e9e is described below

commit b68dcf46e9eacbce3325f70163756f91b0447658
Author: Peter Somogyi <ps...@apache.org>
AuthorDate: Fri Nov 25 15:31:56 2022 +0100

    HBASE-27506 Optionally disable sorting directories by size in CleanerChore (#4896)
    
    Signed-off-by: Wellington Chevreuil <wc...@apache.org>
    (cherry picked from commit 1ddb5bb43cfe4f543710a84884a5df20d02ff0a8)
---
 .../apache/hadoop/hbase/master/cleaner/CleanerChore.java   | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
index 71fe5381549..83ead85eaaf 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
@@ -71,6 +71,13 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
    */
   public static final String LOG_CLEANER_CHORE_SIZE = "hbase.log.cleaner.scan.dir.concurrent.size";
   static final String DEFAULT_LOG_CLEANER_CHORE_POOL_SIZE = "1";
+  /**
+   * Enable the CleanerChore to sort the subdirectories by consumed space and start the cleaning
+   * with the largest subdirectory. Enabled by default.
+   */
+  public static final String LOG_CLEANER_CHORE_DIRECTORY_SORTING =
+    "hbase.cleaner.directory.sorting";
+  static final boolean DEFAULT_LOG_CLEANER_CHORE_DIRECTORY_SORTING = true;
 
   private final DirScanPool pool;
 
@@ -81,6 +88,7 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
   private final AtomicBoolean enabled = new AtomicBoolean(true);
   protected List<T> cleanersChain;
   protected List<String> excludeDirs;
+  private boolean sortDirectories;
 
   public CleanerChore(String name, final int sleepPeriod, final Stoppable s, Configuration conf,
     FileSystem fs, Path oldFileDir, String confKey, DirScanPool pool) {
@@ -122,6 +130,8 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
     if (excludeDirs != null) {
       LOG.info("Cleaner {} excludes sub dirs: {}", name, excludeDirs);
     }
+    sortDirectories = conf.getBoolean(LOG_CLEANER_CHORE_DIRECTORY_SORTING,
+      DEFAULT_LOG_CLEANER_CHORE_DIRECTORY_SORTING);
     initCleanerChain(confKey);
   }
 
@@ -429,7 +439,9 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
       // Step.3: Start to traverse and delete the sub-directories.
       List<CompletableFuture<Boolean>> futures = new ArrayList<>();
       if (!subDirs.isEmpty()) {
-        sortByConsumedSpace(subDirs);
+        if (sortDirectories) {
+          sortByConsumedSpace(subDirs);
+        }
         // Submit the request of sub-directory deletion.
         subDirs.forEach(subDir -> {
           if (!shouldExclude(subDir)) {