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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.storm.daemon.logviewer.utils.DeletionMeta
deleteOldestWhileTooLarge
(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_DIR
public static final int MAX_NUMBER_OF_FILES_FOR_DIR- See Also:
-
-
Constructor Details
-
DirectoryCleaner
-
-
Method Details
-
getStreamForDirectory
Creates DirectoryStream for give directory.- Parameters:
dir
- File instance representing specific directory- Returns:
- DirectoryStream
- Throws:
IOException
-
deleteOldestWhileTooLarge
public 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 deletionquota
- the per-dir quota or the total quota for the all directoriesforPerDir
- if true, deletion happens for a single dir; otherwise, for all directories globallyactiveDirs
- only for global deletion, we want to skip the active logs in activeDirs- Returns:
- number of files deleted
- Throws:
IOException
-
getFilesForDir
Lists 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
-