org.apache.hadoop.hbase.master.cleaner
Class CleanerChore<T extends FileCleanerDelegate>
java.lang.Object
org.apache.hadoop.hbase.util.HasThread
org.apache.hadoop.hbase.Chore
org.apache.hadoop.hbase.master.cleaner.CleanerChore<T>
- Type Parameters:
T - Cleaner delegate class that is dynamically loaded from configuration
- All Implemented Interfaces:
- Runnable
- Direct Known Subclasses:
- HFileCleaner, LogCleaner
public abstract class CleanerChore<T extends FileCleanerDelegate>
- extends Chore
Abstract Cleaner that uses a chain of delegates to clean a directory of files
| Fields inherited from class org.apache.hadoop.hbase.Chore |
stopper |
|
Constructor Summary |
CleanerChore(String name,
int sleepPeriod,
Stoppable s,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path oldFileDir,
String confKey)
|
|
Method Summary |
boolean |
checkAndDeleteDirectory(org.apache.hadoop.fs.Path toCheck)
Attempt to delete a directory and all files under that directory. |
protected void |
chore()
|
void |
cleanup()
|
T |
newFileCleaner(String className,
org.apache.hadoop.conf.Configuration conf)
A utility method to create new instances of LogCleanerDelegate based on the class name of the
LogCleanerDelegate. |
protected abstract 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.util.HasThread |
getName, getThread, interrupt, isAlive, isInterrupted, join, join, join, setDaemon, setName, setPriority, setUncaughtExceptionHandler, start |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
cleanersChain
protected List<T extends FileCleanerDelegate> cleanersChain
CleanerChore
public CleanerChore(String name,
int sleepPeriod,
Stoppable s,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path oldFileDir,
String confKey)
- Parameters:
name - name of the chore being runsleepPeriod - the period of time to sleep between each runs - the stopperconf - configuration to usefs - handle to the FSoldFileDir - the path to the archived filesconfKey - configuration key for the classes to instantiate
validate
protected abstract boolean validate(org.apache.hadoop.fs.Path file)
- 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.
- Parameters:
file - full Path of the file to be checked
- Returns:
- true if the file is valid, false otherwise
newFileCleaner
public T newFileCleaner(String className,
org.apache.hadoop.conf.Configuration conf)
- A utility method to create new instances of LogCleanerDelegate based on the class name of the
LogCleanerDelegate.
- Parameters:
className - fully qualified class name of the LogCleanerDelegateconf -
- Returns:
- the new instance
chore
protected void chore()
- Specified by:
chore in class Chore
checkAndDeleteDirectory
public boolean checkAndDeleteDirectory(org.apache.hadoop.fs.Path toCheck)
throws IOException
- Attempt to delete a directory and all files under that directory. Each child file is passed
through the delegates to see if it can be deleted. If the directory has no children when the
cleaners have finished it is deleted.
If new children files are added between checks of the directory, the directory will not
be deleted.
- Parameters:
toCheck - directory to check
- Returns:
- true if the directory was deleted, false otherwise.
- Throws:
IOException - if there is an unexpected filesystem error
cleanup
public void cleanup()
- Overrides:
cleanup in class Chore
Copyright © 2013 The Apache Software Foundation. All Rights Reserved.