Class HFileCleaner
java.lang.Object
org.apache.hadoop.hbase.ScheduledChore
org.apache.hadoop.hbase.master.cleaner.CleanerChore<BaseHFileCleanerDelegate>
org.apache.hadoop.hbase.master.cleaner.HFileCleaner
- All Implemented Interfaces:
Runnable
,ConfigurationObserver
@Private
public class HFileCleaner
extends CleanerChore<BaseHFileCleanerDelegate>
implements ConfigurationObserver
This Chore, every time it runs, will clear the HFiles in the hfile archive folder that are
deletable for each HFile cleaner in the chain.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprivate long
private long
private static final Comparator<HFileCleaner.HFileDeleteTask>
static final String
(package private) static final long
(package private) static final long
static final int
static final int
static final int
static final int
static final int
private AtomicLong
private AtomicLong
static final String
The custom paths for hfile cleaner, subdirectories of archive, e.g.static final String
Configure hfile cleaner classes for the custom pathsstatic final String
static final String
static final String
static final String
static final String
private int
(package private) StealJobQueue<HFileCleaner.HFileDeleteTask>
private int
private static final org.slf4j.Logger
static final String
private boolean
static final String
static final String
private int
(package private) BlockingQueue<HFileCleaner.HFileDeleteTask>
private int
private int
Fields inherited from class org.apache.hadoop.hbase.master.cleaner.CleanerChore
CHORE_POOL_SIZE, cleanersChain, DEFAULT_CHORE_POOL_SIZE, DEFAULT_LOG_CLEANER_CHORE_DIRECTORY_SORTING, DEFAULT_LOG_CLEANER_CHORE_POOL_SIZE, excludeDirs, fs, LOG_CLEANER_CHORE_DIRECTORY_SORTING, LOG_CLEANER_CHORE_SIZE, params
-
Constructor Summary
ConstructorDescriptionHFileCleaner
(int period, Stoppable stopper, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path directory, DirScanPool pool) HFileCleaner
(int period, Stoppable stopper, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path directory, DirScanPool pool, Map<String, Object> params) HFileCleaner
(int period, Stoppable stopper, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path directory, DirScanPool pool, Map<String, Object> params, List<org.apache.hadoop.fs.Path> excludePaths) HFileCleaner
(String name, int period, Stoppable stopper, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path directory, String confKey, DirScanPool pool, Map<String, Object> params, List<org.apache.hadoop.fs.Path> excludePaths) For creating customized HFileCleaner. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel
(boolean mayInterruptIfRunning) private boolean
checkAndUpdateConfigurations
(org.apache.hadoop.conf.Configuration conf) Check new configuration and update settings if value changedvoid
cleanup()
Override to run cleanup tasks when the Chore encounters an error and must stop runningprotected void
private void
countDeletedFiles
(boolean isLargeFile, boolean fromLargeQueue) private HFileCleaner.HFileDeleteTask
deleteFile
(org.apache.hadoop.fs.FileStatus file) Construct anHFileCleaner.HFileDeleteTask
for each file to delete and add into the correct queueint
deleteFiles
(Iterable<org.apache.hadoop.fs.FileStatus> filesToDelete) Delete the given filesprivate boolean
(package private) long
(package private) long
Exposed for TESTING!long
long
long
long
long
void
onConfigurationChange
(org.apache.hadoop.conf.Configuration conf) This method would be called by theConfigurationManager
object when theConfiguration
object is reloaded from disk.private void
Start threads for hfile deletionprivate void
Stop threads for hfile deletionprotected boolean
validate
(org.apache.hadoop.fs.Path file) Validate the file to see if it even belongs in the directory.Methods inherited from class org.apache.hadoop.hbase.master.cleaner.CleanerChore
calculatePoolSize, chore, getChorePoolSize, getEnabled, initialChore, setEnabled, triggerCleanerNow
Methods inherited from class org.apache.hadoop.hbase.ScheduledChore
cancel, choreForTesting, getInitialDelay, getName, getPeriod, getStopper, getTimeUnit, isInitialChoreComplete, isScheduled, run, shutdown, shutdown, toString, triggerNow
-
Field Details
-
MASTER_HFILE_CLEANER_PLUGINS
- See Also:
-
HFILE_DELETE_THROTTLE_THRESHOLD
- See Also:
-
DEFAULT_HFILE_DELETE_THROTTLE_THRESHOLD
- See Also:
-
LARGE_HFILE_QUEUE_INIT_SIZE
- See Also:
-
DEFAULT_LARGE_HFILE_QUEUE_INIT_SIZE
- See Also:
-
SMALL_HFILE_QUEUE_INIT_SIZE
- See Also:
-
DEFAULT_SMALL_HFILE_QUEUE_INIT_SIZE
- See Also:
-
LARGE_HFILE_DELETE_THREAD_NUMBER
- See Also:
-
DEFAULT_LARGE_HFILE_DELETE_THREAD_NUMBER
- See Also:
-
SMALL_HFILE_DELETE_THREAD_NUMBER
- See Also:
-
DEFAULT_SMALL_HFILE_DELETE_THREAD_NUMBER
- See Also:
-
HFILE_DELETE_THREAD_TIMEOUT_MSEC
- See Also:
-
DEFAULT_HFILE_DELETE_THREAD_TIMEOUT_MSEC
- See Also:
-
HFILE_DELETE_THREAD_CHECK_INTERVAL_MSEC
- See Also:
-
DEFAULT_HFILE_DELETE_THREAD_CHECK_INTERVAL_MSEC
- See Also:
-
HFILE_CLEANER_CUSTOM_PATHS
The custom paths for hfile cleaner, subdirectories of archive, e.g. data/default/testTable1,data/default/testTable2- See Also:
-
HFILE_CLEANER_CUSTOM_PATHS_PLUGINS
Configure hfile cleaner classes for the custom paths- See Also:
-
CUSTOM_POOL_SIZE
- See Also:
-
LOG
-
largeFileQueue
-
smallFileQueue
-
throttlePoint
-
largeQueueInitSize
-
smallQueueInitSize
-
largeFileDeleteThreadNumber
-
smallFileDeleteThreadNumber
-
cleanerThreadTimeoutMsec
-
cleanerThreadCheckIntervalMsec
-
threads
-
running
-
deletedLargeFiles
-
deletedSmallFiles
-
COMPARATOR
-
-
Constructor Details
-
HFileCleaner
public HFileCleaner(int period, Stoppable stopper, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path directory, DirScanPool pool) -
HFileCleaner
public HFileCleaner(int period, Stoppable stopper, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path directory, DirScanPool pool, Map<String, Object> params) - Parameters:
period
- the period of time to sleep between each runstopper
- the stopperconf
- configuration to usefs
- handle to the FSdirectory
- directory to be cleanedpool
- the thread pool used to scan directoriesparams
- params could be used in subclass of BaseHFileCleanerDelegate
-
HFileCleaner
public HFileCleaner(int period, Stoppable stopper, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path directory, DirScanPool pool, Map<String, Object> params, List<org.apache.hadoop.fs.Path> excludePaths) -
HFileCleaner
public HFileCleaner(String name, int period, Stoppable stopper, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path directory, String confKey, DirScanPool pool, Map<String, Object> params, List<org.apache.hadoop.fs.Path> excludePaths) For creating customized HFileCleaner.- Parameters:
name
- name of the chore being runperiod
- the period of time to sleep between each runstopper
- the stopperconf
- configuration to usefs
- handle to the FSdirectory
- directory to be cleanedconfKey
- configuration key for the classes to instantiatepool
- the thread pool used to scan directoriesparams
- params could be used in subclass of BaseHFileCleanerDelegate
-
-
Method Details
-
validate
Description copied from class:CleanerChore
Validate the file to see if it even belongs in the directory. If it is valid, then the file will go through the cleaner delegates, but otherwise the file is just deleted.- Specified by:
validate
in classCleanerChore<BaseHFileCleanerDelegate>
- Parameters:
file
- fullPath
of the file to be checked- Returns:
- true if the file is valid, false otherwise
-
getDelegatesForTesting
Exposed for TESTING! -
deleteFiles
Description copied from class:CleanerChore
Delete the given files- Overrides:
deleteFiles
in classCleanerChore<BaseHFileCleanerDelegate>
- Parameters:
filesToDelete
- files to delete- Returns:
- number of deleted files
-
deleteFile
Construct anHFileCleaner.HFileDeleteTask
for each file to delete and add into the correct queue- Parameters:
file
- the file to delete- Returns:
- HFileDeleteTask to track progress
-
dispatch
-
cleanup
Description copied from class:ScheduledChore
Override to run cleanup tasks when the Chore encounters an error and must stop running- Overrides:
cleanup
in classCleanerChore<BaseHFileCleanerDelegate>
-
startHFileDeleteThreads
Start threads for hfile deletion -
consumerLoop
-
countDeletedFiles
-
stopHFileDeleteThreads
Stop threads for hfile deletion -
getCleanerThreads
-
getNumOfDeletedLargeFiles
-
getNumOfDeletedSmallFiles
-
getLargeQueueInitSize
-
getSmallQueueInitSize
-
getThrottlePoint
-
getCleanerThreadTimeoutMsec
long getCleanerThreadTimeoutMsec() -
getCleanerThreadCheckIntervalMsec
-
onConfigurationChange
Description copied from interface:ConfigurationObserver
This method would be called by theConfigurationManager
object when theConfiguration
object is reloaded from disk.- Specified by:
onConfigurationChange
in interfaceConfigurationObserver
-
checkAndUpdateConfigurations
Check new configuration and update settings if value changed- Parameters:
conf
- The new configuration- Returns:
- true if any configuration for HFileCleaner changes, false if no change
-
cancel
- Overrides:
cancel
in classScheduledChore
-