public final class InternalFileUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static Set<String> |
getAllOpenFiles()
Get the distinct files currently open by any process
|
static boolean |
getAllOpenFilesIsSupportedOnOS()
Will
getAllOpenFiles() work on the current OS? |
static boolean |
hasQueueSuffix(@NotNull File file)
Returns if the provided
file has the Chronicle Queue file
suffix. |
static @NotNull Stream<File> |
removableRollFileCandidates(@NotNull File baseDir)
Returns a Stream of roll Queue files that are likely removable
from the given
baseDir without affecting any Queue
process that is currently active in the given baseDir reading
data sequentially. |
static FileState |
state(@NotNull File file)
Returns if the given
file is used by any process (i.e. |
static FileState |
state(@NotNull File file,
Set<String> allOpenFiles)
Returns if the given
file is used by any process (i.e. |
@NotNull public static @NotNull Stream<File> removableRollFileCandidates(@NotNull @NotNull File baseDir)
baseDir without affecting any Queue
process that is currently active in the given baseDir reading
data sequentially.
Files are returned in order of creation and can successively be removed in that order. If the removal of a particular file fails, then subsequent files must be untouched.
WARNING: This method is inherently un-deterministic as new Queue processes may join or leave at any time asynchronously. Thus, it is not recommended to store results produced by this method for longer periods.
Only sequential reading is supported because random access Tailers can read at any location at any time.
Here is an example of how unused files can be removed:
for (File file : removableFileCandidates(baseDir).collect(Collectors.toList())) {
if (!file.delete()) {
break;
}
}
baseDir - containing queue file removal candidatesbaseDir without affecting any Queue
process that is currently active in the given baseDir
reading data sequentiallyUnsupportedOperationException - if this operation is not
supported for the current platform (e.g. Windows).public static boolean hasQueueSuffix(@NotNull
@NotNull File file)
file has the Chronicle Queue file
suffix. The current file suffix is ".cq4".file - to checkfile has the ChronicleQueue file suffixpublic static FileState state(@NotNull @NotNull File file)
file is used by any process (i.e.
has the file open for reading or writing).
If the open state of the given file can not be determined, true
is returned.
file - to checkfile is used by any processUnsupportedOperationException - if this operation is not
supported for the current platform (e.g. Windows).public static FileState state(@NotNull @NotNull File file, Set<String> allOpenFiles)
file is used by any process (i.e.
has the file open for reading or writing).
If the open state of the given file can not be determined, true
is returned.
file - to checkallOpenFiles - The set of all open files retrieve from getAllOpenFiles()file is used by any processUnsupportedOperationException - if this operation is not
supported for the current platform (e.g. Windows).public static boolean getAllOpenFilesIsSupportedOnOS()
getAllOpenFiles() work on the current OS?public static Set<String> getAllOpenFiles() throws IOException
Set of the absolute paths to all the open files on the systemIOException - if we can't get the open filesCopyright © 2024. All rights reserved.