9090import org .apache .hadoop .hbase .exceptions .DeserializationException ;
9191import org .apache .hadoop .hbase .executor .ExecutorType ;
9292import org .apache .hadoop .hbase .favored .FavoredNodesManager ;
93- import org .apache .hadoop .hbase .favored .FavoredNodesPromoter ;
9493import org .apache .hadoop .hbase .http .InfoServer ;
9594import org .apache .hadoop .hbase .ipc .CoprocessorRpcUtils ;
9695import org .apache .hadoop .hbase .ipc .RpcServer ;
106105import org .apache .hadoop .hbase .master .assignment .TransitRegionStateProcedure ;
107106import org .apache .hadoop .hbase .master .assignment .UnassignProcedure ;
108107import org .apache .hadoop .hbase .master .balancer .BalancerChore ;
109- import org .apache .hadoop .hbase .master .balancer .BaseLoadBalancer ;
110108import org .apache .hadoop .hbase .master .balancer .ClusterStatusChore ;
111109import org .apache .hadoop .hbase .master .balancer .LoadBalancerFactory ;
112110import org .apache .hadoop .hbase .master .cleaner .DirScanPool ;
186184import org .apache .hadoop .hbase .replication .master .ReplicationLogCleaner ;
187185import org .apache .hadoop .hbase .replication .master .ReplicationPeerConfigUpgrader ;
188186import org .apache .hadoop .hbase .replication .regionserver .ReplicationStatus ;
187+ import org .apache .hadoop .hbase .rsgroup .RSGroupBasedLoadBalancer ;
189188import org .apache .hadoop .hbase .rsgroup .RSGroupInfoManager ;
190189import org .apache .hadoop .hbase .security .AccessDeniedException ;
191190import 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}
0 commit comments