Browse Source

Minor Cleanup Dead Code Snapshotting (#57716)

* Use consistent cluster state instead in state update
* Remove dead loop in tests
* Remove some dead exception ctors

Just three trivial/random things I found.
Armin Braun 5 years ago
parent
commit
8c8253d251

+ 0 - 5
server/src/main/java/org/elasticsearch/index/snapshots/IndexShardSnapshotException.java

@@ -33,11 +33,6 @@ public class IndexShardSnapshotException extends ElasticsearchException {
         this(shardId, msg, null);
     }
 
-    public IndexShardSnapshotException(ShardId shardId, Throwable cause) {
-        super(cause);
-        setShard(shardId);
-    }
-
     public IndexShardSnapshotException(ShardId shardId, String msg, Throwable cause) {
         super(msg, cause);
         setShard(shardId);

+ 0 - 4
server/src/main/java/org/elasticsearch/index/snapshots/IndexShardSnapshotFailedException.java

@@ -32,10 +32,6 @@ public class IndexShardSnapshotFailedException extends IndexShardSnapshotExcepti
         super(shardId, msg);
     }
 
-    public IndexShardSnapshotFailedException(ShardId shardId, Throwable cause) {
-        super(shardId, cause);
-    }
-
     public IndexShardSnapshotFailedException(ShardId shardId, String msg, Throwable cause) {
         super(shardId, msg, cause);
     }

+ 1 - 2
server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java

@@ -230,8 +230,7 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
                 logger.trace("[{}][{}] creating snapshot for indices [{}]", repositoryName, snapshotName, indices);
 
                 final List<IndexId> indexIds = repositoryData.resolveNewIndices(indices);
-                final Version version = minCompatibleVersion(
-                        clusterService.state().nodes().getMinNodeVersion(), repositoryData, null);
+                final Version version = minCompatibleVersion(currentState.nodes().getMinNodeVersion(), repositoryData, null);
                 ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards =
                         shards(currentState, indexIds, useShardGenerations(version), repositoryData);
                 if (request.partial() == false) {

+ 0 - 8
server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java

@@ -614,14 +614,6 @@ public class SnapshotResiliencyTests extends ESTestCase {
         Collection<SnapshotId> snapshotIds = getRepositoryData(repository).getSnapshotIds();
         // No snapshots should be left in the repository
         assertThat(snapshotIds, empty());
-
-        for (SnapshotId snapshotId : snapshotIds) {
-            final SnapshotInfo snapshotInfo = repository.getSnapshotInfo(snapshotId);
-            assertEquals(SnapshotState.SUCCESS, snapshotInfo.state());
-            assertThat(snapshotInfo.indices(), containsInAnyOrder(index));
-            assertEquals(shards, snapshotInfo.successfulShards());
-            assertEquals(0, snapshotInfo.failedShards());
-        }
     }
 
     public void testConcurrentSnapshotRestoreAndDeleteOther() {