From e2236396713cfc1cef61150a569e972c2faaca04 Mon Sep 17 00:00:00 2001 From: tedyu Date: Fri, 21 Oct 2016 10:25:42 -0700 Subject: [PATCH] HBASE-16910 Avoid NPE when starting StochasticLoadBalancer (Guanghao Zhang) --- .../apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java | 2 +- .../src/main/java/org/apache/hadoop/hbase/master/HMaster.java | 2 +- .../hadoop/hbase/master/balancer/StochasticLoadBalancer.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java index b5dd7438afb..c42c46d108e 100644 --- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java +++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java @@ -391,8 +391,8 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer, LoadBalanc HBASE_GROUP_LOADBALANCER_CLASS, StochasticLoadBalancer.class, LoadBalancer.class); internalBalancer = ReflectionUtils.newInstance(balancerKlass, config); - internalBalancer.setClusterStatus(clusterStatus); internalBalancer.setMasterServices(masterServices); + internalBalancer.setClusterStatus(clusterStatus); internalBalancer.setConf(config); internalBalancer.initialize(); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index a8329e3ca9e..eac2fa22f8d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -742,8 +742,8 @@ public class HMaster extends HRegionServer implements MasterServices { } //initialize load balancer - this.balancer.setClusterStatus(getClusterStatus()); this.balancer.setMasterServices(this); + this.balancer.setClusterStatus(getClusterStatus()); this.balancer.initialize(); // Check if master is shutting down because of some issue diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java index 345fbf350b1..b02aac1aadd 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java @@ -233,7 +233,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer { updateMetricsSize(tablesCount * (functionsCount + 1)); // +1 for overall } catch (Exception e) { - LOG.error("failed to get the size of all tables, exception = " + e.getMessage()); + LOG.error("failed to get the size of all tables", e); } }