Skip to content

Commit

Permalink
HBASE-25883 The regionFinder and rackManager fields in BaseLoadBalanc…
Browse files Browse the repository at this point in the history
…er should be volatile (#3262)

Signed-off-by: meiyi <[email protected]>
  • Loading branch information
Apache9 authored May 15, 2021
1 parent 8ae4d65 commit 85d8ec7
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
protected static final int MIN_SERVER_BALANCE = 2;
private volatile boolean stopped = false;

protected RegionHDFSBlockLocationFinder regionFinder;
protected volatile RegionHDFSBlockLocationFinder regionFinder;
protected boolean useRegionFinder;
protected boolean isByTable = false;

// slop for regions
protected float slop;
protected RackManager rackManager;
protected volatile RackManager rackManager;
protected MetricsBalancer metricsBalancer = null;
protected ClusterMetrics clusterStatus = null;
protected ServerName masterServerName;
Expand Down Expand Up @@ -386,14 +386,21 @@ protected float getDefaultSlop() {
return 0.2f;
}

private RegionHDFSBlockLocationFinder createRegionLocationFinder(Configuration conf) {
RegionHDFSBlockLocationFinder finder = new RegionHDFSBlockLocationFinder();
finder.setConf(conf);
finder.setClusterInfoProvider(provider);
return finder;
}

protected void loadConf(Configuration conf) {
this.slop =normalizeSlop(conf.getFloat("hbase.regions.slop", getDefaultSlop()));
this.slop = normalizeSlop(conf.getFloat("hbase.regions.slop", getDefaultSlop()));
this.rackManager = new RackManager(conf);
useRegionFinder = conf.getBoolean("hbase.master.balancer.uselocality", true);
if (useRegionFinder) {
regionFinder = new RegionHDFSBlockLocationFinder();
regionFinder.setConf(conf);
regionFinder.setClusterInfoProvider(provider);
regionFinder = createRegionLocationFinder(conf);
} else {
regionFinder = null;
}
this.isByTable = conf.getBoolean(HConstants.HBASE_MASTER_LOADBALANCE_BYTABLE, isByTable);
// Print out base configs. Don't print overallSlop since it for simple balancer exclusively.
Expand Down

0 comments on commit 85d8ec7

Please sign in to comment.