Allow to delete a closed index, closes #859.

This commit is contained in:
kimchy 2011-04-14 20:51:20 +03:00
parent 7c38f20056
commit 897587f981
1 changed files with 10 additions and 9 deletions

View File

@ -74,8 +74,7 @@ public class MetaDataDeleteIndexService extends AbstractComponent {
@Override public ClusterState execute(ClusterState currentState) { @Override public ClusterState execute(ClusterState currentState) {
final DeleteIndexListener listener = new DeleteIndexListener(request, userListener); final DeleteIndexListener listener = new DeleteIndexListener(request, userListener);
try { try {
RoutingTable routingTable = currentState.routingTable(); if (!currentState.metaData().hasIndex(request.index)) {
if (!routingTable.hasIndex(request.index)) {
listener.onFailure(new IndexMissingException(new Index(request.index))); listener.onFailure(new IndexMissingException(new Index(request.index)));
return currentState; return currentState;
} }
@ -100,13 +99,15 @@ public class MetaDataDeleteIndexService extends AbstractComponent {
// initialize the counter only for nodes the shards are allocated to // initialize the counter only for nodes the shards are allocated to
Set<String> allocatedNodes = Sets.newHashSet(); Set<String> allocatedNodes = Sets.newHashSet();
for (IndexShardRoutingTable indexShardRoutingTable : currentState.routingTable().index(request.index)) { if (currentState.routingTable().hasIndex(request.index)) {
for (ShardRouting shardRouting : indexShardRoutingTable) { for (IndexShardRoutingTable indexShardRoutingTable : currentState.routingTable().index(request.index)) {
if (shardRouting.currentNodeId() != null) { for (ShardRouting shardRouting : indexShardRoutingTable) {
allocatedNodes.add(shardRouting.currentNodeId()); if (shardRouting.currentNodeId() != null) {
} allocatedNodes.add(shardRouting.currentNodeId());
if (shardRouting.relocatingNodeId() != null) { }
allocatedNodes.add(shardRouting.relocatingNodeId()); if (shardRouting.relocatingNodeId() != null) {
allocatedNodes.add(shardRouting.relocatingNodeId());
}
} }
} }
} }