Package org.elasticsearch.watcher
Class ResourceWatcherService
- java.lang.Object
-
- org.elasticsearch.common.component.AbstractComponent
-
- 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 usingadd(ResourceWatcher)
method. This service will callResourceWatcher.checkAndNotify()
method of all registered watcher periodically. The frequency of checks can be specified usingresource.reload.interval
setting, which defaults to60s
. The service can be disabled by settingresource.reload.enabled
setting tofalse
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ResourceWatcherService.Frequency
-
Field Summary
Fields Modifier and Type Field Description static Setting<java.lang.Boolean>
ENABLED
static Setting<TimeValue>
RELOAD_INTERVAL_HIGH
static Setting<TimeValue>
RELOAD_INTERVAL_LOW
static Setting<TimeValue>
RELOAD_INTERVAL_MEDIUM
-
Fields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle
-
Fields inherited from class org.elasticsearch.common.component.AbstractComponent
deprecationLogger, logger, settings
-
-
Constructor Summary
Constructors Constructor Description ResourceWatcherService(Settings settings, ThreadPool threadPool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <W extends ResourceWatcher>
WatcherHandle<W>add(W watcher)
Register new resource watcher that will be checked in defaultMEDIUM
frequency<W extends ResourceWatcher>
WatcherHandle<W>add(W watcher, ResourceWatcherService.Frequency frequency)
Register new resource watcher that will be checked in the given frequencyprotected void
doClose()
protected void
doStart()
protected void
doStop()
void
notifyNow()
void
notifyNow(ResourceWatcherService.Frequency frequency)
-
Methods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
-
Methods inherited from class org.elasticsearch.common.component.AbstractComponent
nodeName
-
-
-
-
Field Detail
-
ENABLED
public static final Setting<java.lang.Boolean> ENABLED
-
-
Constructor Detail
-
ResourceWatcherService
@Inject public ResourceWatcherService(Settings settings, ThreadPool threadPool)
-
-
Method Detail
-
doStart
protected void doStart()
- Specified by:
doStart
in classAbstractLifecycleComponent
-
doStop
protected void doStop()
- Specified by:
doStop
in classAbstractLifecycleComponent
-
doClose
protected void doClose()
- Specified by:
doClose
in classAbstractLifecycleComponent
-
add
public <W extends ResourceWatcher> WatcherHandle<W> add(W watcher) throws java.io.IOException
Register new resource watcher that will be checked in defaultMEDIUM
frequency- Throws:
java.io.IOException
-
add
public <W extends ResourceWatcher> WatcherHandle<W> add(W watcher, ResourceWatcherService.Frequency frequency) throws java.io.IOException
Register new resource watcher that will be checked in the given frequency- Throws:
java.io.IOException
-
notifyNow
public void notifyNow()
-
notifyNow
public void notifyNow(ResourceWatcherService.Frequency frequency)
-
-