Skip to content

Commit b68dcf4

Browse files
committed
HBASE-27506 Optionally disable sorting directories by size in CleanerChore (#4896)
Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> (cherry picked from commit 1ddb5bb)
1 parent 2171cdd commit b68dcf4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
7171
*/
7272
public static final String LOG_CLEANER_CHORE_SIZE = "hbase.log.cleaner.scan.dir.concurrent.size";
7373
static final String DEFAULT_LOG_CLEANER_CHORE_POOL_SIZE = "1";
74+
/**
75+
* Enable the CleanerChore to sort the subdirectories by consumed space and start the cleaning
76+
* with the largest subdirectory. Enabled by default.
77+
*/
78+
public static final String LOG_CLEANER_CHORE_DIRECTORY_SORTING =
79+
"hbase.cleaner.directory.sorting";
80+
static final boolean DEFAULT_LOG_CLEANER_CHORE_DIRECTORY_SORTING = true;
7481

7582
private final DirScanPool pool;
7683

@@ -81,6 +88,7 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
8188
private final AtomicBoolean enabled = new AtomicBoolean(true);
8289
protected List<T> cleanersChain;
8390
protected List<String> excludeDirs;
91+
private boolean sortDirectories;
8492

8593
public CleanerChore(String name, final int sleepPeriod, final Stoppable s, Configuration conf,
8694
FileSystem fs, Path oldFileDir, String confKey, DirScanPool pool) {
@@ -122,6 +130,8 @@ public CleanerChore(String name, final int sleepPeriod, final Stoppable s, Confi
122130
if (excludeDirs != null) {
123131
LOG.info("Cleaner {} excludes sub dirs: {}", name, excludeDirs);
124132
}
133+
sortDirectories = conf.getBoolean(LOG_CLEANER_CHORE_DIRECTORY_SORTING,
134+
DEFAULT_LOG_CLEANER_CHORE_DIRECTORY_SORTING);
125135
initCleanerChain(confKey);
126136
}
127137

@@ -429,7 +439,9 @@ private void traverseAndDelete(Path dir, boolean root, CompletableFuture<Boolean
429439
// Step.3: Start to traverse and delete the sub-directories.
430440
List<CompletableFuture<Boolean>> futures = new ArrayList<>();
431441
if (!subDirs.isEmpty()) {
432-
sortByConsumedSpace(subDirs);
442+
if (sortDirectories) {
443+
sortByConsumedSpace(subDirs);
444+
}
433445
// Submit the request of sub-directory deletion.
434446
subDirs.forEach(subDir -> {
435447
if (!shouldExclude(subDir)) {

0 commit comments

Comments
 (0)