fold ClusterSettingsService into ClusterSettings
This commit is contained in:
parent
edd98b0e6c
commit
c9d7c92243
|
@ -24,7 +24,6 @@ import org.elasticsearch.cluster.block.ClusterBlocks;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.common.regex.Regex;
|
import org.elasticsearch.common.regex.Regex;
|
||||||
import org.elasticsearch.common.settings.ClusterSettings;
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -40,12 +39,10 @@ import static org.elasticsearch.cluster.ClusterState.builder;
|
||||||
final class SettingsUpdater {
|
final class SettingsUpdater {
|
||||||
final Settings.Builder transientUpdates = Settings.settingsBuilder();
|
final Settings.Builder transientUpdates = Settings.settingsBuilder();
|
||||||
final Settings.Builder persistentUpdates = Settings.settingsBuilder();
|
final Settings.Builder persistentUpdates = Settings.settingsBuilder();
|
||||||
private final ClusterSettings dynamicSettings;
|
private final ClusterSettings clusterSettings;
|
||||||
private final ClusterSettingsService clusterSettingsService;
|
|
||||||
|
|
||||||
SettingsUpdater(ClusterSettingsService clusterSettingsService) {
|
SettingsUpdater(ClusterSettings clusterSettings) {
|
||||||
this.dynamicSettings = clusterSettingsService.getClusterSettings();
|
this.clusterSettings = clusterSettings;
|
||||||
this.clusterSettingsService = clusterSettingsService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized Settings getTransientUpdates() {
|
synchronized Settings getTransientUpdates() {
|
||||||
|
@ -85,7 +82,7 @@ final class SettingsUpdater {
|
||||||
Settings settings = build.metaData().settings();
|
Settings settings = build.metaData().settings();
|
||||||
// now we try to apply things and if they are invalid we fail
|
// now we try to apply things and if they are invalid we fail
|
||||||
// this dryRun will validate & parse settings but won't actually apply them.
|
// this dryRun will validate & parse settings but won't actually apply them.
|
||||||
clusterSettingsService.dryRun(settings);
|
clusterSettings.dryRun(settings);
|
||||||
return build;
|
return build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +93,7 @@ final class SettingsUpdater {
|
||||||
for (Map.Entry<String, String> entry : toApply.getAsMap().entrySet()) {
|
for (Map.Entry<String, String> entry : toApply.getAsMap().entrySet()) {
|
||||||
if (entry.getValue() == null) {
|
if (entry.getValue() == null) {
|
||||||
toRemove.add(entry.getKey());
|
toRemove.add(entry.getKey());
|
||||||
} else if (dynamicSettings.isLoggerSetting(entry.getKey()) || dynamicSettings.hasDynamicSetting(entry.getKey())) {
|
} else if (clusterSettings.isLoggerSetting(entry.getKey()) || clusterSettings.hasDynamicSetting(entry.getKey())) {
|
||||||
settingsBuilder.put(entry.getKey(), entry.getValue());
|
settingsBuilder.put(entry.getKey(), entry.getValue());
|
||||||
updates.put(entry.getKey(), entry.getValue());
|
updates.put(entry.getKey(), entry.getValue());
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|
|
@ -36,8 +36,8 @@ import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.Priority;
|
import org.elasticsearch.common.Priority;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
@ -50,14 +50,14 @@ public class TransportClusterUpdateSettingsAction extends TransportMasterNodeAct
|
||||||
|
|
||||||
private final AllocationService allocationService;
|
private final AllocationService allocationService;
|
||||||
|
|
||||||
private final ClusterSettingsService clusterSettingsService;
|
private final ClusterSettings clusterSettings;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportClusterUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
public TransportClusterUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||||
AllocationService allocationService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, ClusterSettingsService clusterSettingsService) {
|
AllocationService allocationService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, ClusterSettings clusterSettings) {
|
||||||
super(settings, ClusterUpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterUpdateSettingsRequest::new);
|
super(settings, ClusterUpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterUpdateSettingsRequest::new);
|
||||||
this.allocationService = allocationService;
|
this.allocationService = allocationService;
|
||||||
this.clusterSettingsService = clusterSettingsService;
|
this.clusterSettings = clusterSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,7 +83,7 @@ public class TransportClusterUpdateSettingsAction extends TransportMasterNodeAct
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void masterOperation(final ClusterUpdateSettingsRequest request, final ClusterState state, final ActionListener<ClusterUpdateSettingsResponse> listener) {
|
protected void masterOperation(final ClusterUpdateSettingsRequest request, final ClusterState state, final ActionListener<ClusterUpdateSettingsResponse> listener) {
|
||||||
final SettingsUpdater updater = new SettingsUpdater(clusterSettingsService);
|
final SettingsUpdater updater = new SettingsUpdater(clusterSettings);
|
||||||
clusterService.submitStateUpdateTask("cluster_update_settings",
|
clusterService.submitStateUpdateTask("cluster_update_settings",
|
||||||
new AckedClusterStateUpdateTask<ClusterUpdateSettingsResponse>(Priority.IMMEDIATE, request, listener) {
|
new AckedClusterStateUpdateTask<ClusterUpdateSettingsResponse>(Priority.IMMEDIATE, request, listener) {
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,9 @@ import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataIndexStateService;
|
import org.elasticsearch.cluster.metadata.MetaDataIndexStateService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
@ -50,13 +50,13 @@ public class TransportCloseIndexAction extends TransportMasterNodeAction<CloseIn
|
||||||
@Inject
|
@Inject
|
||||||
public TransportCloseIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportCloseIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, MetaDataIndexStateService indexStateService,
|
ThreadPool threadPool, MetaDataIndexStateService indexStateService,
|
||||||
ClusterSettingsService clusterSettingsService, ActionFilters actionFilters,
|
ClusterSettings clusterSettings, ActionFilters actionFilters,
|
||||||
IndexNameExpressionResolver indexNameExpressionResolver, DestructiveOperations destructiveOperations) {
|
IndexNameExpressionResolver indexNameExpressionResolver, DestructiveOperations destructiveOperations) {
|
||||||
super(settings, CloseIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, CloseIndexRequest::new);
|
super(settings, CloseIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, CloseIndexRequest::new);
|
||||||
this.indexStateService = indexStateService;
|
this.indexStateService = indexStateService;
|
||||||
this.destructiveOperations = destructiveOperations;
|
this.destructiveOperations = destructiveOperations;
|
||||||
this.closeIndexEnabled = CLUSTER_INDICES_CLOSE_ENABLE_SETTING.get(settings);
|
this.closeIndexEnabled = CLUSTER_INDICES_CLOSE_ENABLE_SETTING.get(settings);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_INDICES_CLOSE_ENABLE_SETTING, this::setCloseIndexEnabled);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_INDICES_CLOSE_ENABLE_SETTING, this::setCloseIndexEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCloseIndexEnabled(boolean closeIndexEnabled) {
|
private void setCloseIndexEnabled(boolean closeIndexEnabled) {
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataDeleteIndexService;
|
import org.elasticsearch.cluster.metadata.MetaDataDeleteIndexService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
@ -45,8 +44,7 @@ public class TransportDeleteIndexAction extends TransportMasterNodeAction<Delete
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportDeleteIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportDeleteIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, MetaDataDeleteIndexService deleteIndexService,
|
ThreadPool threadPool, MetaDataDeleteIndexService deleteIndexService, ActionFilters actionFilters,
|
||||||
ClusterSettingsService clusterSettingsService, ActionFilters actionFilters,
|
|
||||||
IndexNameExpressionResolver indexNameExpressionResolver, DestructiveOperations destructiveOperations) {
|
IndexNameExpressionResolver indexNameExpressionResolver, DestructiveOperations destructiveOperations) {
|
||||||
super(settings, DeleteIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteIndexRequest::new);
|
super(settings, DeleteIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteIndexRequest::new);
|
||||||
this.deleteIndexService = deleteIndexService;
|
this.deleteIndexService = deleteIndexService;
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataIndexStateService;
|
import org.elasticsearch.cluster.metadata.MetaDataIndexStateService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
@ -47,7 +46,7 @@ public class TransportOpenIndexAction extends TransportMasterNodeAction<OpenInde
|
||||||
@Inject
|
@Inject
|
||||||
public TransportOpenIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportOpenIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, MetaDataIndexStateService indexStateService,
|
ThreadPool threadPool, MetaDataIndexStateService indexStateService,
|
||||||
ClusterSettingsService clusterSettingsService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
|
||||||
DestructiveOperations destructiveOperations) {
|
DestructiveOperations destructiveOperations) {
|
||||||
super(settings, OpenIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, OpenIndexRequest::new);
|
super(settings, OpenIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, OpenIndexRequest::new);
|
||||||
this.indexStateService = indexStateService;
|
this.indexStateService = indexStateService;
|
||||||
|
|
|
@ -21,9 +21,9 @@ package org.elasticsearch.action.support;
|
||||||
|
|
||||||
import org.elasticsearch.common.component.AbstractComponent;
|
import org.elasticsearch.common.component.AbstractComponent;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for dealing with destructive operations and wildcard usage.
|
* Helper for dealing with destructive operations and wildcard usage.
|
||||||
|
@ -37,10 +37,10 @@ public final class DestructiveOperations extends AbstractComponent {
|
||||||
private volatile boolean destructiveRequiresName;
|
private volatile boolean destructiveRequiresName;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DestructiveOperations(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public DestructiveOperations(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
destructiveRequiresName = REQUIRES_NAME_SETTING.get(settings);
|
destructiveRequiresName = REQUIRES_NAME_SETTING.get(settings);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(REQUIRES_NAME_SETTING, this::setDestructiveRequiresName);
|
clusterSettings.addSettingsUpdateConsumer(REQUIRES_NAME_SETTING, this::setDestructiveRequiresName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDestructiveRequiresName(boolean destructiveRequiresName) {
|
private void setDestructiveRequiresName(boolean destructiveRequiresName) {
|
||||||
|
|
|
@ -62,7 +62,6 @@ import org.elasticsearch.cluster.settings.Validator;
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
import org.elasticsearch.common.inject.AbstractModule;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.util.ExtensionPoint;
|
import org.elasticsearch.common.util.ExtensionPoint;
|
||||||
|
@ -262,8 +261,8 @@ public class ClusterModule extends AbstractModule {
|
||||||
bind(NodeIndexDeletedAction.class).asEagerSingleton();
|
bind(NodeIndexDeletedAction.class).asEagerSingleton();
|
||||||
bind(NodeMappingRefreshAction.class).asEagerSingleton();
|
bind(NodeMappingRefreshAction.class).asEagerSingleton();
|
||||||
bind(MappingUpdatedAction.class).asEagerSingleton();
|
bind(MappingUpdatedAction.class).asEagerSingleton();
|
||||||
final ClusterSettingsService clusterSettingsService = new ClusterSettingsService(settings, new ClusterSettings(new HashSet<>(clusterDynamicSettings.values())));
|
final ClusterSettings clusterSettings = new ClusterSettings(settings, new HashSet<>(clusterDynamicSettings.values()));
|
||||||
bind(ClusterSettingsService.class).toInstance(clusterSettingsService);
|
bind(ClusterSettings.class).toInstance(clusterSettings);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,12 +37,12 @@ import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||||
import org.elasticsearch.common.component.AbstractComponent;
|
import org.elasticsearch.common.component.AbstractComponent;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
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.EsRejectedExecutionException;
|
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
|
||||||
import org.elasticsearch.monitor.fs.FsInfo;
|
import org.elasticsearch.monitor.fs.FsInfo;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.ReceiveTimeoutTransportException;
|
import org.elasticsearch.transport.ReceiveTimeoutTransportException;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class InternalClusterInfoService extends AbstractComponent implements Clu
|
||||||
private final List<Listener> listeners = new CopyOnWriteArrayList<>();
|
private final List<Listener> listeners = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public InternalClusterInfoService(Settings settings, ClusterSettingsService clusterSettingsService,
|
public InternalClusterInfoService(Settings settings, ClusterSettings clusterSettings,
|
||||||
TransportNodesStatsAction transportNodesStatsAction,
|
TransportNodesStatsAction transportNodesStatsAction,
|
||||||
TransportIndicesStatsAction transportIndicesStatsAction, ClusterService clusterService,
|
TransportIndicesStatsAction transportIndicesStatsAction, ClusterService clusterService,
|
||||||
ThreadPool threadPool) {
|
ThreadPool threadPool) {
|
||||||
|
@ -99,9 +99,9 @@ public class InternalClusterInfoService extends AbstractComponent implements Clu
|
||||||
this.updateFrequency = INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING.get(settings);
|
this.updateFrequency = INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING.get(settings);
|
||||||
this.fetchTimeout = INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING.get(settings);
|
this.fetchTimeout = INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING.get(settings);
|
||||||
this.enabled = DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.get(settings);
|
this.enabled = DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.get(settings);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING, this::setFetchTimeout);
|
clusterSettings.addSettingsUpdateConsumer(INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING, this::setFetchTimeout);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING, this::setUpdateFrequency);
|
clusterSettings.addSettingsUpdateConsumer(INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING, this::setUpdateFrequency);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING, this::setEnabled);
|
clusterSettings.addSettingsUpdateConsumer(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING, this::setEnabled);
|
||||||
|
|
||||||
// Add InternalClusterInfoService to listen for Master changes
|
// Add InternalClusterInfoService to listen for Master changes
|
||||||
this.clusterService.add((LocalNodeMasterListener)this);
|
this.clusterService.add((LocalNodeMasterListener)this);
|
||||||
|
|
|
@ -26,12 +26,12 @@ import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.client.IndicesAdminClient;
|
import org.elasticsearch.client.IndicesAdminClient;
|
||||||
import org.elasticsearch.common.component.AbstractComponent;
|
import org.elasticsearch.common.component.AbstractComponent;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
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.index.mapper.MapperService;
|
import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.index.mapper.Mapping;
|
import org.elasticsearch.index.mapper.Mapping;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
@ -47,10 +47,10 @@ public class MappingUpdatedAction extends AbstractComponent {
|
||||||
private volatile TimeValue dynamicMappingUpdateTimeout;
|
private volatile TimeValue dynamicMappingUpdateTimeout;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MappingUpdatedAction(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public MappingUpdatedAction(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.dynamicMappingUpdateTimeout = INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING.get(settings);
|
this.dynamicMappingUpdateTimeout = INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING.get(settings);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING, this::setDynamicMappingUpdateTimeout);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING, this::setDynamicMappingUpdateTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDynamicMappingUpdateTimeout(TimeValue dynamicMappingUpdateTimeout) {
|
private void setDynamicMappingUpdateTimeout(TimeValue dynamicMappingUpdateTimeout) {
|
||||||
|
|
|
@ -41,7 +41,6 @@ import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.gateway.PriorityComparator;
|
import org.elasticsearch.gateway.PriorityComparator;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -82,16 +81,16 @@ public class BalancedShardsAllocator extends AbstractComponent implements Shards
|
||||||
private volatile float threshold;
|
private volatile float threshold;
|
||||||
|
|
||||||
public BalancedShardsAllocator(Settings settings) {
|
public BalancedShardsAllocator(Settings settings) {
|
||||||
this(settings, new ClusterSettingsService(settings, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
|
this(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BalancedShardsAllocator(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public BalancedShardsAllocator(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
weightFunction = new WeightFunction(INDEX_BALANCE_FACTOR_SETTING.get(settings), SHARD_BALANCE_FACTOR_SETTING.get(settings));
|
weightFunction = new WeightFunction(INDEX_BALANCE_FACTOR_SETTING.get(settings), SHARD_BALANCE_FACTOR_SETTING.get(settings));
|
||||||
setThreshold(THRESHOLD_SETTING.get(settings));
|
setThreshold(THRESHOLD_SETTING.get(settings));
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDEX_BALANCE_FACTOR_SETTING, SHARD_BALANCE_FACTOR_SETTING, this::setWeightFunction);
|
clusterSettings.addSettingsUpdateConsumer(INDEX_BALANCE_FACTOR_SETTING, SHARD_BALANCE_FACTOR_SETTING, this::setWeightFunction);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(THRESHOLD_SETTING, this::setThreshold);
|
clusterSettings.addSettingsUpdateConsumer(THRESHOLD_SETTING, this::setThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWeightFunction(float indexBalance, float shardBalanceFactor) {
|
public void setWeightFunction(float indexBalance, float shardBalanceFactor) {
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -98,16 +97,16 @@ public class AwarenessAllocationDecider extends AllocationDecider {
|
||||||
* @param settings {@link Settings} to use
|
* @param settings {@link Settings} to use
|
||||||
*/
|
*/
|
||||||
public AwarenessAllocationDecider(Settings settings) {
|
public AwarenessAllocationDecider(Settings settings) {
|
||||||
this(settings, new ClusterSettingsService(settings, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
|
this(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AwarenessAllocationDecider(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public AwarenessAllocationDecider(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.awarenessAttributes = CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING.get(settings);
|
this.awarenessAttributes = CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING.get(settings);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING, this::setAwarenessAttributes);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING, this::setAwarenessAttributes);
|
||||||
setForcedAwarenessAttributes(CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING.get(settings));
|
setForcedAwarenessAttributes(CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING.get(settings));
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING, this::setForcedAwarenessAttributes);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING, this::setForcedAwarenessAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setForcedAwarenessAttributes(Settings forceSettings) {
|
private void setForcedAwarenessAttributes(Settings forceSettings) {
|
||||||
|
|
|
@ -22,9 +22,9 @@ package org.elasticsearch.cluster.routing.allocation.decider;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class ClusterRebalanceAllocationDecider extends AllocationDecider {
|
||||||
private ClusterRebalanceType type;
|
private ClusterRebalanceType type;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ClusterRebalanceAllocationDecider(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public ClusterRebalanceAllocationDecider(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
try {
|
try {
|
||||||
type = CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.get(settings);
|
type = CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.get(settings);
|
||||||
|
@ -92,7 +92,7 @@ public class ClusterRebalanceAllocationDecider extends AllocationDecider {
|
||||||
}
|
}
|
||||||
logger.debug("using [{}] with [{}]", CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING, type.toString().toLowerCase(Locale.ROOT));
|
logger.debug("using [{}] with [{}]", CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING, type.toString().toLowerCase(Locale.ROOT));
|
||||||
|
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING, this::setType);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING, this::setType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(ClusterRebalanceType type) {
|
public void setType(ClusterRebalanceType type) {
|
||||||
|
|
|
@ -22,9 +22,9 @@ package org.elasticsearch.cluster.routing.allocation.decider;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to the {@link ClusterRebalanceAllocationDecider} this
|
* Similar to the {@link ClusterRebalanceAllocationDecider} this
|
||||||
|
@ -46,11 +46,11 @@ public class ConcurrentRebalanceAllocationDecider extends AllocationDecider {
|
||||||
private volatile int clusterConcurrentRebalance;
|
private volatile int clusterConcurrentRebalance;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ConcurrentRebalanceAllocationDecider(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public ConcurrentRebalanceAllocationDecider(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.clusterConcurrentRebalance = CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE_SETTING.get(settings);
|
this.clusterConcurrentRebalance = CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE_SETTING.get(settings);
|
||||||
logger.debug("using [cluster_concurrent_rebalance] with [{}]", clusterConcurrentRebalance);
|
logger.debug("using [cluster_concurrent_rebalance] with [{}]", clusterConcurrentRebalance);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE_SETTING, this::setClusterConcurrentRebalance);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE_SETTING, this::setClusterConcurrentRebalance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClusterConcurrentRebalance(int concurrentRebalance) {
|
public void setClusterConcurrentRebalance(int concurrentRebalance) {
|
||||||
|
|
|
@ -43,7 +43,6 @@ import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.common.unit.RatioValue;
|
import org.elasticsearch.common.unit.RatioValue;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -191,11 +190,11 @@ public class DiskThresholdDecider extends AllocationDecider {
|
||||||
// It's okay the Client is null here, because the empty cluster info
|
// It's okay the Client is null here, because the empty cluster info
|
||||||
// service will never actually call the listener where the client is
|
// service will never actually call the listener where the client is
|
||||||
// needed. Also this constructor is only used for tests
|
// needed. Also this constructor is only used for tests
|
||||||
this(settings, new ClusterSettingsService(settings, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), EmptyClusterInfoService.INSTANCE, null);
|
this(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), EmptyClusterInfoService.INSTANCE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DiskThresholdDecider(Settings settings, ClusterSettingsService clusterSettingsService, ClusterInfoService infoService, Client client) {
|
public DiskThresholdDecider(Settings settings, ClusterSettings clusterSettings, ClusterInfoService infoService, Client client) {
|
||||||
super(settings);
|
super(settings);
|
||||||
final String lowWatermark = CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.get(settings);
|
final String lowWatermark = CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.get(settings);
|
||||||
final String highWatermark = CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.get(settings);
|
final String highWatermark = CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.get(settings);
|
||||||
|
@ -204,11 +203,11 @@ public class DiskThresholdDecider extends AllocationDecider {
|
||||||
this.includeRelocations = CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.get(settings);
|
this.includeRelocations = CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.get(settings);
|
||||||
this.rerouteInterval = CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING.get(settings);
|
this.rerouteInterval = CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING.get(settings);
|
||||||
this.enabled = CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.get(settings);
|
this.enabled = CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.get(settings);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING, this::setLowWatermark);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING, this::setLowWatermark);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING, this::setHighWatermark);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING, this::setHighWatermark);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING, this::setIncludeRelocations);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING, this::setIncludeRelocations);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING, this::setRerouteInterval);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING, this::setRerouteInterval);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING, this::setEnabled);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING, this::setEnabled);
|
||||||
infoService.addListener(new DiskListener(client));
|
infoService.addListener(new DiskListener(client));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@ import org.elasticsearch.cluster.routing.RoutingNode;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -69,12 +69,12 @@ public class EnableAllocationDecider extends AllocationDecider {
|
||||||
private volatile Allocation enableAllocation;
|
private volatile Allocation enableAllocation;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public EnableAllocationDecider(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public EnableAllocationDecider(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.enableAllocation = CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.get(settings);
|
this.enableAllocation = CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.get(settings);
|
||||||
this.enableRebalance = CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.get(settings);
|
this.enableRebalance = CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.get(settings);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING, this::setEnableAllocation);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING, this::setEnableAllocation);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING, this::setEnableRebalance);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING, this::setEnableRebalance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnableRebalance(Rebalance enableRebalance) {
|
public void setEnableRebalance(Rebalance enableRebalance) {
|
||||||
|
|
|
@ -25,9 +25,9 @@ import org.elasticsearch.cluster.routing.RoutingNode;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodeFilters.OpType.AND;
|
import static org.elasticsearch.cluster.node.DiscoveryNodeFilters.OpType.AND;
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodeFilters.OpType.OR;
|
import static org.elasticsearch.cluster.node.DiscoveryNodeFilters.OpType.OR;
|
||||||
|
@ -73,14 +73,14 @@ public class FilterAllocationDecider extends AllocationDecider {
|
||||||
private volatile DiscoveryNodeFilters clusterExcludeFilters;
|
private volatile DiscoveryNodeFilters clusterExcludeFilters;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FilterAllocationDecider(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public FilterAllocationDecider(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
setClusterRequireFilters(CLUSTER_ROUTING_REQUIRE_GROUP_SETTING.get(settings));
|
setClusterRequireFilters(CLUSTER_ROUTING_REQUIRE_GROUP_SETTING.get(settings));
|
||||||
setClusterExcludeFilters(CLUSTER_ROUTING_EXCLUDE_GROUP_SETTING.get(settings));
|
setClusterExcludeFilters(CLUSTER_ROUTING_EXCLUDE_GROUP_SETTING.get(settings));
|
||||||
setClusterIncludeFilters(CLUSTER_ROUTING_INCLUDE_GROUP_SETTING.get(settings));
|
setClusterIncludeFilters(CLUSTER_ROUTING_INCLUDE_GROUP_SETTING.get(settings));
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_REQUIRE_GROUP_SETTING, this::setClusterRequireFilters);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_REQUIRE_GROUP_SETTING, this::setClusterRequireFilters);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_EXCLUDE_GROUP_SETTING, this::setClusterExcludeFilters);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_EXCLUDE_GROUP_SETTING, this::setClusterExcludeFilters);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_INCLUDE_GROUP_SETTING, this::setClusterIncludeFilters);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_INCLUDE_GROUP_SETTING, this::setClusterIncludeFilters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,9 +25,9 @@ import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
||||||
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This {@link AllocationDecider} limits the number of shards per node on a per
|
* This {@link AllocationDecider} limits the number of shards per node on a per
|
||||||
|
@ -68,10 +68,10 @@ public class ShardsLimitAllocationDecider extends AllocationDecider {
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ShardsLimitAllocationDecider(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public ShardsLimitAllocationDecider(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.clusterShardLimit = CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING.get(settings);
|
this.clusterShardLimit = CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING.get(settings);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING, this::setClusterShardLimit);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING, this::setClusterShardLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setClusterShardLimit(int clusterShardLimit) {
|
private void setClusterShardLimit(int clusterShardLimit) {
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This {@link org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider} prevents shards that
|
* This {@link org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider} prevents shards that
|
||||||
|
@ -57,14 +56,14 @@ public class SnapshotInProgressAllocationDecider extends AllocationDecider {
|
||||||
* @param settings {@link org.elasticsearch.common.settings.Settings} to use
|
* @param settings {@link org.elasticsearch.common.settings.Settings} to use
|
||||||
*/
|
*/
|
||||||
public SnapshotInProgressAllocationDecider(Settings settings) {
|
public SnapshotInProgressAllocationDecider(Settings settings) {
|
||||||
this(settings, new ClusterSettingsService(settings, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
|
this(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SnapshotInProgressAllocationDecider(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public SnapshotInProgressAllocationDecider(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
enableRelocation = CLUSTER_ROUTING_ALLOCATION_SNAPSHOT_RELOCATION_ENABLED_SETTING.get(settings);
|
enableRelocation = CLUSTER_ROUTING_ALLOCATION_SNAPSHOT_RELOCATION_ENABLED_SETTING.get(settings);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_SNAPSHOT_RELOCATION_ENABLED_SETTING, this::setEnableRelocation);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_SNAPSHOT_RELOCATION_ENABLED_SETTING, this::setEnableRelocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEnableRelocation(boolean enableRelocation) {
|
private void setEnableRelocation(boolean enableRelocation) {
|
||||||
|
|
|
@ -23,9 +23,9 @@ import org.elasticsearch.cluster.routing.RoutingNode;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ThrottlingAllocationDecider} controls the recovery process per node in
|
* {@link ThrottlingAllocationDecider} controls the recovery process per node in
|
||||||
|
@ -59,13 +59,13 @@ public class ThrottlingAllocationDecider extends AllocationDecider {
|
||||||
private volatile int concurrentRecoveries;
|
private volatile int concurrentRecoveries;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ThrottlingAllocationDecider(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public ThrottlingAllocationDecider(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.primariesInitialRecoveries = CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING.get(settings);
|
this.primariesInitialRecoveries = CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING.get(settings);
|
||||||
this.concurrentRecoveries = CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES_SETTING.get(settings);
|
this.concurrentRecoveries = CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES_SETTING.get(settings);
|
||||||
logger.debug("using node_concurrent_recoveries [{}], node_initial_primaries_recoveries [{}]", concurrentRecoveries, primariesInitialRecoveries);
|
logger.debug("using node_concurrent_recoveries [{}], node_initial_primaries_recoveries [{}]", concurrentRecoveries, primariesInitialRecoveries);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING, this::setPrimariesInitialRecoveries);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING, this::setPrimariesInitialRecoveries);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES_SETTING, this::setConcurrentRecoveries);
|
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES_SETTING, this::setConcurrentRecoveries);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setConcurrentRecoveries(int concurrentRecoveries) {
|
private void setConcurrentRecoveries(int concurrentRecoveries) {
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.text.StringText;
|
import org.elasticsearch.common.text.StringText;
|
||||||
|
@ -47,7 +48,6 @@ import org.elasticsearch.common.util.concurrent.*;
|
||||||
import org.elasticsearch.common.util.iterable.Iterables;
|
import org.elasticsearch.common.util.iterable.Iterables;
|
||||||
import org.elasticsearch.discovery.Discovery;
|
import org.elasticsearch.discovery.Discovery;
|
||||||
import org.elasticsearch.discovery.DiscoveryService;
|
import org.elasticsearch.discovery.DiscoveryService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
|
||||||
|
|
||||||
private final TransportService transportService;
|
private final TransportService transportService;
|
||||||
|
|
||||||
private final ClusterSettingsService clusterSettingsService;
|
private final ClusterSettings clusterSettings;
|
||||||
private final DiscoveryNodeService discoveryNodeService;
|
private final DiscoveryNodeService discoveryNodeService;
|
||||||
private final Version version;
|
private final Version version;
|
||||||
|
|
||||||
|
@ -108,20 +108,20 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public InternalClusterService(Settings settings, DiscoveryService discoveryService, OperationRouting operationRouting, TransportService transportService,
|
public InternalClusterService(Settings settings, DiscoveryService discoveryService, OperationRouting operationRouting, TransportService transportService,
|
||||||
ClusterSettingsService clusterSettingsService, ThreadPool threadPool, ClusterName clusterName, DiscoveryNodeService discoveryNodeService, Version version) {
|
ClusterSettings clusterSettings, ThreadPool threadPool, ClusterName clusterName, DiscoveryNodeService discoveryNodeService, Version version) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.operationRouting = operationRouting;
|
this.operationRouting = operationRouting;
|
||||||
this.transportService = transportService;
|
this.transportService = transportService;
|
||||||
this.discoveryService = discoveryService;
|
this.discoveryService = discoveryService;
|
||||||
this.threadPool = threadPool;
|
this.threadPool = threadPool;
|
||||||
this.clusterSettingsService = clusterSettingsService;
|
this.clusterSettings = clusterSettings;
|
||||||
this.discoveryNodeService = discoveryNodeService;
|
this.discoveryNodeService = discoveryNodeService;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
|
||||||
// will be replaced on doStart.
|
// will be replaced on doStart.
|
||||||
this.clusterState = ClusterState.builder(clusterName).build();
|
this.clusterState = ClusterState.builder(clusterName).build();
|
||||||
|
|
||||||
this.clusterSettingsService.addSettingsUpdateConsumer(CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, this::setSlowTaskLoggingThreshold);
|
this.clusterSettings.addSettingsUpdateConsumer(CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, this::setSlowTaskLoggingThreshold);
|
||||||
|
|
||||||
this.reconnectInterval = this.settings.getAsTime(SETTING_CLUSTER_SERVICE_RECONNECT_INTERVAL, TimeValue.timeValueSeconds(10));
|
this.reconnectInterval = this.settings.getAsTime(SETTING_CLUSTER_SERVICE_RECONNECT_INTERVAL, TimeValue.timeValueSeconds(10));
|
||||||
|
|
||||||
|
@ -525,7 +525,7 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
|
||||||
// nothing to do until we actually recover from the gateway or any other block indicates we need to disable persistency
|
// nothing to do until we actually recover from the gateway or any other block indicates we need to disable persistency
|
||||||
if (clusterChangedEvent.state().blocks().disableStatePersistence() == false && clusterChangedEvent.metaDataChanged()) {
|
if (clusterChangedEvent.state().blocks().disableStatePersistence() == false && clusterChangedEvent.metaDataChanged()) {
|
||||||
final Settings incomingSettings = clusterChangedEvent.state().metaData().settings();
|
final Settings incomingSettings = clusterChangedEvent.state().metaData().settings();
|
||||||
clusterSettingsService.applySettings(incomingSettings);
|
clusterSettings.applySettings(incomingSettings);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.warn("failed to apply cluster settings", ex);
|
logger.warn("failed to apply cluster settings", ex);
|
||||||
|
|
|
@ -24,9 +24,7 @@ import org.elasticsearch.common.component.AbstractComponent;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
@ -35,12 +33,30 @@ import java.util.function.Predicate;
|
||||||
* A basic setting service that can be used for per-index and per-cluster settings.
|
* A basic setting service that can be used for per-index and per-cluster settings.
|
||||||
* This service offers transactional application of updates settings.
|
* This service offers transactional application of updates settings.
|
||||||
*/
|
*/
|
||||||
public abstract class SettingsService extends AbstractComponent {
|
public abstract class AbstractScopedSettings extends AbstractComponent {
|
||||||
private Settings lastSettingsApplied;
|
private Settings lastSettingsApplied;
|
||||||
private final List<SettingUpdater> settingUpdaters = new ArrayList<>();
|
private final List<SettingUpdater> settingUpdaters = new ArrayList<>();
|
||||||
|
private final Map<String, Setting<?>> groupSettings = new HashMap<>();
|
||||||
|
private final Map<String, Setting<?>> keySettings = new HashMap<>();
|
||||||
|
private final Setting.Scope scope;
|
||||||
|
|
||||||
protected SettingsService(Settings settings) {
|
protected AbstractScopedSettings(Settings settings, Set<Setting<?>> settingsSet, Setting.Scope scope) {
|
||||||
super(settings);
|
super(settings);
|
||||||
|
for (Setting<?> entry : settingsSet) {
|
||||||
|
if (entry.getScope() != scope) {
|
||||||
|
throw new IllegalArgumentException("Setting must be a cluster setting but was: " + entry.getScope());
|
||||||
|
}
|
||||||
|
if (entry.isGroupSetting()) {
|
||||||
|
groupSettings.put(entry.getKey(), entry);
|
||||||
|
} else {
|
||||||
|
keySettings.put(entry.getKey(), entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.scope = scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Setting.Scope getScope() {
|
||||||
|
return this.scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,7 +156,7 @@ public abstract class SettingsService extends AbstractComponent {
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public synchronized <T> void addSettingsUpdateConsumer(Setting<T> setting, Consumer<T> consumer, Predicate<T> predicate) {
|
public synchronized <T> void addSettingsUpdateConsumer(Setting<T> setting, Consumer<T> consumer, Predicate<T> predicate) {
|
||||||
if (setting != getSetting(setting.getKey())) {
|
if (setting != get(setting.getKey())) {
|
||||||
throw new IllegalArgumentException("Setting is not registered for key [" + setting.getKey() + "]");
|
throw new IllegalArgumentException("Setting is not registered for key [" + setting.getKey() + "]");
|
||||||
}
|
}
|
||||||
this.settingUpdaters.add(setting.newUpdater(consumer, logger, settings, predicate));
|
this.settingUpdaters.add(setting.newUpdater(consumer, logger, settings, predicate));
|
||||||
|
@ -153,10 +169,10 @@ public abstract class SettingsService extends AbstractComponent {
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public synchronized <A, B> void addSettingsUpdateConsumer(Setting<A> a, Setting<B> b, BiConsumer<A, B> consumer) {
|
public synchronized <A, B> void addSettingsUpdateConsumer(Setting<A> a, Setting<B> b, BiConsumer<A, B> consumer) {
|
||||||
if (a != getSetting(a.getKey())) {
|
if (a != get(a.getKey())) {
|
||||||
throw new IllegalArgumentException("Setting is not registered for key [" + a.getKey() + "]");
|
throw new IllegalArgumentException("Setting is not registered for key [" + a.getKey() + "]");
|
||||||
}
|
}
|
||||||
if (b != getSetting(b.getKey())) {
|
if (b != get(b.getKey())) {
|
||||||
throw new IllegalArgumentException("Setting is not registered for key [" + b.getKey() + "]");
|
throw new IllegalArgumentException("Setting is not registered for key [" + b.getKey() + "]");
|
||||||
}
|
}
|
||||||
this.settingUpdaters.add(Setting.compoundUpdater(consumer, a, b, logger, settings));
|
this.settingUpdaters.add(Setting.compoundUpdater(consumer, a, b, logger, settings));
|
||||||
|
@ -172,8 +188,6 @@ public abstract class SettingsService extends AbstractComponent {
|
||||||
addSettingsUpdateConsumer(setting, consumer, (s) -> true);
|
addSettingsUpdateConsumer(setting, consumer, (s) -> true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Setting<?> getSetting(String key);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transactional interface to update settings.
|
* Transactional interface to update settings.
|
||||||
* @see Setting
|
* @see Setting
|
||||||
|
@ -198,4 +212,44 @@ public abstract class SettingsService extends AbstractComponent {
|
||||||
void rollback();
|
void rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link Setting} for the given key or <code>null</code> if the setting can not be found.
|
||||||
|
*/
|
||||||
|
public Setting get(String key) {
|
||||||
|
Setting<?> setting = keySettings.get(key);
|
||||||
|
if (setting == null) {
|
||||||
|
for (Map.Entry<String, Setting<?>> entry : groupSettings.entrySet()) {
|
||||||
|
if (entry.getValue().match(key)) {
|
||||||
|
return entry.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return setting;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns <code>true</code> if the setting for the given key is dynamically updateable. Otherwise <code>false</code>.
|
||||||
|
*/
|
||||||
|
public boolean hasDynamicSetting(String key) {
|
||||||
|
final Setting setting = get(key);
|
||||||
|
return setting != null && setting.isDynamic();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a settings object that contains all clustersettings that are not
|
||||||
|
* already set in the given source. The diff contains either the default value for each
|
||||||
|
* setting or the settings value in the given default settings.
|
||||||
|
*/
|
||||||
|
public Settings diff(Settings source, Settings defaultSettings) {
|
||||||
|
Settings.Builder builder = Settings.builder();
|
||||||
|
for (Setting<?> setting : keySettings.values()) {
|
||||||
|
if (setting.exists(source) == false) {
|
||||||
|
builder.put(setting.getKey(), setting.getRaw(defaultSettings));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -26,8 +26,6 @@ import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator;
|
import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator;
|
||||||
import org.elasticsearch.cluster.routing.allocation.decider.*;
|
import org.elasticsearch.cluster.routing.allocation.decider.*;
|
||||||
import org.elasticsearch.cluster.service.InternalClusterService;
|
import org.elasticsearch.cluster.service.InternalClusterService;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
|
||||||
import org.elasticsearch.discovery.DiscoverySettings;
|
import org.elasticsearch.discovery.DiscoverySettings;
|
||||||
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
||||||
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
|
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
|
||||||
|
@ -44,51 +42,10 @@ import java.util.*;
|
||||||
/**
|
/**
|
||||||
* Encapsulates all valid cluster level settings.
|
* Encapsulates all valid cluster level settings.
|
||||||
*/
|
*/
|
||||||
public final class ClusterSettings {
|
public final class ClusterSettings extends AbstractScopedSettings {
|
||||||
|
|
||||||
private final Map<String, Setting<?>> groupSettings = new HashMap<>();
|
public ClusterSettings(Settings settings, Set<Setting<?>> settingsSet) {
|
||||||
private final Map<String, Setting<?>> keySettings = new HashMap<>();
|
super(settings, settingsSet, Setting.Scope.Cluster);
|
||||||
|
|
||||||
public ClusterSettings(Set<Setting<?>> settingsSet) {
|
|
||||||
for (Setting<?> entry : settingsSet) {
|
|
||||||
if (entry.getScope() != Setting.Scope.Cluster) {
|
|
||||||
throw new IllegalArgumentException("Setting must be a cluster setting but was: " + entry.getScope());
|
|
||||||
}
|
|
||||||
if (entry.isGroupSetting()) {
|
|
||||||
groupSettings.put(entry.getKey(), entry);
|
|
||||||
} else {
|
|
||||||
keySettings.put(entry.getKey(), entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClusterSettings() {
|
|
||||||
this(BUILT_IN_CLUSTER_SETTINGS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link Setting} for the given key or <code>null</code> if the setting can not be found.
|
|
||||||
*/
|
|
||||||
public Setting get(String key) {
|
|
||||||
Setting<?> setting = keySettings.get(key);
|
|
||||||
if (setting == null) {
|
|
||||||
for (Map.Entry<String, Setting<?>> entry : groupSettings.entrySet()) {
|
|
||||||
if (entry.getValue().match(key)) {
|
|
||||||
return entry.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return setting;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns <code>true</code> if the setting for the given key is dynamically updateable. Otherwise <code>false</code>.
|
|
||||||
*/
|
|
||||||
public boolean hasDynamicSetting(String key) {
|
|
||||||
final Setting setting = get(key);
|
|
||||||
return setting != null && setting.isDynamic();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,20 +55,6 @@ public final class ClusterSettings {
|
||||||
return key.startsWith("logger.");
|
return key.startsWith("logger.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a settings object that contains all clustersettings that are not
|
|
||||||
* already set in the given source. The diff contains either the default value for each
|
|
||||||
* setting or the settings value in the given default settings.
|
|
||||||
*/
|
|
||||||
public Settings diff(Settings source, Settings defaultSettings) {
|
|
||||||
Settings.Builder builder = Settings.builder();
|
|
||||||
for (Setting<?> setting : keySettings.values()) {
|
|
||||||
if (setting.exists(source) == false) {
|
|
||||||
builder.put(setting.getKey(), setting.getRaw(defaultSettings));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Set<Setting<?>> BUILT_IN_CLUSTER_SETTINGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING,
|
public static Set<Setting<?>> BUILT_IN_CLUSTER_SETTINGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING,
|
||||||
AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING,
|
AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING,
|
||||||
|
@ -171,5 +114,4 @@ public final class ClusterSettings {
|
||||||
TransportService.TRACE_LOG_INCLUDE_SETTING,
|
TransportService.TRACE_LOG_INCLUDE_SETTING,
|
||||||
TransportCloseIndexAction.CLUSTER_INDICES_CLOSE_ENABLE_SETTING,
|
TransportCloseIndexAction.CLUSTER_INDICES_CLOSE_ENABLE_SETTING,
|
||||||
ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING)));
|
ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to Elasticsearch under one or more contributor
|
|
||||||
* license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright
|
|
||||||
* ownership. Elasticsearch licenses this file to you under
|
|
||||||
* the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
* not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.elasticsearch.common.settings;
|
|
||||||
|
|
||||||
import org.elasticsearch.common.component.AbstractComponent;
|
|
||||||
import org.elasticsearch.common.inject.Inject;
|
|
||||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A service that allows to register for node settings change that can come from cluster
|
|
||||||
* events holding new settings.
|
|
||||||
*/
|
|
||||||
public final class ClusterSettingsService extends SettingsService {
|
|
||||||
private final ClusterSettings clusterSettings;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public ClusterSettingsService(Settings settings, ClusterSettings clusterSettings) {
|
|
||||||
super(settings);
|
|
||||||
this.clusterSettings = clusterSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Setting<?> getSetting(String key) {
|
|
||||||
return this.clusterSettings.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClusterSettings getClusterSettings() {
|
|
||||||
return clusterSettings;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -149,11 +149,11 @@ public class Setting<T> extends ToXContentToBytes {
|
||||||
Index;
|
Index;
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsService.SettingUpdater newUpdater(Consumer<T> consumer, ESLogger logger, Settings settings) {
|
AbstractScopedSettings.SettingUpdater newUpdater(Consumer<T> consumer, ESLogger logger, Settings settings) {
|
||||||
return newUpdater(consumer, logger, settings, (s) -> true);
|
return newUpdater(consumer, logger, settings, (s) -> true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsService.SettingUpdater newUpdater(Consumer<T> consumer, ESLogger logger, Settings settings, Predicate<T> accept) {
|
AbstractScopedSettings.SettingUpdater newUpdater(Consumer<T> consumer, ESLogger logger, Settings settings, Predicate<T> accept) {
|
||||||
if (isDynamic()) {
|
if (isDynamic()) {
|
||||||
return new Updater(consumer, logger, settings, accept);
|
return new Updater(consumer, logger, settings, accept);
|
||||||
} else {
|
} else {
|
||||||
|
@ -161,12 +161,12 @@ public class Setting<T> extends ToXContentToBytes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static <A, B> SettingsService.SettingUpdater compoundUpdater(final BiConsumer<A,B> consumer, final Setting<A> aSettting, final Setting<B> bSetting, ESLogger logger, Settings settings) {
|
static <A, B> AbstractScopedSettings.SettingUpdater compoundUpdater(final BiConsumer<A,B> consumer, final Setting<A> aSettting, final Setting<B> bSetting, ESLogger logger, Settings settings) {
|
||||||
final AtomicReference<A> aRef = new AtomicReference<>();
|
final AtomicReference<A> aRef = new AtomicReference<>();
|
||||||
final AtomicReference<B> bRef = new AtomicReference<>();
|
final AtomicReference<B> bRef = new AtomicReference<>();
|
||||||
final SettingsService.SettingUpdater aSettingUpdater = aSettting.newUpdater(aRef::set, logger, settings);
|
final AbstractScopedSettings.SettingUpdater aSettingUpdater = aSettting.newUpdater(aRef::set, logger, settings);
|
||||||
final SettingsService.SettingUpdater bSettingUpdater = bSetting.newUpdater(bRef::set, logger, settings);
|
final AbstractScopedSettings.SettingUpdater bSettingUpdater = bSetting.newUpdater(bRef::set, logger, settings);
|
||||||
return new SettingsService.SettingUpdater() {
|
return new AbstractScopedSettings.SettingUpdater() {
|
||||||
boolean aHasChanged = false;
|
boolean aHasChanged = false;
|
||||||
boolean bHasChanged = false;
|
boolean bHasChanged = false;
|
||||||
@Override
|
@Override
|
||||||
|
@ -204,7 +204,7 @@ public class Setting<T> extends ToXContentToBytes {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class Updater implements SettingsService.SettingUpdater {
|
private class Updater implements AbstractScopedSettings.SettingUpdater {
|
||||||
private final Consumer<T> consumer;
|
private final Consumer<T> consumer;
|
||||||
private final ESLogger logger;
|
private final ESLogger logger;
|
||||||
private final Predicate<T> accept;
|
private final Predicate<T> accept;
|
||||||
|
@ -325,12 +325,12 @@ public class Setting<T> extends ToXContentToBytes {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SettingsService.SettingUpdater newUpdater(Consumer<Settings> consumer, ESLogger logger, Settings settings, Predicate<Settings> accept) {
|
public AbstractScopedSettings.SettingUpdater newUpdater(Consumer<Settings> consumer, ESLogger logger, Settings settings, Predicate<Settings> accept) {
|
||||||
if (isDynamic() == false) {
|
if (isDynamic() == false) {
|
||||||
throw new IllegalStateException("setting [" + getKey() + "] is not dynamic");
|
throw new IllegalStateException("setting [" + getKey() + "] is not dynamic");
|
||||||
}
|
}
|
||||||
final Setting<?> setting = this;
|
final Setting<?> setting = this;
|
||||||
return new SettingsService.SettingUpdater() {
|
return new AbstractScopedSettings.SettingUpdater() {
|
||||||
private Settings pendingSettings;
|
private Settings pendingSettings;
|
||||||
private Settings committedSettings = get(settings);
|
private Settings committedSettings = get(settings);
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,10 @@ import org.elasticsearch.cluster.block.ClusterBlock;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
import org.elasticsearch.common.component.AbstractComponent;
|
import org.elasticsearch.common.component.AbstractComponent;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
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.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
@ -62,12 +62,12 @@ public class DiscoverySettings extends AbstractComponent {
|
||||||
private volatile boolean publishDiff;
|
private volatile boolean publishDiff;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DiscoverySettings(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public DiscoverySettings(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(NO_MASTER_BLOCK_SETTING, this::setNoMasterBlock);
|
clusterSettings.addSettingsUpdateConsumer(NO_MASTER_BLOCK_SETTING, this::setNoMasterBlock);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(PUBLISH_DIFF_ENABLE_SETTING, this::setPublishDiff);
|
clusterSettings.addSettingsUpdateConsumer(PUBLISH_DIFF_ENABLE_SETTING, this::setPublishDiff);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(COMMIT_TIMEOUT_SETTING, this::setCommitTimeout);
|
clusterSettings.addSettingsUpdateConsumer(COMMIT_TIMEOUT_SETTING, this::setCommitTimeout);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(PUBLISH_TIMEOUT_SETTING, this::setPublishTimeout);
|
clusterSettings.addSettingsUpdateConsumer(PUBLISH_TIMEOUT_SETTING, this::setPublishTimeout);
|
||||||
this.noMasterBlock = NO_MASTER_BLOCK_SETTING.get(settings);
|
this.noMasterBlock = NO_MASTER_BLOCK_SETTING.get(settings);
|
||||||
this.publishTimeout = PUBLISH_TIMEOUT_SETTING.get(settings);
|
this.publishTimeout = PUBLISH_TIMEOUT_SETTING.get(settings);
|
||||||
this.commitTimeout = COMMIT_TIMEOUT_SETTING.get(settings);
|
this.commitTimeout = COMMIT_TIMEOUT_SETTING.get(settings);
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.elasticsearch.common.inject.internal.Nullable;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
|
@ -56,7 +57,6 @@ import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
||||||
import org.elasticsearch.discovery.zen.publish.PendingClusterStateStats;
|
import org.elasticsearch.discovery.zen.publish.PendingClusterStateStats;
|
||||||
import org.elasticsearch.discovery.zen.publish.PublishClusterStateAction;
|
import org.elasticsearch.discovery.zen.publish.PublishClusterStateAction;
|
||||||
import org.elasticsearch.node.service.NodeService;
|
import org.elasticsearch.node.service.NodeService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.*;
|
import org.elasticsearch.transport.*;
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ZenDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
public ZenDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||||
TransportService transportService, final ClusterService clusterService, ClusterSettingsService clusterSettingsService,
|
TransportService transportService, final ClusterService clusterService, ClusterSettings clusterSettings,
|
||||||
ZenPingService pingService, ElectMasterService electMasterService,
|
ZenPingService pingService, ElectMasterService electMasterService,
|
||||||
DiscoverySettings discoverySettings) {
|
DiscoverySettings discoverySettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
|
@ -172,7 +172,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
||||||
|
|
||||||
logger.debug("using ping_timeout [{}], join.timeout [{}], master_election.filter_client [{}], master_election.filter_data [{}]", this.pingTimeout, joinTimeout, masterElectionFilterClientNodes, masterElectionFilterDataNodes);
|
logger.debug("using ping_timeout [{}], join.timeout [{}], master_election.filter_client [{}], master_election.filter_data [{}]", this.pingTimeout, joinTimeout, masterElectionFilterClientNodes, masterElectionFilterDataNodes);
|
||||||
|
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING, this::handleMinimumMasterNodesChanged, (value) -> {
|
clusterSettings.addSettingsUpdateConsumer(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING, this::handleMinimumMasterNodesChanged, (value) -> {
|
||||||
final ClusterState clusterState = clusterService.state();
|
final ClusterState clusterState = clusterService.state();
|
||||||
int masterNodes = clusterState.nodes().masterNodes().size();
|
int masterNodes = clusterState.nodes().masterNodes().size();
|
||||||
if (value > masterNodes) {
|
if (value > masterNodes) {
|
||||||
|
@ -180,7 +180,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(REJOIN_ON_MASTER_GONE_SETTING, this::setRejoingOnMasterGone);
|
clusterSettings.addSettingsUpdateConsumer(REJOIN_ON_MASTER_GONE_SETTING, this::setRejoingOnMasterGone);
|
||||||
|
|
||||||
this.masterFD = new MasterFaultDetection(settings, threadPool, transportService, clusterName, clusterService);
|
this.masterFD = new MasterFaultDetection(settings, threadPool, transportService, clusterName, clusterService);
|
||||||
this.masterFD.addListener(new MasterNodeFailureListener());
|
this.masterFD.addListener(new MasterNodeFailureListener());
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.elasticsearch.common.Nullable;
|
||||||
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.io.FileSystemUtils;
|
import org.elasticsearch.common.io.FileSystemUtils;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
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.EsExecutors;
|
import org.elasticsearch.common.util.concurrent.EsExecutors;
|
||||||
|
@ -58,7 +59,6 @@ import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.index.store.IndexStoreConfig;
|
import org.elasticsearch.index.store.IndexStoreConfig;
|
||||||
import org.elasticsearch.indices.mapper.MapperRegistry;
|
import org.elasticsearch.indices.mapper.MapperRegistry;
|
||||||
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.plugins.PluginsService;
|
import org.elasticsearch.plugins.PluginsService;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -100,7 +100,7 @@ public class IndicesService extends AbstractLifecycleComponent<IndicesService> i
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv,
|
public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv,
|
||||||
ClusterSettingsService clusterSettingsService, AnalysisRegistry analysisRegistry,
|
ClusterSettings clusterSettings, AnalysisRegistry analysisRegistry,
|
||||||
IndicesQueriesRegistry indicesQueriesRegistry, IndexNameExpressionResolver indexNameExpressionResolver,
|
IndicesQueriesRegistry indicesQueriesRegistry, IndexNameExpressionResolver indexNameExpressionResolver,
|
||||||
ClusterService clusterService, MapperRegistry mapperRegistry) {
|
ClusterService clusterService, MapperRegistry mapperRegistry) {
|
||||||
super(settings);
|
super(settings);
|
||||||
|
@ -113,8 +113,8 @@ public class IndicesService extends AbstractLifecycleComponent<IndicesService> i
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
this.indexNameExpressionResolver = indexNameExpressionResolver;
|
this.indexNameExpressionResolver = indexNameExpressionResolver;
|
||||||
this.mapperRegistry = mapperRegistry;
|
this.mapperRegistry = mapperRegistry;
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(IndexStoreConfig.INDICES_STORE_THROTTLE_TYPE_SETTING, indexStoreConfig::setRateLimitingType);
|
clusterSettings.addSettingsUpdateConsumer(IndexStoreConfig.INDICES_STORE_THROTTLE_TYPE_SETTING, indexStoreConfig::setRateLimitingType);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(IndexStoreConfig.INDICES_STORE_THROTTLE_MAX_BYTES_PER_SEC_SETTING, indexStoreConfig::setRateLimitingThrottle);
|
clusterSettings.addSettingsUpdateConsumer(IndexStoreConfig.INDICES_STORE_THROTTLE_MAX_BYTES_PER_SEC_SETTING, indexStoreConfig::setRateLimitingThrottle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,10 @@ import org.elasticsearch.common.breaker.CircuitBreakingException;
|
||||||
import org.elasticsearch.common.breaker.NoopCircuitBreaker;
|
import org.elasticsearch.common.breaker.NoopCircuitBreaker;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -66,7 +66,7 @@ public class HierarchyCircuitBreakerService extends CircuitBreakerService {
|
||||||
private final AtomicLong parentTripCount = new AtomicLong(0);
|
private final AtomicLong parentTripCount = new AtomicLong(0);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public HierarchyCircuitBreakerService(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public HierarchyCircuitBreakerService(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.fielddataSettings = new BreakerSettings(CircuitBreaker.FIELDDATA,
|
this.fielddataSettings = new BreakerSettings(CircuitBreaker.FIELDDATA,
|
||||||
FIELDDATA_CIRCUIT_BREAKER_LIMIT_SETTING.get(settings).bytes(),
|
FIELDDATA_CIRCUIT_BREAKER_LIMIT_SETTING.get(settings).bytes(),
|
||||||
|
@ -88,9 +88,9 @@ public class HierarchyCircuitBreakerService extends CircuitBreakerService {
|
||||||
registerBreaker(this.requestSettings);
|
registerBreaker(this.requestSettings);
|
||||||
registerBreaker(this.fielddataSettings);
|
registerBreaker(this.fielddataSettings);
|
||||||
|
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(TOTAL_CIRCUIT_BREAKER_LIMIT_SETTING, this::setTotalCircuitBreakerLimit, this::validateTotalCircuitBreakerLimit);
|
clusterSettings.addSettingsUpdateConsumer(TOTAL_CIRCUIT_BREAKER_LIMIT_SETTING, this::setTotalCircuitBreakerLimit, this::validateTotalCircuitBreakerLimit);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(FIELDDATA_CIRCUIT_BREAKER_LIMIT_SETTING, FIELDDATA_CIRCUIT_BREAKER_OVERHEAD_SETTING, this::setFieldDataBreakerLimit);
|
clusterSettings.addSettingsUpdateConsumer(FIELDDATA_CIRCUIT_BREAKER_LIMIT_SETTING, FIELDDATA_CIRCUIT_BREAKER_OVERHEAD_SETTING, this::setFieldDataBreakerLimit);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, REQUEST_CIRCUIT_BREAKER_OVERHEAD_SETTING, this::setRequestBreakerLimit);
|
clusterSettings.addSettingsUpdateConsumer(REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, REQUEST_CIRCUIT_BREAKER_OVERHEAD_SETTING, this::setRequestBreakerLimit);
|
||||||
}
|
}
|
||||||
private void setRequestBreakerLimit(ByteSizeValue newRequestMax, Double newRequestOverhead) {
|
private void setRequestBreakerLimit(ByteSizeValue newRequestMax, Double newRequestOverhead) {
|
||||||
long newRequestLimitBytes = newRequestMax == null ? HierarchyCircuitBreakerService.this.requestSettings.getLimit() : newRequestMax.bytes();
|
long newRequestLimitBytes = newRequestMax == null ? HierarchyCircuitBreakerService.this.requestSettings.getLimit() : newRequestMax.bytes();
|
||||||
|
|
|
@ -23,13 +23,13 @@ import org.apache.lucene.store.RateLimiter;
|
||||||
import org.apache.lucene.store.RateLimiter.SimpleRateLimiter;
|
import org.apache.lucene.store.RateLimiter.SimpleRateLimiter;
|
||||||
import org.elasticsearch.common.component.AbstractComponent;
|
import org.elasticsearch.common.component.AbstractComponent;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.ByteSizeUnit;
|
import org.elasticsearch.common.unit.ByteSizeUnit;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.util.concurrent.EsExecutors;
|
import org.elasticsearch.common.util.concurrent.EsExecutors;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
|
@ -95,7 +95,7 @@ public class RecoverySettings extends AbstractComponent implements Closeable {
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RecoverySettings(Settings settings, ClusterSettingsService clusterSettingsService) {
|
public RecoverySettings(Settings settings, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.fileChunkSize = INDICES_RECOVERY_FILE_CHUNK_SIZE_SETTING.get(settings);
|
this.fileChunkSize = INDICES_RECOVERY_FILE_CHUNK_SIZE_SETTING.get(settings);
|
||||||
this.translogOps = INDICES_RECOVERY_TRANSLOG_OPS_SETTING.get(settings);
|
this.translogOps = INDICES_RECOVERY_TRANSLOG_OPS_SETTING.get(settings);
|
||||||
|
@ -130,18 +130,18 @@ public class RecoverySettings extends AbstractComponent implements Closeable {
|
||||||
logger.debug("using max_bytes_per_sec[{}], concurrent_streams [{}], file_chunk_size [{}], translog_size [{}], translog_ops [{}], and compress [{}]",
|
logger.debug("using max_bytes_per_sec[{}], concurrent_streams [{}], file_chunk_size [{}], translog_size [{}], translog_ops [{}], and compress [{}]",
|
||||||
maxBytesPerSec, concurrentStreams, fileChunkSize, translogSize, translogOps, compress);
|
maxBytesPerSec, concurrentStreams, fileChunkSize, translogSize, translogOps, compress);
|
||||||
|
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_RECOVERY_FILE_CHUNK_SIZE_SETTING, this::setFileChunkSize);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_RECOVERY_FILE_CHUNK_SIZE_SETTING, this::setFileChunkSize);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_RECOVERY_TRANSLOG_OPS_SETTING, this::setTranslogOps);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_RECOVERY_TRANSLOG_OPS_SETTING, this::setTranslogOps);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_RECOVERY_TRANSLOG_SIZE_SETTING, this::setTranslogSize);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_RECOVERY_TRANSLOG_SIZE_SETTING, this::setTranslogSize);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_RECOVERY_COMPRESS_SETTING, this::setCompress);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_RECOVERY_COMPRESS_SETTING, this::setCompress);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_RECOVERY_CONCURRENT_STREAMS_SETTING, this::setConcurrentStreams);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_RECOVERY_CONCURRENT_STREAMS_SETTING, this::setConcurrentStreams);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_RECOVERY_CONCURRENT_SMALL_FILE_STREAMS_SETTING, this::setConcurrentSmallFileStreams);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_RECOVERY_CONCURRENT_SMALL_FILE_STREAMS_SETTING, this::setConcurrentSmallFileStreams);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING, this::setMaxBytesPerSec);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING, this::setMaxBytesPerSec);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_RECOVERY_RETRY_DELAY_STATE_SYNC_SETTING, this::setRetryDelayStateSync);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_RECOVERY_RETRY_DELAY_STATE_SYNC_SETTING, this::setRetryDelayStateSync);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_RECOVERY_RETRY_DELAY_NETWORK_SETTING, this::setRetryDelayNetwork);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_RECOVERY_RETRY_DELAY_NETWORK_SETTING, this::setRetryDelayNetwork);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_RECOVERY_INTERNAL_ACTION_TIMEOUT_SETTING, this::setInternalActionTimeout);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_RECOVERY_INTERNAL_ACTION_TIMEOUT_SETTING, this::setInternalActionTimeout);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_RECOVERY_INTERNAL_LONG_ACTION_TIMEOUT_SETTING, this::setInternalActionLongTimeout);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_RECOVERY_INTERNAL_LONG_ACTION_TIMEOUT_SETTING, this::setInternalActionLongTimeout);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_RECOVERY_ACTIVITY_TIMEOUT_SETTING, this::setActivityTimeout);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_RECOVERY_ACTIVITY_TIMEOUT_SETTING, this::setActivityTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
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.lucene.uid.Versions;
|
import org.elasticsearch.common.lucene.uid.Versions;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
|
@ -50,7 +51,6 @@ import org.elasticsearch.index.IndexService;
|
||||||
import org.elasticsearch.index.shard.IndexShardState;
|
import org.elasticsearch.index.shard.IndexShardState;
|
||||||
import org.elasticsearch.index.shard.IndexShard;
|
import org.elasticsearch.index.shard.IndexShard;
|
||||||
import org.elasticsearch.indices.IndicesService;
|
import org.elasticsearch.indices.IndicesService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -78,7 +78,7 @@ public class IndicesTTLService extends AbstractLifecycleComponent<IndicesTTLServ
|
||||||
private PurgerThread purgerThread;
|
private PurgerThread purgerThread;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public IndicesTTLService(Settings settings, ClusterService clusterService, IndicesService indicesService, ClusterSettingsService clusterSettingsService, TransportBulkAction bulkAction) {
|
public IndicesTTLService(Settings settings, ClusterService clusterService, IndicesService indicesService, ClusterSettings clusterSettings, TransportBulkAction bulkAction) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
|
@ -86,7 +86,7 @@ public class IndicesTTLService extends AbstractLifecycleComponent<IndicesTTLServ
|
||||||
this.bulkAction = bulkAction;
|
this.bulkAction = bulkAction;
|
||||||
this.bulkSize = this.settings.getAsInt("indices.ttl.bulk_size", 10000);
|
this.bulkSize = this.settings.getAsInt("indices.ttl.bulk_size", 10000);
|
||||||
this.purgerThread = new PurgerThread(EsExecutors.threadName(settings, "[ttl_expire]"), interval);
|
this.purgerThread = new PurgerThread(EsExecutors.threadName(settings, "[ttl_expire]"), interval);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(INDICES_TTL_INTERVAL_SETTING, this.purgerThread::resetInterval);
|
clusterSettings.addSettingsUpdateConsumer(INDICES_TTL_INTERVAL_SETTING, this.purgerThread::resetInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.elasticsearch.cluster.ClusterNameModule;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
|
import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
|
||||||
import org.elasticsearch.cluster.routing.RoutingService;
|
import org.elasticsearch.cluster.routing.RoutingService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettings;
|
|
||||||
import org.elasticsearch.common.StopWatch;
|
import org.elasticsearch.common.StopWatch;
|
||||||
import org.elasticsearch.common.component.Lifecycle;
|
import org.elasticsearch.common.component.Lifecycle;
|
||||||
import org.elasticsearch.common.component.LifecycleComponent;
|
import org.elasticsearch.common.component.LifecycleComponent;
|
||||||
|
@ -44,6 +43,7 @@ import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.common.network.NetworkModule;
|
import org.elasticsearch.common.network.NetworkModule;
|
||||||
import org.elasticsearch.common.network.NetworkService;
|
import org.elasticsearch.common.network.NetworkService;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.SettingsFilter;
|
import org.elasticsearch.common.settings.SettingsFilter;
|
||||||
import org.elasticsearch.common.settings.SettingsModule;
|
import org.elasticsearch.common.settings.SettingsModule;
|
||||||
|
@ -73,7 +73,6 @@ import org.elasticsearch.indices.ttl.IndicesTTLService;
|
||||||
import org.elasticsearch.monitor.MonitorService;
|
import org.elasticsearch.monitor.MonitorService;
|
||||||
import org.elasticsearch.monitor.jvm.JvmInfo;
|
import org.elasticsearch.monitor.jvm.JvmInfo;
|
||||||
import org.elasticsearch.node.internal.InternalSettingsPreparer;
|
import org.elasticsearch.node.internal.InternalSettingsPreparer;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.percolator.PercolatorModule;
|
import org.elasticsearch.percolator.PercolatorModule;
|
||||||
import org.elasticsearch.percolator.PercolatorService;
|
import org.elasticsearch.percolator.PercolatorService;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
|
@ -203,7 +202,7 @@ public class Node implements Releasable {
|
||||||
injector = modules.createInjector();
|
injector = modules.createInjector();
|
||||||
|
|
||||||
client = injector.getInstance(Client.class);
|
client = injector.getInstance(Client.class);
|
||||||
threadPool.setNodeSettingsService(injector.getInstance(ClusterSettingsService.class));
|
threadPool.setNodeSettingsService(injector.getInstance(ClusterSettings.class));
|
||||||
success = true;
|
success = true;
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new ElasticsearchException("failed to bind service", ex);
|
throw new ElasticsearchException("failed to bind service", ex);
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.elasticsearch.common.inject.AbstractModule;
|
||||||
import org.elasticsearch.common.util.BigArrays;
|
import org.elasticsearch.common.util.BigArrays;
|
||||||
import org.elasticsearch.monitor.MonitorService;
|
import org.elasticsearch.monitor.MonitorService;
|
||||||
import org.elasticsearch.node.service.NodeService;
|
import org.elasticsearch.node.service.NodeService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.elasticsearch.common.bytes.BytesReference;
|
||||||
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.lucene.Lucene;
|
import org.elasticsearch.common.lucene.Lucene;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
|
@ -71,7 +72,6 @@ import org.elasticsearch.indices.IndicesService;
|
||||||
import org.elasticsearch.indices.IndicesWarmer;
|
import org.elasticsearch.indices.IndicesWarmer;
|
||||||
import org.elasticsearch.indices.IndicesWarmer.TerminationHandle;
|
import org.elasticsearch.indices.IndicesWarmer.TerminationHandle;
|
||||||
import org.elasticsearch.indices.cache.request.IndicesRequestCache;
|
import org.elasticsearch.indices.cache.request.IndicesRequestCache;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.script.ExecutableScript;
|
import org.elasticsearch.script.ExecutableScript;
|
||||||
import org.elasticsearch.script.ScriptContext;
|
import org.elasticsearch.script.ScriptContext;
|
||||||
import org.elasticsearch.script.ScriptService;
|
import org.elasticsearch.script.ScriptService;
|
||||||
|
@ -152,7 +152,7 @@ public class SearchService extends AbstractLifecycleComponent<SearchService> imp
|
||||||
private final ParseFieldMatcher parseFieldMatcher;
|
private final ParseFieldMatcher parseFieldMatcher;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SearchService(Settings settings, ClusterSettingsService clusterSettingsService, ClusterService clusterService, IndicesService indicesService, IndicesWarmer indicesWarmer, ThreadPool threadPool,
|
public SearchService(Settings settings, ClusterSettings clusterSettings, ClusterService clusterService, IndicesService indicesService, IndicesWarmer indicesWarmer, ThreadPool threadPool,
|
||||||
ScriptService scriptService, PageCacheRecycler pageCacheRecycler, BigArrays bigArrays, DfsPhase dfsPhase, QueryPhase queryPhase, FetchPhase fetchPhase,
|
ScriptService scriptService, PageCacheRecycler pageCacheRecycler, BigArrays bigArrays, DfsPhase dfsPhase, QueryPhase queryPhase, FetchPhase fetchPhase,
|
||||||
IndicesRequestCache indicesQueryCache) {
|
IndicesRequestCache indicesQueryCache) {
|
||||||
super(settings);
|
super(settings);
|
||||||
|
@ -187,7 +187,7 @@ public class SearchService extends AbstractLifecycleComponent<SearchService> imp
|
||||||
this.indicesWarmer.addListener(new SearchWarmer());
|
this.indicesWarmer.addListener(new SearchWarmer());
|
||||||
|
|
||||||
defaultSearchTimeout = DEFAULT_SEARCH_TIMEOUT_SETTING.get(settings);
|
defaultSearchTimeout = DEFAULT_SEARCH_TIMEOUT_SETTING.get(settings);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(DEFAULT_SEARCH_TIMEOUT_SETTING, this::setDefaultSearchTimeout);
|
clusterSettings.addSettingsUpdateConsumer(DEFAULT_SEARCH_TIMEOUT_SETTING, this::setDefaultSearchTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaultSearchTimeout(TimeValue defaultSearchTimeout) {
|
private void setDefaultSearchTimeout(TimeValue defaultSearchTimeout) {
|
||||||
|
|
|
@ -49,7 +49,6 @@ import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||||
import org.elasticsearch.index.shard.IndexShard;
|
import org.elasticsearch.index.shard.IndexShard;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.index.snapshots.IndexShardRepository;
|
import org.elasticsearch.index.snapshots.IndexShardRepository;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.repositories.RepositoriesService;
|
import org.elasticsearch.repositories.RepositoriesService;
|
||||||
import org.elasticsearch.repositories.Repository;
|
import org.elasticsearch.repositories.Repository;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
@ -125,12 +124,12 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
|
||||||
private final CopyOnWriteArrayList<ActionListener<RestoreCompletionResponse>> listeners = new CopyOnWriteArrayList<>();
|
private final CopyOnWriteArrayList<ActionListener<RestoreCompletionResponse>> listeners = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
private final BlockingQueue<UpdateIndexShardRestoreStatusRequest> updatedSnapshotStateQueue = ConcurrentCollections.newBlockingQueue();
|
private final BlockingQueue<UpdateIndexShardRestoreStatusRequest> updatedSnapshotStateQueue = ConcurrentCollections.newBlockingQueue();
|
||||||
private final ClusterSettingsService clusterSettingsService;
|
private final ClusterSettings clusterSettings;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RestoreService(Settings settings, ClusterService clusterService, RepositoriesService repositoriesService, TransportService transportService,
|
public RestoreService(Settings settings, ClusterService clusterService, RepositoriesService repositoriesService, TransportService transportService,
|
||||||
AllocationService allocationService, MetaDataCreateIndexService createIndexService, ClusterSettings dynamicSettings,
|
AllocationService allocationService, MetaDataCreateIndexService createIndexService, ClusterSettings dynamicSettings,
|
||||||
MetaDataIndexUpgradeService metaDataIndexUpgradeService, ClusterSettingsService clusterSettingsService) {
|
MetaDataIndexUpgradeService metaDataIndexUpgradeService, ClusterSettings clusterSettings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
this.repositoriesService = repositoriesService;
|
this.repositoriesService = repositoriesService;
|
||||||
|
@ -141,7 +140,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
|
||||||
this.metaDataIndexUpgradeService = metaDataIndexUpgradeService;
|
this.metaDataIndexUpgradeService = metaDataIndexUpgradeService;
|
||||||
transportService.registerRequestHandler(UPDATE_RESTORE_ACTION_NAME, UpdateIndexShardRestoreStatusRequest::new, ThreadPool.Names.SAME, new UpdateRestoreStateRequestHandler());
|
transportService.registerRequestHandler(UPDATE_RESTORE_ACTION_NAME, UpdateIndexShardRestoreStatusRequest::new, ThreadPool.Names.SAME, new UpdateRestoreStateRequestHandler());
|
||||||
clusterService.add(this);
|
clusterService.add(this);
|
||||||
this.clusterSettingsService = clusterSettingsService;
|
this.clusterSettings = clusterSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -392,7 +391,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
|
||||||
if (request.includeGlobalState()) {
|
if (request.includeGlobalState()) {
|
||||||
if (metaData.persistentSettings() != null) {
|
if (metaData.persistentSettings() != null) {
|
||||||
Settings settings = metaData.persistentSettings();
|
Settings settings = metaData.persistentSettings();
|
||||||
clusterSettingsService.dryRun(settings);
|
clusterSettings.dryRun(settings);
|
||||||
mdBuilder.persistentSettings(settings);
|
mdBuilder.persistentSettings(settings);
|
||||||
}
|
}
|
||||||
if (metaData.templates() != null) {
|
if (metaData.templates() != null) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.common.component.AbstractComponent;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Streamable;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.SettingsException;
|
import org.elasticsearch.common.settings.SettingsException;
|
||||||
|
@ -37,7 +38,6 @@ import org.elasticsearch.common.util.concurrent.XRejectedExecutionHandler;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -250,9 +250,9 @@ public class ThreadPool extends AbstractComponent {
|
||||||
this.estimatedTimeThread.start();
|
this.estimatedTimeThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNodeSettingsService(ClusterSettingsService clusterSettingsService) {
|
public void setNodeSettingsService(ClusterSettings clusterSettings) {
|
||||||
if(settingsListenerIsSet.compareAndSet(false, true)) {
|
if(settingsListenerIsSet.compareAndSet(false, true)) {
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(THREADPOOL_GROUP_SETTING, this::updateSettings, (s) -> {validate(s.getAsGroups()); return true;});
|
clusterSettings.addSettingsUpdateConsumer(THREADPOOL_GROUP_SETTING, this::updateSettings, (s) -> {validate(s.getAsGroups()); return true;});
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("the node settings listener was set more then once");
|
throw new IllegalStateException("the node settings listener was set more then once");
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.common.metrics.MeanMetric;
|
import org.elasticsearch.common.metrics.MeanMetric;
|
||||||
import org.elasticsearch.common.regex.Regex;
|
import org.elasticsearch.common.regex.Regex;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.BoundTransportAddress;
|
import org.elasticsearch.common.transport.BoundTransportAddress;
|
||||||
|
@ -38,7 +39,6 @@ import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||||
import org.elasticsearch.common.util.concurrent.ConcurrentMapLong;
|
import org.elasticsearch.common.util.concurrent.ConcurrentMapLong;
|
||||||
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
|
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
|
||||||
import org.elasticsearch.common.util.concurrent.FutureUtils;
|
import org.elasticsearch.common.util.concurrent.FutureUtils;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -132,9 +132,9 @@ public class TransportService extends AbstractLifecycleComponent<TransportServic
|
||||||
|
|
||||||
// These need to be optional as they don't exist in the context of a transport client
|
// These need to be optional as they don't exist in the context of a transport client
|
||||||
@Inject(optional = true)
|
@Inject(optional = true)
|
||||||
public void setDynamicSettings(ClusterSettingsService clusterSettingsService) {
|
public void setDynamicSettings(ClusterSettings clusterSettings) {
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(TRACE_LOG_INCLUDE_SETTING, this::setTracerLogInclude);
|
clusterSettings.addSettingsUpdateConsumer(TRACE_LOG_INCLUDE_SETTING, this::setTracerLogInclude);
|
||||||
clusterSettingsService.addSettingsUpdateConsumer(TRACE_LOG_EXCLUDE_SETTING, this::setTracelLogExclude);
|
clusterSettings.addSettingsUpdateConsumer(TRACE_LOG_EXCLUDE_SETTING, this::setTracelLogExclude);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTracerLogInclude(String[] tracerLogInclude) {
|
void setTracerLogInclude(String[] tracerLogInclude) {
|
||||||
|
|
|
@ -20,11 +20,9 @@ package org.elasticsearch.action.admin.cluster.settings;
|
||||||
|
|
||||||
import org.elasticsearch.cluster.ClusterName;
|
import org.elasticsearch.cluster.ClusterName;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlocks;
|
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator;
|
import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator;
|
||||||
import org.elasticsearch.common.settings.ClusterSettings;
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
|
@ -37,7 +35,7 @@ public class SettingsUpdaterTests extends ESTestCase {
|
||||||
AtomicReference<Float> index = new AtomicReference<>();
|
AtomicReference<Float> index = new AtomicReference<>();
|
||||||
AtomicReference<Float> shard = new AtomicReference<>();
|
AtomicReference<Float> shard = new AtomicReference<>();
|
||||||
ClusterState.Builder builder = ClusterState.builder(new ClusterName("foo"));
|
ClusterState.Builder builder = ClusterState.builder(new ClusterName("foo"));
|
||||||
ClusterSettingsService settingsService = new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings settingsService = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
settingsService.addSettingsUpdateConsumer(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING, index::set);
|
settingsService.addSettingsUpdateConsumer(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING, index::set);
|
||||||
settingsService.addSettingsUpdateConsumer(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING, shard::set);
|
settingsService.addSettingsUpdateConsumer(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING, shard::set);
|
||||||
SettingsUpdater updater = new SettingsUpdater(settingsService);
|
SettingsUpdater updater = new SettingsUpdater(settingsService);
|
||||||
|
@ -75,7 +73,7 @@ public class SettingsUpdaterTests extends ESTestCase {
|
||||||
|
|
||||||
public void testAllOrNothing() {
|
public void testAllOrNothing() {
|
||||||
ClusterState.Builder builder = ClusterState.builder(new ClusterName("foo"));
|
ClusterState.Builder builder = ClusterState.builder(new ClusterName("foo"));
|
||||||
ClusterSettingsService settingsService = new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings settingsService = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
AtomicReference<Float> index = new AtomicReference<>();
|
AtomicReference<Float> index = new AtomicReference<>();
|
||||||
AtomicReference<Float> shard = new AtomicReference<>();
|
AtomicReference<Float> shard = new AtomicReference<>();
|
||||||
settingsService.addSettingsUpdateConsumer(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING, index::set);
|
settingsService.addSettingsUpdateConsumer(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING, index::set);
|
||||||
|
@ -101,7 +99,7 @@ public class SettingsUpdaterTests extends ESTestCase {
|
||||||
|
|
||||||
public void testClusterBlock() {
|
public void testClusterBlock() {
|
||||||
ClusterState.Builder builder = ClusterState.builder(new ClusterName("foo"));
|
ClusterState.Builder builder = ClusterState.builder(new ClusterName("foo"));
|
||||||
ClusterSettingsService settingsService = new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings settingsService = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
AtomicReference<Float> index = new AtomicReference<>();
|
AtomicReference<Float> index = new AtomicReference<>();
|
||||||
AtomicReference<Float> shard = new AtomicReference<>();
|
AtomicReference<Float> shard = new AtomicReference<>();
|
||||||
settingsService.addSettingsUpdateConsumer(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING, index::set);
|
settingsService.addSettingsUpdateConsumer(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING, index::set);
|
||||||
|
|
|
@ -31,11 +31,10 @@ import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllo
|
||||||
import org.elasticsearch.cluster.routing.allocation.allocator.ShardsAllocator;
|
import org.elasticsearch.cluster.routing.allocation.allocator.ShardsAllocator;
|
||||||
import org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider;
|
import org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider;
|
||||||
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
|
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
|
||||||
import org.elasticsearch.common.settings.ClusterSettings;
|
|
||||||
import org.elasticsearch.cluster.settings.DynamicSettings;
|
import org.elasticsearch.cluster.settings.DynamicSettings;
|
||||||
import org.elasticsearch.cluster.settings.Validator;
|
import org.elasticsearch.cluster.settings.Validator;
|
||||||
import org.elasticsearch.common.inject.ModuleTestCase;
|
import org.elasticsearch.common.inject.ModuleTestCase;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.settings.IndexDynamicSettings;
|
import org.elasticsearch.index.settings.IndexDynamicSettings;
|
||||||
|
@ -86,7 +85,7 @@ public class ClusterModuleTests extends ModuleTestCase {
|
||||||
public void testRegisterClusterDynamicSetting() {
|
public void testRegisterClusterDynamicSetting() {
|
||||||
ClusterModule module = new ClusterModule(Settings.EMPTY);
|
ClusterModule module = new ClusterModule(Settings.EMPTY);
|
||||||
module.registerSetting(Setting.boolSetting("foo.bar", false, true, Setting.Scope.Cluster));
|
module.registerSetting(Setting.boolSetting("foo.bar", false, true, Setting.Scope.Cluster));
|
||||||
assertInstanceBinding(module, ClusterSettingsService.class, service -> service.getClusterSettings().hasDynamicSetting("foo.bar"));
|
assertInstanceBinding(module, ClusterSettings.class, service -> service.hasDynamicSetting("foo.bar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRegisterIndexDynamicSettingDuplicate() {
|
public void testRegisterIndexDynamicSettingDuplicate() {
|
||||||
|
|
|
@ -41,7 +41,6 @@ import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.test.ESAllocationTestCase;
|
import org.elasticsearch.test.ESAllocationTestCase;
|
||||||
import org.elasticsearch.test.gateway.NoopGatewayAllocator;
|
import org.elasticsearch.test.gateway.NoopGatewayAllocator;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
|
@ -283,7 +282,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
|
||||||
settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.2);
|
settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.2);
|
||||||
settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.3);
|
settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.3);
|
||||||
settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 2.0);
|
settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 2.0);
|
||||||
ClusterSettingsService service = new ClusterSettingsService(settingsBuilder().build(), new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings service = new ClusterSettings(settingsBuilder().build(), ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
BalancedShardsAllocator allocator = new BalancedShardsAllocator(settings.build(), service);
|
BalancedShardsAllocator allocator = new BalancedShardsAllocator(settings.build(), service);
|
||||||
assertThat(allocator.getIndexBalance(), Matchers.equalTo(0.2f));
|
assertThat(allocator.getIndexBalance(), Matchers.equalTo(0.2f));
|
||||||
assertThat(allocator.getShardBalance(), Matchers.equalTo(0.3f));
|
assertThat(allocator.getShardBalance(), Matchers.equalTo(0.3f));
|
||||||
|
@ -312,7 +311,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
|
||||||
public void testNoRebalanceOnPrimaryOverload() {
|
public void testNoRebalanceOnPrimaryOverload() {
|
||||||
Settings.Builder settings = settingsBuilder();
|
Settings.Builder settings = settingsBuilder();
|
||||||
AllocationService strategy = new AllocationService(settings.build(), randomAllocationDeciders(settings.build(),
|
AllocationService strategy = new AllocationService(settings.build(), randomAllocationDeciders(settings.build(),
|
||||||
new ClusterSettingsService(Settings.Builder.EMPTY_SETTINGS, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), getRandom()), new ShardsAllocators(settings.build(),
|
new ClusterSettings(Settings.Builder.EMPTY_SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), getRandom()), new ShardsAllocators(settings.build(),
|
||||||
NoopGatewayAllocator.INSTANCE, new ShardsAllocator() {
|
NoopGatewayAllocator.INSTANCE, new ShardsAllocator() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.DummyTransportAddress;
|
import org.elasticsearch.common.transport.DummyTransportAddress;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -46,7 +45,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
*/
|
*/
|
||||||
public class DiskThresholdDeciderUnitTests extends ESTestCase {
|
public class DiskThresholdDeciderUnitTests extends ESTestCase {
|
||||||
public void testDynamicSettings() {
|
public void testDynamicSettings() {
|
||||||
ClusterSettingsService nss = new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings nss = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
|
|
||||||
ClusterInfoService cis = EmptyClusterInfoService.INSTANCE;
|
ClusterInfoService cis = EmptyClusterInfoService.INSTANCE;
|
||||||
DiskThresholdDecider decider = new DiskThresholdDecider(Settings.EMPTY, nss, cis, null);
|
DiskThresholdDecider decider = new DiskThresholdDecider(Settings.EMPTY, nss, cis, null);
|
||||||
|
@ -84,7 +83,7 @@ public class DiskThresholdDeciderUnitTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCanAllocateUsesMaxAvailableSpace() {
|
public void testCanAllocateUsesMaxAvailableSpace() {
|
||||||
ClusterSettingsService nss = new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings nss = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
ClusterInfoService cis = EmptyClusterInfoService.INSTANCE;
|
ClusterInfoService cis = EmptyClusterInfoService.INSTANCE;
|
||||||
DiskThresholdDecider decider = new DiskThresholdDecider(Settings.EMPTY, nss, cis, null);
|
DiskThresholdDecider decider = new DiskThresholdDecider(Settings.EMPTY, nss, cis, null);
|
||||||
|
|
||||||
|
@ -125,7 +124,7 @@ public class DiskThresholdDeciderUnitTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCanRemainUsesLeastAvailableSpace() {
|
public void testCanRemainUsesLeastAvailableSpace() {
|
||||||
ClusterSettingsService nss = new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings nss = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
ClusterInfoService cis = EmptyClusterInfoService.INSTANCE;
|
ClusterInfoService cis = EmptyClusterInfoService.INSTANCE;
|
||||||
DiskThresholdDecider decider = new DiskThresholdDecider(Settings.EMPTY, nss, cis, null);
|
DiskThresholdDecider decider = new DiskThresholdDecider(Settings.EMPTY, nss, cis, null);
|
||||||
ImmutableOpenMap.Builder<ShardRouting, String> shardRoutingMap = ImmutableOpenMap.builder();
|
ImmutableOpenMap.Builder<ShardRouting, String> shardRoutingMap = ImmutableOpenMap.builder();
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.test.ESAllocationTestCase;
|
import org.elasticsearch.test.ESAllocationTestCase;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
@ -162,8 +161,8 @@ public class EnableAllocationTests extends ESAllocationTestCase {
|
||||||
.put(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), useClusterSetting ? Rebalance.NONE: RandomPicks.randomFrom(getRandom(), Rebalance.values())) // index settings override cluster settings
|
.put(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), useClusterSetting ? Rebalance.NONE: RandomPicks.randomFrom(getRandom(), Rebalance.values())) // index settings override cluster settings
|
||||||
.put(ConcurrentRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE_SETTING.getKey(), 3)
|
.put(ConcurrentRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE_SETTING.getKey(), 3)
|
||||||
.build();
|
.build();
|
||||||
ClusterSettingsService clusterSettingsService = new ClusterSettingsService(build, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings clusterSettings = new ClusterSettings(build, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
AllocationService strategy = createAllocationService(build, clusterSettingsService, getRandom());
|
AllocationService strategy = createAllocationService(build, clusterSettings, getRandom());
|
||||||
Settings indexSettings = useClusterSetting ? Settings.EMPTY : settingsBuilder().put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE, Rebalance.NONE).build();
|
Settings indexSettings = useClusterSetting ? Settings.EMPTY : settingsBuilder().put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE, Rebalance.NONE).build();
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
@ -224,7 +223,7 @@ public class EnableAllocationTests extends ESAllocationTestCase {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
clusterSettingsService.applySettings(clusterState.metaData().settings());
|
clusterSettings.applySettings(clusterState.metaData().settings());
|
||||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||||
assertThat("expected 6 shards to be started 2 to relocate useClusterSettings: " + useClusterSetting, clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(6));
|
assertThat("expected 6 shards to be started 2 to relocate useClusterSettings: " + useClusterSetting, clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(6));
|
||||||
|
@ -264,8 +263,8 @@ public class EnableAllocationTests extends ESAllocationTestCase {
|
||||||
.put(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), useClusterSetting ? Rebalance.NONE: RandomPicks.randomFrom(getRandom(), Rebalance.values())) // index settings override cluster settings
|
.put(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), useClusterSetting ? Rebalance.NONE: RandomPicks.randomFrom(getRandom(), Rebalance.values())) // index settings override cluster settings
|
||||||
.put(ConcurrentRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE_SETTING.getKey(), 3)
|
.put(ConcurrentRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE_SETTING.getKey(), 3)
|
||||||
.build();
|
.build();
|
||||||
ClusterSettingsService clusterSettingsService = new ClusterSettingsService(build, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings clusterSettings = new ClusterSettings(build, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
AllocationService strategy = createAllocationService(build, clusterSettingsService, getRandom());
|
AllocationService strategy = createAllocationService(build, clusterSettings, getRandom());
|
||||||
Settings indexSettings = useClusterSetting ? Settings.EMPTY : settingsBuilder().put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE, Rebalance.NONE).build();
|
Settings indexSettings = useClusterSetting ? Settings.EMPTY : settingsBuilder().put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE, Rebalance.NONE).build();
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
@ -315,7 +314,7 @@ public class EnableAllocationTests extends ESAllocationTestCase {
|
||||||
clusterState = ClusterState.builder(clusterState).metaData(MetaData.builder(metaData).removeAllIndices()
|
clusterState = ClusterState.builder(clusterState).metaData(MetaData.builder(metaData).removeAllIndices()
|
||||||
.put(IndexMetaData.builder(meta).settings(settingsBuilder().put(meta.getSettings()).put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE, randomBoolean() ? Rebalance.PRIMARIES : Rebalance.ALL).build()))).build();
|
.put(IndexMetaData.builder(meta).settings(settingsBuilder().put(meta.getSettings()).put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE, randomBoolean() ? Rebalance.PRIMARIES : Rebalance.ALL).build()))).build();
|
||||||
}
|
}
|
||||||
clusterSettingsService.applySettings(clusterState.metaData().settings());
|
clusterSettings.applySettings(clusterState.metaData().settings());
|
||||||
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
routingTable = strategy.reroute(clusterState, "reroute").routingTable();
|
||||||
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
|
||||||
assertThat("expected 4 primaries to be started and 2 to relocate useClusterSettings: " + useClusterSetting, clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(4));
|
assertThat("expected 4 primaries to be started and 2 to relocate useClusterSettings: " + useClusterSetting, clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(4));
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.indices.breaker.BreakerSettings;
|
import org.elasticsearch.indices.breaker.BreakerSettings;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
|
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
@ -88,7 +87,7 @@ public class MemoryCircuitBreakerTests extends ESTestCase {
|
||||||
final AtomicReference<Throwable> lastException = new AtomicReference<>(null);
|
final AtomicReference<Throwable> lastException = new AtomicReference<>(null);
|
||||||
|
|
||||||
final AtomicReference<ChildMemoryCircuitBreaker> breakerRef = new AtomicReference<>(null);
|
final AtomicReference<ChildMemoryCircuitBreaker> breakerRef = new AtomicReference<>(null);
|
||||||
final CircuitBreakerService service = new HierarchyCircuitBreakerService(Settings.EMPTY, new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS))) {
|
final CircuitBreakerService service = new HierarchyCircuitBreakerService(Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CircuitBreaker getBreaker(String name) {
|
public CircuitBreaker getBreaker(String name) {
|
||||||
|
@ -148,7 +147,7 @@ public class MemoryCircuitBreakerTests extends ESTestCase {
|
||||||
|
|
||||||
final AtomicInteger parentTripped = new AtomicInteger(0);
|
final AtomicInteger parentTripped = new AtomicInteger(0);
|
||||||
final AtomicReference<ChildMemoryCircuitBreaker> breakerRef = new AtomicReference<>(null);
|
final AtomicReference<ChildMemoryCircuitBreaker> breakerRef = new AtomicReference<>(null);
|
||||||
final CircuitBreakerService service = new HierarchyCircuitBreakerService(Settings.EMPTY, new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS))) {
|
final CircuitBreakerService service = new HierarchyCircuitBreakerService(Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CircuitBreaker getBreaker(String name) {
|
public CircuitBreaker getBreaker(String name) {
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to Elasticsearch under one or more contributor
|
|
||||||
* license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright
|
|
||||||
* ownership. Elasticsearch licenses this file to you under
|
|
||||||
* the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
* not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.elasticsearch.common.settings;
|
|
||||||
|
|
||||||
import org.elasticsearch.cluster.routing.allocation.decider.FilterAllocationDecider;
|
|
||||||
import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class ClusterSettingsTests extends ESTestCase {
|
|
||||||
|
|
||||||
public void testGet() {
|
|
||||||
ClusterSettings settings = new ClusterSettings();
|
|
||||||
Setting setting = settings.get("cluster.routing.allocation.require.value");
|
|
||||||
assertEquals(setting, FilterAllocationDecider.CLUSTER_ROUTING_REQUIRE_GROUP_SETTING);
|
|
||||||
|
|
||||||
setting = settings.get("cluster.routing.allocation.total_shards_per_node");
|
|
||||||
assertEquals(setting, ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testIsDynamic(){
|
|
||||||
ClusterSettings settings = new ClusterSettings(new HashSet<>(Arrays.asList(Setting.intSetting("foo.bar", 1, true, Setting.Scope.Cluster), Setting.intSetting("foo.bar.baz", 1, false, Setting.Scope.Cluster))));
|
|
||||||
assertFalse(settings.hasDynamicSetting("foo.bar.baz"));
|
|
||||||
assertTrue(settings.hasDynamicSetting("foo.bar"));
|
|
||||||
assertNotNull(settings.get("foo.bar.baz"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testDiff() throws IOException {
|
|
||||||
Setting<Integer> foobarbaz = Setting.intSetting("foo.bar.baz", 1, false, Setting.Scope.Cluster);
|
|
||||||
Setting<Integer> foobar = Setting.intSetting("foo.bar", 1, true, Setting.Scope.Cluster);
|
|
||||||
ClusterSettings settings = new ClusterSettings(new HashSet<>(Arrays.asList(foobar, foobarbaz)));
|
|
||||||
Settings diff = settings.diff(Settings.builder().put("foo.bar", 5).build(), Settings.EMPTY);
|
|
||||||
assertEquals(diff.getAsMap().size(), 1);
|
|
||||||
assertEquals(diff.getAsInt("foo.bar.baz", null), Integer.valueOf(1));
|
|
||||||
|
|
||||||
diff = settings.diff(Settings.builder().put("foo.bar", 5).build(), Settings.builder().put("foo.bar.baz", 17).build());
|
|
||||||
assertEquals(diff.getAsMap().size(), 1);
|
|
||||||
assertEquals(diff.getAsInt("foo.bar.baz", null), Integer.valueOf(17));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -18,23 +18,22 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.common.settings;
|
package org.elasticsearch.common.settings;
|
||||||
|
|
||||||
|
import org.elasticsearch.cluster.routing.allocation.decider.FilterAllocationDecider;
|
||||||
|
import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class SettingsServiceTests extends ESTestCase {
|
public class ScopedSettingsTests extends ESTestCase {
|
||||||
|
|
||||||
public void testAddConsumer() {
|
public void testAddConsumer() {
|
||||||
Setting<Integer> testSetting = Setting.intSetting("foo.bar", 1, true, Setting.Scope.Cluster);
|
Setting<Integer> testSetting = Setting.intSetting("foo.bar", 1, true, Setting.Scope.Cluster);
|
||||||
Setting<Integer> testSetting2 = Setting.intSetting("foo.bar.baz", 1, true, Setting.Scope.Cluster);
|
Setting<Integer> testSetting2 = Setting.intSetting("foo.bar.baz", 1, true, Setting.Scope.Cluster);
|
||||||
SettingsService service = new SettingsService(Settings.EMPTY) {
|
AbstractScopedSettings service = new ClusterSettings(Settings.EMPTY, Collections.singleton(testSetting));
|
||||||
@Override
|
|
||||||
protected Setting<?> getSetting(String key) {
|
|
||||||
if (key.equals(testSetting.getKey())) {
|
|
||||||
return testSetting;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AtomicInteger consumer = new AtomicInteger();
|
AtomicInteger consumer = new AtomicInteger();
|
||||||
service.addSettingsUpdateConsumer(testSetting, consumer::set);
|
service.addSettingsUpdateConsumer(testSetting, consumer::set);
|
||||||
|
@ -46,7 +45,6 @@ public class SettingsServiceTests extends ESTestCase {
|
||||||
assertEquals("Setting is not registered for key [foo.bar.baz]", ex.getMessage());
|
assertEquals("Setting is not registered for key [foo.bar.baz]", ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
service.addSettingsUpdateConsumer(testSetting, testSetting2, (a, b) -> {consumer.set(a); consumer2.set(b);});
|
service.addSettingsUpdateConsumer(testSetting, testSetting2, (a, b) -> {consumer.set(a); consumer2.set(b);});
|
||||||
fail("setting not registered");
|
fail("setting not registered");
|
||||||
|
@ -63,17 +61,7 @@ public class SettingsServiceTests extends ESTestCase {
|
||||||
public void testApply() {
|
public void testApply() {
|
||||||
Setting<Integer> testSetting = Setting.intSetting("foo.bar", 1, true, Setting.Scope.Cluster);
|
Setting<Integer> testSetting = Setting.intSetting("foo.bar", 1, true, Setting.Scope.Cluster);
|
||||||
Setting<Integer> testSetting2 = Setting.intSetting("foo.bar.baz", 1, true, Setting.Scope.Cluster);
|
Setting<Integer> testSetting2 = Setting.intSetting("foo.bar.baz", 1, true, Setting.Scope.Cluster);
|
||||||
SettingsService service = new SettingsService(Settings.EMPTY) {
|
AbstractScopedSettings service = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(testSetting, testSetting2)));
|
||||||
@Override
|
|
||||||
protected Setting<?> getSetting(String key) {
|
|
||||||
if (key.equals(testSetting.getKey())) {
|
|
||||||
return testSetting;
|
|
||||||
} else if (key.equals(testSetting2.getKey())) {
|
|
||||||
return testSetting2;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AtomicInteger consumer = new AtomicInteger();
|
AtomicInteger consumer = new AtomicInteger();
|
||||||
service.addSettingsUpdateConsumer(testSetting, consumer::set);
|
service.addSettingsUpdateConsumer(testSetting, consumer::set);
|
||||||
|
@ -121,4 +109,33 @@ public class SettingsServiceTests extends ESTestCase {
|
||||||
assertEquals(2, aC.get());
|
assertEquals(2, aC.get());
|
||||||
assertEquals(15, bC.get());
|
assertEquals(15, bC.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGet() {
|
||||||
|
ClusterSettings settings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
|
Setting setting = settings.get("cluster.routing.allocation.require.value");
|
||||||
|
assertEquals(setting, FilterAllocationDecider.CLUSTER_ROUTING_REQUIRE_GROUP_SETTING);
|
||||||
|
|
||||||
|
setting = settings.get("cluster.routing.allocation.total_shards_per_node");
|
||||||
|
assertEquals(setting, ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIsDynamic(){
|
||||||
|
ClusterSettings settings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(Setting.intSetting("foo.bar", 1, true, Setting.Scope.Cluster), Setting.intSetting("foo.bar.baz", 1, false, Setting.Scope.Cluster))));
|
||||||
|
assertFalse(settings.hasDynamicSetting("foo.bar.baz"));
|
||||||
|
assertTrue(settings.hasDynamicSetting("foo.bar"));
|
||||||
|
assertNotNull(settings.get("foo.bar.baz"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDiff() throws IOException {
|
||||||
|
Setting<Integer> foobarbaz = Setting.intSetting("foo.bar.baz", 1, false, Setting.Scope.Cluster);
|
||||||
|
Setting<Integer> foobar = Setting.intSetting("foo.bar", 1, true, Setting.Scope.Cluster);
|
||||||
|
ClusterSettings settings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(foobar, foobarbaz)));
|
||||||
|
Settings diff = settings.diff(Settings.builder().put("foo.bar", 5).build(), Settings.EMPTY);
|
||||||
|
assertEquals(diff.getAsMap().size(), 1);
|
||||||
|
assertEquals(diff.getAsInt("foo.bar.baz", null), Integer.valueOf(1));
|
||||||
|
|
||||||
|
diff = settings.diff(Settings.builder().put("foo.bar", 5).build(), Settings.builder().put("foo.bar.baz", 17).build());
|
||||||
|
assertEquals(diff.getAsMap().size(), 1);
|
||||||
|
assertEquals(diff.getAsInt("foo.bar.baz", null), Integer.valueOf(17));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -42,7 +42,7 @@ public class SettingTests extends ESTestCase {
|
||||||
ByteSizeValue byteSizeValue = byteSizeValueSetting.get(Settings.EMPTY);
|
ByteSizeValue byteSizeValue = byteSizeValueSetting.get(Settings.EMPTY);
|
||||||
assertEquals(byteSizeValue.bytes(), 1024);
|
assertEquals(byteSizeValue.bytes(), 1024);
|
||||||
AtomicReference<ByteSizeValue> value = new AtomicReference<>(null);
|
AtomicReference<ByteSizeValue> value = new AtomicReference<>(null);
|
||||||
ClusterSettingsService.SettingUpdater settingUpdater = byteSizeValueSetting.newUpdater(value::set, logger, Settings.EMPTY);
|
ClusterSettings.SettingUpdater settingUpdater = byteSizeValueSetting.newUpdater(value::set, logger, Settings.EMPTY);
|
||||||
try {
|
try {
|
||||||
settingUpdater.prepareApply(Settings.builder().put("a.byte.size", 12).build());
|
settingUpdater.prepareApply(Settings.builder().put("a.byte.size", 12).build());
|
||||||
fail("no unit");
|
fail("no unit");
|
||||||
|
@ -58,7 +58,7 @@ public class SettingTests extends ESTestCase {
|
||||||
public void testSimpleUpdate() {
|
public void testSimpleUpdate() {
|
||||||
Setting<Boolean> booleanSetting = Setting.boolSetting("foo.bar", false, true, Setting.Scope.Cluster);
|
Setting<Boolean> booleanSetting = Setting.boolSetting("foo.bar", false, true, Setting.Scope.Cluster);
|
||||||
AtomicReference<Boolean> atomicBoolean = new AtomicReference<>(null);
|
AtomicReference<Boolean> atomicBoolean = new AtomicReference<>(null);
|
||||||
ClusterSettingsService.SettingUpdater settingUpdater = booleanSetting.newUpdater(atomicBoolean::set, logger, Settings.EMPTY);
|
ClusterSettings.SettingUpdater settingUpdater = booleanSetting.newUpdater(atomicBoolean::set, logger, Settings.EMPTY);
|
||||||
Settings build = Settings.builder().put("foo.bar", false).build();
|
Settings build = Settings.builder().put("foo.bar", false).build();
|
||||||
settingUpdater.prepareApply(build);
|
settingUpdater.prepareApply(build);
|
||||||
assertNull(atomicBoolean.get());
|
assertNull(atomicBoolean.get());
|
||||||
|
@ -96,7 +96,7 @@ public class SettingTests extends ESTestCase {
|
||||||
Setting<Boolean> booleanSetting = Setting.boolSetting("foo.bar", false, true, Setting.Scope.Cluster);
|
Setting<Boolean> booleanSetting = Setting.boolSetting("foo.bar", false, true, Setting.Scope.Cluster);
|
||||||
AtomicReference<Boolean> ab1 = new AtomicReference<>(null);
|
AtomicReference<Boolean> ab1 = new AtomicReference<>(null);
|
||||||
AtomicReference<Boolean> ab2 = new AtomicReference<>(null);
|
AtomicReference<Boolean> ab2 = new AtomicReference<>(null);
|
||||||
ClusterSettingsService.SettingUpdater settingUpdater = booleanSetting.newUpdater(ab1::set, logger, Settings.EMPTY);
|
ClusterSettings.SettingUpdater settingUpdater = booleanSetting.newUpdater(ab1::set, logger, Settings.EMPTY);
|
||||||
settingUpdater.prepareApply(Settings.builder().put("foo.bar", true).build());
|
settingUpdater.prepareApply(Settings.builder().put("foo.bar", true).build());
|
||||||
assertNull(ab1.get());
|
assertNull(ab1.get());
|
||||||
assertNull(ab2.get());
|
assertNull(ab2.get());
|
||||||
|
@ -124,7 +124,7 @@ public class SettingTests extends ESTestCase {
|
||||||
assertFalse(setting.isGroupSetting());
|
assertFalse(setting.isGroupSetting());
|
||||||
ref.set(setting.get(Settings.EMPTY));
|
ref.set(setting.get(Settings.EMPTY));
|
||||||
ComplexType type = ref.get();
|
ComplexType type = ref.get();
|
||||||
ClusterSettingsService.SettingUpdater settingUpdater = setting.newUpdater(ref::set, logger, Settings.EMPTY);
|
ClusterSettings.SettingUpdater settingUpdater = setting.newUpdater(ref::set, logger, Settings.EMPTY);
|
||||||
assertFalse(settingUpdater.prepareApply(Settings.EMPTY));
|
assertFalse(settingUpdater.prepareApply(Settings.EMPTY));
|
||||||
settingUpdater.apply();
|
settingUpdater.apply();
|
||||||
assertSame("no update - type has not changed", type, ref.get());
|
assertSame("no update - type has not changed", type, ref.get());
|
||||||
|
@ -147,7 +147,7 @@ public class SettingTests extends ESTestCase {
|
||||||
Setting<Integer> integerSetting = Setting.intSetting("foo.int.bar", 1, true, Setting.Scope.Cluster);
|
Setting<Integer> integerSetting = Setting.intSetting("foo.int.bar", 1, true, Setting.Scope.Cluster);
|
||||||
assertFalse(integerSetting.isGroupSetting());
|
assertFalse(integerSetting.isGroupSetting());
|
||||||
AtomicReference<Integer> ref = new AtomicReference<>(null);
|
AtomicReference<Integer> ref = new AtomicReference<>(null);
|
||||||
ClusterSettingsService.SettingUpdater settingUpdater = integerSetting.newUpdater(ref::set, logger, Settings.EMPTY);
|
ClusterSettings.SettingUpdater settingUpdater = integerSetting.newUpdater(ref::set, logger, Settings.EMPTY);
|
||||||
assertNull(ref.get());
|
assertNull(ref.get());
|
||||||
assertTrue(settingUpdater.prepareApply(Settings.builder().put("foo.int.bar", "2").build()));
|
assertTrue(settingUpdater.prepareApply(Settings.builder().put("foo.int.bar", "2").build()));
|
||||||
settingUpdater.rollback();
|
settingUpdater.rollback();
|
||||||
|
@ -169,7 +169,7 @@ public class SettingTests extends ESTestCase {
|
||||||
AtomicReference<Settings> ref = new AtomicReference<>(null);
|
AtomicReference<Settings> ref = new AtomicReference<>(null);
|
||||||
Setting<Settings> setting = Setting.groupSetting("foo.bar.", true, Setting.Scope.Cluster);
|
Setting<Settings> setting = Setting.groupSetting("foo.bar.", true, Setting.Scope.Cluster);
|
||||||
assertTrue(setting.isGroupSetting());
|
assertTrue(setting.isGroupSetting());
|
||||||
ClusterSettingsService.SettingUpdater settingUpdater = setting.newUpdater(ref::set, logger, Settings.EMPTY);
|
ClusterSettings.SettingUpdater settingUpdater = setting.newUpdater(ref::set, logger, Settings.EMPTY);
|
||||||
|
|
||||||
assertTrue(settingUpdater.prepareApply(Settings.builder().put("foo.bar.1.value", "1").put("foo.bar.2.value", "2").put("foo.bar.3.value", "3").build()));
|
assertTrue(settingUpdater.prepareApply(Settings.builder().put("foo.bar.1.value", "1").put("foo.bar.2.value", "2").put("foo.bar.3.value", "3").build()));
|
||||||
settingUpdater.apply();
|
settingUpdater.apply();
|
||||||
|
@ -209,7 +209,7 @@ public class SettingTests extends ESTestCase {
|
||||||
assertTrue(setting.match("foo.bar.baz"));
|
assertTrue(setting.match("foo.bar.baz"));
|
||||||
assertFalse(setting.match("foo.baz.bar"));
|
assertFalse(setting.match("foo.baz.bar"));
|
||||||
|
|
||||||
ClusterSettingsService.SettingUpdater predicateSettingUpdater = setting.newUpdater(ref::set, logger, Settings.EMPTY, (s) -> false);
|
ClusterSettings.SettingUpdater predicateSettingUpdater = setting.newUpdater(ref::set, logger, Settings.EMPTY, (s) -> false);
|
||||||
try {
|
try {
|
||||||
predicateSettingUpdater.prepareApply(Settings.builder().put("foo.bar.1.value", "1").put("foo.bar.2.value", "2").build());
|
predicateSettingUpdater.prepareApply(Settings.builder().put("foo.bar.1.value", "1").put("foo.bar.2.value", "2").build());
|
||||||
fail("not accepted");
|
fail("not accepted");
|
||||||
|
@ -243,7 +243,7 @@ public class SettingTests extends ESTestCase {
|
||||||
Composite c = new Composite();
|
Composite c = new Composite();
|
||||||
Setting<Integer> a = Setting.intSetting("foo.int.bar.a", 1, true, Setting.Scope.Cluster);
|
Setting<Integer> a = Setting.intSetting("foo.int.bar.a", 1, true, Setting.Scope.Cluster);
|
||||||
Setting<Integer> b = Setting.intSetting("foo.int.bar.b", 1, true, Setting.Scope.Cluster);
|
Setting<Integer> b = Setting.intSetting("foo.int.bar.b", 1, true, Setting.Scope.Cluster);
|
||||||
ClusterSettingsService.SettingUpdater settingUpdater = Setting.compoundUpdater(c::set, a, b, logger, Settings.EMPTY);
|
ClusterSettings.SettingUpdater settingUpdater = Setting.compoundUpdater(c::set, a, b, logger, Settings.EMPTY);
|
||||||
assertFalse(settingUpdater.prepareApply(Settings.EMPTY));
|
assertFalse(settingUpdater.prepareApply(Settings.EMPTY));
|
||||||
settingUpdater.apply();
|
settingUpdater.apply();
|
||||||
assertNull(c.a);
|
assertNull(c.a);
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.ByteSizeUnit;
|
import org.elasticsearch.common.unit.ByteSizeUnit;
|
||||||
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
|
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
|
||||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
|
@ -339,7 +338,7 @@ public class BigArraysTests extends ESSingleNodeTestCase {
|
||||||
Settings.builder()
|
Settings.builder()
|
||||||
.put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), size - 1, ByteSizeUnit.BYTES)
|
.put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), size - 1, ByteSizeUnit.BYTES)
|
||||||
.build(),
|
.build(),
|
||||||
new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
|
new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
||||||
BigArrays bigArrays = new BigArrays(null, hcbs).withCircuitBreaking();
|
BigArrays bigArrays = new BigArrays(null, hcbs).withCircuitBreaking();
|
||||||
Method create = BigArrays.class.getMethod("new" + type + "Array", long.class);
|
Method create = BigArrays.class.getMethod("new" + type + "Array", long.class);
|
||||||
try {
|
try {
|
||||||
|
@ -359,7 +358,7 @@ public class BigArraysTests extends ESSingleNodeTestCase {
|
||||||
Settings.builder()
|
Settings.builder()
|
||||||
.put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), maxSize, ByteSizeUnit.BYTES)
|
.put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), maxSize, ByteSizeUnit.BYTES)
|
||||||
.build(),
|
.build(),
|
||||||
new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
|
new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
||||||
BigArrays bigArrays = new BigArrays(null, hcbs).withCircuitBreaking();
|
BigArrays bigArrays = new BigArrays(null, hcbs).withCircuitBreaking();
|
||||||
Method create = BigArrays.class.getMethod("new" + type + "Array", long.class);
|
Method create = BigArrays.class.getMethod("new" + type + "Array", long.class);
|
||||||
final int size = scaledRandomIntBetween(1, 20);
|
final int size = scaledRandomIntBetween(1, 20);
|
||||||
|
|
|
@ -39,7 +39,6 @@ import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||||
import org.elasticsearch.common.util.concurrent.BaseFuture;
|
import org.elasticsearch.common.util.concurrent.BaseFuture;
|
||||||
import org.elasticsearch.discovery.DiscoverySettings;
|
import org.elasticsearch.discovery.DiscoverySettings;
|
||||||
import org.elasticsearch.discovery.zen.membership.MembershipAction;
|
import org.elasticsearch.discovery.zen.membership.MembershipAction;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.test.cluster.TestClusterService;
|
import org.elasticsearch.test.cluster.TestClusterService;
|
||||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||||
|
@ -68,7 +67,7 @@ public class NodeJoinControllerTests extends ESTestCase {
|
||||||
// make sure we have a master
|
// make sure we have a master
|
||||||
clusterService.setState(ClusterState.builder(clusterService.state()).nodes(DiscoveryNodes.builder(initialNodes).masterNodeId(localNode.id())));
|
clusterService.setState(ClusterState.builder(clusterService.state()).nodes(DiscoveryNodes.builder(initialNodes).masterNodeId(localNode.id())));
|
||||||
nodeJoinController = new NodeJoinController(clusterService, new NoopRoutingService(Settings.EMPTY),
|
nodeJoinController = new NodeJoinController(clusterService, new NoopRoutingService(Settings.EMPTY),
|
||||||
new DiscoverySettings(Settings.EMPTY, new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS))), Settings.EMPTY);
|
new DiscoverySettings(Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), Settings.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimpleJoinAccumulation() throws InterruptedException, ExecutionException {
|
public void testSimpleJoinAccumulation() throws InterruptedException, ExecutionException {
|
||||||
|
|
|
@ -43,7 +43,6 @@ import org.elasticsearch.discovery.Discovery;
|
||||||
import org.elasticsearch.discovery.DiscoverySettings;
|
import org.elasticsearch.discovery.DiscoverySettings;
|
||||||
import org.elasticsearch.discovery.zen.DiscoveryNodesProvider;
|
import org.elasticsearch.discovery.zen.DiscoveryNodesProvider;
|
||||||
import org.elasticsearch.node.service.NodeService;
|
import org.elasticsearch.node.service.NodeService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||||
import org.elasticsearch.test.transport.MockTransportService;
|
import org.elasticsearch.test.transport.MockTransportService;
|
||||||
|
@ -238,7 +237,7 @@ public class PublishClusterStateActionTests extends ESTestCase {
|
||||||
|
|
||||||
protected MockPublishAction buildPublishClusterStateAction(Settings settings, MockTransportService transportService, DiscoveryNodesProvider nodesProvider,
|
protected MockPublishAction buildPublishClusterStateAction(Settings settings, MockTransportService transportService, DiscoveryNodesProvider nodesProvider,
|
||||||
PublishClusterStateAction.NewPendingClusterStateListener listener) {
|
PublishClusterStateAction.NewPendingClusterStateListener listener) {
|
||||||
DiscoverySettings discoverySettings = new DiscoverySettings(settings, new ClusterSettingsService(settings, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
|
DiscoverySettings discoverySettings = new DiscoverySettings(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
||||||
return new MockPublishAction(settings, transportService, nodesProvider, listener, discoverySettings, ClusterName.DEFAULT);
|
return new MockPublishAction(settings, transportService, nodesProvider, listener, discoverySettings, ClusterName.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.indices.breaker.BreakerSettings;
|
import org.elasticsearch.indices.breaker.BreakerSettings;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
|
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
@ -67,7 +66,7 @@ public class CircuitBreakerUnitTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRegisterCustomBreaker() throws Exception {
|
public void testRegisterCustomBreaker() throws Exception {
|
||||||
CircuitBreakerService service = new HierarchyCircuitBreakerService(Settings.EMPTY, new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
|
CircuitBreakerService service = new HierarchyCircuitBreakerService(Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
||||||
String customName = "custom";
|
String customName = "custom";
|
||||||
BreakerSettings settings = new BreakerSettings(customName, 20, 1.0);
|
BreakerSettings settings = new BreakerSettings(customName, 20, 1.0);
|
||||||
service.registerBreaker(settings);
|
service.registerBreaker(settings);
|
||||||
|
|
|
@ -45,7 +45,6 @@ import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.index.store.DirectoryService;
|
import org.elasticsearch.index.store.DirectoryService;
|
||||||
import org.elasticsearch.index.store.Store;
|
import org.elasticsearch.index.store.Store;
|
||||||
import org.elasticsearch.index.store.StoreFileMetaData;
|
import org.elasticsearch.index.store.StoreFileMetaData;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.test.CorruptionUtils;
|
import org.elasticsearch.test.CorruptionUtils;
|
||||||
import org.elasticsearch.test.DummyShardLock;
|
import org.elasticsearch.test.DummyShardLock;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
@ -61,7 +60,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
public class RecoverySourceHandlerTests extends ESTestCase {
|
public class RecoverySourceHandlerTests extends ESTestCase {
|
||||||
private static final IndexSettings INDEX_SETTINGS = IndexSettingsModule.newIndexSettings(new Index("index"), Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, org.elasticsearch.Version.CURRENT).build());
|
private static final IndexSettings INDEX_SETTINGS = IndexSettingsModule.newIndexSettings(new Index("index"), Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, org.elasticsearch.Version.CURRENT).build());
|
||||||
private final ShardId shardId = new ShardId(INDEX_SETTINGS.getIndex(), 1);
|
private final ShardId shardId = new ShardId(INDEX_SETTINGS.getIndex(), 1);
|
||||||
private final ClusterSettingsService service = new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
private final ClusterSettings service = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
|
|
||||||
public void testSendFiles() throws Throwable {
|
public void testSendFiles() throws Throwable {
|
||||||
Settings settings = Settings.builder().put("indices.recovery.concurrent_streams", 1).
|
Settings settings = Settings.builder().put("indices.recovery.concurrent_streams", 1).
|
||||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.threadpool;
|
||||||
import org.elasticsearch.common.settings.ClusterSettings;
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor;
|
import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.threadpool.ThreadPool.Names;
|
import org.elasticsearch.threadpool.ThreadPool.Names;
|
||||||
|
|
||||||
|
@ -92,10 +91,10 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
ThreadPool threadPool = null;
|
ThreadPool threadPool = null;
|
||||||
try {
|
try {
|
||||||
threadPool = new ThreadPool(settingsBuilder().put("name", "testUpdateSettingsCanNotChangeThreadPoolType").build());
|
threadPool = new ThreadPool(settingsBuilder().put("name", "testUpdateSettingsCanNotChangeThreadPoolType").build());
|
||||||
ClusterSettingsService clusterSettingsService = new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
threadPool.setNodeSettingsService(clusterSettingsService);
|
threadPool.setNodeSettingsService(clusterSettings);
|
||||||
|
|
||||||
clusterSettingsService.applySettings(
|
clusterSettings.applySettings(
|
||||||
settingsBuilder()
|
settingsBuilder()
|
||||||
.put("threadpool." + threadPoolName + ".type", invalidThreadPoolType.getType())
|
.put("threadpool." + threadPoolName + ".type", invalidThreadPoolType.getType())
|
||||||
.build()
|
.build()
|
||||||
|
@ -117,13 +116,13 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
Settings nodeSettings = Settings.settingsBuilder()
|
Settings nodeSettings = Settings.settingsBuilder()
|
||||||
.put("name", "testCachedExecutorType").build();
|
.put("name", "testCachedExecutorType").build();
|
||||||
threadPool = new ThreadPool(nodeSettings);
|
threadPool = new ThreadPool(nodeSettings);
|
||||||
ClusterSettingsService clusterSettingsService = new ClusterSettingsService(nodeSettings, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings clusterSettings = new ClusterSettings(nodeSettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
threadPool.setNodeSettingsService(clusterSettingsService);
|
threadPool.setNodeSettingsService(clusterSettings);
|
||||||
|
|
||||||
assertEquals(info(threadPool, threadPoolName).getThreadPoolType(), ThreadPool.ThreadPoolType.CACHED);
|
assertEquals(info(threadPool, threadPoolName).getThreadPoolType(), ThreadPool.ThreadPoolType.CACHED);
|
||||||
assertThat(threadPool.executor(threadPoolName), instanceOf(EsThreadPoolExecutor.class));
|
assertThat(threadPool.executor(threadPoolName), instanceOf(EsThreadPoolExecutor.class));
|
||||||
|
|
||||||
Settings settings = clusterSettingsService.applySettings(settingsBuilder()
|
Settings settings = clusterSettings.applySettings(settingsBuilder()
|
||||||
.put("threadpool." + threadPoolName + ".keep_alive", "10m")
|
.put("threadpool." + threadPoolName + ".keep_alive", "10m")
|
||||||
.build());
|
.build());
|
||||||
assertEquals(info(threadPool, threadPoolName).getThreadPoolType(), ThreadPool.ThreadPoolType.CACHED);
|
assertEquals(info(threadPool, threadPoolName).getThreadPoolType(), ThreadPool.ThreadPoolType.CACHED);
|
||||||
|
@ -139,7 +138,7 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
|
|
||||||
// Change keep alive
|
// Change keep alive
|
||||||
Executor oldExecutor = threadPool.executor(threadPoolName);
|
Executor oldExecutor = threadPool.executor(threadPoolName);
|
||||||
settings = clusterSettingsService.applySettings(settingsBuilder().put(settings).put("threadpool." + threadPoolName + ".keep_alive", "1m").build());
|
settings = clusterSettings.applySettings(settingsBuilder().put(settings).put("threadpool." + threadPoolName + ".keep_alive", "1m").build());
|
||||||
// Make sure keep alive value changed
|
// Make sure keep alive value changed
|
||||||
assertThat(info(threadPool, threadPoolName).getKeepAlive().minutes(), equalTo(1L));
|
assertThat(info(threadPool, threadPoolName).getKeepAlive().minutes(), equalTo(1L));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(threadPoolName)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(1L));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(threadPoolName)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(1L));
|
||||||
|
@ -148,7 +147,7 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
assertThat(threadPool.executor(threadPoolName), sameInstance(oldExecutor));
|
assertThat(threadPool.executor(threadPoolName), sameInstance(oldExecutor));
|
||||||
|
|
||||||
// Set the same keep alive
|
// Set the same keep alive
|
||||||
settings = clusterSettingsService.applySettings(settingsBuilder().put(settings).put("threadpool." + threadPoolName + ".keep_alive", "1m").build());
|
settings = clusterSettings.applySettings(settingsBuilder().put(settings).put("threadpool." + threadPoolName + ".keep_alive", "1m").build());
|
||||||
// Make sure keep alive value didn't change
|
// Make sure keep alive value didn't change
|
||||||
assertThat(info(threadPool, threadPoolName).getKeepAlive().minutes(), equalTo(1L));
|
assertThat(info(threadPool, threadPoolName).getKeepAlive().minutes(), equalTo(1L));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(threadPoolName)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(1L));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(threadPoolName)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(1L));
|
||||||
|
@ -168,10 +167,10 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
Settings nodeSettings = Settings.settingsBuilder()
|
Settings nodeSettings = Settings.settingsBuilder()
|
||||||
.put("name", "testFixedExecutorType").build();
|
.put("name", "testFixedExecutorType").build();
|
||||||
threadPool = new ThreadPool(nodeSettings);
|
threadPool = new ThreadPool(nodeSettings);
|
||||||
ClusterSettingsService clusterSettingsService = new ClusterSettingsService(nodeSettings, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings clusterSettings = new ClusterSettings(nodeSettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
threadPool.setNodeSettingsService(clusterSettingsService);
|
threadPool.setNodeSettingsService(clusterSettings);
|
||||||
assertThat(threadPool.executor(threadPoolName), instanceOf(EsThreadPoolExecutor.class));
|
assertThat(threadPool.executor(threadPoolName), instanceOf(EsThreadPoolExecutor.class));
|
||||||
Settings settings = clusterSettingsService.applySettings(settingsBuilder()
|
Settings settings = clusterSettings.applySettings(settingsBuilder()
|
||||||
.put("threadpool." + threadPoolName + ".size", "15")
|
.put("threadpool." + threadPoolName + ".size", "15")
|
||||||
.build());
|
.build());
|
||||||
assertEquals(info(threadPool, threadPoolName).getThreadPoolType(), ThreadPool.ThreadPoolType.FIXED);
|
assertEquals(info(threadPool, threadPoolName).getThreadPoolType(), ThreadPool.ThreadPoolType.FIXED);
|
||||||
|
@ -184,7 +183,7 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(threadPoolName)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(0L));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(threadPoolName)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(0L));
|
||||||
|
|
||||||
// Put old type back
|
// Put old type back
|
||||||
settings = clusterSettingsService.applySettings(Settings.EMPTY);
|
settings = clusterSettings.applySettings(Settings.EMPTY);
|
||||||
assertEquals(info(threadPool, threadPoolName).getThreadPoolType(), ThreadPool.ThreadPoolType.FIXED);
|
assertEquals(info(threadPool, threadPoolName).getThreadPoolType(), ThreadPool.ThreadPoolType.FIXED);
|
||||||
// Make sure keep alive value is not used
|
// Make sure keep alive value is not used
|
||||||
assertThat(info(threadPool, threadPoolName).getKeepAlive(), nullValue());
|
assertThat(info(threadPool, threadPoolName).getKeepAlive(), nullValue());
|
||||||
|
@ -197,7 +196,7 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
|
|
||||||
// Change size
|
// Change size
|
||||||
Executor oldExecutor = threadPool.executor(threadPoolName);
|
Executor oldExecutor = threadPool.executor(threadPoolName);
|
||||||
settings = clusterSettingsService.applySettings(settingsBuilder().put(settings).put("threadpool." + threadPoolName + ".size", "10").build());
|
settings = clusterSettings.applySettings(settingsBuilder().put(settings).put("threadpool." + threadPoolName + ".size", "10").build());
|
||||||
// Make sure size values changed
|
// Make sure size values changed
|
||||||
assertThat(info(threadPool, threadPoolName).getMax(), equalTo(10));
|
assertThat(info(threadPool, threadPoolName).getMax(), equalTo(10));
|
||||||
assertThat(info(threadPool, threadPoolName).getMin(), equalTo(10));
|
assertThat(info(threadPool, threadPoolName).getMin(), equalTo(10));
|
||||||
|
@ -208,7 +207,7 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
assertThat(threadPool.executor(threadPoolName), sameInstance(oldExecutor));
|
assertThat(threadPool.executor(threadPoolName), sameInstance(oldExecutor));
|
||||||
|
|
||||||
// Change queue capacity
|
// Change queue capacity
|
||||||
settings = clusterSettingsService.applySettings(settingsBuilder().put(settings).put("threadpool." + threadPoolName + ".queue", "500")
|
settings = clusterSettings.applySettings(settingsBuilder().put(settings).put("threadpool." + threadPoolName + ".queue", "500")
|
||||||
.build());
|
.build());
|
||||||
} finally {
|
} finally {
|
||||||
terminateThreadPoolIfNeeded(threadPool);
|
terminateThreadPoolIfNeeded(threadPool);
|
||||||
|
@ -223,8 +222,8 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
.put("threadpool." + threadPoolName + ".size", 10)
|
.put("threadpool." + threadPoolName + ".size", 10)
|
||||||
.put("name", "testScalingExecutorType").build();
|
.put("name", "testScalingExecutorType").build();
|
||||||
threadPool = new ThreadPool(nodeSettings);
|
threadPool = new ThreadPool(nodeSettings);
|
||||||
ClusterSettingsService clusterSettingsService = new ClusterSettingsService(nodeSettings, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings clusterSettings = new ClusterSettings(nodeSettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
threadPool.setNodeSettingsService(clusterSettingsService);
|
threadPool.setNodeSettingsService(clusterSettings);
|
||||||
assertThat(info(threadPool, threadPoolName).getMin(), equalTo(1));
|
assertThat(info(threadPool, threadPoolName).getMin(), equalTo(1));
|
||||||
assertThat(info(threadPool, threadPoolName).getMax(), equalTo(10));
|
assertThat(info(threadPool, threadPoolName).getMax(), equalTo(10));
|
||||||
assertThat(info(threadPool, threadPoolName).getKeepAlive().minutes(), equalTo(5L));
|
assertThat(info(threadPool, threadPoolName).getKeepAlive().minutes(), equalTo(5L));
|
||||||
|
@ -233,7 +232,7 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
|
|
||||||
// Change settings that doesn't require pool replacement
|
// Change settings that doesn't require pool replacement
|
||||||
Executor oldExecutor = threadPool.executor(threadPoolName);
|
Executor oldExecutor = threadPool.executor(threadPoolName);
|
||||||
clusterSettingsService.applySettings(settingsBuilder()
|
clusterSettings.applySettings(settingsBuilder()
|
||||||
.put("threadpool." + threadPoolName + ".keep_alive", "10m")
|
.put("threadpool." + threadPoolName + ".keep_alive", "10m")
|
||||||
.put("threadpool." + threadPoolName + ".min", "2")
|
.put("threadpool." + threadPoolName + ".min", "2")
|
||||||
.put("threadpool." + threadPoolName + ".size", "15")
|
.put("threadpool." + threadPoolName + ".size", "15")
|
||||||
|
@ -261,8 +260,8 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
.put("threadpool." + threadPoolName + ".queue_size", 1000)
|
.put("threadpool." + threadPoolName + ".queue_size", 1000)
|
||||||
.put("name", "testCachedExecutorType").build();
|
.put("name", "testCachedExecutorType").build();
|
||||||
threadPool = new ThreadPool(nodeSettings);
|
threadPool = new ThreadPool(nodeSettings);
|
||||||
ClusterSettingsService clusterSettingsService = new ClusterSettingsService(nodeSettings, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings clusterSettings = new ClusterSettings(nodeSettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
threadPool.setNodeSettingsService(clusterSettingsService);
|
threadPool.setNodeSettingsService(clusterSettings);
|
||||||
assertEquals(info(threadPool, threadPoolName).getQueueSize().getSingles(), 1000L);
|
assertEquals(info(threadPool, threadPoolName).getQueueSize().getSingles(), 1000L);
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
@ -276,7 +275,7 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
clusterSettingsService.applySettings(settingsBuilder().put("threadpool." + threadPoolName + ".queue_size", 2000).build());
|
clusterSettings.applySettings(settingsBuilder().put("threadpool." + threadPoolName + ".queue_size", 2000).build());
|
||||||
assertThat(threadPool.executor(threadPoolName), not(sameInstance(oldExecutor)));
|
assertThat(threadPool.executor(threadPoolName), not(sameInstance(oldExecutor)));
|
||||||
assertThat(oldExecutor.isShutdown(), equalTo(true));
|
assertThat(oldExecutor.isShutdown(), equalTo(true));
|
||||||
assertThat(oldExecutor.isTerminating(), equalTo(true));
|
assertThat(oldExecutor.isTerminating(), equalTo(true));
|
||||||
|
@ -298,8 +297,8 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
.put("threadpool.my_pool2.queue_size", "1")
|
.put("threadpool.my_pool2.queue_size", "1")
|
||||||
.put("name", "testCustomThreadPool").build();
|
.put("name", "testCustomThreadPool").build();
|
||||||
threadPool = new ThreadPool(nodeSettings);
|
threadPool = new ThreadPool(nodeSettings);
|
||||||
ClusterSettingsService clusterSettingsService = new ClusterSettingsService(nodeSettings, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings clusterSettings = new ClusterSettings(nodeSettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
threadPool.setNodeSettingsService(clusterSettingsService);
|
threadPool.setNodeSettingsService(clusterSettings);
|
||||||
ThreadPoolInfo groups = threadPool.info();
|
ThreadPoolInfo groups = threadPool.info();
|
||||||
boolean foundPool1 = false;
|
boolean foundPool1 = false;
|
||||||
boolean foundPool2 = false;
|
boolean foundPool2 = false;
|
||||||
|
@ -331,7 +330,7 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase {
|
||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.put("threadpool.my_pool2.size", "10")
|
.put("threadpool.my_pool2.size", "10")
|
||||||
.build();
|
.build();
|
||||||
clusterSettingsService.applySettings(settings);
|
clusterSettings.applySettings(settings);
|
||||||
|
|
||||||
groups = threadPool.info();
|
groups = threadPool.info();
|
||||||
foundPool1 = false;
|
foundPool1 = false;
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||||
import org.elasticsearch.test.transport.MockTransportService;
|
import org.elasticsearch.test.transport.MockTransportService;
|
||||||
|
@ -652,7 +651,7 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
|
||||||
includeSettings = "test";
|
includeSettings = "test";
|
||||||
excludeSettings = "DOESN'T_MATCH";
|
excludeSettings = "DOESN'T_MATCH";
|
||||||
}
|
}
|
||||||
ClusterSettingsService service = new ClusterSettingsService(Settings.EMPTY, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
ClusterSettings service = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
||||||
serviceA.setDynamicSettings(service);
|
serviceA.setDynamicSettings(service);
|
||||||
service.applySettings(Settings.builder()
|
service.applySettings(Settings.builder()
|
||||||
.put(TransportService.TRACE_LOG_INCLUDE_SETTING.getKey(), includeSettings, TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), excludeSettings)
|
.put(TransportService.TRACE_LOG_INCLUDE_SETTING.getKey(), includeSettings, TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), excludeSettings)
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||||
import org.elasticsearch.common.util.BigArrays;
|
import org.elasticsearch.common.util.BigArrays;
|
||||||
import org.elasticsearch.common.util.MockBigArrays;
|
import org.elasticsearch.common.util.MockBigArrays;
|
||||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.netty.NettyTransport;
|
import org.elasticsearch.transport.netty.NettyTransport;
|
||||||
|
@ -65,7 +64,7 @@ public class NettySizeHeaderFrameDecoderTests extends ESTestCase {
|
||||||
@Before
|
@Before
|
||||||
public void startThreadPool() {
|
public void startThreadPool() {
|
||||||
threadPool = new ThreadPool(settings);
|
threadPool = new ThreadPool(settings);
|
||||||
threadPool.setNodeSettingsService(new ClusterSettingsService(settings, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
|
threadPool.setNodeSettingsService(new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
|
||||||
NetworkService networkService = new NetworkService(settings);
|
NetworkService networkService = new NetworkService(settings);
|
||||||
BigArrays bigArrays = new MockBigArrays(new MockPageCacheRecycler(settings, threadPool), new NoneCircuitBreakerService());
|
BigArrays bigArrays = new MockBigArrays(new MockPageCacheRecycler(settings, threadPool), new NoneCircuitBreakerService());
|
||||||
nettyTransport = new NettyTransport(settings, threadPool, networkService, bigArrays, Version.CURRENT, new NamedWriteableRegistry());
|
nettyTransport = new NettyTransport(settings, threadPool, networkService, bigArrays, Version.CURRENT, new NamedWriteableRegistry());
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.elasticsearch.discovery.DiscoverySettings;
|
||||||
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
||||||
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
|
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
|
||||||
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.elasticsearch.discovery.DiscoverySettings;
|
||||||
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
||||||
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
|
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
|
||||||
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.elasticsearch.discovery.DiscoverySettings;
|
||||||
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
||||||
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
|
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
|
||||||
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,11 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.DummyTransportAddress;
|
import org.elasticsearch.common.transport.DummyTransportAddress;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.monitor.fs.FsInfo;
|
import org.elasticsearch.monitor.fs.FsInfo;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
|
||||||
|
@ -78,11 +78,11 @@ public class MockInternalClusterInfoService extends InternalClusterInfoService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MockInternalClusterInfoService(Settings settings, ClusterSettingsService clusterSettingsService,
|
public MockInternalClusterInfoService(Settings settings, ClusterSettings clusterSettings,
|
||||||
TransportNodesStatsAction transportNodesStatsAction,
|
TransportNodesStatsAction transportNodesStatsAction,
|
||||||
TransportIndicesStatsAction transportIndicesStatsAction,
|
TransportIndicesStatsAction transportIndicesStatsAction,
|
||||||
ClusterService clusterService, ThreadPool threadPool) {
|
ClusterService clusterService, ThreadPool threadPool) {
|
||||||
super(settings, clusterSettingsService, transportNodesStatsAction, transportIndicesStatsAction, clusterService, threadPool);
|
super(settings, clusterSettings, transportNodesStatsAction, transportIndicesStatsAction, clusterService, threadPool);
|
||||||
this.clusterName = ClusterName.clusterNameFromSettings(settings);
|
this.clusterName = ClusterName.clusterNameFromSettings(settings);
|
||||||
stats[0] = makeStats("node_t1", new DiskUsage("node_t1", "n1", "/dev/null", 100, 100));
|
stats[0] = makeStats("node_t1", new DiskUsage("node_t1", "n1", "/dev/null", 100, 100));
|
||||||
stats[1] = makeStats("node_t2", new DiskUsage("node_t2", "n2", "/dev/null", 100, 100));
|
stats[1] = makeStats("node_t2", new DiskUsage("node_t2", "n2", "/dev/null", 100, 100));
|
||||||
|
|
|
@ -22,12 +22,12 @@ package org.elasticsearch.search;
|
||||||
import org.elasticsearch.cache.recycler.PageCacheRecycler;
|
import org.elasticsearch.cache.recycler.PageCacheRecycler;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.util.BigArrays;
|
import org.elasticsearch.common.util.BigArrays;
|
||||||
import org.elasticsearch.indices.IndicesService;
|
import org.elasticsearch.indices.IndicesService;
|
||||||
import org.elasticsearch.indices.IndicesWarmer;
|
import org.elasticsearch.indices.IndicesWarmer;
|
||||||
import org.elasticsearch.indices.cache.request.IndicesRequestCache;
|
import org.elasticsearch.indices.cache.request.IndicesRequestCache;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.script.ScriptService;
|
import org.elasticsearch.script.ScriptService;
|
||||||
import org.elasticsearch.search.dfs.DfsPhase;
|
import org.elasticsearch.search.dfs.DfsPhase;
|
||||||
|
@ -67,13 +67,13 @@ public class MockSearchService extends SearchService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MockSearchService(Settings settings, ClusterSettingsService clusterSettingsService, ClusterService clusterService, IndicesService indicesService, IndicesWarmer indicesWarmer,
|
public MockSearchService(Settings settings, ClusterSettings clusterSettings, ClusterService clusterService, IndicesService indicesService, IndicesWarmer indicesWarmer,
|
||||||
ThreadPool threadPool, ScriptService scriptService, PageCacheRecycler pageCacheRecycler, BigArrays bigArrays,
|
ThreadPool threadPool, ScriptService scriptService, PageCacheRecycler pageCacheRecycler, BigArrays bigArrays,
|
||||||
DfsPhase dfsPhase, QueryPhase queryPhase, FetchPhase fetchPhase, IndicesRequestCache indicesQueryCache) {
|
DfsPhase dfsPhase, QueryPhase queryPhase, FetchPhase fetchPhase, IndicesRequestCache indicesQueryCache) {
|
||||||
super(settings, clusterSettingsService, clusterService, indicesService, indicesWarmer, threadPool, scriptService, pageCacheRecycler, bigArrays, dfsPhase,
|
super(settings, clusterSettings, clusterService, indicesService, indicesWarmer, threadPool, scriptService, pageCacheRecycler, bigArrays, dfsPhase,
|
||||||
queryPhase, fetchPhase, indicesQueryCache);
|
queryPhase, fetchPhase, indicesQueryCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void putContext(SearchContext context) {
|
protected void putContext(SearchContext context) {
|
||||||
super.putContext(context);
|
super.putContext(context);
|
||||||
|
|
|
@ -44,7 +44,6 @@ import org.elasticsearch.gateway.AsyncShardFetch;
|
||||||
import org.elasticsearch.gateway.GatewayAllocator;
|
import org.elasticsearch.gateway.GatewayAllocator;
|
||||||
import org.elasticsearch.gateway.ReplicaShardAllocator;
|
import org.elasticsearch.gateway.ReplicaShardAllocator;
|
||||||
import org.elasticsearch.indices.store.TransportNodesListShardStoreMetaData;
|
import org.elasticsearch.indices.store.TransportNodesListShardStoreMetaData;
|
||||||
import org.elasticsearch.common.settings.ClusterSettingsService;
|
|
||||||
import org.elasticsearch.test.gateway.NoopGatewayAllocator;
|
import org.elasticsearch.test.gateway.NoopGatewayAllocator;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
@ -68,37 +67,37 @@ public abstract class ESAllocationTestCase extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MockAllocationService createAllocationService(Settings settings, Random random) {
|
public static MockAllocationService createAllocationService(Settings settings, Random random) {
|
||||||
return createAllocationService(settings, new ClusterSettingsService(Settings.Builder.EMPTY_SETTINGS, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), random);
|
return createAllocationService(settings, new ClusterSettings(Settings.Builder.EMPTY_SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), random);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MockAllocationService createAllocationService(Settings settings, ClusterSettingsService clusterSettingsService, Random random) {
|
public static MockAllocationService createAllocationService(Settings settings, ClusterSettings clusterSettings, Random random) {
|
||||||
return new MockAllocationService(settings,
|
return new MockAllocationService(settings,
|
||||||
randomAllocationDeciders(settings, clusterSettingsService, random),
|
randomAllocationDeciders(settings, clusterSettings, random),
|
||||||
new ShardsAllocators(settings, NoopGatewayAllocator.INSTANCE), EmptyClusterInfoService.INSTANCE);
|
new ShardsAllocators(settings, NoopGatewayAllocator.INSTANCE), EmptyClusterInfoService.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MockAllocationService createAllocationService(Settings settings, ClusterInfoService clusterInfoService) {
|
public static MockAllocationService createAllocationService(Settings settings, ClusterInfoService clusterInfoService) {
|
||||||
return new MockAllocationService(settings,
|
return new MockAllocationService(settings,
|
||||||
randomAllocationDeciders(settings, new ClusterSettingsService(Settings.Builder.EMPTY_SETTINGS, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), getRandom()),
|
randomAllocationDeciders(settings, new ClusterSettings(Settings.Builder.EMPTY_SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), getRandom()),
|
||||||
new ShardsAllocators(settings, NoopGatewayAllocator.INSTANCE), clusterInfoService);
|
new ShardsAllocators(settings, NoopGatewayAllocator.INSTANCE), clusterInfoService);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MockAllocationService createAllocationService(Settings settings, GatewayAllocator allocator) {
|
public static MockAllocationService createAllocationService(Settings settings, GatewayAllocator allocator) {
|
||||||
return new MockAllocationService(settings,
|
return new MockAllocationService(settings,
|
||||||
randomAllocationDeciders(settings, new ClusterSettingsService(Settings.Builder.EMPTY_SETTINGS, new ClusterSettings(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), getRandom()),
|
randomAllocationDeciders(settings, new ClusterSettings(Settings.Builder.EMPTY_SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), getRandom()),
|
||||||
new ShardsAllocators(settings, allocator), EmptyClusterInfoService.INSTANCE);
|
new ShardsAllocators(settings, allocator), EmptyClusterInfoService.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static AllocationDeciders randomAllocationDeciders(Settings settings, ClusterSettingsService clusterSettingsService, Random random) {
|
public static AllocationDeciders randomAllocationDeciders(Settings settings, ClusterSettings clusterSettings, Random random) {
|
||||||
final List<Class<? extends AllocationDecider>> defaultAllocationDeciders = ClusterModule.DEFAULT_ALLOCATION_DECIDERS;
|
final List<Class<? extends AllocationDecider>> defaultAllocationDeciders = ClusterModule.DEFAULT_ALLOCATION_DECIDERS;
|
||||||
final List<AllocationDecider> list = new ArrayList<>();
|
final List<AllocationDecider> list = new ArrayList<>();
|
||||||
for (Class<? extends AllocationDecider> deciderClass : ClusterModule.DEFAULT_ALLOCATION_DECIDERS) {
|
for (Class<? extends AllocationDecider> deciderClass : ClusterModule.DEFAULT_ALLOCATION_DECIDERS) {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
Constructor<? extends AllocationDecider> constructor = deciderClass.getConstructor(Settings.class, ClusterSettingsService.class);
|
Constructor<? extends AllocationDecider> constructor = deciderClass.getConstructor(Settings.class, ClusterSettings.class);
|
||||||
list.add(constructor.newInstance(settings, clusterSettingsService));
|
list.add(constructor.newInstance(settings, clusterSettings));
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
Constructor<? extends AllocationDecider> constructor = null;
|
Constructor<? extends AllocationDecider> constructor = null;
|
||||||
constructor = deciderClass.getConstructor(Settings.class);
|
constructor = deciderClass.getConstructor(Settings.class);
|
||||||
|
|
Loading…
Reference in New Issue