Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-27506 Optionally disable sorting directories by size in CleanerChore #4896

Merged
merged 1 commit into from
Nov 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,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 @@ -82,6 +89,7 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
protected List<String> excludeDirs;
private CompletableFuture<Boolean> future;
private boolean forceRun;
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 @@ -123,6 +131,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 @@ -475,7 +485,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