|
@@ -20,8 +20,8 @@
|
|
|
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.inject.multibindings.MapBinder;
|
|
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
|
|
import org.elasticsearch.env.Environment;
|
|
|
import org.elasticsearch.plugins.RepositoryPlugin;
|
|
@@ -29,6 +29,8 @@ 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;
|
|
|
|
|
|
import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
@@ -40,9 +42,10 @@ import java.util.Map;
|
|
|
*/
|
|
|
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<>();
|
|
|
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
|
|
|
protected void configure() {
|
|
|
- bind(RepositoriesService.class).asEagerSingleton();
|
|
|
+ bind(RepositoriesService.class).toInstance(repositoriesService);
|
|
|
bind(SnapshotsService.class).asEagerSingleton();
|
|
|
bind(SnapshotShardsService.class).asEagerSingleton();
|
|
|
bind(TransportNodesSnapshotsStatus.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));
|
|
|
}
|
|
|
}
|