Core: Deguice RepositoriesService (#36016)
This commit moves the RepositoriesService to be created outside of guice.
This commit is contained in:
parent
465233787e
commit
afd42df15f
|
@ -151,7 +151,6 @@ import org.elasticsearch.usage.UsageService;
|
||||||
import org.elasticsearch.watcher.ResourceWatcherService;
|
import org.elasticsearch.watcher.ResourceWatcherService;
|
||||||
|
|
||||||
import javax.net.ssl.SNIHostName;
|
import javax.net.ssl.SNIHostName;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -396,7 +395,6 @@ public class Node implements Closeable {
|
||||||
.flatMap(p -> p.getNamedXContent().stream()),
|
.flatMap(p -> p.getNamedXContent().stream()),
|
||||||
ClusterModule.getNamedXWriteables().stream())
|
ClusterModule.getNamedXWriteables().stream())
|
||||||
.flatMap(Function.identity()).collect(toList()));
|
.flatMap(Function.identity()).collect(toList()));
|
||||||
modules.add(new RepositoriesModule(this.environment, pluginsService.filterPlugins(RepositoryPlugin.class), xContentRegistry));
|
|
||||||
final MetaStateService metaStateService = new MetaStateService(nodeEnvironment, xContentRegistry);
|
final MetaStateService metaStateService = new MetaStateService(nodeEnvironment, xContentRegistry);
|
||||||
|
|
||||||
// collect engine factory providers from server and from plugins
|
// collect engine factory providers from server and from plugins
|
||||||
|
@ -478,6 +476,10 @@ public class Node implements Closeable {
|
||||||
SearchExecutionStatsCollector.makeWrapper(responseCollectorService));
|
SearchExecutionStatsCollector.makeWrapper(responseCollectorService));
|
||||||
final HttpServerTransport httpServerTransport = newHttpTransport(networkModule);
|
final HttpServerTransport httpServerTransport = newHttpTransport(networkModule);
|
||||||
|
|
||||||
|
|
||||||
|
modules.add(new RepositoriesModule(this.environment, pluginsService.filterPlugins(RepositoryPlugin.class), transportService,
|
||||||
|
clusterService, threadPool, xContentRegistry));
|
||||||
|
|
||||||
final DiscoveryModule discoveryModule = new DiscoveryModule(this.settings, threadPool, transportService, namedWriteableRegistry,
|
final DiscoveryModule discoveryModule = new DiscoveryModule(this.settings, threadPool, transportService, namedWriteableRegistry,
|
||||||
networkService, clusterService.getMasterService(), clusterService.getClusterApplierService(),
|
networkService, clusterService.getMasterService(), clusterService.getClusterApplierService(),
|
||||||
clusterService.getClusterSettings(), pluginsService.filterPlugins(DiscoveryPlugin.class),
|
clusterService.getClusterSettings(), pluginsService.filterPlugins(DiscoveryPlugin.class),
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
package org.elasticsearch.repositories;
|
package org.elasticsearch.repositories;
|
||||||
|
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.status.TransportNodesSnapshotsStatus;
|
import org.elasticsearch.action.admin.cluster.snapshots.status.TransportNodesSnapshotsStatus;
|
||||||
|
import org.elasticsearch.cluster.service.ClusterService;
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
import org.elasticsearch.common.inject.AbstractModule;
|
||||||
import org.elasticsearch.common.inject.multibindings.MapBinder;
|
|
||||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.plugins.RepositoryPlugin;
|
import org.elasticsearch.plugins.RepositoryPlugin;
|
||||||
|
@ -29,6 +29,8 @@ import org.elasticsearch.repositories.fs.FsRepository;
|
||||||
import org.elasticsearch.snapshots.RestoreService;
|
import org.elasticsearch.snapshots.RestoreService;
|
||||||
import org.elasticsearch.snapshots.SnapshotShardsService;
|
import org.elasticsearch.snapshots.SnapshotShardsService;
|
||||||
import org.elasticsearch.snapshots.SnapshotsService;
|
import org.elasticsearch.snapshots.SnapshotsService;
|
||||||
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -40,9 +42,10 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class RepositoriesModule extends AbstractModule {
|
public class RepositoriesModule extends AbstractModule {
|
||||||
|
|
||||||
private final Map<String, Repository.Factory> repositoryTypes;
|
private final RepositoriesService repositoriesService;
|
||||||
|
|
||||||
public RepositoriesModule(Environment env, List<RepositoryPlugin> repoPlugins, NamedXContentRegistry namedXContentRegistry) {
|
public RepositoriesModule(Environment env, List<RepositoryPlugin> repoPlugins, TransportService transportService,
|
||||||
|
ClusterService clusterService, ThreadPool threadPool, NamedXContentRegistry namedXContentRegistry) {
|
||||||
Map<String, Repository.Factory> factories = new HashMap<>();
|
Map<String, Repository.Factory> factories = new HashMap<>();
|
||||||
factories.put(FsRepository.TYPE, (metadata) -> new FsRepository(metadata, env, namedXContentRegistry));
|
factories.put(FsRepository.TYPE, (metadata) -> new FsRepository(metadata, env, namedXContentRegistry));
|
||||||
|
|
||||||
|
@ -54,17 +57,17 @@ public class RepositoriesModule extends AbstractModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repositoryTypes = Collections.unmodifiableMap(factories);
|
|
||||||
|
Map<String, Repository.Factory> repositoryTypes = Collections.unmodifiableMap(factories);
|
||||||
|
repositoriesService = new RepositoriesService(env.settings(), clusterService, transportService, repositoryTypes, threadPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(RepositoriesService.class).asEagerSingleton();
|
bind(RepositoriesService.class).toInstance(repositoriesService);
|
||||||
bind(SnapshotsService.class).asEagerSingleton();
|
bind(SnapshotsService.class).asEagerSingleton();
|
||||||
bind(SnapshotShardsService.class).asEagerSingleton();
|
bind(SnapshotShardsService.class).asEagerSingleton();
|
||||||
bind(TransportNodesSnapshotsStatus.class).asEagerSingleton();
|
bind(TransportNodesSnapshotsStatus.class).asEagerSingleton();
|
||||||
bind(RestoreService.class).asEagerSingleton();
|
bind(RestoreService.class).asEagerSingleton();
|
||||||
MapBinder<String, Repository.Factory> typesBinder = MapBinder.newMapBinder(binder(), String.class, Repository.Factory.class);
|
|
||||||
repositoryTypes.forEach((k, v) -> typesBinder.addBinding(k).toInstance(v));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.elasticsearch.cluster.metadata.RepositoriesMetaData;
|
||||||
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
|
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.cluster.service.ClusterService;
|
import org.elasticsearch.cluster.service.ClusterService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
|
||||||
import org.elasticsearch.common.regex.Regex;
|
import org.elasticsearch.common.regex.Regex;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.snapshots.RestoreService;
|
import org.elasticsearch.snapshots.RestoreService;
|
||||||
|
@ -68,7 +67,6 @@ public class RepositoriesService implements ClusterStateApplier {
|
||||||
|
|
||||||
private volatile Map<String, Repository> repositories = Collections.emptyMap();
|
private volatile Map<String, Repository> repositories = Collections.emptyMap();
|
||||||
|
|
||||||
@Inject
|
|
||||||
public RepositoriesService(Settings settings, ClusterService clusterService, TransportService transportService,
|
public RepositoriesService(Settings settings, ClusterService clusterService, TransportService transportService,
|
||||||
Map<String, Repository.Factory> typesRegistry,
|
Map<String, Repository.Factory> typesRegistry,
|
||||||
ThreadPool threadPool) {
|
ThreadPool threadPool) {
|
||||||
|
|
Loading…
Reference in New Issue