Class DirectoryCleaner
java.lang.Object
org.apache.storm.daemon.logviewer.utils.DirectoryCleaner
Provide methods to help Logviewer to clean up
 files in directories and to get a list of files without
 worrying about excessive memory usage.
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionorg.apache.storm.daemon.logviewer.utils.DeletionMetadeleteOldestWhileTooLarge(List<Path> dirs, long quota, boolean forPerDir, Set<Path> activeDirs) If totalSize of files exceeds the either the per-worker quota or global quota, Logviewer deletes oldest inactive log files in a worker directory or in all worker dirs.getFilesForDir(Path dir) Lists files in directory.Creates DirectoryStream for give directory.
- 
Field Details- 
MAX_NUMBER_OF_FILES_FOR_DIRpublic static final int MAX_NUMBER_OF_FILES_FOR_DIR- See Also:
 
 
- 
- 
Constructor Details- 
DirectoryCleaner
 
- 
- 
Method Details- 
getStreamForDirectoryCreates DirectoryStream for give directory.- Parameters:
- dir- File instance representing specific directory
- Returns:
- DirectoryStream
- Throws:
- IOException
 
- 
deleteOldestWhileTooLargepublic org.apache.storm.daemon.logviewer.utils.DeletionMeta deleteOldestWhileTooLarge(List<Path> dirs, long quota, boolean forPerDir, Set<Path> activeDirs) throws IOException If totalSize of files exceeds the either the per-worker quota or global quota, Logviewer deletes oldest inactive log files in a worker directory or in all worker dirs. We use the parameter forPerDir to switch between the two deletion modes.- Parameters:
- dirs- the list of directories to be scanned for deletion
- quota- the per-dir quota or the total quota for the all directories
- forPerDir- if true, deletion happens for a single dir; otherwise, for all directories globally
- activeDirs- only for global deletion, we want to skip the active logs in activeDirs
- Returns:
- number of files deleted
- Throws:
- IOException
 
- 
getFilesForDirLists files in directory. Note that to avoid memory problem, we only return the first 1024 files in a directory.- Parameters:
- dir- directory to get file list
- Returns:
- files in directory
- Throws:
- IOException
 
 
-