ACCUMULO-4602 Fixed ChaoticLoadBalancer edge case
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/520d23d8 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/520d23d8 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/520d23d8 Branch: refs/heads/master Commit: 520d23d85dfce9297bab887726322861163a1fb2 Parents: f81a4b1 Author: Mike Miller <[email protected]> Authored: Thu Jul 13 18:29:57 2017 -0400 Committer: Mike Miller <[email protected]> Committed: Thu Jul 13 18:29:57 2017 -0400 ---------------------------------------------------------------------- .../master/balancer/ChaoticLoadBalancer.java | 2 +- .../test/functional/ChaoticBalancerIT.java | 22 +++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/520d23d8/server/base/src/main/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancer.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancer.java b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancer.java index 738e0aa..1f421bc 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancer.java +++ b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancer.java @@ -73,7 +73,7 @@ public class ChaoticLoadBalancer extends TabletBalancer { for (TableInfo ti : e.getValue().getTableMap().values()) { numTablets += ti.tablets; } - if (numTablets < avg) { + if (numTablets <= avg) { tServerArray.add(e.getKey()); toAssign.put(e.getKey(), avg - numTablets); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/520d23d8/test/src/main/java/org/apache/accumulo/test/functional/ChaoticBalancerIT.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ChaoticBalancerIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ChaoticBalancerIT.java index 21d6351..e5222c5 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/ChaoticBalancerIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/ChaoticBalancerIT.java @@ -17,22 +17,23 @@ package org.apache.accumulo.test.functional; import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.accumulo.core.cli.BatchWriterOpts; import org.apache.accumulo.core.cli.ScannerOpts; import org.apache.accumulo.core.client.ClientConfiguration; import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty; import org.apache.accumulo.core.client.Connector; +import org.apache.accumulo.core.client.admin.NewTableConfiguration; import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.core.util.Pair; import org.apache.accumulo.harness.AccumuloClusterHarness; import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl; import org.apache.accumulo.server.master.balancer.ChaoticLoadBalancer; import org.apache.accumulo.test.TestIngest; import org.apache.accumulo.test.VerifyIngest; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.io.Text; import org.junit.Test; public class ChaoticBalancerIT extends AccumuloClusterHarness { @@ -55,15 +56,12 @@ public class ChaoticBalancerIT extends AccumuloClusterHarness { Connector c = getConnector(); String[] names = getUniqueNames(2); String tableName = names[0], unused = names[1]; - c.tableOperations().create(tableName); - c.tableOperations().setProperty(tableName, Property.TABLE_LOAD_BALANCER.getKey(), ChaoticLoadBalancer.class.getName()); - c.tableOperations().setProperty(tableName, Property.TABLE_SPLIT_THRESHOLD.getKey(), "10K"); - SortedSet<Text> splits = new TreeSet<>(); - for (int i = 0; i < 100; i++) { - splits.add(new Text(String.format("%03d", i))); - } - c.tableOperations().create(unused); - c.tableOperations().addSplits(unused, splits); + NewTableConfiguration ntc = new NewTableConfiguration(); + ntc.setProperties(Stream.of(new Pair<>(Property.TABLE_LOAD_BALANCER.getKey(), ChaoticLoadBalancer.class.getName()), + new Pair<>(Property.TABLE_SPLIT_THRESHOLD.getKey(), "10K"), new Pair<>(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE.getKey(), "1K")).collect( + Collectors.toMap(k -> k.getFirst(), v -> v.getSecond()))); + c.tableOperations().create(tableName, ntc); + TestIngest.Opts opts = new TestIngest.Opts(); VerifyIngest.Opts vopts = new VerifyIngest.Opts(); vopts.rows = opts.rows = 20000;
