From 46ccee8f8988ad52fba7d635000e69065bc696fb Mon Sep 17 00:00:00 2001 From: kimchy Date: Thu, 19 Aug 2010 17:21:14 +0300 Subject: [PATCH] when deleting an index, remove any blocks associated with it --- .../org/elasticsearch/cluster/block/ClusterBlocks.java | 8 ++++++++ .../cluster/metadata/MetaDataDeleteIndexService.java | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java index f7fc68c5ca9..3a06cdf12e5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java @@ -194,6 +194,14 @@ public class ClusterBlocks { return this; } + public Builder removeIndexBlocks(String index) { + if (!indices.containsKey(index)) { + return this; + } + indices.remove(index); + return this; + } + public Builder removeIndexBlock(String index, ClusterBlock block) { if (!indices.containsKey(index)) { return this; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java index 23b149e1982..e5c21a0c0c5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java @@ -23,6 +23,7 @@ import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateUpdateTask; import org.elasticsearch.cluster.action.index.NodeIndexDeletedAction; +import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.routing.IndexRoutingTable; import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.strategy.ShardsRoutingStrategy; @@ -91,6 +92,8 @@ public class MetaDataDeleteIndexService extends AbstractComponent { RoutingTable newRoutingTable = shardsRoutingStrategy.reroute( newClusterStateBuilder().state(currentState).routingTable(routingTableBuilder).metaData(newMetaData).build()); + ClusterBlocks blocks = ClusterBlocks.builder().blocks(currentState.blocks()).removeIndexBlocks(request.index).build(); + final AtomicInteger counter = new AtomicInteger(currentState.nodes().size()); final NodeIndexDeletedAction.Listener nodeIndexDeleteListener = new NodeIndexDeletedAction.Listener() { @@ -114,7 +117,7 @@ public class MetaDataDeleteIndexService extends AbstractComponent { listener.timeout = timeoutTask; - return newClusterStateBuilder().state(currentState).routingTable(newRoutingTable).metaData(newMetaData).build(); + return newClusterStateBuilder().state(currentState).routingTable(newRoutingTable).metaData(newMetaData).blocks(blocks).build(); } catch (Exception e) { listener.onFailure(e); return currentState;