diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java index 6ab0bafb2fb..390e4c6dda7 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java @@ -128,6 +128,7 @@ public class ListTasksResponse extends BaseTasksResponse implements ToXContent { * {@code group_by=nodes}. */ public void setDiscoveryNodes(DiscoveryNodes discoveryNodes) { + //WTF is this? Why isn't this set by default; this.discoveryNodes = discoveryNodes; } diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index fb6f98ea3b1..5f2cb10212d 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -48,23 +48,6 @@ import static org.elasticsearch.common.transport.TransportAddressSerializers.add */ public class DiscoveryNode implements Writeable, ToXContent { - public static boolean isLocalNode(Settings settings) { - if (Node.NODE_LOCAL_SETTING.exists(settings)) { - return Node.NODE_LOCAL_SETTING.get(settings); - } - if (Node.NODE_MODE_SETTING.exists(settings)) { - String nodeMode = Node.NODE_MODE_SETTING.get(settings); - if ("local".equals(nodeMode)) { - return true; - } else if ("network".equals(nodeMode)) { - return false; - } else { - throw new IllegalArgumentException("unsupported node.mode [" + nodeMode + "]. Should be one of [local, network]."); - } - } - return false; - } - public static boolean nodeRequiresLocalStorage(Settings settings) { boolean localStorageEnable = Node.NODE_LOCAL_STORAGE_SETTING.get(settings); if (localStorageEnable == false && diff --git a/core/src/main/java/org/elasticsearch/common/network/NetworkModule.java b/core/src/main/java/org/elasticsearch/common/network/NetworkModule.java index 0ef71502207..a91f36ad307 100644 --- a/core/src/main/java/org/elasticsearch/common/network/NetworkModule.java +++ b/core/src/main/java/org/elasticsearch/common/network/NetworkModule.java @@ -54,8 +54,9 @@ public class NetworkModule extends AbstractModule { 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 Setting TRANSPORT_DEFAULT_TYPE_SETTING = Setting.simpleString("transport.type.default", Property.NodeScope); + public static final Setting HTTP_DEFAULT_TYPE_SETTING = Setting.simpleString("http.type.default", Property.NodeScope); public static final Setting HTTP_TYPE_SETTING = Setting.simpleString(HTTP_TYPE_KEY, Property.NodeScope); public static final Setting HTTP_ENABLED = Setting.boolSetting("http.enabled", true, Property.NodeScope); public static final Setting TRANSPORT_SERVICE_TYPE_SETTING = @@ -85,7 +86,7 @@ public class NetworkModule extends AbstractModule { this.settings = settings; this.transportClient = transportClient; this.namedWriteableRegistry = namedWriteableRegistry; - registerTransportService(NETTY_TRANSPORT, TransportService.class); + registerTransportService("default", TransportService.class); registerTransport(LOCAL_TRANSPORT, LocalTransport.class); registerTaskStatus(ReplicationTask.Status.NAME, ReplicationTask.Status::new); registerTaskStatus(RawTaskStatus.NAME, RawTaskStatus::new); @@ -146,16 +147,13 @@ public class NetworkModule extends AbstractModule { protected void configure() { bind(NetworkService.class).toInstance(networkService); bind(NamedWriteableRegistry.class).toInstance(namedWriteableRegistry); - - boolean nettyRegistered = transportTypes.getExtension(NETTY_TRANSPORT) != null; - transportServiceTypes.bindType(binder(), settings, TRANSPORT_SERVICE_TYPE_KEY, NETTY_TRANSPORT); - String defaultTransport = DiscoveryNode.isLocalNode(settings) || nettyRegistered == false ? LOCAL_TRANSPORT : NETTY_TRANSPORT; - transportTypes.bindType(binder(), settings, TRANSPORT_TYPE_KEY, defaultTransport); + transportServiceTypes.bindType(binder(), settings, TRANSPORT_SERVICE_TYPE_KEY, "default"); + transportTypes.bindType(binder(), settings, TRANSPORT_TYPE_KEY, TRANSPORT_DEFAULT_TYPE_SETTING.get(settings)); if (transportClient == false) { if (HTTP_ENABLED.get(settings)) { bind(HttpServer.class).asEagerSingleton(); - httpTransportTypes.bindType(binder(), settings, HTTP_TYPE_SETTING.getKey(), NETTY_TRANSPORT); + httpTransportTypes.bindType(binder(), settings, HTTP_TYPE_SETTING.getKey(), HTTP_DEFAULT_TYPE_SETTING.get(settings)); } else { bind(HttpServer.class).toProvider(Providers.of(null)); } diff --git a/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java index 736371a08b3..1c9136d52fd 100644 --- a/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java +++ b/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java @@ -214,6 +214,8 @@ public final class ClusterSettings extends AbstractScopedSettings { GatewayService.RECOVER_AFTER_NODES_SETTING, GatewayService.RECOVER_AFTER_TIME_SETTING, NetworkModule.HTTP_ENABLED, + NetworkModule.HTTP_DEFAULT_TYPE_SETTING, + NetworkModule.TRANSPORT_DEFAULT_TYPE_SETTING, NetworkModule.HTTP_TYPE_SETTING, NetworkModule.TRANSPORT_SERVICE_TYPE_SETTING, NetworkModule.TRANSPORT_TYPE_SETTING, @@ -339,8 +341,6 @@ public final class ClusterSettings extends AbstractScopedSettings { Node.NODE_NAME_SETTING, Node.NODE_DATA_SETTING, Node.NODE_MASTER_SETTING, - Node.NODE_LOCAL_SETTING, - Node.NODE_MODE_SETTING, Node.NODE_INGEST_SETTING, Node.NODE_ATTRIBUTES, Node.NODE_LOCAL_STORAGE_SETTING, diff --git a/core/src/main/java/org/elasticsearch/common/util/ExtensionPoint.java b/core/src/main/java/org/elasticsearch/common/util/ExtensionPoint.java index 4b68512502d..fcdfaafb1d5 100644 --- a/core/src/main/java/org/elasticsearch/common/util/ExtensionPoint.java +++ b/core/src/main/java/org/elasticsearch/common/util/ExtensionPoint.java @@ -72,7 +72,7 @@ public abstract class ExtensionPoint { */ public static class ClassMap extends ExtensionPoint { protected final Class extensionClass; - private final Map> extensions = new HashMap<>(); + protected final Map> extensions = new HashMap<>(); private final Set reservedKeys; /** @@ -147,7 +147,8 @@ public abstract class ExtensionPoint { } final Class instance = getExtension(type); if (instance == null) { - throw new IllegalArgumentException("Unknown [" + this.name + "] type [" + type + "]"); + throw new IllegalArgumentException("Unknown [" + this.name + "] type [" + type + "] possible values: " + + extensions.keySet()); } if (extensionClass == instance) { binder.bind(extensionClass).asEagerSingleton(); diff --git a/core/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java b/core/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java index f70eb46e666..040066adeb6 100644 --- a/core/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java +++ b/core/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java @@ -47,7 +47,7 @@ import java.util.function.Function; public class DiscoveryModule extends AbstractModule { public static final Setting DISCOVERY_TYPE_SETTING = - new Setting<>("discovery.type", settings -> DiscoveryNode.isLocalNode(settings) ? "local" : "zen", Function.identity(), + new Setting<>("discovery.type", "zen", Function.identity(), Property.NodeScope); public static final Setting ZEN_MASTER_SERVICE_TYPE_SETTING = new Setting<>("discovery.zen.masterservice.type", "zen", Function.identity(), Property.NodeScope); diff --git a/core/src/main/java/org/elasticsearch/node/Node.java b/core/src/main/java/org/elasticsearch/node/Node.java index 22c6092471e..7966c8d8f49 100644 --- a/core/src/main/java/org/elasticsearch/node/Node.java +++ b/core/src/main/java/org/elasticsearch/node/Node.java @@ -147,10 +147,6 @@ public class Node implements Closeable { public static final Setting NODE_DATA_SETTING = Setting.boolSetting("node.data", true, Property.NodeScope); public static final Setting NODE_MASTER_SETTING = Setting.boolSetting("node.master", true, Property.NodeScope); - public static final Setting NODE_LOCAL_SETTING = - Setting.boolSetting("node.local", false, Property.NodeScope); - public static final Setting NODE_MODE_SETTING = - new Setting<>("node.mode", "network", Function.identity(), Property.NodeScope); public static final Setting NODE_INGEST_SETTING = Setting.boolSetting("node.ingest", true, Property.NodeScope); diff --git a/core/src/main/java/org/elasticsearch/search/SearchModule.java b/core/src/main/java/org/elasticsearch/search/SearchModule.java index 9740592c2bb..673aa1cb134 100644 --- a/core/src/main/java/org/elasticsearch/search/SearchModule.java +++ b/core/src/main/java/org/elasticsearch/search/SearchModule.java @@ -382,10 +382,8 @@ public class SearchModule extends AbstractModule { * Register an aggregation. */ public void registerAggregation(AggregationSpec spec) { - if (false == transportClient) { - namedWriteableRegistry.register(AggregationBuilder.class, spec.aggregationName.getPreferredName(), spec.builderReader); - aggregationParserRegistry.register(spec.aggregationParser, spec.aggregationName); - } + namedWriteableRegistry.register(AggregationBuilder.class, spec.aggregationName.getPreferredName(), spec.builderReader); + aggregationParserRegistry.register(spec.aggregationParser, spec.aggregationName); for (Map.Entry> t : spec.resultReaders.entrySet()) { String writeableName = t.getKey(); Writeable.Reader internalReader = t.getValue(); @@ -414,7 +412,7 @@ public class SearchModule extends AbstractModule { } /** - * Add a reader for the shard level results of the aggregation with {@linkplain aggregationName}'s + * Add a reader for the shard level results of the aggregation with {@linkplain #aggregationName}'s * {@link ParseField#getPreferredName()} as the {@link NamedWriteable#getWriteableName()}. */ public AggregationSpec addResultReader(Writeable.Reader resultReader) { @@ -444,9 +442,9 @@ public class SearchModule extends AbstractModule { Writeable.Reader internalReader, Writeable.Reader bucketReader, PipelineAggregator.Parser aggregationParser, ParseField aggregationName) { if (false == transportClient) { - namedWriteableRegistry.register(PipelineAggregationBuilder.class, aggregationName.getPreferredName(), reader); pipelineAggregationParserRegistry.register(aggregationParser, aggregationName); } + namedWriteableRegistry.register(PipelineAggregationBuilder.class, aggregationName.getPreferredName(), reader); namedWriteableRegistry.register(PipelineAggregator.class, aggregationName.getPreferredName(), internalReader); namedWriteableRegistry.register(InternalAggregation.class, aggregationName.getPreferredName(), bucketReader); } @@ -469,9 +467,9 @@ public class SearchModule extends AbstractModule { bind(IndicesQueriesRegistry.class).toInstance(queryParserRegistry); bind(Suggesters.class).toInstance(getSuggesters()); configureSearch(); - configureShapes(); bind(AggregatorParsers.class).toInstance(aggregatorParsers); } + configureShapes(); } private void registerBuiltinAggregations() { diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java index 072165e1b80..e7e75330889 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java @@ -199,7 +199,7 @@ public class InternalRange ranges, DocValueFormat formatter, boolean keyed, List pipelineAggregators, Map metaData) { - return (R) new InternalRange<>(name, ranges, formatter, keyed, pipelineAggregators, metaData); + return (R) new InternalRange(name, ranges, formatter, keyed, pipelineAggregators, metaData); } @SuppressWarnings("unchecked") @@ -210,7 +210,7 @@ public class InternalRange ranges, R prototype) { - return (R) new InternalRange<>(prototype.name, ranges, prototype.format, prototype.keyed, prototype.pipelineAggregators(), + return (R) new InternalRange(prototype.name, ranges, prototype.format, prototype.keyed, prototype.pipelineAggregators(), prototype.metaData); } @@ -295,7 +295,7 @@ public class InternalRange aggregations, ReduceContext reduceContext) { List[] rangeList = new List[ranges.size()]; for (int i = 0; i < rangeList.length; ++i) { - rangeList[i] = new ArrayList(); + rangeList[i] = new ArrayList<>(); } for (InternalAggregation aggregation : aggregations) { InternalRange ranges = (InternalRange) aggregation; diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java index f9045b58413..d479af2b1be 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java +++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java @@ -98,6 +98,11 @@ public class TasksIT extends ESIntegTestCase { private Map, RecordingTaskManagerListener> listeners = new HashMap<>(); + @Override + protected boolean addMockTransportService() { + return false; + } + @Override protected Collection> nodePlugins() { return pluginList(MockTransportService.TestPlugin.class, TestTaskPlugin.class); diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java index e5cabd417b8..a4a9178f2e0 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java @@ -158,6 +158,7 @@ public class BulkProcessorIT extends ESIntegTestCase { //we create a transport client with no nodes to make sure it throws NoNodeAvailableException Settings settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) + .put("transport.type", "local") .build(); Client transportClient = TransportClient.builder().settings(settings).build(); diff --git a/core/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java b/core/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java index 9cef4d46e8b..e8a616a6377 100644 --- a/core/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java @@ -21,6 +21,7 @@ package org.elasticsearch.action.search; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; +import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.query.QueryBuilders; @@ -40,6 +41,7 @@ public class SearchRequestBuilderTests extends ESTestCase { //that is why we create it but we don't add any transport address to it Settings settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) + .put(NetworkModule.TRANSPORT_TYPE_KEY, "local") .build(); client = TransportClient.builder().settings(settings).build(); } diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientHeadersTests.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientHeadersTests.java index eee74b66148..81aad7648d6 100644 --- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientHeadersTests.java +++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientHeadersTests.java @@ -68,6 +68,7 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTestCase { .settings(Settings.builder() .put("client.transport.sniff", false) .put("cluster.name", "cluster1") + .put(NetworkModule.TRANSPORT_TYPE_KEY, "local") .put("node.name", "transport_client_" + this.getTestName()) .put(headersSettings) .build()) @@ -82,6 +83,7 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTestCase { .settings(Settings.builder() .put("client.transport.sniff", true) .put("cluster.name", "cluster1") + .put(NetworkModule.TRANSPORT_TYPE_KEY, "local") .put("node.name", "transport_client_" + this.getTestName() + "_1") .put("client.transport.nodes_sampler_interval", "1s") .put(HEADER_SETTINGS) diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java index b96201f831c..af706963516 100644 --- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java +++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java @@ -56,6 +56,7 @@ public class TransportClientIT extends ESIntegTestCase { .put(internalCluster().getDefaultSettings()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) .put("node.name", "testNodeVersionIsUpdated") + .put("transport.type", "local") .put(NetworkModule.HTTP_ENABLED.getKey(), false) .put(Node.NODE_DATA_SETTING.getKey(), false) .put("cluster.name", "foobar") @@ -90,7 +91,8 @@ public class TransportClientIT extends ESIntegTestCase { public void testThatTransportClientSettingCannotBeChanged() { Settings baseSettings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) - .build(); + .put("transport.type", "local") + .build(); try (TransportClient client = TransportClient.builder().settings(baseSettings).build()) { Settings settings = client.injector.getInstance(Settings.class); assertThat(Client.CLIENT_TYPE_SETTING_S.get(settings), is("transport")); diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientRetryIT.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientRetryIT.java index ed9136851b4..d8d4115dc7d 100644 --- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientRetryIT.java +++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientRetryIT.java @@ -25,6 +25,7 @@ import org.elasticsearch.action.support.PlainListenableActionFuture; import org.elasticsearch.client.Requests; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.env.Environment; @@ -52,13 +53,13 @@ public class TransportClientRetryIT extends ESIntegTestCase { Settings.Builder builder = Settings.builder().put("client.transport.nodes_sampler_interval", "1s") .put("node.name", "transport_client_retry_test") - .put(Node.NODE_MODE_SETTING.getKey(), internalCluster().getNodeMode()) + .put(NetworkModule.TRANSPORT_TYPE_KEY, "local") .put(ClusterName.CLUSTER_NAME_SETTING.getKey(), internalCluster().getClusterName()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()); try (TransportClient client = TransportClient.builder().settings(builder.build()).build()) { client.addTransportAddresses(addresses); - assertThat(client.connectedNodes().size(), equalTo(internalCluster().size())); + assertEquals(client.connectedNodes().size(), internalCluster().size()); int size = cluster().size(); //kill all nodes one by one, leaving a single master/data node at the end of the loop diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientTests.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientTests.java index ec2065b67e2..98529518803 100644 --- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientTests.java +++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.client.transport; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; +import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESTestCase; @@ -31,7 +32,8 @@ import static org.hamcrest.object.HasToString.hasToString; public class TransportClientTests extends ESTestCase { public void testThatUsingAClosedClientThrowsAnException() throws ExecutionException, InterruptedException { - final TransportClient client = TransportClient.builder().settings(Settings.EMPTY).build(); + final TransportClient client = TransportClient.builder().settings(Settings.builder().put(NetworkModule.TRANSPORT_TYPE_KEY, "local")) + .build(); client.close(); final IllegalStateException e = expectThrows(IllegalStateException.class, () -> client.admin().cluster().health(new ClusterHealthRequest()).get()); diff --git a/core/src/test/java/org/elasticsearch/common/network/NetworkModuleTests.java b/core/src/test/java/org/elasticsearch/common/network/NetworkModuleTests.java index cfd123272cd..f5a5928c980 100644 --- a/core/src/test/java/org/elasticsearch/common/network/NetworkModuleTests.java +++ b/core/src/test/java/org/elasticsearch/common/network/NetworkModuleTests.java @@ -110,6 +110,7 @@ public class NetworkModuleTests extends ModuleTestCase { public void testRegisterTransportService() { Settings settings = Settings.builder().put(NetworkModule.TRANSPORT_SERVICE_TYPE_KEY, "custom") .put(NetworkModule.HTTP_ENABLED.getKey(), false) + .put(NetworkModule.TRANSPORT_TYPE_KEY, "local") .build(); NetworkModule module = new NetworkModule(new NetworkService(settings), settings, false, new NamedWriteableRegistry()); module.registerTransportService("custom", FakeTransportService.class); @@ -140,7 +141,9 @@ public class NetworkModuleTests extends ModuleTestCase { } public void testRegisterHttpTransport() { - Settings settings = Settings.builder().put(NetworkModule.HTTP_TYPE_SETTING.getKey(), "custom").build(); + Settings settings = Settings.builder() + .put(NetworkModule.HTTP_TYPE_SETTING.getKey(), "custom") + .put(NetworkModule.TRANSPORT_TYPE_KEY, "local").build(); NetworkModule module = new NetworkModule(new NetworkService(settings), settings, false, new NamedWriteableRegistry()); module.registerHttpTransport("custom", FakeHttpTransport.class); assertBinding(module, HttpServerTransport.class, FakeHttpTransport.class); @@ -158,7 +161,8 @@ public class NetworkModuleTests extends ModuleTestCase { } // not added if http is disabled - settings = Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false).build(); + settings = Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false) + .put(NetworkModule.TRANSPORT_TYPE_KEY, "local").build(); module = new NetworkModule(new NetworkService(settings), settings, false, new NamedWriteableRegistry()); assertNotBound(module, HttpServerTransport.class); assertFalse(module.isTransportClient()); diff --git a/core/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java b/core/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java index 86c3cd91bff..057b54c7a07 100644 --- a/core/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java @@ -38,10 +38,8 @@ public class DiscoveryModuleTests extends ModuleTestCase { } } - public void testRegisterMasterElectionService() { - Settings settings = Settings.builder().put(Node.NODE_LOCAL_SETTING.getKey(), false). - put(DiscoveryModule.ZEN_MASTER_SERVICE_TYPE_SETTING.getKey(), "custom").build(); + Settings settings = Settings.builder().put(DiscoveryModule.ZEN_MASTER_SERVICE_TYPE_SETTING.getKey(), "custom").build(); DiscoveryModule module = new DiscoveryModule(settings); module.addElectMasterService("custom", DummyMasterElectionService.class); assertBinding(module, ElectMasterService.class, DummyMasterElectionService.class); @@ -49,24 +47,20 @@ public class DiscoveryModuleTests extends ModuleTestCase { } public void testLoadUnregisteredMasterElectionService() { - Settings settings = Settings.builder().put(Node.NODE_LOCAL_SETTING.getKey(), false). - put(DiscoveryModule.ZEN_MASTER_SERVICE_TYPE_SETTING.getKey(), "foobar").build(); + Settings settings = Settings.builder().put(DiscoveryModule.ZEN_MASTER_SERVICE_TYPE_SETTING.getKey(), "foobar").build(); DiscoveryModule module = new DiscoveryModule(settings); module.addElectMasterService("custom", DummyMasterElectionService.class); assertBindingFailure(module, "Unknown master service type [foobar]"); } public void testRegisterDefaults() { - boolean local = randomBoolean(); - Settings settings = Settings.builder().put(Node.NODE_LOCAL_SETTING.getKey(), local).build(); + Settings settings = Settings.EMPTY; DiscoveryModule module = new DiscoveryModule(settings); - assertBinding(module, Discovery.class, local ? LocalDiscovery.class : ZenDiscovery.class); + assertBinding(module, Discovery.class, ZenDiscovery.class); } public void testRegisterDiscovery() { - boolean local = randomBoolean(); - Settings settings = Settings.builder().put(Node.NODE_LOCAL_SETTING.getKey(), local). - put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "custom").build(); + Settings settings = Settings.builder().put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "custom").build(); DiscoveryModule module = new DiscoveryModule(settings); module.addDiscoveryType("custom", NoopDiscovery.class); assertBinding(module, Discovery.class, NoopDiscovery.class); diff --git a/core/src/test/java/org/elasticsearch/index/query/plugin/CustomQueryParserIT.java b/core/src/test/java/org/elasticsearch/index/query/plugin/CustomQueryParserIT.java index ba87b293701..c5935f7b32a 100644 --- a/core/src/test/java/org/elasticsearch/index/query/plugin/CustomQueryParserIT.java +++ b/core/src/test/java/org/elasticsearch/index/query/plugin/CustomQueryParserIT.java @@ -43,6 +43,11 @@ public class CustomQueryParserIT extends ESIntegTestCase { return pluginList(DummyQueryParserPlugin.class); } + @Override + protected Collection> transportClientPlugins() { + return pluginList(DummyQueryParserPlugin.class); + } + @Override @Before public void setUp() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java index 2c00fe2c740..c79f803fefe 100644 --- a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java +++ b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java @@ -61,6 +61,11 @@ public class FunctionScorePluginIT extends ESIntegTestCase { return pluginList(CustomDistanceScorePlugin.class); } + @Override + protected Collection> transportClientPlugins() { + return pluginList(CustomDistanceScorePlugin.class); + } + public void testPlugin() throws Exception { client().admin() .indices() diff --git a/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java index c792bc02c92..9aab222dd9a 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java @@ -60,6 +60,11 @@ public class CustomSuggesterSearchIT extends ESIntegTestCase { return pluginList(CustomSuggesterPlugin.class); } + @Override + protected Collection> transportClientPlugins() { + return pluginList(CustomSuggesterPlugin.class); + } + public void testThatCustomSuggestersCanBeRegisteredAndWork() throws Exception { createIndex("test"); client().prepareIndex("test", "test", "1").setSource(jsonBuilder() diff --git a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java index b7521bdf74f..e1df7201fbe 100644 --- a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java +++ b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java @@ -36,6 +36,7 @@ import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; +import org.elasticsearch.discovery.DiscoveryModule; import org.elasticsearch.discovery.MasterNotDiscoveredException; import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing; import org.elasticsearch.node.Node; @@ -76,11 +77,9 @@ public class TribeIT extends ESIntegTestCase { @Before public void setupSecondCluster() throws Exception { if (cluster2 == null) { - final Tuple configSource = getNodeConfigSource(); - final String nodeMode = configSource.v1(); - final NodeConfigurationSource nodeConfigurationSource = configSource.v2(); - cluster2 = new InternalTestCluster(nodeMode, randomLong(), createTempDir(), true, 2, 2, - UUIDs.randomBase64UUID(random()), nodeConfigurationSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(), + final NodeConfigurationSource configSource = getNodeConfigSource(); + cluster2 = new InternalTestCluster(randomLong(), createTempDir(), true, 2, 2, + UUIDs.randomBase64UUID(random()), configSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(), Function.identity()); cluster2.beforeTest(random(), 0.1); cluster2.ensureAtLeastNumDataNodes(2); @@ -131,9 +130,16 @@ public class TribeIT extends ESIntegTestCase { Settings merged = Settings.builder() .put("tribe.t1.cluster.name", internalCluster().getClusterName()) .put("tribe.t2.cluster.name", cluster2.getClusterName()) + .put("tribe.t1.transport.type", "local") + .put("tribe.t2.transport.type", "local") + .put("tribe.t1.discovery.type", "local") + .put("tribe.t2.discovery.type", "local") + .put("transport.type", "local") + .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "local") .put("tribe.blocks.write", false) .put(NetworkModule.HTTP_ENABLED.getKey(), false) .put(settings) + .put(tribe1Defaults.build()) .put(tribe2Defaults.build()) .put(internalCluster().getDefaultSettings()) diff --git a/docs/reference/migration/migrate_5_0/settings.asciidoc b/docs/reference/migration/migrate_5_0/settings.asciidoc index b17881c6204..da0a5776ad0 100644 --- a/docs/reference/migration/migrate_5_0/settings.asciidoc +++ b/docs/reference/migration/migrate_5_0/settings.asciidoc @@ -28,6 +28,9 @@ The `name` setting has been removed and is replaced by `node.name`. Usage of The `node.add_id_to_custom_path` was renamed to `add_lock_id_to_custom_path`. +The settings `node.mode` and `node.local` are removed. Local mode should be configured via +`discovery.type: local` and `transport.type:local`. In order to disable _http_ please use `http.enabled: false` + ==== Node attribute settings Node level attributes used for allocation filtering, forced awareness or other node identification / grouping diff --git a/modules/transport-netty/src/main/java/org/elasticsearch/transport/NettyPlugin.java b/modules/transport-netty/src/main/java/org/elasticsearch/transport/NettyPlugin.java index 5a9a8af009e..f03200de94e 100644 --- a/modules/transport-netty/src/main/java/org/elasticsearch/transport/NettyPlugin.java +++ b/modules/transport-netty/src/main/java/org/elasticsearch/transport/NettyPlugin.java @@ -33,8 +33,6 @@ import java.util.Arrays; import java.util.List; public class NettyPlugin extends Plugin { - - public static final String NETTY_TRANSPORT_NAME = "netty"; public static final String NETTY_HTTP_TRANSPORT_NAME = "netty"; @@ -85,6 +83,16 @@ public class NettyPlugin extends Plugin { ); } + @Override + public Settings additionalSettings() { + return Settings.builder() + // here we set the netty transport and http transport as the default. This is a set once setting + // ie. if another plugin does that as well the server will fail - only one default network can exist! + .put(NetworkModule.HTTP_DEFAULT_TYPE_SETTING.getKey(), NETTY_HTTP_TRANSPORT_NAME) + .put(NetworkModule.TRANSPORT_DEFAULT_TYPE_SETTING.getKey(), NETTY_TRANSPORT_NAME) + .build(); + } + public void onModule(NetworkModule networkModule) { if (networkModule.canRegisterHttpExtensions()) { networkModule.registerHttpTransport(NETTY_HTTP_TRANSPORT_NAME, NettyHttpServerTransport.class); diff --git a/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java b/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java index e9d16408537..bc5ff91f812 100644 --- a/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java +++ b/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java @@ -43,9 +43,7 @@ public abstract class AbstractAzureComputeServiceTestCase extends ESIntegTestCas protected Settings nodeSettings(int nodeOrdinal) { Settings.Builder builder = Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put("discovery.type", "azure") - // We need the network to make the mock working - .put(Node.NODE_MODE_SETTING.getKey(), "network"); + .put("discovery.type", "azure"); // We add a fake subscription_id to start mock compute service builder.put(Management.SUBSCRIPTION_ID_SETTING.getKey(), "fake") diff --git a/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/discovery/azure/classic/AzureSimpleTests.java b/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/discovery/azure/classic/AzureSimpleTests.java index d2234632122..d6d68e75843 100644 --- a/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/discovery/azure/classic/AzureSimpleTests.java +++ b/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/discovery/azure/classic/AzureSimpleTests.java @@ -29,10 +29,7 @@ import org.elasticsearch.test.ESIntegTestCase; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.notNullValue; -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, - numDataNodes = 0, - transportClientRatio = 0.0, - numClientNodes = 0) +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, transportClientRatio = 0.0, numClientNodes = 0) public class AzureSimpleTests extends AbstractAzureComputeServiceTestCase { public AzureSimpleTests() { super(AzureComputeServiceSimpleMock.TestPlugin.class); diff --git a/qa/evil-tests/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java b/qa/evil-tests/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java index f6266f05562..95550f6f654 100644 --- a/qa/evil-tests/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java +++ b/qa/evil-tests/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java @@ -26,6 +26,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.discovery.DiscoveryModule; import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.node.Node; @@ -52,13 +53,13 @@ public class TribeUnitTests extends ESTestCase { private static Node tribe1; private static Node tribe2; - private static final String NODE_MODE = InternalTestCluster.configuredNodeMode(); @BeforeClass public static void createTribes() { Settings baseSettings = Settings.builder() .put(NetworkModule.HTTP_ENABLED.getKey(), false) - .put(Node.NODE_MODE_SETTING.getKey(), NODE_MODE) + .put("transport.type", "local") + .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "local") .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build(); tribe1 = new TribeClientNode( @@ -94,26 +95,23 @@ public class TribeUnitTests extends ESTestCase { } private static void assertTribeNodeSuccessfullyCreated(Settings extraSettings) throws Exception { - //tribe node doesn't need the node.mode setting, as it's forced local internally anyways. The tribe clients do need it to make sure - //they can find their corresponding tribes using the proper transport + //The tribe clients do need it to make sure they can find their corresponding tribes using the proper transport Settings settings = Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false).put("node.name", "tribe_node") - .put("tribe.t1.node.mode", NODE_MODE).put("tribe.t2.node.mode", NODE_MODE) + .put("transport.type", "local").put("discovery.type", "local") + .put("tribe.t1.transport.type", "local").put("tribe.t2.transport.type", "local") + .put("tribe.t1.discovery.type", "local").put("tribe.t2.discovery.type", "local") .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) - .put(Node.NODE_MODE_SETTING.getKey(), NODE_MODE) .put(extraSettings).build(); try (Node node = new Node(settings).start()) { try (Client client = node.client()) { - assertBusy(new Runnable() { - @Override - public void run() { - ClusterState state = client.admin().cluster().prepareState().clear().setNodes(true).get().getState(); - assertThat(state.getClusterName().value(), equalTo("tribe_node_cluster")); - assertThat(state.getNodes().getSize(), equalTo(5)); - for (DiscoveryNode discoveryNode : state.getNodes()) { - assertThat(discoveryNode.getName(), either(equalTo("tribe1_node")).or(equalTo("tribe2_node")) - .or(equalTo("tribe_node")).or(equalTo("tribe_node/t1")).or(equalTo("tribe_node/t2"))); - } + assertBusy(() -> { + ClusterState state = client.admin().cluster().prepareState().clear().setNodes(true).get().getState(); + assertThat(state.getClusterName().value(), equalTo("tribe_node_cluster")); + assertThat(state.getNodes().getSize(), equalTo(5)); + for (DiscoveryNode discoveryNode : state.getNodes()) { + assertThat(discoveryNode.getName(), either(equalTo("tribe1_node")).or(equalTo("tribe2_node")) + .or(equalTo("tribe_node")).or(equalTo("tribe_node/t1")).or(equalTo("tribe_node/t2"))); } }); } diff --git a/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/ESSmokeClientTestCase.java b/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/ESSmokeClientTestCase.java index f037ad7142e..6b44bed33bb 100644 --- a/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/ESSmokeClientTestCase.java +++ b/qa/smoke-test-client/src/test/java/org/elasticsearch/smoketest/ESSmokeClientTestCase.java @@ -96,8 +96,7 @@ public abstract class ESSmokeClientTestCase extends LuceneTestCase { Settings.Builder builder = Settings.builder() .put("node.name", "qa_smoke_client_" + counter.getAndIncrement()) .put("client.transport.ignore_cluster_name", true) - .put(Environment.PATH_HOME_SETTING.getKey(), tempDir) - .put(Node.NODE_MODE_SETTING.getKey(), "network");// we require network here! + .put(Environment.PATH_HOME_SETTING.getKey(), tempDir); if (random().nextBoolean()) { builder.put(NetworkModule.TRANSPORT_TYPE_KEY, NettyPlugin.NETTY_TRANSPORT_NAME); transportClientBuilder.addPlugin(NettyPlugin.class); diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESBackcompatTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESBackcompatTestCase.java index 69bacfd3ffa..2a6cebfc2da 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESBackcompatTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESBackcompatTestCase.java @@ -29,6 +29,7 @@ import org.elasticsearch.common.io.PathUtils; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.discovery.DiscoveryModule; import org.elasticsearch.node.Node; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.junit.annotations.TestLogging; @@ -242,7 +243,7 @@ public abstract class ESBackcompatTestCase extends ESIntegTestCase { protected Settings commonNodeSettings(int nodeOrdinal) { Settings.Builder builder = Settings.builder().put(requiredSettings()); builder.put(NetworkModule.TRANSPORT_TYPE_KEY, "netty"); // run same transport / disco as external - builder.put(Node.NODE_MODE_SETTING.getKey(), "network"); + builder.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "zen"); return builder.build(); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index 445f70026dc..73edf000b96 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -28,6 +28,7 @@ import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.TestUtil; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ExceptionsHelper; +import org.elasticsearch.discovery.DiscoveryModule; import org.elasticsearch.transport.MockTcpTransportPlugin; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ShardOperationFailedException; @@ -1724,37 +1725,53 @@ public abstract class ESIntegTestCase extends ESTestCase { maxNumDataNodes = getMaxNumDataNodes(); } Collection> mockPlugins = getMockPlugins(); - Tuple configSource = getNodeConfigSource(); - final String nodeMode = configSource.v1(); - final NodeConfigurationSource nodeConfigurationSource = configSource.v2(); - return new InternalTestCluster(nodeMode, seed, createTempDir(), supportsDedicatedMasters, minNumDataNodes, maxNumDataNodes, + final NodeConfigurationSource nodeConfigurationSource = getNodeConfigSource(); + if (addMockTransportService()) { + ArrayList> mocks = new ArrayList<>(mockPlugins); + // add both mock plugins - local and tcp if they are not there + // we do this in case somebody overrides getMockPlugins and misses to call super + if (mockPlugins.contains(AssertingLocalTransport.TestPlugin.class) == false) { + mocks.add(AssertingLocalTransport.TestPlugin.class); + } + if (mockPlugins.contains(MockTcpTransportPlugin.class) == false) { + mocks.add(MockTcpTransportPlugin.class); + } + mockPlugins = mocks; + } + return new InternalTestCluster(seed, createTempDir(), supportsDedicatedMasters, minNumDataNodes, maxNumDataNodes, InternalTestCluster.clusterName(scope.name(), seed) + "-cluster", nodeConfigurationSource, getNumClientNodes(), InternalTestCluster.DEFAULT_ENABLE_HTTP_PIPELINING, nodePrefix, mockPlugins, getClientWrapper()); } - protected Tuple getNodeConfigSource() { + protected NodeConfigurationSource getNodeConfigSource() { SuppressLocalMode noLocal = getAnnotation(this.getClass(), SuppressLocalMode.class); SuppressNetworkMode noNetwork = getAnnotation(this.getClass(), SuppressNetworkMode.class); - String nodeMode = InternalTestCluster.configuredNodeMode(); Settings.Builder networkSettings = Settings.builder(); + final boolean isNetwork; if (noLocal != null && noNetwork != null) { throw new IllegalStateException("Can't suppress both network and local mode"); } else if (noLocal != null) { - nodeMode = "network"; if (addMockTransportService()) { networkSettings.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME); } - } else if (noNetwork != null) { - nodeMode = "local"; + isNetwork = true; + } else { if (addMockTransportService()) { networkSettings.put(NetworkModule.TRANSPORT_TYPE_KEY, AssertingLocalTransport.ASSERTING_TRANSPORT_NAME); + } else { + networkSettings.put(NetworkModule.TRANSPORT_TYPE_KEY, "local"); } + isNetwork = false; } - final boolean isNetwork = "network".equals(nodeMode); + NodeConfigurationSource nodeConfigurationSource = new NodeConfigurationSource() { @Override public Settings nodeSettings(int nodeOrdinal) { - return Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false).put(networkSettings.build()). + return Settings.builder() + .put(NetworkModule.HTTP_ENABLED.getKey(), false) + .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), + isNetwork ? DiscoveryModule.DISCOVERY_TYPE_SETTING.getDefault(Settings.EMPTY) : "local") + .put(networkSettings.build()). put(ESIntegTestCase.this.nodeSettings(nodeOrdinal)).build(); } @@ -1775,11 +1792,14 @@ public abstract class ESIntegTestCase extends ESTestCase { if (isNetwork && plugins.contains(MockTcpTransportPlugin.class) == false) { plugins = new ArrayList<>(plugins); plugins.add(MockTcpTransportPlugin.class); + } else if (isNetwork == false && plugins.contains(AssertingLocalTransport.class) == false) { + plugins = new ArrayList<>(plugins); + plugins.add(AssertingLocalTransport.TestPlugin.class); } return Collections.unmodifiableCollection(plugins); } }; - return new Tuple<>(nodeMode, nodeConfigurationSource); + return nodeConfigurationSource; } /** @@ -1819,12 +1839,12 @@ public abstract class ESIntegTestCase extends ESTestCase { mocks.add(MockSearchService.TestPlugin.class); } } - mocks.add(TestSeedPlugin.class); + if (addMockTransportService()) { - // add both mock plugins - local and tcp mocks.add(AssertingLocalTransport.TestPlugin.class); mocks.add(MockTcpTransportPlugin.class); } + mocks.add(TestSeedPlugin.class); return Collections.unmodifiableList(mocks); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java index addac8da08b..0ae94057ecb 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java @@ -179,13 +179,13 @@ public abstract class ESSingleNodeTestCase extends ESTestCase { .put("script.stored", "true") .put(EsExecutors.PROCESSORS_SETTING.getKey(), 1) // limit the number of threads created .put(NetworkModule.HTTP_ENABLED.getKey(), false) - .put(Node.NODE_LOCAL_SETTING.getKey(), true) + .put("discovery.type", "local") + .put("transport.type", "local") .put(Node.NODE_DATA_SETTING.getKey(), true) .put(nodeSettings()) // allow test cases to provide their own settings or override these .build(); Node build = new MockNode(settings, getPlugins()); build.start(); - assertThat(DiscoveryNode.isLocalNode(build.settings()), is(true)); return build; } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ExternalNode.java b/test/framework/src/main/java/org/elasticsearch/test/ExternalNode.java index 8216f67cfed..221cb8ec254 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ExternalNode.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ExternalNode.java @@ -51,7 +51,7 @@ final class ExternalNode implements Closeable { public static final Settings REQUIRED_SETTINGS = Settings.builder() .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "zen") - .put(Node.NODE_MODE_SETTING.getKey(), "network").build(); // we need network mode for this + .put(NetworkModule.TRANSPORT_TYPE_KEY, "netty").build(); // we need network mode for this private final Path path; private final Random random; @@ -106,8 +106,6 @@ final class ExternalNode implements Closeable { case "cluster.name": case "node.name": case "path.home": - case "node.mode": - case "node.local": case NetworkModule.TRANSPORT_TYPE_KEY: case "discovery.type": case NetworkModule.TRANSPORT_SERVICE_TYPE_KEY: diff --git a/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java index 6cee28b50bb..75bf3fa308c 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java @@ -77,8 +77,7 @@ public final class ExternalTestCluster extends TestCluster { .put(additionalSettings) .put("node.name", InternalTestCluster.TRANSPORT_CLIENT_PREFIX + EXTERNAL_CLUSTER_PREFIX + counter.getAndIncrement()) .put("client.transport.ignore_cluster_name", true) - .put(Environment.PATH_HOME_SETTING.getKey(), tempDir) - .put(Node.NODE_MODE_SETTING.getKey(), "network");// we require network here! + .put(Environment.PATH_HOME_SETTING.getKey(), tempDir); TransportClient.Builder transportClientBuilder = TransportClient.builder(); boolean addMockTcpTransport = additionalSettings.get(NetworkModule.TRANSPORT_TYPE_KEY) == null; if (addMockTcpTransport) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index 9ef47cd78cf..f242ba00f28 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -53,6 +53,7 @@ import org.elasticsearch.common.io.FileSystemUtils; import org.elasticsearch.common.lease.Releasables; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; +import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings.Builder; import org.elasticsearch.common.transport.InetSocketTransportAddress; @@ -224,19 +225,14 @@ public final class InternalTestCluster extends TestCluster { private final Path baseDir; private ServiceDisruptionScheme activeDisruptionScheme; - private String nodeMode; private Function clientWrapper; - public InternalTestCluster(String nodeMode, long clusterSeed, Path baseDir, + public InternalTestCluster(long clusterSeed, Path baseDir, boolean randomlyAddDedicatedMasters, int minNumDataNodes, int maxNumDataNodes, String clusterName, NodeConfigurationSource nodeConfigurationSource, int numClientNodes, boolean enableHttpPipelining, String nodePrefix, Collection> mockPlugins, Function clientWrapper) { super(clusterSeed); - if ("network".equals(nodeMode) == false && "local".equals(nodeMode) == false) { - throw new IllegalArgumentException("Unknown nodeMode: " + nodeMode); - } this.clientWrapper = clientWrapper; - this.nodeMode = nodeMode; this.baseDir = baseDir; this.clusterName = clusterName; if (minNumDataNodes < 0 || maxNumDataNodes < 0) { @@ -308,7 +304,6 @@ public final class InternalTestCluster extends TestCluster { builder.put(Environment.PATH_REPO_SETTING.getKey(), baseDir.resolve("repos")); builder.put(TransportSettings.PORT.getKey(), TRANSPORT_BASE_PORT + "-" + (TRANSPORT_BASE_PORT + PORTS_PER_CLUSTER)); builder.put("http.port", HTTP_BASE_PORT + "-" + (HTTP_BASE_PORT + PORTS_PER_CLUSTER)); - builder.put(Node.NODE_MODE_SETTING.getKey(), nodeMode); builder.put("http.pipelining", enableHttpPipelining); if (Strings.hasLength(System.getProperty("tests.es.logger.level"))) { builder.put("logger.level", System.getProperty("tests.es.logger.level")); @@ -333,24 +328,6 @@ public final class InternalTestCluster extends TestCluster { executor = EsExecutors.newScaling("test runner", 0, Integer.MAX_VALUE, 0, TimeUnit.SECONDS, EsExecutors.daemonThreadFactory("test_" + clusterName), new ThreadContext(Settings.EMPTY)); } - public static String configuredNodeMode() { - Builder builder = Settings.builder(); - if (Strings.isEmpty(System.getProperty("tests.es.node.mode")) && Strings.isEmpty(System.getProperty("tests.node.local"))) { - return "local"; // default if nothing is specified - } - if (Strings.hasLength(System.getProperty("tests.es.node.mode"))) { - builder.put(Node.NODE_MODE_SETTING.getKey(), System.getProperty("tests.es.node.mode")); - } - if (Strings.hasLength(System.getProperty("tests.es.node.local"))) { - builder.put(Node.NODE_LOCAL_SETTING.getKey(), System.getProperty("tests.es.node.local")); - } - if (DiscoveryNode.isLocalNode(builder.build())) { - return "local"; - } else { - return "network"; - } - } - @Override public String getClusterName() { return clusterName; @@ -360,10 +337,6 @@ public final class InternalTestCluster extends TestCluster { return nodes.keySet().toArray(Strings.EMPTY_ARRAY); } - private boolean isLocalTransportConfigured() { - return "local".equals(nodeMode); - } - private Settings getSettings(int nodeOrdinal, long nodeSeed, Settings others) { Builder builder = Settings.builder().put(defaultSettings) .put(getRandomNodeSettings(nodeSeed)); @@ -390,9 +363,7 @@ public final class InternalTestCluster extends TestCluster { private Settings getRandomNodeSettings(long seed) { Random random = new Random(seed); Builder builder = Settings.builder(); - if (isLocalTransportConfigured() == false) { - builder.put(Transport.TRANSPORT_TCP_COMPRESS.getKey(), rarely(random)); - } + builder.put(Transport.TRANSPORT_TCP_COMPRESS.getKey(), rarely(random)); if (random.nextBoolean()) { builder.put("cache.recycler.page.type", RandomPicks.randomFrom(random, PageCacheRecycler.Type.values())); } @@ -768,10 +739,6 @@ public final class InternalTestCluster extends TestCluster { } } - public String getNodeMode() { - return nodeMode; - } - private final class NodeAndClient implements Closeable { private MockNode node; private Client nodeClient; @@ -839,7 +806,7 @@ public final class InternalTestCluster extends TestCluster { /* no sniff client for now - doesn't work will all tests since it might throw NoNodeAvailableException if nodes are shut down. * we first need support of transportClientRatio as annotations or so */ - transportClient = new TransportClientFactory(false, nodeConfigurationSource.transportClientSettings(), baseDir, nodeMode, nodeConfigurationSource.transportClientPlugins()).client(node, clusterName); + transportClient = new TransportClientFactory(false, nodeConfigurationSource.transportClientSettings(), baseDir, nodeConfigurationSource.transportClientPlugins()).client(node, clusterName); } return clientWrapper.apply(transportClient); } @@ -914,14 +881,12 @@ public final class InternalTestCluster extends TestCluster { private final boolean sniff; private final Settings settings; private final Path baseDir; - private final String nodeMode; private final Collection> plugins; - TransportClientFactory(boolean sniff, Settings settings, Path baseDir, String nodeMode, Collection> plugins) { + TransportClientFactory(boolean sniff, Settings settings, Path baseDir, Collection> plugins) { this.sniff = sniff; this.settings = settings != null ? settings : Settings.EMPTY; this.baseDir = baseDir; - this.nodeMode = nodeMode; this.plugins = plugins; } @@ -933,15 +898,12 @@ public final class InternalTestCluster extends TestCluster { .put(Environment.PATH_HOME_SETTING.getKey(), baseDir) .put("node.name", TRANSPORT_CLIENT_PREFIX + node.settings().get("node.name")) .put(ClusterName.CLUSTER_NAME_SETTING.getKey(), clusterName).put("client.transport.sniff", sniff) - .put(Node.NODE_MODE_SETTING.getKey(), Node.NODE_MODE_SETTING.exists(nodeSettings) ? Node.NODE_MODE_SETTING.get(nodeSettings) : nodeMode) .put("logger.prefix", nodeSettings.get("logger.prefix", "")) .put("logger.level", nodeSettings.get("logger.level", "INFO")) .put(settings); - - if (Node.NODE_LOCAL_SETTING.exists(nodeSettings)) { - builder.put(Node.NODE_LOCAL_SETTING.getKey(), Node.NODE_LOCAL_SETTING.get(nodeSettings)); + if ( NetworkModule.TRANSPORT_TYPE_SETTING.exists(settings)) { + builder.put(NetworkModule.TRANSPORT_TYPE_KEY, NetworkModule.TRANSPORT_TYPE_SETTING.get(settings)); } - TransportClient.Builder clientBuilder = TransportClient.builder().settings(builder.build()); for (Class plugin : plugins) { clientBuilder.addPlugin(plugin); diff --git a/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java b/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java index 2bdec79f3a0..7103cda945b 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java +++ b/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java @@ -140,8 +140,7 @@ public class ReproduceInfoPrinter extends RunListener { appendProperties("tests.es.logger.level"); if (inVerifyPhase()) { // these properties only make sense for integration tests - appendProperties("tests.es.node.mode", "tests.es.node.local", TESTS_CLUSTER, - ESIntegTestCase.TESTS_ENABLE_MOCK_MODULES); + appendProperties(TESTS_CLUSTER, ESIntegTestCase.TESTS_ENABLE_MOCK_MODULES); } appendProperties("tests.assertion.disabled", "tests.security.manager", "tests.nightly", "tests.jvms", "tests.client.ratio", "tests.heap.size", "tests.bwc", "tests.bwc.version"); diff --git a/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java b/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java index 43f276197c6..b5fd7b662cc 100644 --- a/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java +++ b/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java @@ -26,6 +26,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.discovery.DiscoveryModule; import org.elasticsearch.discovery.DiscoverySettings; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.test.ESTestCase; @@ -76,10 +77,10 @@ public class InternalTestClusterTests extends ESTestCase { String nodePrefix = randomRealisticUnicodeOfCodepointLengthBetween(1, 10); Path baseDir = createTempDir(); - InternalTestCluster cluster0 = new InternalTestCluster("local", clusterSeed, baseDir, masterNodes, + InternalTestCluster cluster0 = new InternalTestCluster(clusterSeed, baseDir, masterNodes, minNumDataNodes, maxNumDataNodes, clusterName, nodeConfigurationSource, numClientNodes, enableHttpPipelining, nodePrefix, Collections.emptyList(), Function.identity()); - InternalTestCluster cluster1 = new InternalTestCluster("local", clusterSeed, baseDir, masterNodes, + InternalTestCluster cluster1 = new InternalTestCluster(clusterSeed, baseDir, masterNodes, minNumDataNodes, maxNumDataNodes, clusterName, nodeConfigurationSource, numClientNodes, enableHttpPipelining, nodePrefix, Collections.emptyList(), Function.identity()); // TODO: this is not ideal - we should have a way to make sure ports are initialized in the same way @@ -131,7 +132,16 @@ public class InternalTestClusterTests extends ESTestCase { NodeConfigurationSource nodeConfigurationSource = new NodeConfigurationSource() { @Override public Settings nodeSettings(int nodeOrdinal) { - return Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false).build(); + return Settings.builder() + .put(NetworkModule.HTTP_ENABLED.getKey(), false) + .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "local") + .put(NetworkModule.TRANSPORT_TYPE_KEY, "local").build(); + } + + @Override + public Settings transportClientSettings() { + return Settings.builder() + .put(NetworkModule.TRANSPORT_TYPE_KEY, "local").build(); } }; int numClientNodes = randomIntBetween(0, 2); @@ -139,10 +149,10 @@ public class InternalTestClusterTests extends ESTestCase { String nodePrefix = "foobar"; Path baseDir = createTempDir(); - InternalTestCluster cluster0 = new InternalTestCluster("local", clusterSeed, baseDir, masterNodes, + InternalTestCluster cluster0 = new InternalTestCluster(clusterSeed, baseDir, masterNodes, minNumDataNodes, maxNumDataNodes, clusterName1, nodeConfigurationSource, numClientNodes, enableHttpPipelining, nodePrefix, Collections.emptyList(), Function.identity()); - InternalTestCluster cluster1 = new InternalTestCluster("local", clusterSeed, baseDir, masterNodes, + InternalTestCluster cluster1 = new InternalTestCluster(clusterSeed, baseDir, masterNodes, minNumDataNodes, maxNumDataNodes, clusterName2, nodeConfigurationSource, numClientNodes, enableHttpPipelining, nodePrefix, Collections.emptyList(), Function.identity()); @@ -182,13 +192,21 @@ public class InternalTestClusterTests extends ESTestCase { NodeConfigurationSource nodeConfigurationSource = new NodeConfigurationSource() { @Override public Settings nodeSettings(int nodeOrdinal) { - return Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false).build(); + return Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false) + .put(NetworkModule.TRANSPORT_TYPE_KEY, "local") + .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "local") + .build(); + } + @Override + public Settings transportClientSettings() { + return Settings.builder() + .put(NetworkModule.TRANSPORT_TYPE_KEY, "local").build(); } }; int numClientNodes = randomIntBetween(0, 2); boolean enableHttpPipelining = randomBoolean(); String nodePrefix = "test"; Path baseDir = createTempDir(); - InternalTestCluster cluster = new InternalTestCluster("local", clusterSeed, baseDir, masterNodes, + InternalTestCluster cluster = new InternalTestCluster(clusterSeed, baseDir, masterNodes, minNumDataNodes, maxNumDataNodes, clusterName1, nodeConfigurationSource, numClientNodes, enableHttpPipelining, nodePrefix, Collections.emptyList(), Function.identity()); try { @@ -250,18 +268,21 @@ public class InternalTestClusterTests extends ESTestCase { public void testDifferentRolesMaintainPathOnRestart() throws Exception { final Path baseDir = createTempDir(); - InternalTestCluster cluster = new InternalTestCluster("local", randomLong(), baseDir, true, 0, 0, "test", + InternalTestCluster cluster = new InternalTestCluster(randomLong(), baseDir, true, 0, 0, "test", new NodeConfigurationSource() { @Override public Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(NetworkModule.HTTP_ENABLED.getKey(), false) + .put(NetworkModule.TRANSPORT_TYPE_KEY, "local") + .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "local") .put(DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.getKey(), 0).build(); } @Override public Settings transportClientSettings() { - return Settings.EMPTY; + return Settings.builder() + .put(NetworkModule.TRANSPORT_TYPE_KEY, "local").build(); } }, 0, randomBoolean(), "", Collections.emptyList(), Function.identity()); cluster.beforeTest(random(), 0.0);