Convert several more settings
This commit is contained in:
parent
71b204ea49
commit
8543d7795e
|
@ -36,6 +36,7 @@ import org.elasticsearch.indices.recovery.RecoverySettings;
|
|||
import org.elasticsearch.indices.ttl.IndicesTTLService;
|
||||
import org.elasticsearch.search.SearchService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -134,5 +135,6 @@ public final class ClusterSettings extends AbstractScopedSettings {
|
|||
ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING,
|
||||
InternalClusterService.CLUSTER_SERVICE_RECONNECT_INTERVAL_SETTING,
|
||||
HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_TYPE_SETTING,
|
||||
HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_TYPE_SETTING)));
|
||||
HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_TYPE_SETTING,
|
||||
Transport.TRANSPORT_PROFILES_SETTING)));
|
||||
}
|
||||
|
|
|
@ -312,6 +312,9 @@ public class Setting<T> extends ToXContentToBytes {
|
|||
}
|
||||
|
||||
public static <T> Setting<List<T>> listSetting(String key, List<String> defaultStringValue, Function<String, T> singleValueParser, boolean dynamic, Scope scope) {
|
||||
return listSetting(key, (s) -> defaultStringValue, singleValueParser, dynamic, scope);
|
||||
}
|
||||
public static <T> Setting<List<T>> listSetting(String key, Function<Settings, List<String>> defaultStringValue, Function<String, T> singleValueParser, boolean dynamic, Scope scope) {
|
||||
Function<String, List<T>> parser = (s) -> {
|
||||
try (XContentParser xContentParser = XContentType.JSON.xContent().createParser(s)){
|
||||
XContentParser.Token token = xContentParser.nextToken();
|
||||
|
@ -330,7 +333,7 @@ public class Setting<T> extends ToXContentToBytes {
|
|||
throw new IllegalArgumentException("failed to parse array", e);
|
||||
}
|
||||
};
|
||||
return new Setting<List<T>>(key, arrayToParsableString(defaultStringValue.toArray(Strings.EMPTY_ARRAY)), parser, dynamic, scope) {
|
||||
return new Setting<List<T>>(key, (s) -> arrayToParsableString(defaultStringValue.apply(s).toArray(Strings.EMPTY_ARRAY)), parser, dynamic, scope) {
|
||||
private final Pattern pattern = Pattern.compile(Pattern.quote(key)+"(\\.\\d+)?");
|
||||
@Override
|
||||
public String getRaw(Settings settings) {
|
||||
|
|
|
@ -652,7 +652,11 @@ public final class Settings implements ToXContent {
|
|||
* Returns group settings for the given setting prefix.
|
||||
*/
|
||||
public Map<String, Settings> getAsGroups() throws SettingsException {
|
||||
return getGroupsInternal("", false);
|
||||
return getAsGroups(false);
|
||||
}
|
||||
|
||||
public Map<String, Settings> getAsGroups(boolean ignoreNonGrouped) throws SettingsException {
|
||||
return getGroupsInternal("", ignoreNonGrouped);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,6 +21,8 @@ package org.elasticsearch.transport;
|
|||
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.component.LifecycleComponent;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.BoundTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
|
||||
|
@ -34,6 +36,8 @@ import java.util.Map;
|
|||
public interface Transport extends LifecycleComponent<Transport> {
|
||||
|
||||
|
||||
Setting<Settings> TRANSPORT_PROFILES_SETTING = Setting.groupSetting("transport.profiles.", false, Setting.Scope.CLUSTER);
|
||||
|
||||
public static class TransportSettings {
|
||||
public static final String TRANSPORT_TCP_COMPRESS = "transport.tcp.compress";
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS;
|
||||
|
@ -84,8 +85,9 @@ public class TransportService extends AbstractLifecycleComponent<TransportServic
|
|||
|
||||
// tracer log
|
||||
|
||||
public static final Setting<List<String>> TRACE_LOG_INCLUDE_SETTING = Setting.listSetting("transport.tracer.include", Collections.emptyList(), (s) -> s, true, Setting.Scope.CLUSTER);
|
||||
public static final Setting<List<String>> TRACE_LOG_EXCLUDE_SETTING = Setting.listSetting("transport.tracer.exclude", Arrays.asList("internal:discovery/zen/fd*", TransportLivenessAction.NAME), (s) -> s, true, Setting.Scope.CLUSTER);
|
||||
public static final Setting<List<String>> TRACE_LOG_INCLUDE_SETTING = Setting.listSetting("transport.tracer.include", Collections.emptyList(), Function.identity(), true, Setting.Scope.CLUSTER);
|
||||
public static final Setting<List<String>> TRACE_LOG_EXCLUDE_SETTING = Setting.listSetting("transport.tracer.exclude", Arrays.asList("internal:discovery/zen/fd*", TransportLivenessAction.NAME), Function.identity(), true, Setting.Scope.CLUSTER);
|
||||
|
||||
|
||||
private final ESLogger tracerLog;
|
||||
|
||||
|
|
|
@ -295,7 +295,7 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
|
|||
this.serverOpenChannels = openChannels;
|
||||
|
||||
// extract default profile first and create standard bootstrap
|
||||
Map<String, Settings> profiles = settings.getGroups("transport.profiles", true);
|
||||
Map<String, Settings> profiles = TRANSPORT_PROFILES_SETTING.get(settings()).getAsGroups(true);
|
||||
if (!profiles.containsKey(DEFAULT_PROFILE)) {
|
||||
profiles = new HashMap<>(profiles);
|
||||
profiles.put(DEFAULT_PROFILE, Settings.EMPTY);
|
||||
|
|
|
@ -90,7 +90,7 @@ public class ReusePeerRecoverySharedTest {
|
|||
|
||||
// Disable allocations while we are closing nodes
|
||||
client().admin().cluster().prepareUpdateSettings().setTransientSettings(settingsBuilder()
|
||||
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, EnableAllocationDecider.Allocation.NONE)).get();
|
||||
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), EnableAllocationDecider.Allocation.NONE)).get();
|
||||
logger.info("--> full cluster restart");
|
||||
restartCluster.run();
|
||||
|
||||
|
@ -105,7 +105,7 @@ public class ReusePeerRecoverySharedTest {
|
|||
logger.info("--> disabling allocation while the cluster is shut down", useSyncIds ? "" : " a second time");
|
||||
// Disable allocations while we are closing nodes
|
||||
client().admin().cluster().prepareUpdateSettings().setTransientSettings(
|
||||
settingsBuilder().put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, EnableAllocationDecider.Allocation.NONE))
|
||||
settingsBuilder().put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), EnableAllocationDecider.Allocation.NONE))
|
||||
.get();
|
||||
logger.info("--> full cluster restart");
|
||||
restartCluster.run();
|
||||
|
|
Loading…
Reference in New Issue