convert settings for ResourceWatcherService to new infrastructure

This commit converts the settings for the ResourceWatcherService to use the new infrastructure and
registers the settings so that they do not cause errors when used.
This commit is contained in:
jaymode 2016-04-25 06:24:38 -04:00
parent 5fe1916be9
commit e70420ef2b
2 changed files with 20 additions and 6 deletions

View File

@ -94,6 +94,7 @@ import org.elasticsearch.transport.TransportService;
import org.elasticsearch.transport.TransportSettings; import org.elasticsearch.transport.TransportSettings;
import org.elasticsearch.transport.netty.NettyTransport; import org.elasticsearch.transport.netty.NettyTransport;
import org.elasticsearch.tribe.TribeService; import org.elasticsearch.tribe.TribeService;
import org.elasticsearch.watcher.ResourceWatcherService;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@ -411,6 +412,10 @@ public final class ClusterSettings extends AbstractScopedSettings {
IndexingMemoryController.MIN_INDEX_BUFFER_SIZE_SETTING, IndexingMemoryController.MIN_INDEX_BUFFER_SIZE_SETTING,
IndexingMemoryController.MAX_INDEX_BUFFER_SIZE_SETTING, IndexingMemoryController.MAX_INDEX_BUFFER_SIZE_SETTING,
IndexingMemoryController.SHARD_INACTIVE_TIME_SETTING, IndexingMemoryController.SHARD_INACTIVE_TIME_SETTING,
IndexingMemoryController.SHARD_MEMORY_INTERVAL_TIME_SETTING IndexingMemoryController.SHARD_MEMORY_INTERVAL_TIME_SETTING,
ResourceWatcherService.ENABLED,
ResourceWatcherService.RELOAD_INTERVAL_HIGH,
ResourceWatcherService.RELOAD_INTERVAL_MEDIUM,
ResourceWatcherService.RELOAD_INTERVAL_LOW
))); )));
} }

View File

@ -20,6 +20,8 @@ package org.elasticsearch.watcher;
import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.FutureUtils; import org.elasticsearch.common.util.concurrent.FutureUtils;
@ -64,6 +66,14 @@ public class ResourceWatcherService extends AbstractLifecycleComponent<ResourceW
} }
} }
public static final Setting<Boolean> ENABLED = Setting.boolSetting("resource.reload.enabled", true, Property.NodeScope);
public static final Setting<TimeValue> RELOAD_INTERVAL_HIGH =
Setting.timeSetting("resource.reload.interval.high", Frequency.HIGH.interval, Property.NodeScope);
public static final Setting<TimeValue> RELOAD_INTERVAL_MEDIUM = Setting.timeSetting("resource.reload.interval.medium",
Setting.timeSetting("resource.reload.interval", Frequency.MEDIUM.interval), Property.NodeScope);
public static final Setting<TimeValue> RELOAD_INTERVAL_LOW =
Setting.timeSetting("resource.reload.interval.low", Frequency.LOW.interval, Property.NodeScope);
private final boolean enabled; private final boolean enabled;
private final ThreadPool threadPool; private final ThreadPool threadPool;
@ -78,15 +88,14 @@ public class ResourceWatcherService extends AbstractLifecycleComponent<ResourceW
@Inject @Inject
public ResourceWatcherService(Settings settings, ThreadPool threadPool) { public ResourceWatcherService(Settings settings, ThreadPool threadPool) {
super(settings); super(settings);
this.enabled = settings.getAsBoolean("resource.reload.enabled", true); this.enabled = ENABLED.get(settings);
this.threadPool = threadPool; this.threadPool = threadPool;
TimeValue interval = settings.getAsTime("resource.reload.interval.low", Frequency.LOW.interval); TimeValue interval = RELOAD_INTERVAL_LOW.get(settings);
lowMonitor = new ResourceMonitor(interval, Frequency.LOW); lowMonitor = new ResourceMonitor(interval, Frequency.LOW);
interval = settings.getAsTime("resource.reload.interval.medium", interval = RELOAD_INTERVAL_MEDIUM.get(settings);
settings.getAsTime("resource.reload.interval", Frequency.MEDIUM.interval));
mediumMonitor = new ResourceMonitor(interval, Frequency.MEDIUM); mediumMonitor = new ResourceMonitor(interval, Frequency.MEDIUM);
interval = settings.getAsTime("resource.reload.interval.high", Frequency.HIGH.interval); interval = RELOAD_INTERVAL_HIGH.get(settings);
highMonitor = new ResourceMonitor(interval, Frequency.HIGH); highMonitor = new ResourceMonitor(interval, Frequency.HIGH);
logRemovedSetting("watcher.enabled", "resource.reload.enabled"); logRemovedSetting("watcher.enabled", "resource.reload.enabled");