Skip to content

Commit 16b821b

Browse files
committed
HBASE-22971 Deprecated RSGroupAdminEndpoint and make RSGroup feature always enabled
1 parent 9300631 commit 16b821b

28 files changed

+235
-401
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;
@@ -383,7 +382,7 @@ public void run() {
383382

384383
private final LockManager lockManager = new LockManager(this);
385384

386-
private LoadBalancer balancer;
385+
private RSGroupBasedLoadBalancer balancer;
387386
private RegionNormalizer normalizer;
388387
private BalancerChore balancerChore;
389388
private RegionNormalizerChore normalizerChore;
@@ -438,9 +437,6 @@ public void run() {
438437
private long splitPlanCount;
439438
private long mergePlanCount;
440439

441-
/* Handle favored nodes information */
442-
private FavoredNodesManager favoredNodesManager;
443-
444440
/** jetty server for master to redirect requests to regionserver infoServer */
445441
private Server masterJettyServer;
446442

@@ -765,7 +761,8 @@ public MetricsMaster getMasterMetrics() {
765761
@VisibleForTesting
766762
protected void initializeZKBasedSystemTrackers()
767763
throws IOException, InterruptedException, KeeperException, ReplicationException {
768-
this.balancer = LoadBalancerFactory.getLoadBalancer(conf);
764+
this.balancer = new RSGroupBasedLoadBalancer();
765+
this.balancer.setConf(conf);
769766
this.normalizer = RegionNormalizerFactory.getRegionNormalizer(conf);
770767
this.normalizer.setMasterServices(this);
771768
this.normalizer.setMasterRpcServices((MasterRpcServices)rpcServices);
@@ -1049,9 +1046,6 @@ private void finishActiveMasterInitialization(MonitoredTask status) throws IOExc
10491046
return temp;
10501047
});
10511048
}
1052-
if (this.balancer instanceof FavoredNodesPromoter) {
1053-
favoredNodesManager = new FavoredNodesManager(this);
1054-
}
10551049

10561050
// initialize load balancer
10571051
this.balancer.setMasterServices(this);
@@ -1101,11 +1095,11 @@ private void finishActiveMasterInitialization(MonitoredTask status) throws IOExc
11011095
// table states messing up master launch (namespace table, etc., are not assigned).
11021096
this.assignmentManager.processOfflineRegions();
11031097
// Initialize after meta is up as below scans meta
1104-
if (favoredNodesManager != null && !maintenanceMode) {
1098+
if (getFavoredNodesManager() != null && !maintenanceMode) {
11051099
SnapshotOfRegionAssignmentFromMeta snapshotOfRegionAssignment =
11061100
new SnapshotOfRegionAssignmentFromMeta(getConnection());
11071101
snapshotOfRegionAssignment.initialize();
1108-
favoredNodesManager.initialize(snapshotOfRegionAssignment);
1102+
getFavoredNodesManager().initialize(snapshotOfRegionAssignment);
11091103
}
11101104

11111105
// set cluster status again after user regions are assigned
@@ -2042,14 +2036,13 @@ public void move(final byte[] encodedRegionName, byte[] destServerName) throws I
20422036
LOG.debug("Unable to determine a plan to assign " + hri);
20432037
return;
20442038
}
2045-
// TODO: What is this? I don't get it.
2046-
if (dest.equals(serverName) && balancer instanceof BaseLoadBalancer
2047-
&& !((BaseLoadBalancer)balancer).shouldBeOnMaster(hri)) {
2039+
// TODO: deal with table on master for rs group.
2040+
if (dest.equals(serverName)) {
20482041
// To avoid unnecessary region moving later by balancer. Don't put user
20492042
// regions on master.
2050-
LOG.debug("Skipping move of region " + hri.getRegionNameAsString()
2051-
+ " to avoid unnecessary region moving later by load balancer,"
2052-
+ " because it should not be on master");
2043+
LOG.debug("Skipping move of region " + hri.getRegionNameAsString() +
2044+
" to avoid unnecessary region moving later by load balancer," +
2045+
" because it should not be on master");
20532046
return;
20542047
}
20552048
}
@@ -3483,12 +3476,14 @@ public boolean isSplitOrMergeEnabled(MasterSwitchType switchType) {
34833476

34843477
/**
34853478
* Fetch the configured {@link LoadBalancer} class name. If none is set, a default is returned.
3486-
*
3479+
* <p/>
3480+
* Notice that, the base load balancer will always be {@link RSGroupBasedLoadBalancer} now, so
3481+
* this method will return the balancer used inside each rs group.
34873482
* @return The name of the {@link LoadBalancer} in use.
34883483
*/
34893484
public String getLoadBalancerClassName() {
3490-
return conf.get(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, LoadBalancerFactory
3491-
.getDefaultLoadBalancerClass().getName());
3485+
return conf.get(HConstants.HBASE_MASTER_LOADBALANCER_CLASS,
3486+
LoadBalancerFactory.getDefaultLoadBalancerClass().getName());
34923487
}
34933488

34943489
/**
@@ -3503,13 +3498,13 @@ public SplitOrMergeTracker getSplitOrMergeTracker() {
35033498
}
35043499

35053500
@Override
3506-
public LoadBalancer getLoadBalancer() {
3501+
public RSGroupBasedLoadBalancer getLoadBalancer() {
35073502
return balancer;
35083503
}
35093504

35103505
@Override
35113506
public FavoredNodesManager getFavoredNodesManager() {
3512-
return favoredNodesManager;
3507+
return balancer.getFavoredNodesManager();
35133508
}
35143509

35153510
private long executePeerProcedure(AbstractPeerProcedure<?> procedure) throws IOException {
@@ -3795,7 +3790,7 @@ public HbckChore getHbckChore() {
37953790
}
37963791

37973792
@Override
3798-
public RSGroupInfoManager getRSRSGroupInfoManager() {
3793+
public RSGroupInfoManager getRSGroupInfoManager() {
37993794
return rsGroupInfoManager;
38003795
}
38013796
}

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
*/

0 commit comments

Comments
 (0)