Package org.apache.lucene.util
Class FileDeleter
java.lang.Object
org.apache.lucene.util.FileDeleter
This class provides ability to track the reference counts of a set of index files and delete them
when their counts decreased to 0.
This class is NOT thread-safe, the user should make sure the thread-safety themselves
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Types of messages this file deleter will broadcast REF: messages about reference FILE: messages about filestatic final class
Tracks the reference count for a single index file: -
Constructor Summary
ConstructorDescriptionFileDeleter
(Directory directory, BiConsumer<FileDeleter.MsgType, String> messenger) Create a new FileDeleter with a messenger consumes various verbose messages -
Method Summary
Modifier and TypeMethodDescriptionvoid
decRef
(Collection<String> fileNames) Decrease ref counts for all provided files, delete them if ref counts down to 0, even on exception.void
deleteFileIfNoRef
(String fileName) void
deleteFilesIfNoRef
(Collection<String> files) delete only files that are unref'edboolean
return true only if file is touched and also has larger than 0 ref countvoid
forceDelete
(String fileName) get all files, some of them may have ref count 0int
getRefCount
(String fileName) get ref count for a provided file, if the file is not yet recorded, this method will return 0get files that are touched but not incref'edvoid
void
incRef
(Collection<String> fileNames) void
initRefCount
(String fileName) if the file is not yet recorded, this method will create a new RefCount object with count 0
-
Constructor Details
-
FileDeleter
Create a new FileDeleter with a messenger consumes various verbose messages- Parameters:
directory
- the index directorymessenger
- two arguments will be passed in,FileDeleter.MsgType
and the actual message in String. Can be null if the user do not want debug infos
-
-
Method Details
-
incRef
-
incRef
-
decRef
Decrease ref counts for all provided files, delete them if ref counts down to 0, even on exception. Throw first exception hit, if any- Throws:
IOException
-
initRefCount
if the file is not yet recorded, this method will create a new RefCount object with count 0 -
getRefCount
get ref count for a provided file, if the file is not yet recorded, this method will return 0 -
getAllFiles
get all files, some of them may have ref count 0 -
exists
return true only if file is touched and also has larger than 0 ref count -
getUnrefedFiles
get files that are touched but not incref'ed -
deleteFilesIfNoRef
delete only files that are unref'ed- Throws:
IOException
-
forceDelete
- Throws:
IOException
-
deleteFileIfNoRef
- Throws:
IOException
-