Class AbstractFileWatchingService

java.lang.Object
org.elasticsearch.common.component.AbstractLifecycleComponent
org.elasticsearch.common.file.AbstractFileWatchingService
All Implemented Interfaces:
Closeable, AutoCloseable, LifecycleComponent, Releasable
Direct Known Subclasses:
MasterNodeFileWatchingService

public abstract class AbstractFileWatchingService extends AbstractLifecycleComponent
A skeleton service for watching and reacting to a single file changing on disk

A file watching service watches for changes in a particular file on disk. There are three assumptions about the file structure:

  1. The file itself may or may not exist.
  2. The file's parent directory may or may not exist.
  3. The directory above the file's parent directory must always exist.

For example, if the watched file is under /usr/elastic/elasticsearch/conf/special/settings.yml, then /usr/elastic/elasticsearch/conf/ must exist, but special/ and special/settings.yml may be created, updated, or deleted during runtime.

What this class does not do is define what should happen after the file changes. An implementation class should override processFileChanges() to define the correct behavior.