Package org.elasticsearch.watcher
Class ResourceWatcherService
java.lang.Object
org.elasticsearch.common.component.AbstractLifecycleComponent
org.elasticsearch.watcher.ResourceWatcherService
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,LifecycleComponent,Releasable
public class ResourceWatcherService extends AbstractLifecycleComponent
Generic resource watcher service
Other elasticsearch services can register their resource watchers with this service using
add(ResourceWatcher)
method. This service will call ResourceWatcher.checkAndNotify() method of all
registered watcher periodically. The frequency of checks can be specified using resource.reload.interval setting, which
defaults to 60s. The service can be disabled by setting resource.reload.enabled setting to false.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classResourceWatcherService.Frequency -
Field Summary
Fields Modifier and Type Field Description static Setting<java.lang.Boolean>ENABLEDstatic Setting<TimeValue>RELOAD_INTERVAL_HIGHstatic Setting<TimeValue>RELOAD_INTERVAL_LOWstatic Setting<TimeValue>RELOAD_INTERVAL_MEDIUM -
Constructor Summary
Constructors Constructor Description ResourceWatcherService(Settings settings, ThreadPool threadPool) -
Method Summary
Modifier and Type Method Description <W extends ResourceWatcher>
WatcherHandle<W>add(W watcher)Register new resource watcher that will be checked in defaultMEDIUMfrequency<W extends ResourceWatcher>
WatcherHandle<W>add(W watcher, ResourceWatcherService.Frequency frequency)Register new resource watcher that will be checked in the given frequencyprotected voiddoClose()protected voiddoStart()protected voiddoStop()voidnotifyNow()voidnotifyNow(ResourceWatcherService.Frequency frequency)Methods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
-
Field Details
-
Constructor Details
-
Method Details
-
doStart
protected void doStart()- Specified by:
doStartin classAbstractLifecycleComponent
-
doStop
protected void doStop()- Specified by:
doStopin classAbstractLifecycleComponent
-
doClose
protected void doClose()- Specified by:
doClosein classAbstractLifecycleComponent
-
add
Register new resource watcher that will be checked in defaultMEDIUMfrequency- Throws:
java.io.IOException
-
add
public <W extends ResourceWatcher> WatcherHandle<W> add(W watcher, ResourceWatcherService.Frequency frequency) throws java.io.IOExceptionRegister new resource watcher that will be checked in the given frequency- Throws:
java.io.IOException
-
notifyNow
public void notifyNow() -
notifyNow
-