109
109
import org .apache .hadoop .hbase .client .TableState ;
110
110
import org .apache .hadoop .hbase .conf .ConfigurationManager ;
111
111
import org .apache .hadoop .hbase .coprocessor .CoprocessorHost ;
112
+ import org .apache .hadoop .hbase .exceptions .DeserializationException ;
112
113
import org .apache .hadoop .hbase .exceptions .MasterStoppedException ;
113
114
import org .apache .hadoop .hbase .executor .ExecutorType ;
114
115
import org .apache .hadoop .hbase .favored .FavoredNodesManager ;
129
130
import org .apache .hadoop .hbase .master .balancer .BaseLoadBalancer ;
130
131
import org .apache .hadoop .hbase .master .balancer .ClusterStatusChore ;
131
132
import org .apache .hadoop .hbase .master .balancer .LoadBalancerFactory ;
133
+ import org .apache .hadoop .hbase .master .balancer .LoadBalancerStateStore ;
132
134
import org .apache .hadoop .hbase .master .balancer .MaintenanceLoadBalancer ;
133
135
import org .apache .hadoop .hbase .master .cleaner .DirScanPool ;
134
136
import org .apache .hadoop .hbase .master .cleaner .HFileCleaner ;
145
147
import org .apache .hadoop .hbase .master .migrate .RollingUpgradeChore ;
146
148
import org .apache .hadoop .hbase .master .normalizer .RegionNormalizerFactory ;
147
149
import org .apache .hadoop .hbase .master .normalizer .RegionNormalizerManager ;
150
+ import org .apache .hadoop .hbase .master .normalizer .RegionNormalizerStateStore ;
148
151
import org .apache .hadoop .hbase .master .procedure .CreateTableProcedure ;
149
152
import org .apache .hadoop .hbase .master .procedure .DeleteNamespaceProcedure ;
150
153
import org .apache .hadoop .hbase .master .procedure .DeleteTableProcedure ;
174
177
import org .apache .hadoop .hbase .master .replication .TransitPeerSyncReplicationStateProcedure ;
175
178
import org .apache .hadoop .hbase .master .replication .UpdatePeerConfigProcedure ;
176
179
import org .apache .hadoop .hbase .master .slowlog .SlowLogMasterService ;
180
+ import org .apache .hadoop .hbase .master .snapshot .SnapshotCleanupStateStore ;
177
181
import org .apache .hadoop .hbase .master .snapshot .SnapshotManager ;
178
182
import org .apache .hadoop .hbase .master .waleventtracker .WALEventTrackerTableCreator ;
179
183
import org .apache .hadoop .hbase .master .zksyncer .MasterAddressSyncer ;
246
250
import org .apache .hadoop .hbase .util .TableDescriptorChecker ;
247
251
import org .apache .hadoop .hbase .util .Threads ;
248
252
import org .apache .hadoop .hbase .util .VersionInfo ;
249
- import org .apache .hadoop .hbase .zookeeper .LoadBalancerTracker ;
250
253
import org .apache .hadoop .hbase .zookeeper .MasterAddressTracker ;
251
254
import org .apache .hadoop .hbase .zookeeper .MetaTableLocator ;
252
- import org .apache .hadoop .hbase .zookeeper .RegionNormalizerTracker ;
253
- import org .apache .hadoop .hbase .zookeeper .SnapshotCleanupTracker ;
254
255
import org .apache .hadoop .hbase .zookeeper .ZKClusterId ;
255
256
import org .apache .hadoop .hbase .zookeeper .ZKUtil ;
256
257
import org .apache .hadoop .hbase .zookeeper .ZKWatcher ;
@@ -306,17 +307,17 @@ public class HMaster extends HBaseServerBase<MasterRpcServices> implements Maste
306
307
// Draining region server tracker
307
308
private DrainingServerTracker drainingServerTracker ;
308
309
// Tracker for load balancer state
309
- LoadBalancerTracker loadBalancerTracker ;
310
+ LoadBalancerStateStore loadBalancerStateStore ;
310
311
// Tracker for meta location, if any client ZK quorum specified
311
312
private MetaLocationSyncer metaLocationSyncer ;
312
313
// Tracker for active master location, if any client ZK quorum specified
313
314
@ InterfaceAudience .Private
314
315
MasterAddressSyncer masterAddressSyncer ;
315
316
// Tracker for auto snapshot cleanup state
316
- SnapshotCleanupTracker snapshotCleanupTracker ;
317
+ SnapshotCleanupStateStore snapshotCleanupStateStore ;
317
318
318
319
// Tracker for split and merge state
319
- private SplitOrMergeTracker splitOrMergeTracker ;
320
+ private SplitOrMergeStateStore splitOrMergeStateStore ;
320
321
321
322
private ClusterSchemaService clusterSchemaService ;
322
323
@@ -750,24 +751,22 @@ public MetricsMaster getMasterMetrics() {
750
751
* should have already been initialized along with {@link ServerManager}.
751
752
*/
752
753
private void initializeZKBasedSystemTrackers ()
753
- throws IOException , KeeperException , ReplicationException {
754
+ throws IOException , KeeperException , ReplicationException , DeserializationException {
754
755
if (maintenanceMode ) {
755
756
// in maintenance mode, always use MaintenanceLoadBalancer.
756
757
conf .unset (LoadBalancer .HBASE_RSGROUP_LOADBALANCER_CLASS );
757
758
conf .setClass (HConstants .HBASE_MASTER_LOADBALANCER_CLASS , MaintenanceLoadBalancer .class ,
758
759
LoadBalancer .class );
759
760
}
760
761
this .balancer = new RSGroupBasedLoadBalancer ();
761
- this .loadBalancerTracker = new LoadBalancerTracker (zooKeeper , this );
762
- this .loadBalancerTracker .start ();
762
+ this .loadBalancerStateStore = new LoadBalancerStateStore (masterRegion , zooKeeper );
763
763
764
764
this .regionNormalizerManager =
765
- RegionNormalizerFactory .createNormalizerManager (conf , zooKeeper , this );
765
+ RegionNormalizerFactory .createNormalizerManager (conf , masterRegion , zooKeeper , this );
766
766
this .configurationManager .registerObserver (regionNormalizerManager );
767
767
this .regionNormalizerManager .start ();
768
768
769
- this .splitOrMergeTracker = new SplitOrMergeTracker (zooKeeper , conf , this );
770
- this .splitOrMergeTracker .start ();
769
+ this .splitOrMergeStateStore = new SplitOrMergeStateStore (masterRegion , zooKeeper , conf );
771
770
772
771
// This is for backwards compatible. We do not need the CP for rs group now but if user want to
773
772
// load it, we need to enable rs group.
@@ -787,8 +786,7 @@ private void initializeZKBasedSystemTrackers()
787
786
this .drainingServerTracker = new DrainingServerTracker (zooKeeper , this , this .serverManager );
788
787
this .drainingServerTracker .start ();
789
788
790
- this .snapshotCleanupTracker = new SnapshotCleanupTracker (zooKeeper , this );
791
- this .snapshotCleanupTracker .start ();
789
+ this .snapshotCleanupStateStore = new SnapshotCleanupStateStore (masterRegion , zooKeeper );
792
790
793
791
String clientQuorumServers = conf .get (HConstants .CLIENT_ZOOKEEPER_QUORUM );
794
792
boolean clientZkObserverMode = conf .getBoolean (HConstants .CLIENT_ZOOKEEPER_OBSERVER_MODE ,
@@ -910,8 +908,8 @@ private void tryMigrateMetaLocationsFromZooKeeper() throws IOException, KeeperEx
910
908
* Notice that now we will not schedule a special procedure to make meta online(unless the first
911
909
* time where meta has not been created yet), we will rely on SCP to bring meta online.
912
910
*/
913
- private void finishActiveMasterInitialization (MonitoredTask status )
914
- throws IOException , InterruptedException , KeeperException , ReplicationException {
911
+ private void finishActiveMasterInitialization (MonitoredTask status ) throws IOException ,
912
+ InterruptedException , KeeperException , ReplicationException , DeserializationException {
915
913
/*
916
914
* We are active master now... go initialize components we need to run.
917
915
*/
@@ -1640,7 +1638,7 @@ conf, getMasterFileSystem().getFileSystem(), new Path(archiveDir, path),
1640
1638
new ReplicationBarrierCleaner (conf , this , getConnection (), replicationPeerManager );
1641
1639
getChoreService ().scheduleChore (replicationBarrierCleaner );
1642
1640
1643
- final boolean isSnapshotChoreEnabled = this .snapshotCleanupTracker . isSnapshotCleanupEnabled ();
1641
+ final boolean isSnapshotChoreEnabled = this .snapshotCleanupStateStore . get ();
1644
1642
this .snapshotCleanerChore = new SnapshotCleanerChore (this , conf , getSnapshotManager ());
1645
1643
if (isSnapshotChoreEnabled ) {
1646
1644
getChoreService ().scheduleChore (this .snapshotCleanerChore );
@@ -1762,7 +1760,7 @@ protected void startProcedureExecutor() throws IOException {
1762
1760
* Turn on/off Snapshot Cleanup Chore
1763
1761
* @param on indicates whether Snapshot Cleanup Chore is to be run
1764
1762
*/
1765
- void switchSnapshotCleanup (final boolean on , final boolean synchronous ) {
1763
+ void switchSnapshotCleanup (final boolean on , final boolean synchronous ) throws IOException {
1766
1764
if (synchronous ) {
1767
1765
synchronized (this .snapshotCleanerChore ) {
1768
1766
switchSnapshotCleanup (on );
@@ -1772,16 +1770,12 @@ void switchSnapshotCleanup(final boolean on, final boolean synchronous) {
1772
1770
}
1773
1771
}
1774
1772
1775
- private void switchSnapshotCleanup (final boolean on ) {
1776
- try {
1777
- snapshotCleanupTracker .setSnapshotCleanupEnabled (on );
1778
- if (on ) {
1779
- getChoreService ().scheduleChore (this .snapshotCleanerChore );
1780
- } else {
1781
- this .snapshotCleanerChore .cancel ();
1782
- }
1783
- } catch (KeeperException e ) {
1784
- LOG .error ("Error updating snapshot cleanup mode to {}" , on , e );
1773
+ private void switchSnapshotCleanup (final boolean on ) throws IOException {
1774
+ snapshotCleanupStateStore .set (on );
1775
+ if (on ) {
1776
+ getChoreService ().scheduleChore (this .snapshotCleanerChore );
1777
+ } else {
1778
+ this .snapshotCleanerChore .cancel ();
1785
1779
}
1786
1780
}
1787
1781
@@ -1955,9 +1949,7 @@ public BalanceResponse balance(BalanceRequest request) throws IOException {
1955
1949
1956
1950
BalanceResponse .Builder responseBuilder = BalanceResponse .newBuilder ();
1957
1951
1958
- if (
1959
- loadBalancerTracker == null || !(loadBalancerTracker .isBalancerOn () || request .isDryRun ())
1960
- ) {
1952
+ if (loadBalancerStateStore == null || !(loadBalancerStateStore .get () || request .isDryRun ())) {
1961
1953
return responseBuilder .build ();
1962
1954
}
1963
1955
@@ -2889,8 +2881,8 @@ public ClusterMetrics getClusterMetricsWithoutCoprocessor(EnumSet<Option> option
2889
2881
break ;
2890
2882
}
2891
2883
case BALANCER_ON : {
2892
- if (loadBalancerTracker != null ) {
2893
- builder .setBalancerOn (loadBalancerTracker . isBalancerOn ());
2884
+ if (loadBalancerStateStore != null ) {
2885
+ builder .setBalancerOn (loadBalancerStateStore . get ());
2894
2886
}
2895
2887
break ;
2896
2888
}
@@ -3727,33 +3719,32 @@ public void reportMobCompactionEnd(TableName tableName) throws IOException {
3727
3719
}
3728
3720
3729
3721
/**
3730
- * Queries the state of the {@link LoadBalancerTracker }. If the balancer is not initialized, false
3731
- * is returned.
3722
+ * Queries the state of the {@link LoadBalancerStateStore }. If the balancer is not initialized,
3723
+ * false is returned.
3732
3724
* @return The state of the load balancer, or false if the load balancer isn't defined.
3733
3725
*/
3734
3726
public boolean isBalancerOn () {
3735
- return !isInMaintenanceMode () && loadBalancerTracker != null
3736
- && loadBalancerTracker .isBalancerOn ();
3727
+ return !isInMaintenanceMode () && loadBalancerStateStore != null && loadBalancerStateStore .get ();
3737
3728
}
3738
3729
3739
3730
/**
3740
- * Queries the state of the {@link RegionNormalizerTracker }. If it's not initialized, false is
3731
+ * Queries the state of the {@link RegionNormalizerStateStore }. If it's not initialized, false is
3741
3732
* returned.
3742
3733
*/
3743
3734
public boolean isNormalizerOn () {
3744
3735
return !isInMaintenanceMode () && getRegionNormalizerManager ().isNormalizerOn ();
3745
3736
}
3746
3737
3747
3738
/**
3748
- * Queries the state of the {@link SplitOrMergeTracker }. If it is not initialized, false is
3739
+ * Queries the state of the {@link SplitOrMergeStateStore }. If it is not initialized, false is
3749
3740
* returned. If switchType is illegal, false will return.
3750
3741
* @param switchType see {@link org.apache.hadoop.hbase.client.MasterSwitchType}
3751
3742
* @return The state of the switch
3752
3743
*/
3753
3744
@ Override
3754
3745
public boolean isSplitOrMergeEnabled (MasterSwitchType switchType ) {
3755
- return !isInMaintenanceMode () && splitOrMergeTracker != null
3756
- && splitOrMergeTracker .isSplitOrMergeEnabled (switchType );
3746
+ return !isInMaintenanceMode () && splitOrMergeStateStore != null
3747
+ && splitOrMergeStateStore .isSplitOrMergeEnabled (switchType );
3757
3748
}
3758
3749
3759
3750
/**
@@ -3768,8 +3759,8 @@ public String getLoadBalancerClassName() {
3768
3759
LoadBalancerFactory .getDefaultLoadBalancerClass ().getName ());
3769
3760
}
3770
3761
3771
- public SplitOrMergeTracker getSplitOrMergeTracker () {
3772
- return splitOrMergeTracker ;
3762
+ public SplitOrMergeStateStore getSplitOrMergeStateStore () {
3763
+ return splitOrMergeStateStore ;
3773
3764
}
3774
3765
3775
3766
@ Override
0 commit comments