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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate longprivate static final Comparator<HFileCleaner.HFileDeleteTask>static final String(package private) static final long(package private) static final longstatic final intstatic final intstatic final intstatic final intstatic final intprivate AtomicLongprivate AtomicLongstatic final StringThe custom paths for hfile cleaner, subdirectories of archive, e.g.static final StringConfigure hfile cleaner classes for the custom pathsstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate int(package private) StealJobQueue<HFileCleaner.HFileDeleteTask>private intprivate static final org.slf4j.Loggerstatic final Stringprivate booleanstatic final Stringstatic final Stringprivate int(package private) BlockingQueue<HFileCleaner.HFileDeleteTask>private intprivate intFields 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
ConstructorsConstructorDescriptionHFileCleaner(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 TypeMethodDescriptionvoidcancel(boolean mayInterruptIfRunning) private booleancheckAndUpdateConfigurations(org.apache.hadoop.conf.Configuration conf) Check new configuration and update settings if value changedvoidcleanup()Override to run cleanup tasks when the Chore encounters an error and must stop runningprotected voidprivate voidcountDeletedFiles(boolean isLargeFile, boolean fromLargeQueue) private HFileCleaner.HFileDeleteTaskdeleteFile(org.apache.hadoop.fs.FileStatus file) Construct anHFileCleaner.HFileDeleteTaskfor each file to delete and add into the correct queueintdeleteFiles(Iterable<org.apache.hadoop.fs.FileStatus> filesToDelete) Delete the given filesprivate boolean(package private) long(package private) longExposed for TESTING!longlonglonglonglongvoidonConfigurationChange(org.apache.hadoop.conf.Configuration conf) This method would be called by theConfigurationManagerobject when theConfigurationobject is reloaded from disk.private voidStart threads for hfile deletionprivate voidStop threads for hfile deletionprotected booleanvalidate(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, triggerCleanerNowMethods 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:CleanerChoreValidate 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:
validatein classCleanerChore<BaseHFileCleanerDelegate>- Parameters:
file- fullPathof the file to be checked- Returns:
- true if the file is valid, false otherwise
-
getDelegatesForTesting
Exposed for TESTING! -
deleteFiles
Description copied from class:CleanerChoreDelete the given files- Overrides:
deleteFilesin classCleanerChore<BaseHFileCleanerDelegate>- Parameters:
filesToDelete- files to delete- Returns:
- number of deleted files
-
deleteFile
Construct anHFileCleaner.HFileDeleteTaskfor 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:ScheduledChoreOverride to run cleanup tasks when the Chore encounters an error and must stop running- Overrides:
cleanupin 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:ConfigurationObserverThis method would be called by theConfigurationManagerobject when theConfigurationobject is reloaded from disk.- Specified by:
onConfigurationChangein 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:
cancelin classScheduledChore
-