From 790765d3f985db03b43907a55612560266a7f013 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Wed, 21 Aug 2019 19:26:19 +0200 Subject: [PATCH] Remove Dep. on SnapshotsService in SnapshotShardsService (#45776) (#45791) SnapshotShardsService depends on the RepositoriesService not the SnapshotsService, no need to have this indirection. --- server/src/main/java/org/elasticsearch/node/Node.java | 5 +++-- .../elasticsearch/snapshots/SnapshotShardsService.java | 9 +++++---- .../org/elasticsearch/snapshots/SnapshotsService.java | 4 ---- .../elasticsearch/snapshots/SnapshotResiliencyTests.java | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index db9b8d4a00f..e8a68928188 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -495,8 +495,9 @@ public class Node implements Closeable { 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()); + SnapshotShardsService snapshotShardsService = new SnapshotShardsService(settings, clusterService, repositoryService, + 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(), diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java index 851233019ca..f313aff03b9 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java @@ -65,6 +65,7 @@ import org.elasticsearch.index.snapshots.IndexShardSnapshotStatus; import org.elasticsearch.index.snapshots.IndexShardSnapshotStatus.Stage; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.repositories.IndexId; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.repositories.Repository; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportException; @@ -99,7 +100,7 @@ public class SnapshotShardsService extends AbstractLifecycleComponent implements private final IndicesService indicesService; - private final SnapshotsService snapshotsService; + private final RepositoriesService repositoriesService; private final TransportService transportService; @@ -114,11 +115,11 @@ public class SnapshotShardsService extends AbstractLifecycleComponent implements private final SnapshotStateExecutor snapshotStateExecutor = new SnapshotStateExecutor(); private final UpdateSnapshotStatusAction updateSnapshotStatusHandler; - public SnapshotShardsService(Settings settings, ClusterService clusterService, SnapshotsService snapshotsService, + public SnapshotShardsService(Settings settings, ClusterService clusterService, RepositoriesService repositoriesService, ThreadPool threadPool, TransportService transportService, IndicesService indicesService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) { this.indicesService = indicesService; - this.snapshotsService = snapshotsService; + this.repositoriesService = repositoriesService; this.transportService = transportService; this.clusterService = clusterService; this.threadPool = threadPool; @@ -361,7 +362,7 @@ public class SnapshotShardsService extends AbstractLifecycleComponent implements throw new IndexShardSnapshotFailedException(shardId, "shard didn't fully recover yet"); } - final Repository repository = snapshotsService.getRepositoriesService().repository(snapshot.getRepository()); + final Repository repository = repositoriesService.repository(snapshot.getRepository()); try { // we flush first to make sure we get the latest writes snapshotted try (Engine.IndexCommitRef snapshotRef = indexShard.acquireLastIndexCommit(true)) { diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java index 63e12ead7cb..e9b7915cf98 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java @@ -1468,8 +1468,4 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus protected void doClose() { clusterService.removeApplier(this); } - - public RepositoriesService getRepositoriesService() { - return repositoriesService; - } } diff --git a/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java index cadc93b9aaa..68860a7ff52 100644 --- a/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java +++ b/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java @@ -903,7 +903,7 @@ public class SnapshotResiliencyTests extends ESTestCase { final RecoverySettings recoverySettings = new RecoverySettings(settings, clusterSettings); final ActionFilters actionFilters = new ActionFilters(emptySet()); snapshotShardsService = new SnapshotShardsService( - settings, clusterService, snapshotsService, threadPool, + settings, clusterService, repositoriesService, threadPool, transportService, indicesService, actionFilters, indexNameExpressionResolver); final ShardStateAction shardStateAction = new ShardStateAction( clusterService, transportService, allocationService,