public class DirectoryCleaner extends Object
Provide methods to help Logviewer to clean up files in directories and to get a list of files without worrying about excessive memory usage.
Constructor and Description |
---|
DirectoryCleaner() |
Modifier and Type | Method and Description |
---|---|
int |
deleteOldestWhileTooLarge(List<File> dirs,
long quota,
boolean for_per_dir,
Set<String> active_dirs)
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.
|
static List<File> |
getFilesForDir(File dir) |
DirectoryStream<Path> |
getStreamForDirectory(File dir) |
public DirectoryStream<Path> getStreamForDirectory(File dir) throws IOException
IOException
public int deleteOldestWhileTooLarge(List<File> dirs, long quota, boolean for_per_dir, Set<String> active_dirs) 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 for_per_dir to switch between the two deletion modes.
dirs
- the list of directories to be scanned for deletionquota
- the per-dir quota or the total quota for the all directoriesfor_per_dir
- if true, deletion happens for a single dir; otherwise, for all directories globallyactive_dirs
- only for global deletion, we want to skip the active logs in active_dirsIOException
public static List<File> getFilesForDir(File dir) throws IOException
IOException
Copyright © 2019 The Apache Software Foundation. All Rights Reserved.