|
19 | 19 |
|
20 | 20 | package org.elasticsearch.snapshots;
|
21 | 21 |
|
| 22 | +import org.apache.lucene.util.SetOnce; |
22 | 23 | import org.elasticsearch.ExceptionsHelper;
|
23 | 24 | import org.elasticsearch.Version;
|
24 | 25 | import org.elasticsearch.action.ActionFuture;
|
|
93 | 94 | import org.elasticsearch.script.StoredScriptsIT;
|
94 | 95 | import org.elasticsearch.snapshots.mockstore.MockRepository;
|
95 | 96 | import org.elasticsearch.test.junit.annotations.TestLogging;
|
| 97 | +import org.elasticsearch.threadpool.ThreadPool; |
96 | 98 |
|
97 | 99 | import java.io.IOException;
|
98 | 100 | import java.nio.channels.SeekableByteChannel;
|
@@ -1262,7 +1264,7 @@ public void testDeleteSnapshotWithMissingIndexAndShardMetadata() throws Exceptio
|
1262 | 1264 | RepositoriesService service = internalCluster().getInstance(RepositoriesService.class, internalCluster().getMasterName());
|
1263 | 1265 | Repository repository = service.repository("test-repo");
|
1264 | 1266 |
|
1265 |
| - final Map<String, IndexId> indexIds = repository.getRepositoryData().getIndices(); |
| 1267 | + final Map<String, IndexId> indexIds = getRepositoryData(repository).getIndices(); |
1266 | 1268 | final Path indicesPath = repo.resolve("indices");
|
1267 | 1269 |
|
1268 | 1270 | logger.info("--> delete index metadata and shard metadata");
|
@@ -2564,7 +2566,7 @@ public void testDeleteOrphanSnapshot() throws Exception {
|
2564 | 2566 |
|
2565 | 2567 | logger.info("--> emulate an orphan snapshot");
|
2566 | 2568 | RepositoriesService repositoriesService = internalCluster().getInstance(RepositoriesService.class, internalCluster().getMasterName());
|
2567 |
| - final RepositoryData repositoryData = repositoriesService.repository(repositoryName).getRepositoryData(); |
| 2569 | + final RepositoryData repositoryData = getRepositoryData(repositoriesService.repository(repositoryName)); |
2568 | 2570 | final IndexId indexId = repositoryData.resolveIndexId(idxName);
|
2569 | 2571 |
|
2570 | 2572 | clusterService.submitStateUpdateTask("orphan snapshot test", new ClusterStateUpdateTask() {
|
@@ -2785,7 +2787,8 @@ public void testRestoreSnapshotWithCorruptedIndexMetadata() throws Exception {
|
2785 | 2787 | RepositoriesService service = internalCluster().getInstance(RepositoriesService.class, internalCluster().getMasterName());
|
2786 | 2788 | Repository repository = service.repository("test-repo");
|
2787 | 2789 |
|
2788 |
| - final Map<String, IndexId> indexIds = repository.getRepositoryData().getIndices(); |
| 2790 | + final RepositoryData repositoryData = getRepositoryData(repository); |
| 2791 | + final Map<String, IndexId> indexIds = repositoryData.getIndices(); |
2789 | 2792 | assertThat(indexIds.size(), equalTo(nbIndices));
|
2790 | 2793 |
|
2791 | 2794 | // Choose a random index from the snapshot
|
@@ -3446,6 +3449,19 @@ public void testAbortedSnapshotDuringInitDoesNotStart() throws Exception {
|
3446 | 3449 | }
|
3447 | 3450 | }
|
3448 | 3451 |
|
| 3452 | + private RepositoryData getRepositoryData(Repository repository) throws InterruptedException { |
| 3453 | + ThreadPool threadPool = internalCluster().getInstance(ThreadPool.class, internalCluster().getMasterName()); |
| 3454 | + final SetOnce<RepositoryData> repositoryData = new SetOnce<>(); |
| 3455 | + final CountDownLatch latch = new CountDownLatch(1); |
| 3456 | + threadPool.executor(ThreadPool.Names.SNAPSHOT).execute(() -> { |
| 3457 | + repositoryData.set(repository.getRepositoryData()); |
| 3458 | + latch.countDown(); |
| 3459 | + }); |
| 3460 | + |
| 3461 | + latch.await(); |
| 3462 | + return repositoryData.get(); |
| 3463 | + } |
| 3464 | + |
3449 | 3465 | private void verifySnapshotInfo(final GetSnapshotsResponse response, final Map<String, List<String>> indicesPerSnapshot) {
|
3450 | 3466 | for (SnapshotInfo snapshotInfo : response.getSnapshots()) {
|
3451 | 3467 | final List<String> expected = snapshotInfo.indices();
|
|
0 commit comments