Skip to content

Commit

Permalink
Open correct (renamed) index on restore
Browse files Browse the repository at this point in the history
Closes #5212
  • Loading branch information
imotov committed Feb 23, 2014
1 parent dab1f76 commit 7209f9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Expand Up @@ -195,7 +195,7 @@ public ClusterState execute(ClusterState currentState) {
indexMdBuilder.version(Math.max(snapshotIndexMetaData.version(), currentIndexMetaData.version() + 1));
IndexMetaData updatedIndexMetaData = indexMdBuilder.index(renamedIndex).build();
rtBuilder.addAsRestore(updatedIndexMetaData, restoreSource);
blocks.removeIndexBlock(index, INDEX_CLOSED_BLOCK);
blocks.removeIndexBlock(renamedIndex, INDEX_CLOSED_BLOCK);
mdBuilder.put(updatedIndexMetaData, true);
}
for (int shard = 0; shard < snapshotIndexMetaData.getNumberOfShards(); shard++) {
Expand Down
Expand Up @@ -680,6 +680,19 @@ public void renameOnRestoreTest() throws Exception {
assertThat(client.prepareCount("test-idx-1-copy").get().getCount(), equalTo(100L));
assertThat(client.prepareCount("test-idx-2-copy").get().getCount(), equalTo(100L));

logger.info("--> close just restored indices");
client.admin().indices().prepareClose("test-idx-1-copy", "test-idx-2-copy").get();

logger.info("--> and try to restore these indices again");
restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
.setRenamePattern("(.+)").setRenameReplacement("$1-copy").setWaitForCompletion(true).execute().actionGet();
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));

ensureGreen();
assertThat(client.prepareCount("test-idx-1-copy").get().getCount(), equalTo(100L));
assertThat(client.prepareCount("test-idx-2-copy").get().getCount(), equalTo(100L));


logger.info("--> close indices");
client.admin().indices().prepareClose("test-idx-1", "test-idx-2-copy").get();

Expand Down

0 comments on commit 7209f9f

Please sign in to comment.