T - Cleaner delegate class that is dynamically loaded from configuration@InterfaceAudience.Private public abstract class CleanerChore<T extends FileCleanerDelegate> extends ScheduledChore implements ConfigurationObserver
| Modifier and Type | Class and Description | 
|---|---|
| private static interface  | CleanerChore.Action<T> | 
| private class  | CleanerChore.CleanerTaskAttemps to clean up a directory, its subdirectories, and files. | 
| Modifier and Type | Field and Description | 
|---|---|
| private static int | AVAIL_PROCESSORS | 
| static String | CHORE_POOL_SIZEIf it is an integer and >= 1, it would be the size;
 if 0.0 < size <= 1.0, size would be available processors * size. | 
| private static ForkJoinPool | CHOREPOOL | 
| private static int | CHOREPOOLSIZE | 
| protected List<T> | cleanersChain | 
| private org.apache.hadoop.conf.Configuration | conf | 
| private static String | DEFAULT_CHORE_POOL_SIZE | 
| private AtomicBoolean | enabled | 
| protected org.apache.hadoop.fs.FileSystem | fs | 
| private static org.slf4j.Logger | LOG | 
| private org.apache.hadoop.fs.Path | oldFileDir | 
| protected Map<String,Object> | params | 
| private AtomicBoolean | reconfig | 
| 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) static int | calculatePoolSize(String poolSize)Calculate size for cleaner pool. | 
| 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 | 
| protected int | deleteFiles(Iterable<org.apache.hadoop.fs.FileStatus> filesToDelete)Delete the given files | 
| (package private) int | getChorePoolSize() | 
| boolean | getEnabled() | 
| 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. | 
| void | onConfigurationChange(org.apache.hadoop.conf.Configuration conf)This method would be called by the  ConfigurationManagerobject when theConfigurationobject is reloaded from disk. | 
| private void | preRunCleaner() | 
| Boolean | runCleaner() | 
| boolean | setEnabled(boolean enabled) | 
| private void | sortByConsumedSpace(List<org.apache.hadoop.fs.FileStatus> dirs)Sort the given list in (descending) order of the space each element takes | 
| private void | updateChorePoolSize(int updatedSize) | 
| 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, triggerNowprivate static final org.slf4j.Logger LOG
private static final int AVAIL_PROCESSORS
public static final String CHORE_POOL_SIZE
private static final String DEFAULT_CHORE_POOL_SIZE
private static volatile ForkJoinPool CHOREPOOL
private static volatile int CHOREPOOLSIZE
protected final org.apache.hadoop.fs.FileSystem fs
private final org.apache.hadoop.fs.Path oldFileDir
private final org.apache.hadoop.conf.Configuration conf
private final AtomicBoolean enabled
private final AtomicBoolean reconfig
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 cleanerstatic int calculatePoolSize(String poolSize)
poolSize - size from configurationprotected 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 configurationpublic void onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
ConfigurationObserverConfigurationManager
 object when the Configuration object is reloaded from disk.onConfigurationChange in interface ConfigurationObserverprivate void updateChorePoolSize(int updatedSize)
private T newFileCleaner(String className, org.apache.hadoop.conf.Configuration conf)
className - fully qualified class name of the LogCleanerDelegateconf - used configurationprotected void chore()
ScheduledChorechore in class ScheduledChoreprivate void preRunCleaner()
public Boolean runCleaner()
private void sortByConsumedSpace(List<org.apache.hadoop.fs.FileStatus> dirs)
dirs - the list to sort, element in it should be directory (not file)private boolean checkAndDeleteFiles(List<org.apache.hadoop.fs.FileStatus> files)
files - List of FileStatus for the files to check (and possibly delete)protected int deleteFiles(Iterable<org.apache.hadoop.fs.FileStatus> filesToDelete)
filesToDelete - files to deletepublic void cleanup()
ScheduledChorecleanup in class ScheduledChoreint getChorePoolSize()
public boolean setEnabled(boolean enabled)
enabled - public boolean getEnabled()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.