From f6deb4597094ac46ad862f1c5817db66c40c6dea Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Mon, 30 Jan 2012 01:58:51 +0200 Subject: [PATCH] Cluster Allocation: cluster.routing.allocation.allow_rebalance does not allow for rebalancing on relocating shard, closes #1651. --- .../allocation/decider/ClusterRebalanceAllocationDecider.java | 4 ++-- .../routing/allocation/ConcurrentRebalanceRoutingTests.java | 3 +-- .../routing/allocation/ShardsLimitAllocationTests.java | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ClusterRebalanceAllocationDecider.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ClusterRebalanceAllocationDecider.java index c6ae0530911..98d4a3e39c3 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ClusterRebalanceAllocationDecider.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ClusterRebalanceAllocationDecider.java @@ -67,7 +67,7 @@ public class ClusterRebalanceAllocationDecider extends AllocationDecider { List shards = node.shards(); for (int i = 0; i < shards.size(); i++) { MutableShardRouting shard = shards.get(i); - if (shard.primary() && !shard.active()) { + if (shard.primary() && !shard.active() && shard.relocatingNodeId() == null) { return false; } } @@ -82,7 +82,7 @@ public class ClusterRebalanceAllocationDecider extends AllocationDecider { List shards = node.shards(); for (int i = 0; i < shards.size(); i++) { MutableShardRouting shard = shards.get(i); - if (!shard.active()) { + if (!shard.active() && shard.relocatingNodeId() == null) { return false; } } diff --git a/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java index 82a94298264..e0110e744a7 100644 --- a/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java @@ -35,8 +35,8 @@ import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; @@ -50,7 +50,6 @@ public class ConcurrentRebalanceRoutingTests { public void testClusterConcurrentRebalance() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) - .put("cluster.routing.allocation.allow_rebalance", "always") .put("cluster.routing.allocation.cluster_concurrent_rebalance", 3) .build()); diff --git a/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ShardsLimitAllocationTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ShardsLimitAllocationTests.java index 47e2a2f7200..aca39ea2ca3 100644 --- a/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ShardsLimitAllocationTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ShardsLimitAllocationTests.java @@ -100,7 +100,6 @@ public class ShardsLimitAllocationTests { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) - .put("cluster.routing.allocation.allow_rebalance", "always") .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .build());