Fixed close index when the index is already closed

Closes #3601
This commit is contained in:
Luca Cavanna 2013-09-02 10:58:09 +02:00
parent 206ab3a6d4
commit 38be478c46
2 changed files with 9 additions and 9 deletions

View File

@ -96,14 +96,14 @@ public class MetaDataIndexStateService extends AbstractComponent {
if (indexMetaData == null) {
throw new IndexMissingException(new Index(index));
}
IndexRoutingTable indexRoutingTable = currentState.routingTable().index(index);
for (IndexShardRoutingTable shard : indexRoutingTable) {
if (!shard.primaryAllocatedPostApi()) {
throw new IndexPrimaryShardNotAllocatedException(new Index(index));
}
}
if (indexMetaData.state() != IndexMetaData.State.CLOSE) {
IndexRoutingTable indexRoutingTable = currentState.routingTable().index(index);
for (IndexShardRoutingTable shard : indexRoutingTable) {
if (!shard.primaryAllocatedPostApi()) {
throw new IndexPrimaryShardNotAllocatedException(new Index(index));
}
}
indicesToClose.add(index);
}
}

View File

@ -227,9 +227,9 @@ public class OpenCloseIndexTests extends AbstractSharedClusterTest {
assertIndexIsClosed("test1");
//no problem if we try to close an index that's already in close state
OpenIndexResponse openIndexResponse1 = client.admin().indices().prepareOpen("test1").execute().actionGet();
assertThat(openIndexResponse1.isAcknowledged(), equalTo(true));
assertIndexIsOpened("test1");
closeIndexResponse = client.admin().indices().prepareClose("test1").execute().actionGet();
assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
assertIndexIsClosed("test1");
}
@Test