From 1ddd969fa7a0743b68f7fb3f8625c03b61c6125c Mon Sep 17 00:00:00 2001 From: kimchy Date: Sat, 21 Aug 2010 17:52:02 +0300 Subject: [PATCH] pass to canAllocate (though nothing is done there now) the actual routing nodes --- .../org/elasticsearch/cluster/routing/RoutingNode.java | 4 +--- .../cluster/routing/strategy/ShardsRoutingStrategy.java | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java index beace1d9b3c..dc3668e4051 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java @@ -19,8 +19,6 @@ package org.elasticsearch.cluster.routing; -import org.elasticsearch.cluster.metadata.MetaData; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -119,7 +117,7 @@ public class RoutingNode implements Iterable { return count; } - public boolean canAllocate(MetaData metaData, RoutingTable routingTable) { + public boolean canAllocate(RoutingNodes nodes) { return true; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/strategy/ShardsRoutingStrategy.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/strategy/ShardsRoutingStrategy.java index 41bbb404b8c..475b3cc30be 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/strategy/ShardsRoutingStrategy.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/strategy/ShardsRoutingStrategy.java @@ -171,7 +171,7 @@ public class ShardsRoutingStrategy extends AbstractComponent { continue; } - if (lowRoutingNode.canAllocate(routingNodes.metaData(), routingNodes.routingTable()) && lowRoutingNode.canAllocate(startedShard)) { + if (lowRoutingNode.canAllocate(routingNodes) && lowRoutingNode.canAllocate(startedShard)) { changed = true; lowRoutingNode.add(new MutableShardRouting(startedShard.index(), startedShard.id(), lowRoutingNode.nodeId(), startedShard.currentNodeId(), @@ -245,7 +245,7 @@ public class ShardsRoutingStrategy extends AbstractComponent { if (lastNode == nodes.size()) lastNode = 0; - if (node.canAllocate(routingNodes.metaData(), routingNodes.routingTable()) && node.canAllocate(shard)) { + if (node.canAllocate(routingNodes) && node.canAllocate(shard)) { int numberOfShardsToAllocate = routingNodes.requiredAverageNumberOfShardsPerNode() - node.shards().size(); if (numberOfShardsToAllocate == 0) { continue; @@ -271,7 +271,7 @@ public class ShardsRoutingStrategy extends AbstractComponent { } // go over the nodes and try and allocate the remaining ones for (RoutingNode routingNode : routingNodes.nodesToShards().values()) { - if (routingNode.canAllocate(routingNodes.metaData(), routingNodes.routingTable()) && routingNode.canAllocate(shard)) { + if (routingNode.canAllocate(routingNodes) && routingNode.canAllocate(shard)) { changed = true; routingNode.add(shard); it.remove(); @@ -463,7 +463,7 @@ public class ShardsRoutingStrategy extends AbstractComponent { List sortedNodesLeastToHigh = routingNodes.sortedNodesLeastToHigh(); for (RoutingNode target : sortedNodesLeastToHigh) { if (target.canAllocate(failedShard) && - target.canAllocate(routingNodes.metaData(), routingNodes.routingTable()) && + target.canAllocate(routingNodes) && !target.nodeId().equals(failedShard.currentNodeId())) { target.add(new MutableShardRouting(failedShard.index(), failedShard.id(),