Local Gateway: Possible failure to allocate shards to nodes when more than one index exists in the cluster (on full cluster restart), closes #409.

This commit is contained in:
kimchy 2010-10-06 00:35:10 +02:00
parent abf1855509
commit 31d94b19a1
1 changed files with 9 additions and 7 deletions

View File

@ -224,15 +224,17 @@ public class LocalGatewayNodeAllocation extends NodeAllocation {
if (allocate) {
changed = true;
// we found all nodes to allocate to, do the allocation
// we found all nodes to allocate to, do the allocation (but only for the index we are working on)
for (Iterator<MutableShardRouting> it = routingNodes.unassigned().iterator(); it.hasNext();) {
MutableShardRouting shardRouting = it.next();
if (shardRouting.primary()) {
DiscoveryNode node = shards.get(shardRouting.shardId()).v1();
logger.debug("[{}][{}] initial allocation to [{}]", shardRouting.index(), shardRouting.id(), node);
RoutingNode routingNode = routingNodes.node(node.id());
routingNode.add(shardRouting);
it.remove();
if (shardRouting.index().equals(indexRoutingTable.index())) {
if (shardRouting.primary()) {
DiscoveryNode node = shards.get(shardRouting.shardId()).v1();
logger.debug("[{}][{}] initial allocation to [{}]", shardRouting.index(), shardRouting.id(), node);
RoutingNode routingNode = routingNodes.node(node.id());
routingNode.add(shardRouting);
it.remove();
}
}
}
} else {