Apply feedback from @bleskes and add fix some minor issues
This commit is contained in:
parent
818a9eefb2
commit
ed492901ed
|
@ -150,10 +150,11 @@ public class NetworkModule extends AbstractModule {
|
|||
|
||||
public static final String TRANSPORT_TYPE_KEY = "transport.type";
|
||||
public static final String TRANSPORT_SERVICE_TYPE_KEY = "transport.service.type";
|
||||
public static final String HTTP_TYPE_KEY = "http.type";
|
||||
public static final String LOCAL_TRANSPORT = "local";
|
||||
public static final String NETTY_TRANSPORT = "netty";
|
||||
|
||||
public static final String HTTP_TYPE_KEY = "http.type";
|
||||
public static final Setting<String> HTTP_TYPE_SETTING = Setting.simpleString("http.type", false, Scope.CLUSTER);
|
||||
public static final Setting<Boolean> HTTP_ENABLED = Setting.boolSetting("http.enabled", true, false, Scope.CLUSTER);
|
||||
public static final Setting<String> TRANSPORT_SERVICE_TYPE_SETTING = Setting.simpleString("transport.service.type", false, Scope.CLUSTER);
|
||||
public static final Setting<String> TRANSPORT_TYPE_SETTING = Setting.simpleString("transport.type", false, Scope.CLUSTER);
|
||||
|
@ -162,7 +163,6 @@ public class NetworkModule extends AbstractModule {
|
|||
|
||||
private static final List<Class<? extends RestHandler>> builtinRestHandlers = Arrays.asList(
|
||||
RestMainAction.class,
|
||||
|
||||
RestNodesInfoAction.class,
|
||||
RestNodesStatsAction.class,
|
||||
RestNodesHotThreadsAction.class,
|
||||
|
@ -383,7 +383,7 @@ public class NetworkModule extends AbstractModule {
|
|||
} else {
|
||||
if (HTTP_ENABLED.get(settings)) {
|
||||
bind(HttpServer.class).asEagerSingleton();
|
||||
httpTransportTypes.bindType(binder(), settings, HTTP_TYPE_KEY, NETTY_TRANSPORT);
|
||||
httpTransportTypes.bindType(binder(), settings, HTTP_TYPE_SETTING.getKey(), NETTY_TRANSPORT);
|
||||
}
|
||||
bind(RestController.class).asEagerSingleton();
|
||||
catHandlers.bind(binder());
|
||||
|
|
|
@ -209,6 +209,7 @@ public final class ClusterSettings extends AbstractScopedSettings {
|
|||
GatewayService.RECOVER_AFTER_NODES_SETTING,
|
||||
GatewayService.RECOVER_AFTER_TIME_SETTING,
|
||||
NetworkModule.HTTP_ENABLED,
|
||||
NetworkModule.HTTP_TYPE_SETTING,
|
||||
NetworkModule.TRANSPORT_SERVICE_TYPE_SETTING,
|
||||
NetworkModule.TRANSPORT_TYPE_SETTING,
|
||||
HttpTransportSettings.SETTING_CORS_ALLOW_CREDENTIALS,
|
||||
|
|
|
@ -38,7 +38,7 @@ public class SettingsModule extends AbstractModule {
|
|||
private final SettingsFilter settingsFilter;
|
||||
private final Map<String, Setting<?>> clusterSettings = new HashMap<>();
|
||||
private final Map<String, Setting<?>> indexSettings = new HashMap<>();
|
||||
private static final Predicate<String> NO_TRIBE_PREDICATE = (s) -> s.startsWith("tribe.") == false || TribeService.TRIBE_SETTING_KEYS.contains(s);
|
||||
private static final Predicate<String> TRIBE_CLIENT_NODE_SETTINGS_PREDICATE = (s) -> s.startsWith("tribe.") && TribeService.TRIBE_SETTING_KEYS.contains(s) == false;
|
||||
|
||||
|
||||
public SettingsModule(Settings settings, SettingsFilter settingsFilter) {
|
||||
|
@ -58,8 +58,8 @@ public class SettingsModule extends AbstractModule {
|
|||
final ClusterSettings clusterSettings = new ClusterSettings(settings, new HashSet<>(this.clusterSettings.values()));
|
||||
// by now we are fully configured, lets check node level settings for unregistered index settings
|
||||
indexScopedSettings.validate(settings.filter(IndexScopedSettings.INDEX_SETTINGS_KEY_PREDICATE));
|
||||
Predicate<String> noIndexSettingPredicate = IndexScopedSettings.INDEX_SETTINGS_KEY_PREDICATE.negate();
|
||||
clusterSettings.validate(settings.filter(NO_TRIBE_PREDICATE.and(noIndexSettingPredicate)));
|
||||
final Predicate<String> acceptOnlyClusterSettings = TRIBE_CLIENT_NODE_SETTINGS_PREDICATE.or(IndexScopedSettings.INDEX_SETTINGS_KEY_PREDICATE).negate();
|
||||
clusterSettings.validate(settings.filter(acceptOnlyClusterSettings));
|
||||
validateTribeSettings(settings, clusterSettings);
|
||||
bind(Settings.class).toInstance(settings);
|
||||
bind(SettingsFilter.class).toInstance(settingsFilter);
|
||||
|
@ -86,7 +86,7 @@ public class SettingsModule extends AbstractModule {
|
|||
}
|
||||
|
||||
public void validateTribeSettings(Settings settings, ClusterSettings clusterSettings) {
|
||||
Map<String, Settings> groups = settings.filter(NO_TRIBE_PREDICATE.negate()).getGroups("tribe.", true);
|
||||
Map<String, Settings> groups = settings.filter(TRIBE_CLIENT_NODE_SETTINGS_PREDICATE).getGroups("tribe.", true);
|
||||
for (Map.Entry<String, Settings> tribeSettings : groups.entrySet()) {
|
||||
Settings thisTribesSettings = tribeSettings.getValue();
|
||||
for (Map.Entry<String, String> entry : thisTribesSettings.getAsMap().entrySet()) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.BytesRestResponse;
|
||||
import org.elasticsearch.rest.RestChannel;
|
||||
|
@ -77,7 +78,7 @@ public class RestMainAction extends BaseRestHandler {
|
|||
|
||||
builder.startObject();
|
||||
assert settings.get("node.name") != null;
|
||||
builder.field("name", settings.get("node.name"));
|
||||
builder.field("name", Node.NODE_NAME_SETTING.get(settings));
|
||||
builder.field("cluster_name", clusterName.value());
|
||||
builder.startObject("version")
|
||||
.field("number", version.number())
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.elasticsearch.common.util.concurrent.XRejectedExecutionHandler;
|
|||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||
import org.elasticsearch.node.Node;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
@ -206,13 +207,13 @@ public class ThreadPool extends AbstractComponent implements Closeable {
|
|||
private final ThreadContext threadContext;
|
||||
|
||||
public ThreadPool(String name) {
|
||||
this(Settings.builder().put("node.name", name).build());
|
||||
this(Settings.builder().put(Node.NODE_NAME_SETTING.getKey(), name).build());
|
||||
}
|
||||
|
||||
public ThreadPool(Settings settings) {
|
||||
super(settings);
|
||||
|
||||
assert settings.get("node.name") != null : "ThreadPool's settings should contain a name";
|
||||
assert Node.NODE_NAME_SETTING.exists(settings) : "ThreadPool's settings should contain a name";
|
||||
threadContext = new ThreadContext(settings);
|
||||
Map<String, Settings> groupSettings = THREADPOOL_GROUP_SETTING.get(settings).getAsGroups();
|
||||
validate(groupSettings);
|
||||
|
|
|
@ -127,7 +127,7 @@ public class NetworkModuleTests extends ModuleTestCase {
|
|||
}
|
||||
|
||||
public void testRegisterHttpTransport() {
|
||||
Settings settings = Settings.builder().put(NetworkModule.HTTP_TYPE_KEY, "custom").build();
|
||||
Settings settings = Settings.builder().put(NetworkModule.HTTP_TYPE_SETTING.getKey(), "custom").build();
|
||||
NetworkModule module = new NetworkModule(new NetworkService(settings), settings, false, null);
|
||||
module.registerHttpTransport("custom", FakeHttpTransport.class);
|
||||
assertBinding(module, HttpServerTransport.class, FakeHttpTransport.class);
|
||||
|
|
|
@ -194,7 +194,7 @@ final class ExternalNode implements Closeable {
|
|||
|
||||
Settings clientSettings = settingsBuilder().put(externalNodeSettings)
|
||||
.put("client.transport.nodes_sampler_interval", "1s")
|
||||
.put("name", "transport_client_" + nodeInfo.getNode().name())
|
||||
.put("node.name", "transport_client_" + nodeInfo.getNode().name())
|
||||
.put(ClusterName.CLUSTER_NAME_SETTING.getKey(), clusterName).put("client.transport.sniff", false).build();
|
||||
TransportClient client = TransportClient.builder().settings(clientSettings).build();
|
||||
client.addTransportAddress(addr);
|
||||
|
|
|
@ -73,7 +73,7 @@ public final class ExternalTestCluster extends TestCluster {
|
|||
super(0);
|
||||
Settings clientSettings = Settings.settingsBuilder()
|
||||
.put(additionalSettings)
|
||||
.put("node. name", InternalTestCluster.TRANSPORT_CLIENT_PREFIX + EXTERNAL_CLUSTER_PREFIX + counter.getAndIncrement())
|
||||
.put("node.name", InternalTestCluster.TRANSPORT_CLIENT_PREFIX + EXTERNAL_CLUSTER_PREFIX + counter.getAndIncrement())
|
||||
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true) // prevents any settings to be replaced by system properties.
|
||||
.put("client.transport.ignore_cluster_name", true)
|
||||
.put(Environment.PATH_HOME_SETTING.getKey(), tempDir)
|
||||
|
|
Loading…
Reference in New Issue