|
72 | 72 | import org.elasticsearch.common.unit.TimeValue; |
73 | 73 | import org.elasticsearch.index.Index; |
74 | 74 | import org.elasticsearch.index.shard.ShardId; |
75 | | -import org.elasticsearch.index.snapshots.IndexShardSnapshotStatus; |
76 | 75 | import org.elasticsearch.repositories.IndexId; |
77 | 76 | import org.elasticsearch.repositories.RepositoriesService; |
78 | 77 | import org.elasticsearch.repositories.Repository; |
|
105 | 104 |
|
106 | 105 | import static java.util.Collections.emptySet; |
107 | 106 | import static java.util.Collections.unmodifiableList; |
108 | | -import static java.util.Collections.unmodifiableMap; |
109 | 107 | import static org.elasticsearch.cluster.SnapshotsInProgress.completed; |
110 | 108 |
|
111 | 109 | /** |
@@ -418,67 +416,6 @@ public static List<SnapshotsInProgress.Entry> currentSnapshots(@Nullable Snapsho |
418 | 416 | return unmodifiableList(builder); |
419 | 417 | } |
420 | 418 |
|
421 | | - /** |
422 | | - * Returns status of shards currently finished snapshots |
423 | | - * <p> |
424 | | - * This method is executed on master node and it's complimentary to the |
425 | | - * {@link SnapshotShardsService#currentSnapshotShards(Snapshot)} because it |
426 | | - * returns similar information but for already finished snapshots. |
427 | | - * </p> |
428 | | - * |
429 | | - * @param repositoryName repository name |
430 | | - * @param snapshotInfo snapshot info |
431 | | - * @return map of shard id to snapshot status |
432 | | - */ |
433 | | - public Map<ShardId, IndexShardSnapshotStatus> snapshotShards(final String repositoryName, |
434 | | - final RepositoryData repositoryData, |
435 | | - final SnapshotInfo snapshotInfo) throws IOException { |
436 | | - final Repository repository = repositoriesService.repository(repositoryName); |
437 | | - final Map<ShardId, IndexShardSnapshotStatus> shardStatus = new HashMap<>(); |
438 | | - for (String index : snapshotInfo.indices()) { |
439 | | - IndexId indexId = repositoryData.resolveIndexId(index); |
440 | | - IndexMetadata indexMetaData = repository.getSnapshotIndexMetaData(repositoryData, snapshotInfo.snapshotId(), indexId); |
441 | | - if (indexMetaData != null) { |
442 | | - int numberOfShards = indexMetaData.getNumberOfShards(); |
443 | | - for (int i = 0; i < numberOfShards; i++) { |
444 | | - ShardId shardId = new ShardId(indexMetaData.getIndex(), i); |
445 | | - SnapshotShardFailure shardFailure = findShardFailure(snapshotInfo.shardFailures(), shardId); |
446 | | - if (shardFailure != null) { |
447 | | - shardStatus.put(shardId, IndexShardSnapshotStatus.newFailed(shardFailure.reason())); |
448 | | - } else { |
449 | | - final IndexShardSnapshotStatus shardSnapshotStatus; |
450 | | - if (snapshotInfo.state() == SnapshotState.FAILED) { |
451 | | - // If the snapshot failed, but the shard's snapshot does |
452 | | - // not have an exception, it means that partial snapshots |
453 | | - // were disabled and in this case, the shard snapshot will |
454 | | - // *not* have any metadata, so attempting to read the shard |
455 | | - // snapshot status will throw an exception. Instead, we create |
456 | | - // a status for the shard to indicate that the shard snapshot |
457 | | - // could not be taken due to partial being set to false. |
458 | | - shardSnapshotStatus = IndexShardSnapshotStatus.newFailed("skipped"); |
459 | | - } else { |
460 | | - shardSnapshotStatus = repository.getShardSnapshotStatus( |
461 | | - snapshotInfo.snapshotId(), |
462 | | - indexId, |
463 | | - shardId); |
464 | | - } |
465 | | - shardStatus.put(shardId, shardSnapshotStatus); |
466 | | - } |
467 | | - } |
468 | | - } |
469 | | - } |
470 | | - return unmodifiableMap(shardStatus); |
471 | | - } |
472 | | - |
473 | | - private static SnapshotShardFailure findShardFailure(List<SnapshotShardFailure> shardFailures, ShardId shardId) { |
474 | | - for (SnapshotShardFailure shardFailure : shardFailures) { |
475 | | - if (shardId.getIndexName().equals(shardFailure.index()) && shardId.getId() == shardFailure.shardId()) { |
476 | | - return shardFailure; |
477 | | - } |
478 | | - } |
479 | | - return null; |
480 | | - } |
481 | | - |
482 | 419 | @Override |
483 | 420 | public void applyClusterState(ClusterChangedEvent event) { |
484 | 421 | try { |
|
0 commit comments