java.lang.Object
org.elasticsearch.watcher.AbstractResourceWatcher<FileChangesListener>
org.elasticsearch.watcher.FileWatcher
- All Implemented Interfaces:
ResourceWatcher
File resources watcher
The file watcher checks directory and all its subdirectories for file changes and notifies its listeners accordingly
-
Constructor Summary
ConstructorsConstructorDescriptionFileWatcher(Path path) Creates new file watcher on the given directoryFileWatcher(Path path, boolean checkFileContents) Creates new file watcher on the given directory -
Method Summary
Modifier and TypeMethodDescriptionvoidClears any state with the FileWatcher, making all files show up as newprotected voidWill be called periodicallyprotected voiddoInit()Will be called once on initializationprotected booleanfileExists(Path path) getPath()protected DirectoryStream<Path> protected InputStreamnewInputStream(Path path) protected BasicFileAttributesreadAttributes(Path path) Methods inherited from class org.elasticsearch.watcher.AbstractResourceWatcher
addListener, checkAndNotify, init, listeners, remove
-
Constructor Details
-
FileWatcher
Creates new file watcher on the given directory- Parameters:
path- the directory to watch
-
FileWatcher
Creates new file watcher on the given directory- Parameters:
path- the directory to watchcheckFileContents- whether to inspect the content of the file for changes (via a message digest) - this is a "best efforts" check and will err on the side of sending extra change notifications if the file might have changed.
-
-
Method Details
-
getPath
-
clearState
public void clearState()Clears any state with the FileWatcher, making all files show up as new -
doInit
Description copied from class:AbstractResourceWatcherWill be called once on initialization- Specified by:
doInitin classAbstractResourceWatcher<FileChangesListener>- Throws:
IOException
-
doCheckAndNotify
Description copied from class:AbstractResourceWatcherWill be called periodicallyImplementing watcher should check resource and notify all
AbstractResourceWatcher.listeners().- Specified by:
doCheckAndNotifyin classAbstractResourceWatcher<FileChangesListener>- Throws:
IOException
-
fileExists
-
readAttributes
- Throws:
IOException
-
newInputStream
- Throws:
IOException
-
listFiles
- Throws:
IOException
-