Skip to content

Commit

Permalink
Acknowledge problem for put mapping with multiple indices or all indi…
Browse files Browse the repository at this point in the history
…ces, closes elastic#720.
  • Loading branch information
kimchy committed Feb 24, 2011
1 parent 642baf6 commit 3ba2d39
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Expand Up @@ -282,13 +282,10 @@ public void putMapping(final PutRequest request, final Listener listener) {
for (String index : request.indices) {
IndexRoutingTable indexRoutingTable = clusterState.routingTable().index(index);
if (indexRoutingTable != null) {
counter += indexRoutingTable.numberOfNodesShardsAreAllocatedOn();
counter += indexRoutingTable.numberOfNodesShardsAreAllocatedOn(clusterState.nodes().masterNodeId());
}
}

if (counter > 0) {
counter = counter - 1; // we already added the mapping on the master here...
}
if (counter == 0) {
listener.onResponse(new Response(true));
return;
Expand Down
Expand Up @@ -102,12 +102,24 @@ public void validate(RoutingTableValidation validation, MetaData metaData) {
return shards.values().iterator();
}

public int numberOfNodesShardsAreAllocatedOn() {
public int numberOfNodesShardsAreAllocatedOn(String... excludedNodes) {
Set<String> nodes = Sets.newHashSet();
for (IndexShardRoutingTable shardRoutingTable : this) {
for (ShardRouting shardRouting : shardRoutingTable) {
if (shardRouting.assignedToNode()) {
nodes.add(shardRouting.currentNodeId());
String currentNodeId = shardRouting.currentNodeId();
boolean excluded = false;
if (excludedNodes != null) {
for (String excludedNode : excludedNodes) {
if (currentNodeId.equals(excludedNode)) {
excluded = true;
break;
}
}
}
if (!excluded) {
nodes.add(currentNodeId);
}
}
}
}
Expand Down

0 comments on commit 3ba2d39

Please sign in to comment.