Skip to content

Commit

Permalink
HBASE-27506 Optionally disable sorting directories by size in Cleaner…
Browse files Browse the repository at this point in the history
…Chore (apache#4896)

Signed-off-by: Wellington Chevreuil <[email protected]>
(cherry picked from commit 1ddb5bb)
  • Loading branch information
petersomogyi committed Nov 25, 2022
1 parent 2171cdd commit b68dcf4
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {
Expand Down Expand Up @@ -122,6 +130,8 @@ public CleanerChore(String name, final int sleepPeriod, final Stoppable s, Confi
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);
}

Expand Down Expand Up @@ -429,7 +439,9 @@ private void traverseAndDelete(Path dir, boolean root, CompletableFuture<Boolean
// 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)) {
Expand Down

0 comments on commit b68dcf4

Please sign in to comment.