T
- Cleaner delegate class that is dynamically loaded from configurationpublic abstract class CleanerChore<T extends FileCleanerDelegate> extends ScheduledChore
Modifier and Type | Field and Description |
---|---|
protected List<T> |
cleanersChain |
private org.apache.hadoop.conf.Configuration |
conf |
private org.apache.hadoop.fs.FileSystem |
fs |
private static org.apache.commons.logging.Log |
LOG |
private org.apache.hadoop.fs.Path |
oldFileDir |
protected Map<String,Object> |
params |
Constructor and Description |
---|
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) |
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,
Map<String,Object> params) |
Modifier and Type | Method and Description |
---|---|
(package private) boolean |
checkAndDeleteDirectory(org.apache.hadoop.fs.Path dir)
Attempt to delete a directory and all files under that directory.
|
private boolean |
checkAndDeleteEntries(org.apache.hadoop.fs.FileStatus[] entries)
Loop over the given directory entries, and check whether they can be deleted.
|
private boolean |
checkAndDeleteFiles(List<org.apache.hadoop.fs.FileStatus> files)
Run the given files through each of the cleaners to see if it should be deleted, deleting it if
necessary.
|
protected void |
chore()
The task to execute on each scheduled execution of the Chore
|
void |
cleanup()
Override to run cleanup tasks when the Chore encounters an error and must stop running
|
private void |
initCleanerChain(String confKey)
Instantiate and initialize all the file cleaners set in the configuration
|
private 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.
|
cancel, cancel, choreForTesting, getInitialDelay, getName, getPeriod, getStopper, getTimeUnit, initialChore, isInitialChoreComplete, isScheduled, run, toString, triggerNow
private static final org.apache.commons.logging.Log LOG
private final org.apache.hadoop.fs.FileSystem fs
private final org.apache.hadoop.fs.Path oldFileDir
private final org.apache.hadoop.conf.Configuration conf
protected List<T extends FileCleanerDelegate> cleanersChain
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)
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, Map<String,Object> params)
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 instantiateparams
- members could be used in cleanerprotected abstract boolean validate(org.apache.hadoop.fs.Path file)
file
- full Path
of the file to be checkedprivate void initCleanerChain(String confKey)
confKey
- key to get the file cleaner classes from the configurationprivate T newFileCleaner(String className, org.apache.hadoop.conf.Configuration conf)
className
- fully qualified class name of the LogCleanerDelegateconf
- protected void chore()
ScheduledChore
chore
in class ScheduledChore
private boolean checkAndDeleteEntries(org.apache.hadoop.fs.FileStatus[] entries)
entries
- directory entries to checkboolean checkAndDeleteDirectory(org.apache.hadoop.fs.Path dir)
If new children files are added between checks of the directory, the directory will not be deleted.
dir
- directory to checkprivate boolean checkAndDeleteFiles(List<org.apache.hadoop.fs.FileStatus> files)
files
- List of FileStatus for the files to check (and possibly delete)public void cleanup()
ScheduledChore
cleanup
in class ScheduledChore
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.