Permalink
Browse files

[#eng-3619] don't rebalance shards when there's only a single node in…

… the cluster
  • Loading branch information...
1 parent 29d2291 commit 87060a5f7015388a001e5a8a6252cdde7d3c3da5 @dakrone dakrone committed Feb 28, 2013
Showing with 8 additions and 3 deletions.
  1. +2 −3 pom.xml
  2. +6 −0 src/main/java/com/sonian/elasticsearch/equilibrium/DiskShardsAllocator.java
View
@@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.sonian</groupId>
<artifactId>elasticsearch-equilibrium</artifactId>
- <version>0.20.1</version>
+ <version>0.20.2-SNAPSHOT</version>
<packaging>jar</packaging>
<description>Shard allocation plugin for ElasticSearch</description>
<inceptionYear>2011</inceptionYear>
@@ -46,8 +46,7 @@
</parent>
<properties>
- <elasticsearch.version>0.20.2</elasticsearch.version>
- <allocation.version>3.3.3</allocation.version>
+ <elasticsearch.version>0.20.5</elasticsearch.version>
</properties>
<repositories>
@@ -188,6 +188,12 @@ public boolean rebalance(RoutingAllocation allocation) {
RoutingNode[] sortedNodesLeastToHigh = sortedNodesByShardCountLeastToHigh(allocation);
int lowIndex = 0;
int highIndex = sortedNodesLeastToHigh.length - 1;
+
+ // If only a single node is present, don't bother trying to rebalance.
+ if (sortedNodesLeastToHigh.length <= 1) {
+ return false;
+ }
+
boolean relocationPerformed;
do {
relocationPerformed = false;

0 comments on commit 87060a5

Please sign in to comment.