diff --git a/core/src/main/java/org/elasticsearch/env/EnvironmentModule.java b/core/src/main/java/org/elasticsearch/env/EnvironmentModule.java deleted file mode 100644 index 6a893a73437..00000000000 --- a/core/src/main/java/org/elasticsearch/env/EnvironmentModule.java +++ /dev/null @@ -1,43 +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.env; - -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.threadpool.ThreadPool; - -/** - * - */ -public class EnvironmentModule extends AbstractModule { - - private final Environment environment; - private final ThreadPool threadPool; - - public EnvironmentModule(Environment environment, ThreadPool threadPool) { - this.threadPool = threadPool; - this.environment = environment; - } - - @Override - protected void configure() { - bind(ThreadPool.class).toInstance(threadPool); - bind(Environment.class).toInstance(environment); - } -} diff --git a/core/src/main/java/org/elasticsearch/env/NodeEnvironmentModule.java b/core/src/main/java/org/elasticsearch/env/NodeEnvironmentModule.java deleted file mode 100644 index 162c3108120..00000000000 --- a/core/src/main/java/org/elasticsearch/env/NodeEnvironmentModule.java +++ /dev/null @@ -1,48 +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.env; - -import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.inject.AbstractModule; - -/** - * - */ -public class NodeEnvironmentModule extends AbstractModule { - - private final NodeEnvironment nodeEnvironment; - - public NodeEnvironmentModule() { - this(null); - } - - public NodeEnvironmentModule(@Nullable NodeEnvironment nodeEnvironment) { - this.nodeEnvironment = nodeEnvironment; - } - - @Override - protected void configure() { - if (nodeEnvironment != null) { - bind(NodeEnvironment.class).toInstance(nodeEnvironment); - } else { - bind(NodeEnvironment.class).asEagerSingleton(); - } - } -} \ No newline at end of file diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayModule.java b/core/src/main/java/org/elasticsearch/gateway/GatewayModule.java index 651123882a5..f736c070272 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayModule.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayModule.java @@ -27,11 +27,6 @@ import org.elasticsearch.common.settings.Settings; */ public class GatewayModule extends AbstractModule { - private final Settings settings; - - public GatewayModule(Settings settings) { - this.settings = settings; - } @Override protected void configure() { diff --git a/core/src/main/java/org/elasticsearch/node/Node.java b/core/src/main/java/org/elasticsearch/node/Node.java index 70e0c356ba2..2069320104a 100644 --- a/core/src/main/java/org/elasticsearch/node/Node.java +++ b/core/src/main/java/org/elasticsearch/node/Node.java @@ -67,9 +67,7 @@ import org.elasticsearch.discovery.Discovery; import org.elasticsearch.discovery.DiscoveryModule; import org.elasticsearch.discovery.DiscoverySettings; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.env.NodeEnvironment; -import org.elasticsearch.env.NodeEnvironmentModule; import org.elasticsearch.gateway.GatewayAllocator; import org.elasticsearch.gateway.GatewayModule; import org.elasticsearch.gateway.GatewayService; @@ -104,9 +102,7 @@ import org.elasticsearch.tasks.TaskPersistenceService; import org.elasticsearch.threadpool.ExecutorBuilder; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.tribe.TribeModule; import org.elasticsearch.tribe.TribeService; -import org.elasticsearch.watcher.ResourceWatcherModule; import org.elasticsearch.watcher.ResourceWatcherService; import java.io.BufferedWriter; @@ -242,9 +238,13 @@ public class Node implements Closeable { } catch (IOException ex) { throw new IllegalStateException("Failed to created node environment", ex); } + final ResourceWatcherService resourceWatcherService = new ResourceWatcherService(settings, threadPool); + resourcesToClose.add(resourceWatcherService); final NetworkService networkService = new NetworkService(settings); final ClusterService clusterService = new ClusterService(settings, settingsModule.getClusterSettings(), threadPool); resourcesToClose.add(clusterService); + final TribeService tribeService = new TribeService(settings, clusterService); + resourcesToClose.add(tribeService); NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(); ModulesBuilder modules = new ModulesBuilder(); // plugin modules must be added here, before others or we can get crazy injection errors... @@ -253,28 +253,32 @@ public class Node implements Closeable { } final MonitorService monitorService = new MonitorService(settings, nodeEnvironment, threadPool); modules.add(new PluginsModule(pluginsService)); - modules.add(new EnvironmentModule(environment, threadPool)); modules.add(new NodeModule(this, monitorService)); modules.add(new NetworkModule(networkService, settings, false, namedWriteableRegistry)); modules.add(scriptModule); - modules.add(new NodeEnvironmentModule(nodeEnvironment)); modules.add(new DiscoveryModule(this.settings)); modules.add(new ClusterModule(this.settings, clusterService)); modules.add(new IndicesModule(namedWriteableRegistry)); modules.add(new SearchModule(settings, namedWriteableRegistry)); modules.add(new ActionModule(DiscoveryNode.isIngestNode(settings), false)); - modules.add(new GatewayModule(settings)); + modules.add(new GatewayModule()); modules.add(new NodeClientModule()); - modules.add(new ResourceWatcherModule()); modules.add(new RepositoriesModule()); - modules.add(new TribeModule()); modules.add(new AnalysisModule(environment)); pluginsService.processModules(modules); CircuitBreakerService circuitBreakerService = createCircuitBreakerService(settingsModule.getSettings(), settingsModule.getClusterSettings()); resourcesToClose.add(circuitBreakerService); modules.add(settingsModule); - modules.add(b -> b.bind(CircuitBreakerService.class).toInstance(circuitBreakerService)); + modules.add(b -> { + b.bind(Environment.class).toInstance(new Environment(settings)); + b.bind(ThreadPool.class).toInstance(threadPool); + b.bind(NodeEnvironment.class).toInstance(nodeEnvironment); + b.bind(TribeService.class).toInstance(tribeService); + b.bind(ResourceWatcherService.class).toInstance(resourceWatcherService); + b.bind(CircuitBreakerService.class).toInstance(circuitBreakerService); + } + ); injector = modules.createInjector(); client = injector.getInstance(Client.class); success = true; diff --git a/core/src/main/java/org/elasticsearch/tribe/TribeModule.java b/core/src/main/java/org/elasticsearch/tribe/TribeModule.java deleted file mode 100644 index fb642d1b034..00000000000 --- a/core/src/main/java/org/elasticsearch/tribe/TribeModule.java +++ /dev/null @@ -1,32 +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.tribe; - -import org.elasticsearch.common.inject.AbstractModule; - -/** - */ -public class TribeModule extends AbstractModule { - - @Override - protected void configure() { - bind(TribeService.class).asEagerSingleton(); - } -} diff --git a/core/src/main/java/org/elasticsearch/tribe/TribeService.java b/core/src/main/java/org/elasticsearch/tribe/TribeService.java index 50be6e39b07..259a9d443a3 100644 --- a/core/src/main/java/org/elasticsearch/tribe/TribeService.java +++ b/core/src/main/java/org/elasticsearch/tribe/TribeService.java @@ -40,7 +40,6 @@ import org.elasticsearch.common.Priority; import org.elasticsearch.common.Strings; import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.component.AbstractLifecycleComponent; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.regex.Regex; @@ -175,7 +174,6 @@ public class TribeService extends AbstractLifecycleComponent { private final List nodes = new CopyOnWriteArrayList<>(); - @Inject public TribeService(Settings settings, ClusterService clusterService) { super(settings); this.clusterService = clusterService; diff --git a/core/src/main/java/org/elasticsearch/watcher/ResourceWatcherModule.java b/core/src/main/java/org/elasticsearch/watcher/ResourceWatcherModule.java deleted file mode 100644 index a3ae84a954f..00000000000 --- a/core/src/main/java/org/elasticsearch/watcher/ResourceWatcherModule.java +++ /dev/null @@ -1,31 +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.watcher; - -import org.elasticsearch.common.inject.AbstractModule; - -/** - * - */ -public class ResourceWatcherModule extends AbstractModule { - @Override - protected void configure() { - bind(ResourceWatcherService.class).asEagerSingleton(); - } -} diff --git a/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java b/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java index 65c0a4fddef..d88813203b2 100644 --- a/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java +++ b/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java @@ -28,7 +28,6 @@ import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.script.ScriptService.ScriptType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.InternalSettingsPlugin; @@ -41,9 +40,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; -import static java.util.Collections.singleton; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; @@ -60,7 +57,10 @@ public class NativeScriptTests extends ESTestCase { SettingsModule settingsModule = new SettingsModule(settings, scriptSettings, Collections.emptyList()); final ThreadPool threadPool = new ThreadPool(settings); Injector injector = new ModulesBuilder().add( - new EnvironmentModule(new Environment(settings), threadPool), + (b) -> { + b.bind(Environment.class).toInstance(new Environment(settings)); + b.bind(ThreadPool.class).toInstance(threadPool); + }, new SettingsModule(settings), scriptModule).createInjector(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorParsingTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorParsingTests.java index 5dd321bdf07..a78c405929a 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorParsingTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorParsingTests.java @@ -38,7 +38,6 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; import org.elasticsearch.test.AbstractQueryTestCase; import org.elasticsearch.index.query.QueryParseContext; @@ -109,7 +108,11 @@ public class AggregatorParsingTests extends ESTestCase { List> scriptSettings = scriptModule.getSettings(); scriptSettings.add(InternalSettingsPlugin.VERSION_CREATED); SettingsModule settingsModule = new SettingsModule(settings, scriptSettings, Collections.emptyList()); - injector = new ModulesBuilder().add(new EnvironmentModule(new Environment(settings), threadPool), settingsModule + injector = new ModulesBuilder().add( + (b) -> { + b.bind(Environment.class).toInstance(new Environment(settings)); + b.bind(ThreadPool.class).toInstance(threadPool); + }, settingsModule , scriptModule, new IndicesModule(namedWriteableRegistry) { @Override diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java b/core/src/test/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java index c7d1084067a..b1065c90efa 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java @@ -42,7 +42,6 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; import org.elasticsearch.test.AbstractQueryTestCase; import org.elasticsearch.index.query.QueryParseContext; @@ -124,7 +123,10 @@ public abstract class BaseAggregationTestCase { + b.bind(Environment.class).toInstance(new Environment(settings)); + b.bind(ThreadPool.class).toInstance(threadPool); + }, settingsModule, scriptModule, new IndicesModule(namedWriteableRegistry) { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/BasePipelineAggregationTestCase.java b/core/src/test/java/org/elasticsearch/search/aggregations/BasePipelineAggregationTestCase.java index a907e75d5f7..0410c5d91d9 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/BasePipelineAggregationTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/BasePipelineAggregationTestCase.java @@ -42,7 +42,6 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; import org.elasticsearch.index.query.QueryParseContext; import org.elasticsearch.indices.IndicesModule; @@ -124,7 +123,10 @@ public abstract class BasePipelineAggregationTestCase { + b.bind(Environment.class).toInstance(new Environment(settings)); + b.bind(ThreadPool.class).toInstance(threadPool); + }, settingsModule, scriptModule, new IndicesModule(namedWriteableRegistry) { diff --git a/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java b/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java index 3fe1d2a0480..5822372bfa9 100644 --- a/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java @@ -46,7 +46,6 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryParseContext; @@ -132,7 +131,10 @@ public class SearchSourceBuilderTests extends ESTestCase { scriptSettings.add(InternalSettingsPlugin.VERSION_CREATED); SettingsModule settingsModule = new SettingsModule(settings, scriptSettings, Collections.emptyList()); injector = new ModulesBuilder().add( - new EnvironmentModule(new Environment(settings), threadPool), settingsModule, + (b) -> { + b.bind(Environment.class).toInstance(new Environment(settings)); + b.bind(ThreadPool.class).toInstance(threadPool); + }, settingsModule, scriptModule, new IndicesModule(namedWriteableRegistry) { @Override protected void configure() { diff --git a/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/TemplateQueryParserTests.java b/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/TemplateQueryParserTests.java index f0422314c74..60316818a79 100644 --- a/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/TemplateQueryParserTests.java +++ b/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/TemplateQueryParserTests.java @@ -38,7 +38,6 @@ import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.analysis.AnalysisRegistry; @@ -59,7 +58,6 @@ import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache; import org.elasticsearch.indices.mapper.MapperRegistry; import org.elasticsearch.indices.query.IndicesQueriesRegistry; -import org.elasticsearch.script.ScriptEngineRegistry; import org.elasticsearch.script.ScriptModule; import org.elasticsearch.script.ScriptService; import org.elasticsearch.script.mustache.MustacheScriptEngineService; @@ -110,7 +108,10 @@ public class TemplateQueryParserTests extends ESTestCase { SettingsModule settingsModule = new SettingsModule(settings, scriptSettings, Collections.emptyList()); final ThreadPool threadPool = new ThreadPool(settings); injector = new ModulesBuilder().add( - new EnvironmentModule(new Environment(settings), threadPool), + (b) -> { + b.bind(Environment.class).toInstance(new Environment(settings)); + b.bind(ThreadPool.class).toInstance(threadPool); + }, settingsModule, new SearchModule(settings, new NamedWriteableRegistry()) { @Override diff --git a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java index 319222caa7e..edb062d9e30 100644 --- a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java +++ b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java @@ -76,10 +76,7 @@ public class Ec2DiscoveryTests extends ESTestCase { protected List buildDynamicNodes(Settings nodeSettings, int nodes, List> tagsList) { AwsEc2Service awsEc2Service = new AwsEc2ServiceMock(nodeSettings, nodes, tagsList); - - AwsEc2UnicastHostsProvider provider = new AwsEc2UnicastHostsProvider(nodeSettings, transportService, - awsEc2Service, Version.CURRENT); - + AwsEc2UnicastHostsProvider provider = new AwsEc2UnicastHostsProvider(nodeSettings, transportService, awsEc2Service); List discoveryNodes = provider.buildDynamicNodes(); logger.debug("--> nodes found: {}", discoveryNodes); return discoveryNodes; @@ -231,14 +228,14 @@ public class Ec2DiscoveryTests extends ESTestCase { abstract class DummyEc2HostProvider extends AwsEc2UnicastHostsProvider { public int fetchCount = 0; - public DummyEc2HostProvider(Settings settings, TransportService transportService, AwsEc2Service service, Version version) { - super(settings, transportService, service, version); + public DummyEc2HostProvider(Settings settings, TransportService transportService, AwsEc2Service service) { + super(settings, transportService, service); } } public void testGetNodeListEmptyCache() throws Exception { AwsEc2Service awsEc2Service = new AwsEc2ServiceMock(Settings.EMPTY, 1, null); - DummyEc2HostProvider provider = new DummyEc2HostProvider(Settings.EMPTY, transportService, awsEc2Service, Version.CURRENT) { + DummyEc2HostProvider provider = new DummyEc2HostProvider(Settings.EMPTY, transportService, awsEc2Service) { @Override protected List fetchDynamicNodes() { fetchCount++; @@ -255,7 +252,7 @@ public class Ec2DiscoveryTests extends ESTestCase { Settings.Builder builder = Settings.builder() .put(DISCOVERY_EC2.NODE_CACHE_TIME_SETTING.getKey(), "500ms"); AwsEc2Service awsEc2Service = new AwsEc2ServiceMock(Settings.EMPTY, 1, null); - DummyEc2HostProvider provider = new DummyEc2HostProvider(builder.build(), transportService, awsEc2Service, Version.CURRENT) { + DummyEc2HostProvider provider = new DummyEc2HostProvider(builder.build(), transportService, awsEc2Service) { @Override protected List fetchDynamicNodes() { fetchCount++; diff --git a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoveryTests.java b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoveryTests.java index e1041360b1f..07b2ef774b4 100644 --- a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoveryTests.java +++ b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoveryTests.java @@ -78,7 +78,7 @@ public class GceDiscoveryTests extends ESTestCase { @AfterClass public static void stopThreadPool() { - if (threadPool !=null) { + if (threadPool != null) { threadPool.shutdownNow(); threadPool = null; } @@ -111,8 +111,8 @@ public class GceDiscoveryTests extends ESTestCase { } protected List buildDynamicNodes(GceComputeService gceComputeService, Settings nodeSettings) { - GceUnicastHostsProvider provider = new GceUnicastHostsProvider(nodeSettings, gceComputeService, - transportService, new NetworkService(Settings.EMPTY), Version.CURRENT); + GceUnicastHostsProvider provider = new GceUnicastHostsProvider(nodeSettings, gceComputeService, transportService, + new NetworkService(Settings.EMPTY)); List discoveryNodes = provider.buildDynamicNodes(); logger.info("--> nodes found: {}", discoveryNodes); diff --git a/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java index 62a843cee35..65c43fd38c6 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java @@ -53,7 +53,6 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.ModulesBuilder; -import org.elasticsearch.common.inject.multibindings.Multibinder; import org.elasticsearch.common.inject.util.Providers; import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; @@ -70,7 +69,6 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.analysis.AnalysisRegistry; @@ -97,15 +95,9 @@ import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.PluginsModule; import org.elasticsearch.plugins.PluginsService; -import org.elasticsearch.script.MockScriptEngine; import org.elasticsearch.script.Script.ScriptParseException; -import org.elasticsearch.script.ScriptContext; -import org.elasticsearch.script.ScriptContextRegistry; -import org.elasticsearch.script.ScriptEngineRegistry; -import org.elasticsearch.script.ScriptEngineService; import org.elasticsearch.script.ScriptModule; import org.elasticsearch.script.ScriptService; -import org.elasticsearch.script.ScriptSettings; import org.elasticsearch.search.SearchModule; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.threadpool.ThreadPool; @@ -120,14 +112,11 @@ import java.io.IOException; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Set; import java.util.concurrent.ExecutionException; import static org.hamcrest.Matchers.containsString; @@ -902,7 +891,10 @@ public abstract class AbstractQueryTestCase> } modulesBuilder.add(new PluginsModule(pluginsService)); modulesBuilder.add( - new EnvironmentModule(new Environment(settings), threadPool), + (b) -> { + b.bind(Environment.class).toInstance(new Environment(settings)); + b.bind(ThreadPool.class).toInstance(threadPool); + }, settingsModule, new IndicesModule(namedWriteableRegistry) { @Override public void configure() {