mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
Unguice Snapshot / Restore services (#42357)
This removes the @Inject annotations from the Snapshot/Restore infrastructure classes and registers them manually in Node.java
This commit is contained in:
parent
a497603219
commit
5a884dac03
@ -30,7 +30,6 @@ import org.elasticsearch.action.support.nodes.TransportNodesAction;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
@ -60,7 +59,6 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
|
||||
|
||||
private final SnapshotShardsService snapshotShardsService;
|
||||
|
||||
@Inject
|
||||
public TransportNodesSnapshotsStatus(ThreadPool threadPool, ClusterService clusterService,
|
||||
TransportService transportService, SnapshotShardsService snapshotShardsService,
|
||||
ActionFilters actionFilters) {
|
||||
|
@ -28,6 +28,7 @@ import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.ElasticsearchTimeoutException;
|
||||
import org.elasticsearch.action.Action;
|
||||
import org.elasticsearch.action.ActionModule;
|
||||
import org.elasticsearch.action.admin.cluster.snapshots.status.TransportNodesSnapshotsStatus;
|
||||
import org.elasticsearch.action.search.SearchExecutionStatsCollector;
|
||||
import org.elasticsearch.action.search.SearchPhaseController;
|
||||
import org.elasticsearch.action.search.SearchTransportService;
|
||||
@ -135,12 +136,14 @@ import org.elasticsearch.plugins.RepositoryPlugin;
|
||||
import org.elasticsearch.plugins.ScriptPlugin;
|
||||
import org.elasticsearch.plugins.SearchPlugin;
|
||||
import org.elasticsearch.repositories.RepositoriesModule;
|
||||
import org.elasticsearch.repositories.RepositoriesService;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.script.ScriptModule;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchModule;
|
||||
import org.elasticsearch.search.SearchService;
|
||||
import org.elasticsearch.search.fetch.FetchPhase;
|
||||
import org.elasticsearch.snapshots.RestoreService;
|
||||
import org.elasticsearch.snapshots.SnapshotShardsService;
|
||||
import org.elasticsearch.snapshots.SnapshotsService;
|
||||
import org.elasticsearch.tasks.Task;
|
||||
@ -478,8 +481,17 @@ public class Node implements Closeable {
|
||||
final HttpServerTransport httpServerTransport = newHttpTransport(networkModule);
|
||||
|
||||
|
||||
modules.add(new RepositoriesModule(this.environment, pluginsService.filterPlugins(RepositoryPlugin.class), transportService,
|
||||
clusterService, threadPool, xContentRegistry));
|
||||
RepositoriesModule repositoriesModule = new RepositoriesModule(this.environment,
|
||||
pluginsService.filterPlugins(RepositoryPlugin.class), transportService, clusterService, threadPool, xContentRegistry);
|
||||
RepositoriesService repositoryService = repositoriesModule.getRepositoryService();
|
||||
SnapshotsService snapshotsService = new SnapshotsService(settings, clusterService,
|
||||
clusterModule.getIndexNameExpressionResolver(), repositoryService, threadPool);
|
||||
SnapshotShardsService snapshotShardsService = new SnapshotShardsService(settings, clusterService, snapshotsService, threadPool,
|
||||
transportService, indicesService, actionModule.getActionFilters(), clusterModule.getIndexNameExpressionResolver());
|
||||
TransportNodesSnapshotsStatus nodesSnapshotsStatus = new TransportNodesSnapshotsStatus(threadPool, clusterService,
|
||||
transportService, snapshotShardsService, actionModule.getActionFilters());
|
||||
RestoreService restoreService = new RestoreService(clusterService, repositoryService, clusterModule.getAllocationService(),
|
||||
metaDataCreateIndexService, metaDataIndexUpgradeService, clusterService.getClusterSettings());
|
||||
|
||||
final DiscoveryModule discoveryModule = new DiscoveryModule(settings, threadPool, transportService, namedWriteableRegistry,
|
||||
networkService, clusterService.getMasterService(), clusterService.getClusterApplierService(),
|
||||
@ -554,6 +566,11 @@ public class Node implements Closeable {
|
||||
b.bind(PersistentTasksService.class).toInstance(persistentTasksService);
|
||||
b.bind(PersistentTasksClusterService.class).toInstance(persistentTasksClusterService);
|
||||
b.bind(PersistentTasksExecutorRegistry.class).toInstance(registry);
|
||||
b.bind(RepositoriesService.class).toInstance(repositoryService);
|
||||
b.bind(SnapshotsService.class).toInstance(snapshotsService);
|
||||
b.bind(SnapshotShardsService.class).toInstance(snapshotShardsService);
|
||||
b.bind(TransportNodesSnapshotsStatus.class).toInstance(nodesSnapshotsStatus);
|
||||
b.bind(RestoreService.class).toInstance(restoreService);
|
||||
}
|
||||
);
|
||||
injector = modules.createInjector();
|
||||
|
@ -19,16 +19,12 @@
|
||||
|
||||
package org.elasticsearch.repositories;
|
||||
|
||||
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.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.plugins.RepositoryPlugin;
|
||||
import org.elasticsearch.repositories.fs.FsRepository;
|
||||
import org.elasticsearch.snapshots.RestoreService;
|
||||
import org.elasticsearch.snapshots.SnapshotShardsService;
|
||||
import org.elasticsearch.snapshots.SnapshotsService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
@ -40,7 +36,7 @@ import java.util.Map;
|
||||
/**
|
||||
* Sets up classes for Snapshot/Restore.
|
||||
*/
|
||||
public class RepositoriesModule extends AbstractModule {
|
||||
public final class RepositoriesModule {
|
||||
|
||||
private final RepositoriesService repositoriesService;
|
||||
|
||||
@ -72,18 +68,14 @@ public class RepositoriesModule extends AbstractModule {
|
||||
}
|
||||
}
|
||||
|
||||
Settings settings = env.settings();
|
||||
Map<String, Repository.Factory> repositoryTypes = Collections.unmodifiableMap(factories);
|
||||
Map<String, Repository.Factory> internalRepositoryTypes = Collections.unmodifiableMap(internalFactories);
|
||||
repositoriesService = new RepositoriesService(env.settings(), clusterService, transportService, repositoryTypes,
|
||||
repositoriesService = new RepositoriesService(settings, clusterService, transportService, repositoryTypes,
|
||||
internalRepositoryTypes, threadPool);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(RepositoriesService.class).toInstance(repositoriesService);
|
||||
bind(SnapshotsService.class).asEagerSingleton();
|
||||
bind(SnapshotShardsService.class).asEagerSingleton();
|
||||
bind(TransportNodesSnapshotsStatus.class).asEagerSingleton();
|
||||
bind(RestoreService.class).asEagerSingleton();
|
||||
public RepositoriesService getRepositoryService() {
|
||||
return repositoriesService;
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,6 @@ import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.common.UUIDs;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
@ -152,7 +151,6 @@ public class RestoreService implements ClusterStateApplier {
|
||||
|
||||
private final CleanRestoreStateTaskExecutor cleanRestoreStateTaskExecutor;
|
||||
|
||||
@Inject
|
||||
public RestoreService(ClusterService clusterService, RepositoriesService repositoriesService,
|
||||
AllocationService allocationService, MetaDataCreateIndexService createIndexService,
|
||||
MetaDataIndexUpgradeService metaDataIndexUpgradeService, ClusterSettings clusterSettings) {
|
||||
|
@ -48,7 +48,6 @@ import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
@ -114,7 +113,6 @@ public class SnapshotShardsService extends AbstractLifecycleComponent implements
|
||||
private final SnapshotStateExecutor snapshotStateExecutor = new SnapshotStateExecutor();
|
||||
private final UpdateSnapshotStatusAction updateSnapshotStatusHandler;
|
||||
|
||||
@Inject
|
||||
public SnapshotShardsService(Settings settings, ClusterService clusterService, SnapshotsService snapshotsService,
|
||||
ThreadPool threadPool, TransportService transportService, IndicesService indicesService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
|
@ -56,7 +56,6 @@ import org.elasticsearch.common.UUIDs;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||
@ -130,7 +129,6 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
||||
// Set of snapshots that are currently being ended by this node
|
||||
private final Set<Snapshot> endingSnapshots = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
@Inject
|
||||
public SnapshotsService(Settings settings, ClusterService clusterService, IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
RepositoriesService repositoriesService, ThreadPool threadPool) {
|
||||
this.clusterService = clusterService;
|
||||
|
Loading…
x
Reference in New Issue
Block a user