From 161832243a5ed3517e646d7536df04afb936ff6c Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Tue, 17 Sep 2013 06:03:05 +0000 Subject: [PATCH] HBASE-9555 Reset loadbalancer back to StochasticLoadBalancer git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1523914 13f79535-47bb-0310-9956-ffa450edef68 --- hbase-common/src/main/resources/hbase-default.xml | 6 +++++- .../{DefaultLoadBalancer.java => SimpleLoadBalancer.java} | 4 ++-- .../test/java/org/apache/hadoop/hbase/TestZooKeeper.java | 4 ++-- .../apache/hadoop/hbase/master/TestAssignmentManager.java | 8 ++++---- .../hbase/master/balancer/TestDefaultLoadBalancer.java | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) rename hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/{DefaultLoadBalancer.java => SimpleLoadBalancer.java} (99%) diff --git a/hbase-common/src/main/resources/hbase-default.xml b/hbase-common/src/main/resources/hbase-default.xml index 26e70b7bed7..b3242ae7f37 100644 --- a/hbase-common/src/main/resources/hbase-default.xml +++ b/hbase-common/src/main/resources/hbase-default.xml @@ -1057,9 +1057,13 @@ possible configurations would overwhelm and obscure the important. hbase.master.loadbalancer.class - org.apache.hadoop.hbase.master.balancer.DefaultLoadBalancer + org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer Class used to execute the regions balancing when the period occurs. + See the class comment for more on how it works + http://hbase.apache.org/devapidocs/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.html + It replaces the DefaultLoadBalancer as the default (since renamed + as the SimpleLoadBalancer). diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/DefaultLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/SimpleLoadBalancer.java similarity index 99% rename from hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/DefaultLoadBalancer.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/SimpleLoadBalancer.java index 9b899278838..da6b44382e6 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/DefaultLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/SimpleLoadBalancer.java @@ -54,8 +54,8 @@ import com.google.common.collect.MinMaxPriorityQueue; *

This classes produces plans for the {@link AssignmentManager} to execute. */ @InterfaceAudience.Private -public class DefaultLoadBalancer extends BaseLoadBalancer { - private static final Log LOG = LogFactory.getLog(DefaultLoadBalancer.class); +public class SimpleLoadBalancer extends BaseLoadBalancer { + private static final Log LOG = LogFactory.getLog(SimpleLoadBalancer.class); private static final Random RANDOM = new Random(System.currentTimeMillis()); private RegionInfoComparator riComparator = new RegionInfoComparator(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java index 482a9b3003a..f2d0bc781a2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java @@ -45,7 +45,7 @@ import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.master.HMaster; import org.apache.hadoop.hbase.master.LoadBalancer; -import org.apache.hadoop.hbase.master.balancer.DefaultLoadBalancer; +import org.apache.hadoop.hbase.master.balancer.SimpleLoadBalancer; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Threads; import org.apache.hadoop.hbase.zookeeper.EmptyWatcher; @@ -556,7 +556,7 @@ public class TestZooKeeper { } } - static class MockLoadBalancer extends DefaultLoadBalancer { + static class MockLoadBalancer extends SimpleLoadBalancer { static boolean retainAssignCalled = false; @Override diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java index 98fd2f46c23..b681db65777 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java @@ -56,7 +56,7 @@ import org.apache.hadoop.hbase.executor.ExecutorType; import org.apache.hadoop.hbase.ipc.PayloadCarryingRpcController; import org.apache.hadoop.hbase.master.RegionState.State; import org.apache.hadoop.hbase.master.TableLockManager.NullTableLockManager; -import org.apache.hadoop.hbase.master.balancer.DefaultLoadBalancer; +import org.apache.hadoop.hbase.master.balancer.SimpleLoadBalancer; import org.apache.hadoop.hbase.master.balancer.LoadBalancerFactory; import org.apache.hadoop.hbase.master.handler.EnableTableHandler; import org.apache.hadoop.hbase.master.handler.ServerShutdownHandler; @@ -797,7 +797,7 @@ public class TestAssignmentManager { Mocking.waitForRegionPendingOpenInRIT(am, REGIONINFO.getEncodedName()); } finally { this.server.getConfiguration().setClass( - HConstants.HBASE_MASTER_LOADBALANCER_CLASS, DefaultLoadBalancer.class, + HConstants.HBASE_MASTER_LOADBALANCER_CLASS, SimpleLoadBalancer.class, LoadBalancer.class); am.getExecutorService().shutdown(); am.shutdown(); @@ -808,7 +808,7 @@ public class TestAssignmentManager { * Mocked load balancer class used in the testcase to make sure that the testcase waits until * random assignment is called and the gate variable is set to true. */ - public static class MockedLoadBalancer extends DefaultLoadBalancer { + public static class MockedLoadBalancer extends SimpleLoadBalancer { private AtomicBoolean gate; public void setGateVariable(AtomicBoolean gate) { @@ -899,7 +899,7 @@ public class TestAssignmentManager { am.getZKTable().isDisabledTable(REGIONINFO.getTable())); } finally { this.server.getConfiguration().setClass( - HConstants.HBASE_MASTER_LOADBALANCER_CLASS, DefaultLoadBalancer.class, + HConstants.HBASE_MASTER_LOADBALANCER_CLASS, SimpleLoadBalancer.class, LoadBalancer.class); am.getZKTable().setEnabledTable(REGIONINFO.getTable()); am.shutdown(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestDefaultLoadBalancer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestDefaultLoadBalancer.java index 8c00abd6ba3..e93507f1678 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestDefaultLoadBalancer.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestDefaultLoadBalancer.java @@ -46,7 +46,7 @@ public class TestDefaultLoadBalancer extends BalancerTestBase { public static void beforeAllTests() throws Exception { Configuration conf = HBaseConfiguration.create(); conf.set("hbase.regions.slop", "0"); - loadBalancer = new DefaultLoadBalancer(); + loadBalancer = new SimpleLoadBalancer(); loadBalancer.setConf(conf); }