From f36d89c55410fdd6e431c05e7dee007b25200bbb Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Sun, 25 Sep 2011 21:28:55 +0300 Subject: [PATCH] use index iteration over iterator --- .../allocation/decider/SameShardAllocationDecider.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java index b2b9d9381d3..b8c259c4a6d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java @@ -26,6 +26,8 @@ import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; +import java.util.List; + /** * An allocation strategy that does not allow for the same shard instance to be allocated on the same node. */ @@ -36,9 +38,10 @@ public class SameShardAllocationDecider extends AllocationDecider { } @Override public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { - for (MutableShardRouting current : node.shards()) { + List shards = node.shards(); + for (int i = 0; i < shards.size(); i++) { // we do not allow for two shards of the same shard id to exists on the same node - if (current.shardId().equals(shardRouting.shardId())) { + if (shards.get(i).shardId().equals(shardRouting.shardId())) { return Decision.NO; } }