HBASE-27506 Optionally disable sorting directories by size in CleanerChore (#4896)
Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
(cherry picked from commit b68dcf46e9
)
This commit is contained in:
parent
a3ac3c581d
commit
0a37292113
|
@ -63,6 +63,13 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
|
||||||
*/
|
*/
|
||||||
public static final String CHORE_POOL_SIZE = "hbase.cleaner.scan.dir.concurrent.size";
|
public static final String CHORE_POOL_SIZE = "hbase.cleaner.scan.dir.concurrent.size";
|
||||||
static final String DEFAULT_CHORE_POOL_SIZE = "0.25";
|
static final String DEFAULT_CHORE_POOL_SIZE = "0.25";
|
||||||
|
/**
|
||||||
|
* 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;
|
private final DirScanPool pool;
|
||||||
|
|
||||||
|
@ -72,6 +79,7 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
|
||||||
protected final Map<String, Object> params;
|
protected final Map<String, Object> params;
|
||||||
private final AtomicBoolean enabled = new AtomicBoolean(true);
|
private final AtomicBoolean enabled = new AtomicBoolean(true);
|
||||||
protected List<T> cleanersChain;
|
protected List<T> cleanersChain;
|
||||||
|
private boolean sortDirectories;
|
||||||
|
|
||||||
public CleanerChore(String name, final int sleepPeriod, final Stoppable s, Configuration conf,
|
public CleanerChore(String name, final int sleepPeriod, final Stoppable s, Configuration conf,
|
||||||
FileSystem fs, Path oldFileDir, String confKey, DirScanPool pool) {
|
FileSystem fs, Path oldFileDir, String confKey, DirScanPool pool) {
|
||||||
|
@ -99,6 +107,8 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
|
||||||
this.oldFileDir = oldFileDir;
|
this.oldFileDir = oldFileDir;
|
||||||
this.conf = conf;
|
this.conf = conf;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
|
sortDirectories = conf.getBoolean(LOG_CLEANER_CHORE_DIRECTORY_SORTING,
|
||||||
|
DEFAULT_LOG_CLEANER_CHORE_DIRECTORY_SORTING);
|
||||||
initCleanerChain(confKey);
|
initCleanerChain(confKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +416,9 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
|
||||||
// Step.3: Start to traverse and delete the sub-directories.
|
// Step.3: Start to traverse and delete the sub-directories.
|
||||||
List<CompletableFuture<Boolean>> futures = new ArrayList<>();
|
List<CompletableFuture<Boolean>> futures = new ArrayList<>();
|
||||||
if (!subDirs.isEmpty()) {
|
if (!subDirs.isEmpty()) {
|
||||||
sortByConsumedSpace(subDirs);
|
if (sortDirectories) {
|
||||||
|
sortByConsumedSpace(subDirs);
|
||||||
|
}
|
||||||
// Submit the request of sub-directory deletion.
|
// Submit the request of sub-directory deletion.
|
||||||
subDirs.forEach(subDir -> {
|
subDirs.forEach(subDir -> {
|
||||||
CompletableFuture<Boolean> subFuture = new CompletableFuture<>();
|
CompletableFuture<Boolean> subFuture = new CompletableFuture<>();
|
||||||
|
|
Loading…
Reference in New Issue