Skip to content

Commit 4319c9a

Browse files
committed
HBASE-22971 Deprecated RSGroupAdminEndpoint and make RSGroup feature always enabled
1 parent ce72633 commit 4319c9a

19 files changed

+107
-115
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodeLoadBalancer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ private void addRegionToMap(Map<ServerName, List<RegionInfo>> assignmentMapForFa
321321
regionsOnServer.add(region);
322322
}
323323

324+
@Override
324325
public synchronized List<ServerName> getFavoredNodes(RegionInfo regionInfo) {
325326
return this.fnm.getFavoredNodes(regionInfo);
326327
}

hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodesPromoter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ void generateFavoredNodesForDaughter(List<ServerName> servers,
3535

3636
void generateFavoredNodesForMergedRegion(RegionInfo merged, RegionInfo [] mergeParents)
3737
throws IOException;
38+
39+
List<ServerName> getFavoredNodes(RegionInfo regionInfo);
3840
}

hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
import org.apache.hadoop.hbase.exceptions.DeserializationException;
9191
import org.apache.hadoop.hbase.executor.ExecutorType;
9292
import org.apache.hadoop.hbase.favored.FavoredNodesManager;
93-
import org.apache.hadoop.hbase.favored.FavoredNodesPromoter;
9493
import org.apache.hadoop.hbase.http.InfoServer;
9594
import org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils;
9695
import org.apache.hadoop.hbase.ipc.RpcServer;
@@ -106,7 +105,6 @@
106105
import org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure;
107106
import org.apache.hadoop.hbase.master.assignment.UnassignProcedure;
108107
import org.apache.hadoop.hbase.master.balancer.BalancerChore;
109-
import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer;
110108
import org.apache.hadoop.hbase.master.balancer.ClusterStatusChore;
111109
import org.apache.hadoop.hbase.master.balancer.LoadBalancerFactory;
112110
import org.apache.hadoop.hbase.master.cleaner.DirScanPool;
@@ -186,6 +184,7 @@
186184
import org.apache.hadoop.hbase.replication.master.ReplicationLogCleaner;
187185
import org.apache.hadoop.hbase.replication.master.ReplicationPeerConfigUpgrader;
188186
import org.apache.hadoop.hbase.replication.regionserver.ReplicationStatus;
187+
import org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer;
189188
import org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager;
190189
import org.apache.hadoop.hbase.security.AccessDeniedException;
191190
import org.apache.hadoop.hbase.security.SecurityConstants;
@@ -380,7 +379,7 @@ public void run() {
380379

381380
private final LockManager lockManager = new LockManager(this);
382381

383-
private LoadBalancer balancer;
382+
private RSGroupBasedLoadBalancer balancer;
384383
private RegionNormalizer normalizer;
385384
private BalancerChore balancerChore;
386385
private RegionNormalizerChore normalizerChore;
@@ -435,9 +434,6 @@ public void run() {
435434
private long splitPlanCount;
436435
private long mergePlanCount;
437436

438-
/* Handle favored nodes information */
439-
private FavoredNodesManager favoredNodesManager;
440-
441437
/** jetty server for master to redirect requests to regionserver infoServer */
442438
private Server masterJettyServer;
443439

@@ -762,7 +758,8 @@ public MetricsMaster getMasterMetrics() {
762758
@VisibleForTesting
763759
protected void initializeZKBasedSystemTrackers()
764760
throws IOException, InterruptedException, KeeperException, ReplicationException {
765-
this.balancer = LoadBalancerFactory.getLoadBalancer(conf);
761+
this.balancer = new RSGroupBasedLoadBalancer();
762+
this.balancer.setConf(conf);
766763
this.normalizer = RegionNormalizerFactory.getRegionNormalizer(conf);
767764
this.normalizer.setMasterServices(this);
768765
this.normalizer.setMasterRpcServices((MasterRpcServices)rpcServices);
@@ -1043,9 +1040,6 @@ private void finishActiveMasterInitialization(MonitoredTask status) throws IOExc
10431040
return temp;
10441041
});
10451042
}
1046-
if (this.balancer instanceof FavoredNodesPromoter) {
1047-
favoredNodesManager = new FavoredNodesManager(this);
1048-
}
10491043

10501044
// initialize load balancer
10511045
this.balancer.setMasterServices(this);
@@ -1095,11 +1089,11 @@ private void finishActiveMasterInitialization(MonitoredTask status) throws IOExc
10951089
// table states messing up master launch (namespace table, etc., are not assigned).
10961090
this.assignmentManager.processOfflineRegions();
10971091
// Initialize after meta is up as below scans meta
1098-
if (favoredNodesManager != null && !maintenanceMode) {
1092+
if (getFavoredNodesManager() != null && !maintenanceMode) {
10991093
SnapshotOfRegionAssignmentFromMeta snapshotOfRegionAssignment =
11001094
new SnapshotOfRegionAssignmentFromMeta(getConnection());
11011095
snapshotOfRegionAssignment.initialize();
1102-
favoredNodesManager.initialize(snapshotOfRegionAssignment);
1096+
getFavoredNodesManager().initialize(snapshotOfRegionAssignment);
11031097
}
11041098

11051099
// set cluster status again after user regions are assigned
@@ -2005,14 +1999,13 @@ public void move(final byte[] encodedRegionName, byte[] destServerName) throws I
20051999
LOG.debug("Unable to determine a plan to assign " + hri);
20062000
return;
20072001
}
2008-
// TODO: What is this? I don't get it.
2009-
if (dest.equals(serverName) && balancer instanceof BaseLoadBalancer
2010-
&& !((BaseLoadBalancer)balancer).shouldBeOnMaster(hri)) {
2002+
// TODO: deal with table on master for rs group.
2003+
if (dest.equals(serverName)) {
20112004
// To avoid unnecessary region moving later by balancer. Don't put user
20122005
// regions on master.
2013-
LOG.debug("Skipping move of region " + hri.getRegionNameAsString()
2014-
+ " to avoid unnecessary region moving later by load balancer,"
2015-
+ " because it should not be on master");
2006+
LOG.debug("Skipping move of region " + hri.getRegionNameAsString() +
2007+
" to avoid unnecessary region moving later by load balancer," +
2008+
" because it should not be on master");
20162009
return;
20172010
}
20182011
}
@@ -3446,12 +3439,14 @@ public boolean isSplitOrMergeEnabled(MasterSwitchType switchType) {
34463439

34473440
/**
34483441
* Fetch the configured {@link LoadBalancer} class name. If none is set, a default is returned.
3449-
*
3442+
* <p/>
3443+
* Notice that, the base load balancer will always be {@link RSGroupBasedLoadBalancer} now, so
3444+
* this method will return the balancer used inside each rs group.
34503445
* @return The name of the {@link LoadBalancer} in use.
34513446
*/
34523447
public String getLoadBalancerClassName() {
3453-
return conf.get(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, LoadBalancerFactory
3454-
.getDefaultLoadBalancerClass().getName());
3448+
return conf.get(HConstants.HBASE_MASTER_LOADBALANCER_CLASS,
3449+
LoadBalancerFactory.getDefaultLoadBalancerClass().getName());
34553450
}
34563451

34573452
/**
@@ -3466,13 +3461,13 @@ public SplitOrMergeTracker getSplitOrMergeTracker() {
34663461
}
34673462

34683463
@Override
3469-
public LoadBalancer getLoadBalancer() {
3464+
public RSGroupBasedLoadBalancer getLoadBalancer() {
34703465
return balancer;
34713466
}
34723467

34733468
@Override
34743469
public FavoredNodesManager getFavoredNodesManager() {
3475-
return favoredNodesManager;
3470+
return balancer.getFavoredNodesManager();
34763471
}
34773472

34783473
private long executePeerProcedure(AbstractPeerProcedure<?> procedure) throws IOException {
@@ -3758,7 +3753,7 @@ public HbckChore getHbckChore() {
37583753
}
37593754

37603755
@Override
3761-
public RSGroupInfoManager getRSRSGroupInfoManager() {
3756+
public RSGroupInfoManager getRSGroupInfoManager() {
37623757
return rsGroupInfoManager;
37633758
}
37643759
}

hbase-server/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ public interface LoadBalancer extends Configurable, Stoppable, ConfigurationObse
6464
// We deliberately use 'localhost' so the operation will fail fast
6565
ServerName BOGUS_SERVER_NAME = ServerName.valueOf("localhost,1,1");
6666

67+
/**
68+
* Config for pluggable load balancers.
69+
* @deprecated since 3.0.0, will be removed in 4.0.0. In the new implementation, as the base load
70+
* balancer will always be the rs group based one, you should just use
71+
* {@link org.apache.hadoop.hbase.HConstants#HBASE_MASTER_LOADBALANCER_CLASS} to
72+
* config the per group load balancer.
73+
*/
74+
@Deprecated
75+
String HBASE_RSGROUP_LOADBALANCER_CLASS = "hbase.rsgroup.grouploadbalancer.class";
6776
/**
6877
* Set the current cluster status. This allows a LoadBalancer to map host name to a server
6978
*/

hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,5 +539,5 @@ default SplitWALManager getSplitWALManager(){
539539
/**
540540
* @return the {@link RSGroupInfoManager}
541541
*/
542-
RSGroupInfoManager getRSRSGroupInfoManager();
542+
RSGroupInfoManager getRSGroupInfoManager();
543543
}

hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import org.apache.hadoop.hbase.procedure2.ProcedureInMemoryChore;
6868
import org.apache.hadoop.hbase.procedure2.util.StringUtils;
6969
import org.apache.hadoop.hbase.regionserver.SequenceId;
70+
import org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer;
7071
import org.apache.hadoop.hbase.util.Bytes;
7172
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
7273
import org.apache.hadoop.hbase.util.HasThread;
@@ -324,6 +325,11 @@ private LoadBalancer getBalancer() {
324325
return master.getLoadBalancer();
325326
}
326327

328+
private FavoredNodesPromoter getFavoredNodePromoter() {
329+
return (FavoredNodesPromoter) ((RSGroupBasedLoadBalancer) master.getLoadBalancer())
330+
.getInternalBalancer();
331+
}
332+
327333
private MasterProcedureEnv getProcedureEnvironment() {
328334
return master.getMasterProcedureExecutor().getEnvironment();
329335
}
@@ -367,7 +373,7 @@ public RegionStateStore getRegionStateStore() {
367373

368374
public List<ServerName> getFavoredNodes(final RegionInfo regionInfo) {
369375
return this.shouldAssignRegionsWithFavoredNodes
370-
? ((FavoredStochasticBalancer) getBalancer()).getFavoredNodes(regionInfo)
376+
? getFavoredNodePromoter().getFavoredNodes(regionInfo)
371377
: ServerName.EMPTY_SERVER_LIST;
372378
}
373379

@@ -1773,8 +1779,8 @@ public void markRegionAsSplit(final RegionInfo parent, final ServerName serverNa
17731779
regionStateStore.splitRegion(parent, daughterA, daughterB, serverName);
17741780
if (shouldAssignFavoredNodes(parent)) {
17751781
List<ServerName> onlineServers = this.master.getServerManager().getOnlineServersList();
1776-
((FavoredNodesPromoter)getBalancer()).
1777-
generateFavoredNodesForDaughter(onlineServers, parent, daughterA, daughterB);
1782+
getFavoredNodePromoter().generateFavoredNodesForDaughter(onlineServers, parent, daughterA,
1783+
daughterB);
17781784
}
17791785
}
17801786

@@ -1799,8 +1805,7 @@ public void markRegionAsMerged(final RegionInfo child, final ServerName serverNa
17991805
}
18001806
regionStateStore.mergeRegions(child, mergeParents, serverName);
18011807
if (shouldAssignFavoredNodes(child)) {
1802-
((FavoredNodesPromoter)getBalancer()).
1803-
generateFavoredNodesForMergedRegion(child, mergeParents);
1808+
getFavoredNodePromoter().generateFavoredNodesForMergedRegion(child, mergeParents);
18041809
}
18051810
}
18061811

hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredStochasticBalancer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ private List<ServerName> getOnlineFavoredNodes(List<ServerName> onlineServers,
473473
}
474474
}
475475

476+
@Override
476477
public synchronized List<ServerName> getFavoredNodes(RegionInfo regionInfo) {
477478
return this.fnm.getFavoredNodes(regionInfo);
478479
}

hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/LoadBalancerFactory.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
*/
1818
package org.apache.hadoop.hbase.master.balancer;
1919

20-
import org.apache.yetus.audience.InterfaceAudience;
2120
import org.apache.hadoop.conf.Configuration;
2221
import org.apache.hadoop.hbase.HConstants;
2322
import org.apache.hadoop.hbase.master.LoadBalancer;
24-
import org.apache.hadoop.util.ReflectionUtils;
23+
import org.apache.hadoop.hbase.util.ReflectionUtils;
24+
import org.apache.yetus.audience.InterfaceAudience;
2525

2626
/**
2727
* The class that creates a load balancer from a conf.
@@ -30,8 +30,7 @@
3030
public class LoadBalancerFactory {
3131

3232
/**
33-
* The default {@link LoadBalancer} class.
34-
*
33+
* The default {@link LoadBalancer} class.
3534
* @return The Class for the default {@link LoadBalancer}.
3635
*/
3736
public static Class<? extends LoadBalancer> getDefaultLoadBalancerClass() {
@@ -40,16 +39,15 @@ public static Class<? extends LoadBalancer> getDefaultLoadBalancerClass() {
4039

4140
/**
4241
* Create a loadbalancer from the given conf.
43-
* @param conf
4442
* @return A {@link LoadBalancer}
4543
*/
4644
public static LoadBalancer getLoadBalancer(Configuration conf) {
47-
4845
// Create the balancer
4946
Class<? extends LoadBalancer> balancerKlass =
50-
conf.getClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, getDefaultLoadBalancerClass(),
51-
LoadBalancer.class);
52-
return ReflectionUtils.newInstance(balancerKlass, conf);
53-
47+
conf.getClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, getDefaultLoadBalancerClass(),
48+
LoadBalancer.class);
49+
LoadBalancer balancer = ReflectionUtils.newInstance(balancerKlass);
50+
balancer.setConf(conf);
51+
return balancer;
5452
}
5553
}

hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.function.Supplier;
2828
import java.util.stream.Collectors;
2929
import org.apache.hadoop.hbase.CoprocessorEnvironment;
30-
import org.apache.hadoop.hbase.HConstants;
3130
import org.apache.hadoop.hbase.NamespaceDescriptor;
3231
import org.apache.hadoop.hbase.ServerName;
3332
import org.apache.hadoop.hbase.TableName;
@@ -66,13 +65,8 @@ public void start(CoprocessorEnvironment env) throws IOException {
6665
}
6766

6867
master = ((HasMasterServices) env).getMasterServices();
69-
groupInfoManager = master.getRSRSGroupInfoManager();
68+
groupInfoManager = master.getRSGroupInfoManager();
7069
groupAdminServer = new RSGroupAdminServer(master, groupInfoManager);
71-
Class<?> clazz =
72-
master.getConfiguration().getClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, null);
73-
if (!RSGroupableBalancer.class.isAssignableFrom(clazz)) {
74-
throw new IOException("Configured balancer does not support RegionServer groups.");
75-
}
7670
AccessChecker accessChecker = ((HasMasterServices) env).getMasterServices().getAccessChecker();
7771

7872
// set the user-provider.

0 commit comments

Comments
 (0)