Internal: Deguice IndicesService

Almost all the dependencies of indices service are already created outside of
guice. This change deguices MetaStateService, and then IndicesService.
This commit is contained in:
Ryan Ernst 2016-08-19 00:27:37 -07:00
parent 207d3a60e7
commit 59636a0844
5 changed files with 10 additions and 5 deletions

View File

@ -30,7 +30,6 @@ public class GatewayModule extends AbstractModule {
@Override @Override
protected void configure() { protected void configure() {
bind(MetaStateService.class).asEagerSingleton();
bind(DanglingIndicesState.class).asEagerSingleton(); bind(DanglingIndicesState.class).asEagerSingleton();
bind(GatewayService.class).asEagerSingleton(); bind(GatewayService.class).asEagerSingleton();
bind(TransportNodesListGatewayMetaState.class).asEagerSingleton(); bind(TransportNodesListGatewayMetaState.class).asEagerSingleton();

View File

@ -40,7 +40,6 @@ public class MetaStateService extends AbstractComponent {
private final NodeEnvironment nodeEnv; private final NodeEnvironment nodeEnv;
@Inject
public MetaStateService(Settings settings, NodeEnvironment nodeEnv) { public MetaStateService(Settings settings, NodeEnvironment nodeEnv) {
super(settings); super(settings);
this.nodeEnv = nodeEnv; this.nodeEnv = nodeEnv;

View File

@ -173,7 +173,6 @@ public class IndicesModule extends AbstractModule {
protected void configure() { protected void configure() {
bindMapperExtension(); bindMapperExtension();
bind(IndicesService.class).asEagerSingleton();
bind(RecoverySettings.class).asEagerSingleton(); bind(RecoverySettings.class).asEagerSingleton();
bind(RecoveryTargetService.class).asEagerSingleton(); bind(RecoveryTargetService.class).asEagerSingleton();
bind(RecoverySource.class).asEagerSingleton(); bind(RecoverySource.class).asEagerSingleton();

View File

@ -168,7 +168,6 @@ public class IndicesService extends AbstractLifecycleComponent
threadPool.schedule(this.cleanInterval, ThreadPool.Names.SAME, this.cacheCleaner); threadPool.schedule(this.cleanInterval, ThreadPool.Names.SAME, this.cacheCleaner);
} }
@Inject
public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv, public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv,
ClusterSettings clusterSettings, AnalysisRegistry analysisRegistry, ClusterSettings clusterSettings, AnalysisRegistry analysisRegistry,
IndicesQueriesRegistry indicesQueriesRegistry, IndexNameExpressionResolver indexNameExpressionResolver, IndicesQueriesRegistry indicesQueriesRegistry, IndexNameExpressionResolver indexNameExpressionResolver,

View File

@ -74,6 +74,7 @@ import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.gateway.GatewayAllocator; import org.elasticsearch.gateway.GatewayAllocator;
import org.elasticsearch.gateway.GatewayModule; import org.elasticsearch.gateway.GatewayModule;
import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.gateway.MetaStateService;
import org.elasticsearch.http.HttpServer; import org.elasticsearch.http.HttpServer;
import org.elasticsearch.http.HttpServerTransport; import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.index.analysis.AnalysisRegistry; import org.elasticsearch.index.analysis.AnalysisRegistry;
@ -349,6 +350,11 @@ public class Node implements Closeable {
.flatMap(p -> p.getNamedWriteables().stream())) .flatMap(p -> p.getNamedWriteables().stream()))
.flatMap(Function.identity()).collect(Collectors.toList()); .flatMap(Function.identity()).collect(Collectors.toList());
final NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(namedWriteables); final NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(namedWriteables);
final MetaStateService metaStateService = new MetaStateService(settings, nodeEnvironment);
final IndicesService indicesService = new IndicesService(settings, pluginsService, nodeEnvironment,
settingsModule.getClusterSettings(), analysisModule.getAnalysisRegistry(), searchModule.getQueryParserRegistry(),
clusterModule.getIndexNameExpressionResolver(), indicesModule.getMapperRegistry(), namedWriteableRegistry,
threadPool, settingsModule.getIndexScopedSettings(), circuitBreakerService, metaStateService);
client = new NodeClient(settings, threadPool); client = new NodeClient(settings, threadPool);
Collection<Object> pluginComponents = pluginsService.filterPlugins(Plugin.class).stream() Collection<Object> pluginComponents = pluginsService.filterPlugins(Plugin.class).stream()
.flatMap(p -> p.createComponents(client, clusterService, threadPool, resourceWatcherService, .flatMap(p -> p.createComponents(client, clusterService, threadPool, resourceWatcherService,
@ -374,6 +380,9 @@ public class Node implements Closeable {
b.bind(AnalysisRegistry.class).toInstance(analysisModule.getAnalysisRegistry()); b.bind(AnalysisRegistry.class).toInstance(analysisModule.getAnalysisRegistry());
b.bind(IngestService.class).toInstance(ingestService); b.bind(IngestService.class).toInstance(ingestService);
b.bind(NamedWriteableRegistry.class).toInstance(namedWriteableRegistry); b.bind(NamedWriteableRegistry.class).toInstance(namedWriteableRegistry);
b.bind(MetaDataUpgrader.class).toInstance(metaDataUpgrader);
b.bind(MetaStateService.class).toInstance(metaStateService);
b.bind(IndicesService.class).toInstance(indicesService);
Class<? extends SearchService> searchServiceImpl = pickSearchServiceImplementation(); Class<? extends SearchService> searchServiceImpl = pickSearchServiceImplementation();
if (searchServiceImpl == SearchService.class) { if (searchServiceImpl == SearchService.class) {
b.bind(SearchService.class).asEagerSingleton(); b.bind(SearchService.class).asEagerSingleton();
@ -381,7 +390,7 @@ public class Node implements Closeable {
b.bind(SearchService.class).to(searchServiceImpl).asEagerSingleton(); b.bind(SearchService.class).to(searchServiceImpl).asEagerSingleton();
} }
pluginComponents.stream().forEach(p -> b.bind((Class) p.getClass()).toInstance(p)); pluginComponents.stream().forEach(p -> b.bind((Class) p.getClass()).toInstance(p));
b.bind(MetaDataUpgrader.class).toInstance(metaDataUpgrader);
} }
); );
injector = modules.createInjector(); injector = modules.createInjector();