hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [25/51] [partial] hbase-site git commit: Published site at 82d554e3783372cc6b05489452c815b57c06f6cd.
Date Tue, 18 Apr 2017 14:59:03 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/2fcc2ae0/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.InitializationMonitor.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.InitializationMonitor.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.InitializationMonitor.html
index a58f559..98b388b 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.InitializationMonitor.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.InitializationMonitor.html
@@ -756,2562 +756,2560 @@
 <span class="sourceLineNo">748</span><a name="line.748"></a>
 <span class="sourceLineNo">749</span>    this.masterActiveTime = System.currentTimeMillis();<a name="line.749"></a>
 <span class="sourceLineNo">750</span>    // TODO: Do this using Dependency Injection, using PicoContainer, Guice or Spring.<a name="line.750"></a>
-<span class="sourceLineNo">751</span>    // Initialize the chunkCreator<a name="line.751"></a>
-<span class="sourceLineNo">752</span>    initializeMemStoreChunkCreator();<a name="line.752"></a>
-<span class="sourceLineNo">753</span>    this.fileSystemManager = new MasterFileSystem(this);<a name="line.753"></a>
-<span class="sourceLineNo">754</span>    this.walManager = new MasterWalManager(this);<a name="line.754"></a>
-<span class="sourceLineNo">755</span><a name="line.755"></a>
-<span class="sourceLineNo">756</span>    // enable table descriptors cache<a name="line.756"></a>
-<span class="sourceLineNo">757</span>    this.tableDescriptors.setCacheOn();<a name="line.757"></a>
-<span class="sourceLineNo">758</span>    // set the META's descriptor to the correct replication<a name="line.758"></a>
-<span class="sourceLineNo">759</span>    this.tableDescriptors.get(TableName.META_TABLE_NAME).setRegionReplication(<a name="line.759"></a>
-<span class="sourceLineNo">760</span>        conf.getInt(HConstants.META_REPLICAS_NUM, HConstants.DEFAULT_META_REPLICA_NUM));<a name="line.760"></a>
-<span class="sourceLineNo">761</span>    // warm-up HTDs cache on master initialization<a name="line.761"></a>
-<span class="sourceLineNo">762</span>    if (preLoadTableDescriptors) {<a name="line.762"></a>
-<span class="sourceLineNo">763</span>      status.setStatus("Pre-loading table descriptors");<a name="line.763"></a>
-<span class="sourceLineNo">764</span>      this.tableDescriptors.getAll();<a name="line.764"></a>
-<span class="sourceLineNo">765</span>    }<a name="line.765"></a>
-<span class="sourceLineNo">766</span><a name="line.766"></a>
-<span class="sourceLineNo">767</span>    // publish cluster ID<a name="line.767"></a>
-<span class="sourceLineNo">768</span>    status.setStatus("Publishing Cluster ID in ZooKeeper");<a name="line.768"></a>
-<span class="sourceLineNo">769</span>    ZKClusterId.setClusterId(this.zooKeeper, fileSystemManager.getClusterId());<a name="line.769"></a>
-<span class="sourceLineNo">770</span>    this.initLatch.countDown();<a name="line.770"></a>
+<span class="sourceLineNo">751</span>    this.fileSystemManager = new MasterFileSystem(this);<a name="line.751"></a>
+<span class="sourceLineNo">752</span>    this.walManager = new MasterWalManager(this);<a name="line.752"></a>
+<span class="sourceLineNo">753</span><a name="line.753"></a>
+<span class="sourceLineNo">754</span>    // enable table descriptors cache<a name="line.754"></a>
+<span class="sourceLineNo">755</span>    this.tableDescriptors.setCacheOn();<a name="line.755"></a>
+<span class="sourceLineNo">756</span>    // set the META's descriptor to the correct replication<a name="line.756"></a>
+<span class="sourceLineNo">757</span>    this.tableDescriptors.get(TableName.META_TABLE_NAME).setRegionReplication(<a name="line.757"></a>
+<span class="sourceLineNo">758</span>        conf.getInt(HConstants.META_REPLICAS_NUM, HConstants.DEFAULT_META_REPLICA_NUM));<a name="line.758"></a>
+<span class="sourceLineNo">759</span>    // warm-up HTDs cache on master initialization<a name="line.759"></a>
+<span class="sourceLineNo">760</span>    if (preLoadTableDescriptors) {<a name="line.760"></a>
+<span class="sourceLineNo">761</span>      status.setStatus("Pre-loading table descriptors");<a name="line.761"></a>
+<span class="sourceLineNo">762</span>      this.tableDescriptors.getAll();<a name="line.762"></a>
+<span class="sourceLineNo">763</span>    }<a name="line.763"></a>
+<span class="sourceLineNo">764</span><a name="line.764"></a>
+<span class="sourceLineNo">765</span>    // publish cluster ID<a name="line.765"></a>
+<span class="sourceLineNo">766</span>    status.setStatus("Publishing Cluster ID in ZooKeeper");<a name="line.766"></a>
+<span class="sourceLineNo">767</span>    ZKClusterId.setClusterId(this.zooKeeper, fileSystemManager.getClusterId());<a name="line.767"></a>
+<span class="sourceLineNo">768</span>    this.initLatch.countDown();<a name="line.768"></a>
+<span class="sourceLineNo">769</span><a name="line.769"></a>
+<span class="sourceLineNo">770</span>    this.serverManager = createServerManager(this);<a name="line.770"></a>
 <span class="sourceLineNo">771</span><a name="line.771"></a>
-<span class="sourceLineNo">772</span>    this.serverManager = createServerManager(this);<a name="line.772"></a>
+<span class="sourceLineNo">772</span>    this.tableStateManager = new TableStateManager(this);<a name="line.772"></a>
 <span class="sourceLineNo">773</span><a name="line.773"></a>
-<span class="sourceLineNo">774</span>    this.tableStateManager = new TableStateManager(this);<a name="line.774"></a>
-<span class="sourceLineNo">775</span><a name="line.775"></a>
-<span class="sourceLineNo">776</span>    status.setStatus("Initializing ZK system trackers");<a name="line.776"></a>
-<span class="sourceLineNo">777</span>    initializeZKBasedSystemTrackers();<a name="line.777"></a>
-<span class="sourceLineNo">778</span><a name="line.778"></a>
-<span class="sourceLineNo">779</span>    // This is for backwards compatibility<a name="line.779"></a>
-<span class="sourceLineNo">780</span>    // See HBASE-11393<a name="line.780"></a>
-<span class="sourceLineNo">781</span>    status.setStatus("Update TableCFs node in ZNode");<a name="line.781"></a>
-<span class="sourceLineNo">782</span>    TableCFsUpdater tableCFsUpdater = new TableCFsUpdater(zooKeeper,<a name="line.782"></a>
-<span class="sourceLineNo">783</span>            conf, this.clusterConnection);<a name="line.783"></a>
-<span class="sourceLineNo">784</span>    tableCFsUpdater.update();<a name="line.784"></a>
-<span class="sourceLineNo">785</span><a name="line.785"></a>
-<span class="sourceLineNo">786</span>    // initialize master side coprocessors before we start handling requests<a name="line.786"></a>
-<span class="sourceLineNo">787</span>    status.setStatus("Initializing master coprocessors");<a name="line.787"></a>
-<span class="sourceLineNo">788</span>    this.cpHost = new MasterCoprocessorHost(this, this.conf);<a name="line.788"></a>
-<span class="sourceLineNo">789</span><a name="line.789"></a>
-<span class="sourceLineNo">790</span>    // start up all service threads.<a name="line.790"></a>
-<span class="sourceLineNo">791</span>    status.setStatus("Initializing master service threads");<a name="line.791"></a>
-<span class="sourceLineNo">792</span>    startServiceThreads();<a name="line.792"></a>
-<span class="sourceLineNo">793</span><a name="line.793"></a>
-<span class="sourceLineNo">794</span>    // Wake up this server to check in<a name="line.794"></a>
-<span class="sourceLineNo">795</span>    sleeper.skipSleepCycle();<a name="line.795"></a>
-<span class="sourceLineNo">796</span><a name="line.796"></a>
-<span class="sourceLineNo">797</span>    // Wait for region servers to report in<a name="line.797"></a>
-<span class="sourceLineNo">798</span>    status.setStatus("Wait for region servers to report in");<a name="line.798"></a>
-<span class="sourceLineNo">799</span>    waitForRegionServers(status);<a name="line.799"></a>
-<span class="sourceLineNo">800</span><a name="line.800"></a>
-<span class="sourceLineNo">801</span>    // get a list for previously failed RS which need log splitting work<a name="line.801"></a>
-<span class="sourceLineNo">802</span>    // we recover hbase:meta region servers inside master initialization and<a name="line.802"></a>
-<span class="sourceLineNo">803</span>    // handle other failed servers in SSH in order to start up master node ASAP<a name="line.803"></a>
-<span class="sourceLineNo">804</span>    MasterMetaBootstrap metaBootstrap = createMetaBootstrap(this, status);<a name="line.804"></a>
-<span class="sourceLineNo">805</span>    metaBootstrap.splitMetaLogsBeforeAssignment();<a name="line.805"></a>
+<span class="sourceLineNo">774</span>    status.setStatus("Initializing ZK system trackers");<a name="line.774"></a>
+<span class="sourceLineNo">775</span>    initializeZKBasedSystemTrackers();<a name="line.775"></a>
+<span class="sourceLineNo">776</span><a name="line.776"></a>
+<span class="sourceLineNo">777</span>    // This is for backwards compatibility<a name="line.777"></a>
+<span class="sourceLineNo">778</span>    // See HBASE-11393<a name="line.778"></a>
+<span class="sourceLineNo">779</span>    status.setStatus("Update TableCFs node in ZNode");<a name="line.779"></a>
+<span class="sourceLineNo">780</span>    TableCFsUpdater tableCFsUpdater = new TableCFsUpdater(zooKeeper,<a name="line.780"></a>
+<span class="sourceLineNo">781</span>            conf, this.clusterConnection);<a name="line.781"></a>
+<span class="sourceLineNo">782</span>    tableCFsUpdater.update();<a name="line.782"></a>
+<span class="sourceLineNo">783</span><a name="line.783"></a>
+<span class="sourceLineNo">784</span>    // initialize master side coprocessors before we start handling requests<a name="line.784"></a>
+<span class="sourceLineNo">785</span>    status.setStatus("Initializing master coprocessors");<a name="line.785"></a>
+<span class="sourceLineNo">786</span>    this.cpHost = new MasterCoprocessorHost(this, this.conf);<a name="line.786"></a>
+<span class="sourceLineNo">787</span><a name="line.787"></a>
+<span class="sourceLineNo">788</span>    // start up all service threads.<a name="line.788"></a>
+<span class="sourceLineNo">789</span>    status.setStatus("Initializing master service threads");<a name="line.789"></a>
+<span class="sourceLineNo">790</span>    startServiceThreads();<a name="line.790"></a>
+<span class="sourceLineNo">791</span><a name="line.791"></a>
+<span class="sourceLineNo">792</span>    // Wake up this server to check in<a name="line.792"></a>
+<span class="sourceLineNo">793</span>    sleeper.skipSleepCycle();<a name="line.793"></a>
+<span class="sourceLineNo">794</span><a name="line.794"></a>
+<span class="sourceLineNo">795</span>    // Wait for region servers to report in<a name="line.795"></a>
+<span class="sourceLineNo">796</span>    status.setStatus("Wait for region servers to report in");<a name="line.796"></a>
+<span class="sourceLineNo">797</span>    waitForRegionServers(status);<a name="line.797"></a>
+<span class="sourceLineNo">798</span><a name="line.798"></a>
+<span class="sourceLineNo">799</span>    // get a list for previously failed RS which need log splitting work<a name="line.799"></a>
+<span class="sourceLineNo">800</span>    // we recover hbase:meta region servers inside master initialization and<a name="line.800"></a>
+<span class="sourceLineNo">801</span>    // handle other failed servers in SSH in order to start up master node ASAP<a name="line.801"></a>
+<span class="sourceLineNo">802</span>    MasterMetaBootstrap metaBootstrap = createMetaBootstrap(this, status);<a name="line.802"></a>
+<span class="sourceLineNo">803</span>    metaBootstrap.splitMetaLogsBeforeAssignment();<a name="line.803"></a>
+<span class="sourceLineNo">804</span><a name="line.804"></a>
+<span class="sourceLineNo">805</span>    this.initializationBeforeMetaAssignment = true;<a name="line.805"></a>
 <span class="sourceLineNo">806</span><a name="line.806"></a>
-<span class="sourceLineNo">807</span>    this.initializationBeforeMetaAssignment = true;<a name="line.807"></a>
-<span class="sourceLineNo">808</span><a name="line.808"></a>
-<span class="sourceLineNo">809</span>    if (this.balancer instanceof FavoredNodesPromoter) {<a name="line.809"></a>
-<span class="sourceLineNo">810</span>      favoredNodesManager = new FavoredNodesManager(this);<a name="line.810"></a>
-<span class="sourceLineNo">811</span>    }<a name="line.811"></a>
-<span class="sourceLineNo">812</span>    // Wait for regionserver to finish initialization.<a name="line.812"></a>
-<span class="sourceLineNo">813</span>    if (BaseLoadBalancer.tablesOnMaster(conf)) {<a name="line.813"></a>
-<span class="sourceLineNo">814</span>      waitForServerOnline();<a name="line.814"></a>
-<span class="sourceLineNo">815</span>    }<a name="line.815"></a>
-<span class="sourceLineNo">816</span><a name="line.816"></a>
-<span class="sourceLineNo">817</span>    //initialize load balancer<a name="line.817"></a>
-<span class="sourceLineNo">818</span>    this.balancer.setMasterServices(this);<a name="line.818"></a>
-<span class="sourceLineNo">819</span>    this.balancer.setClusterStatus(getClusterStatus());<a name="line.819"></a>
-<span class="sourceLineNo">820</span>    this.balancer.initialize();<a name="line.820"></a>
-<span class="sourceLineNo">821</span><a name="line.821"></a>
-<span class="sourceLineNo">822</span>    // Check if master is shutting down because of some issue<a name="line.822"></a>
-<span class="sourceLineNo">823</span>    // in initializing the regionserver or the balancer.<a name="line.823"></a>
-<span class="sourceLineNo">824</span>    if (isStopped()) return;<a name="line.824"></a>
-<span class="sourceLineNo">825</span><a name="line.825"></a>
-<span class="sourceLineNo">826</span>    // Make sure meta assigned before proceeding.<a name="line.826"></a>
-<span class="sourceLineNo">827</span>    status.setStatus("Assigning Meta Region");<a name="line.827"></a>
-<span class="sourceLineNo">828</span>    metaBootstrap.assignMeta();<a name="line.828"></a>
-<span class="sourceLineNo">829</span><a name="line.829"></a>
-<span class="sourceLineNo">830</span>    // check if master is shutting down because above assignMeta could return even hbase:meta isn't<a name="line.830"></a>
-<span class="sourceLineNo">831</span>    // assigned when master is shutting down<a name="line.831"></a>
-<span class="sourceLineNo">832</span>    if (isStopped()) return;<a name="line.832"></a>
-<span class="sourceLineNo">833</span><a name="line.833"></a>
-<span class="sourceLineNo">834</span>    //Initialize after meta as it scans meta<a name="line.834"></a>
-<span class="sourceLineNo">835</span>    if (favoredNodesManager != null) {<a name="line.835"></a>
-<span class="sourceLineNo">836</span>      SnapshotOfRegionAssignmentFromMeta snapshotOfRegionAssignment =<a name="line.836"></a>
-<span class="sourceLineNo">837</span>          new SnapshotOfRegionAssignmentFromMeta(getConnection());<a name="line.837"></a>
-<span class="sourceLineNo">838</span>      snapshotOfRegionAssignment.initialize();<a name="line.838"></a>
-<span class="sourceLineNo">839</span>      favoredNodesManager.initialize(snapshotOfRegionAssignment);<a name="line.839"></a>
-<span class="sourceLineNo">840</span>    }<a name="line.840"></a>
-<span class="sourceLineNo">841</span><a name="line.841"></a>
-<span class="sourceLineNo">842</span>    // migrating existent table state from zk, so splitters<a name="line.842"></a>
-<span class="sourceLineNo">843</span>    // and recovery process treat states properly.<a name="line.843"></a>
-<span class="sourceLineNo">844</span>    for (Map.Entry&lt;TableName, TableState.State&gt; entry : ZKDataMigrator<a name="line.844"></a>
-<span class="sourceLineNo">845</span>        .queryForTableStates(getZooKeeper()).entrySet()) {<a name="line.845"></a>
-<span class="sourceLineNo">846</span>      LOG.info("Converting state from zk to new states:" + entry);<a name="line.846"></a>
-<span class="sourceLineNo">847</span>      tableStateManager.setTableState(entry.getKey(), entry.getValue());<a name="line.847"></a>
-<span class="sourceLineNo">848</span>    }<a name="line.848"></a>
-<span class="sourceLineNo">849</span>    ZKUtil.deleteChildrenRecursively(getZooKeeper(), getZooKeeper().znodePaths.tableZNode);<a name="line.849"></a>
-<span class="sourceLineNo">850</span><a name="line.850"></a>
-<span class="sourceLineNo">851</span>    status.setStatus("Submitting log splitting work for previously failed region servers");<a name="line.851"></a>
-<span class="sourceLineNo">852</span>    metaBootstrap.processDeadServers();<a name="line.852"></a>
-<span class="sourceLineNo">853</span><a name="line.853"></a>
-<span class="sourceLineNo">854</span>    // Fix up assignment manager status<a name="line.854"></a>
-<span class="sourceLineNo">855</span>    status.setStatus("Starting assignment manager");<a name="line.855"></a>
-<span class="sourceLineNo">856</span>    this.assignmentManager.joinCluster();<a name="line.856"></a>
-<span class="sourceLineNo">857</span><a name="line.857"></a>
-<span class="sourceLineNo">858</span>    // set cluster status again after user regions are assigned<a name="line.858"></a>
-<span class="sourceLineNo">859</span>    this.balancer.setClusterStatus(getClusterStatus());<a name="line.859"></a>
-<span class="sourceLineNo">860</span><a name="line.860"></a>
-<span class="sourceLineNo">861</span>    // Start balancer and meta catalog janitor after meta and regions have been assigned.<a name="line.861"></a>
-<span class="sourceLineNo">862</span>    status.setStatus("Starting balancer and catalog janitor");<a name="line.862"></a>
-<span class="sourceLineNo">863</span>    this.clusterStatusChore = new ClusterStatusChore(this, balancer);<a name="line.863"></a>
-<span class="sourceLineNo">864</span>    getChoreService().scheduleChore(clusterStatusChore);<a name="line.864"></a>
-<span class="sourceLineNo">865</span>    this.balancerChore = new BalancerChore(this);<a name="line.865"></a>
-<span class="sourceLineNo">866</span>    getChoreService().scheduleChore(balancerChore);<a name="line.866"></a>
-<span class="sourceLineNo">867</span>    this.normalizerChore = new RegionNormalizerChore(this);<a name="line.867"></a>
-<span class="sourceLineNo">868</span>    getChoreService().scheduleChore(normalizerChore);<a name="line.868"></a>
-<span class="sourceLineNo">869</span>    this.catalogJanitorChore = new CatalogJanitor(this);<a name="line.869"></a>
-<span class="sourceLineNo">870</span>    getChoreService().scheduleChore(catalogJanitorChore);<a name="line.870"></a>
-<span class="sourceLineNo">871</span><a name="line.871"></a>
-<span class="sourceLineNo">872</span>    // Do Metrics periodically<a name="line.872"></a>
-<span class="sourceLineNo">873</span>    periodicDoMetricsChore = new PeriodicDoMetrics(msgInterval, this);<a name="line.873"></a>
-<span class="sourceLineNo">874</span>    getChoreService().scheduleChore(periodicDoMetricsChore);<a name="line.874"></a>
-<span class="sourceLineNo">875</span><a name="line.875"></a>
-<span class="sourceLineNo">876</span>    status.setStatus("Starting cluster schema service");<a name="line.876"></a>
-<span class="sourceLineNo">877</span>    initClusterSchemaService();<a name="line.877"></a>
-<span class="sourceLineNo">878</span><a name="line.878"></a>
-<span class="sourceLineNo">879</span>    if (this.cpHost != null) {<a name="line.879"></a>
-<span class="sourceLineNo">880</span>      try {<a name="line.880"></a>
-<span class="sourceLineNo">881</span>        this.cpHost.preMasterInitialization();<a name="line.881"></a>
-<span class="sourceLineNo">882</span>      } catch (IOException e) {<a name="line.882"></a>
-<span class="sourceLineNo">883</span>        LOG.error("Coprocessor preMasterInitialization() hook failed", e);<a name="line.883"></a>
-<span class="sourceLineNo">884</span>      }<a name="line.884"></a>
-<span class="sourceLineNo">885</span>    }<a name="line.885"></a>
-<span class="sourceLineNo">886</span><a name="line.886"></a>
-<span class="sourceLineNo">887</span>    status.markComplete("Initialization successful");<a name="line.887"></a>
-<span class="sourceLineNo">888</span>    LOG.info("Master has completed initialization");<a name="line.888"></a>
-<span class="sourceLineNo">889</span>    configurationManager.registerObserver(this.balancer);<a name="line.889"></a>
-<span class="sourceLineNo">890</span>    configurationManager.registerObserver(this.hfileCleaner);<a name="line.890"></a>
-<span class="sourceLineNo">891</span><a name="line.891"></a>
-<span class="sourceLineNo">892</span>    // Set master as 'initialized'.<a name="line.892"></a>
-<span class="sourceLineNo">893</span>    setInitialized(true);<a name="line.893"></a>
-<span class="sourceLineNo">894</span><a name="line.894"></a>
-<span class="sourceLineNo">895</span>    status.setStatus("Assign meta replicas");<a name="line.895"></a>
-<span class="sourceLineNo">896</span>    metaBootstrap.assignMetaReplicas();<a name="line.896"></a>
-<span class="sourceLineNo">897</span><a name="line.897"></a>
-<span class="sourceLineNo">898</span>    status.setStatus("Starting quota manager");<a name="line.898"></a>
-<span class="sourceLineNo">899</span>    initQuotaManager();<a name="line.899"></a>
-<span class="sourceLineNo">900</span><a name="line.900"></a>
-<span class="sourceLineNo">901</span>    // clear the dead servers with same host name and port of online server because we are not<a name="line.901"></a>
-<span class="sourceLineNo">902</span>    // removing dead server with same hostname and port of rs which is trying to check in before<a name="line.902"></a>
-<span class="sourceLineNo">903</span>    // master initialization. See HBASE-5916.<a name="line.903"></a>
-<span class="sourceLineNo">904</span>    this.serverManager.clearDeadServersWithSameHostNameAndPortOfOnlineServer();<a name="line.904"></a>
-<span class="sourceLineNo">905</span><a name="line.905"></a>
-<span class="sourceLineNo">906</span>    // Check and set the znode ACLs if needed in case we are overtaking a non-secure configuration<a name="line.906"></a>
-<span class="sourceLineNo">907</span>    status.setStatus("Checking ZNode ACLs");<a name="line.907"></a>
-<span class="sourceLineNo">908</span>    zooKeeper.checkAndSetZNodeAcls();<a name="line.908"></a>
-<span class="sourceLineNo">909</span><a name="line.909"></a>
-<span class="sourceLineNo">910</span>    status.setStatus("Initializing MOB Cleaner");<a name="line.910"></a>
-<span class="sourceLineNo">911</span>    initMobCleaner();<a name="line.911"></a>
-<span class="sourceLineNo">912</span><a name="line.912"></a>
-<span class="sourceLineNo">913</span>    status.setStatus("Calling postStartMaster coprocessors");<a name="line.913"></a>
-<span class="sourceLineNo">914</span>    if (this.cpHost != null) {<a name="line.914"></a>
-<span class="sourceLineNo">915</span>      // don't let cp initialization errors kill the master<a name="line.915"></a>
-<span class="sourceLineNo">916</span>      try {<a name="line.916"></a>
-<span class="sourceLineNo">917</span>        this.cpHost.postStartMaster();<a name="line.917"></a>
-<span class="sourceLineNo">918</span>      } catch (IOException ioe) {<a name="line.918"></a>
-<span class="sourceLineNo">919</span>        LOG.error("Coprocessor postStartMaster() hook failed", ioe);<a name="line.919"></a>
-<span class="sourceLineNo">920</span>      }<a name="line.920"></a>
-<span class="sourceLineNo">921</span>    }<a name="line.921"></a>
-<span class="sourceLineNo">922</span><a name="line.922"></a>
-<span class="sourceLineNo">923</span>    zombieDetector.interrupt();<a name="line.923"></a>
-<span class="sourceLineNo">924</span>  }<a name="line.924"></a>
-<span class="sourceLineNo">925</span><a name="line.925"></a>
-<span class="sourceLineNo">926</span>  private void initMobCleaner() {<a name="line.926"></a>
-<span class="sourceLineNo">927</span>    this.expiredMobFileCleanerChore = new ExpiredMobFileCleanerChore(this);<a name="line.927"></a>
-<span class="sourceLineNo">928</span>    getChoreService().scheduleChore(expiredMobFileCleanerChore);<a name="line.928"></a>
-<span class="sourceLineNo">929</span><a name="line.929"></a>
-<span class="sourceLineNo">930</span>    int mobCompactionPeriod = conf.getInt(MobConstants.MOB_COMPACTION_CHORE_PERIOD,<a name="line.930"></a>
-<span class="sourceLineNo">931</span>        MobConstants.DEFAULT_MOB_COMPACTION_CHORE_PERIOD);<a name="line.931"></a>
-<span class="sourceLineNo">932</span>    if (mobCompactionPeriod &gt; 0) {<a name="line.932"></a>
-<span class="sourceLineNo">933</span>      this.mobCompactChore = new MobCompactionChore(this, mobCompactionPeriod);<a name="line.933"></a>
-<span class="sourceLineNo">934</span>      getChoreService().scheduleChore(mobCompactChore);<a name="line.934"></a>
-<span class="sourceLineNo">935</span>    } else {<a name="line.935"></a>
-<span class="sourceLineNo">936</span>      LOG<a name="line.936"></a>
-<span class="sourceLineNo">937</span>        .info("The period is " + mobCompactionPeriod + " seconds, MobCompactionChore is disabled");<a name="line.937"></a>
-<span class="sourceLineNo">938</span>    }<a name="line.938"></a>
-<span class="sourceLineNo">939</span>    this.mobCompactThread = new MasterMobCompactionThread(this);<a name="line.939"></a>
-<span class="sourceLineNo">940</span>  }<a name="line.940"></a>
-<span class="sourceLineNo">941</span><a name="line.941"></a>
-<span class="sourceLineNo">942</span>  /**<a name="line.942"></a>
-<span class="sourceLineNo">943</span>   * Create a {@link MasterMetaBootstrap} instance.<a name="line.943"></a>
-<span class="sourceLineNo">944</span>   */<a name="line.944"></a>
-<span class="sourceLineNo">945</span>  MasterMetaBootstrap createMetaBootstrap(final HMaster master, final MonitoredTask status) {<a name="line.945"></a>
-<span class="sourceLineNo">946</span>    // We put this out here in a method so can do a Mockito.spy and stub it out<a name="line.946"></a>
-<span class="sourceLineNo">947</span>    // w/ a mocked up MasterMetaBootstrap.<a name="line.947"></a>
-<span class="sourceLineNo">948</span>    return new MasterMetaBootstrap(master, status);<a name="line.948"></a>
-<span class="sourceLineNo">949</span>  }<a name="line.949"></a>
-<span class="sourceLineNo">950</span><a name="line.950"></a>
-<span class="sourceLineNo">951</span>  /**<a name="line.951"></a>
-<span class="sourceLineNo">952</span>   * Create a {@link ServerManager} instance.<a name="line.952"></a>
-<span class="sourceLineNo">953</span>   */<a name="line.953"></a>
-<span class="sourceLineNo">954</span>  ServerManager createServerManager(final MasterServices master) throws IOException {<a name="line.954"></a>
-<span class="sourceLineNo">955</span>    // We put this out here in a method so can do a Mockito.spy and stub it out<a name="line.955"></a>
-<span class="sourceLineNo">956</span>    // w/ a mocked up ServerManager.<a name="line.956"></a>
-<span class="sourceLineNo">957</span>    setupClusterConnection();<a name="line.957"></a>
-<span class="sourceLineNo">958</span>    return new ServerManager(master);<a name="line.958"></a>
-<span class="sourceLineNo">959</span>  }<a name="line.959"></a>
-<span class="sourceLineNo">960</span><a name="line.960"></a>
-<span class="sourceLineNo">961</span>  private void waitForRegionServers(final MonitoredTask status)<a name="line.961"></a>
-<span class="sourceLineNo">962</span>      throws IOException, InterruptedException {<a name="line.962"></a>
-<span class="sourceLineNo">963</span>    this.serverManager.waitForRegionServers(status);<a name="line.963"></a>
-<span class="sourceLineNo">964</span>    // Check zk for region servers that are up but didn't register<a name="line.964"></a>
-<span class="sourceLineNo">965</span>    for (ServerName sn: this.regionServerTracker.getOnlineServers()) {<a name="line.965"></a>
-<span class="sourceLineNo">966</span>      // The isServerOnline check is opportunistic, correctness is handled inside<a name="line.966"></a>
-<span class="sourceLineNo">967</span>      if (!this.serverManager.isServerOnline(sn)<a name="line.967"></a>
-<span class="sourceLineNo">968</span>          &amp;&amp; serverManager.checkAndRecordNewServer(sn, ServerLoad.EMPTY_SERVERLOAD)) {<a name="line.968"></a>
-<span class="sourceLineNo">969</span>        LOG.info("Registered server found up in zk but who has not yet reported in: " + sn);<a name="line.969"></a>
-<span class="sourceLineNo">970</span>      }<a name="line.970"></a>
-<span class="sourceLineNo">971</span>    }<a name="line.971"></a>
-<span class="sourceLineNo">972</span>  }<a name="line.972"></a>
-<span class="sourceLineNo">973</span><a name="line.973"></a>
-<span class="sourceLineNo">974</span>  void initClusterSchemaService() throws IOException, InterruptedException {<a name="line.974"></a>
-<span class="sourceLineNo">975</span>    this.clusterSchemaService = new ClusterSchemaServiceImpl(this);<a name="line.975"></a>
-<span class="sourceLineNo">976</span>    this.clusterSchemaService.startAndWait();<a name="line.976"></a>
-<span class="sourceLineNo">977</span>    if (!this.clusterSchemaService.isRunning()) throw new HBaseIOException("Failed start");<a name="line.977"></a>
-<span class="sourceLineNo">978</span>  }<a name="line.978"></a>
-<span class="sourceLineNo">979</span><a name="line.979"></a>
-<span class="sourceLineNo">980</span>  void initQuotaManager() throws IOException {<a name="line.980"></a>
-<span class="sourceLineNo">981</span>    MasterQuotaManager quotaManager = new MasterQuotaManager(this);<a name="line.981"></a>
-<span class="sourceLineNo">982</span>    this.assignmentManager.setRegionStateListener((RegionStateListener)quotaManager);<a name="line.982"></a>
-<span class="sourceLineNo">983</span>    quotaManager.start();<a name="line.983"></a>
-<span class="sourceLineNo">984</span>    this.quotaManager = quotaManager;<a name="line.984"></a>
-<span class="sourceLineNo">985</span>  }<a name="line.985"></a>
-<span class="sourceLineNo">986</span><a name="line.986"></a>
-<span class="sourceLineNo">987</span>  boolean isCatalogJanitorEnabled() {<a name="line.987"></a>
-<span class="sourceLineNo">988</span>    return catalogJanitorChore != null ?<a name="line.988"></a>
-<span class="sourceLineNo">989</span>      catalogJanitorChore.getEnabled() : false;<a name="line.989"></a>
-<span class="sourceLineNo">990</span>  }<a name="line.990"></a>
-<span class="sourceLineNo">991</span><a name="line.991"></a>
-<span class="sourceLineNo">992</span>  boolean isCleanerChoreEnabled() {<a name="line.992"></a>
-<span class="sourceLineNo">993</span>    boolean hfileCleanerFlag = true, logCleanerFlag = true;<a name="line.993"></a>
-<span class="sourceLineNo">994</span><a name="line.994"></a>
-<span class="sourceLineNo">995</span>    if (hfileCleaner != null) {<a name="line.995"></a>
-<span class="sourceLineNo">996</span>      hfileCleanerFlag = hfileCleaner.getEnabled();<a name="line.996"></a>
-<span class="sourceLineNo">997</span>    }<a name="line.997"></a>
-<span class="sourceLineNo">998</span><a name="line.998"></a>
-<span class="sourceLineNo">999</span>    if (logCleaner != null) {<a name="line.999"></a>
-<span class="sourceLineNo">1000</span>      logCleanerFlag = logCleaner.getEnabled();<a name="line.1000"></a>
-<span class="sourceLineNo">1001</span>    }<a name="line.1001"></a>
-<span class="sourceLineNo">1002</span><a name="line.1002"></a>
-<span class="sourceLineNo">1003</span>    return (hfileCleanerFlag &amp;&amp; logCleanerFlag);<a name="line.1003"></a>
-<span class="sourceLineNo">1004</span>  }<a name="line.1004"></a>
-<span class="sourceLineNo">1005</span><a name="line.1005"></a>
-<span class="sourceLineNo">1006</span>  @Override<a name="line.1006"></a>
-<span class="sourceLineNo">1007</span>  public TableDescriptors getTableDescriptors() {<a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>    return this.tableDescriptors;<a name="line.1008"></a>
-<span class="sourceLineNo">1009</span>  }<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span><a name="line.1010"></a>
-<span class="sourceLineNo">1011</span>  @Override<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>  public ServerManager getServerManager() {<a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>    return this.serverManager;<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>  }<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span><a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>  @Override<a name="line.1016"></a>
-<span class="sourceLineNo">1017</span>  public MasterFileSystem getMasterFileSystem() {<a name="line.1017"></a>
-<span class="sourceLineNo">1018</span>    return this.fileSystemManager;<a name="line.1018"></a>
-<span class="sourceLineNo">1019</span>  }<a name="line.1019"></a>
-<span class="sourceLineNo">1020</span><a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>  @Override<a name="line.1021"></a>
-<span class="sourceLineNo">1022</span>  public MasterWalManager getMasterWalManager() {<a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>    return this.walManager;<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>  }<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span><a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>  @Override<a name="line.1026"></a>
-<span class="sourceLineNo">1027</span>  public TableStateManager getTableStateManager() {<a name="line.1027"></a>
-<span class="sourceLineNo">1028</span>    return tableStateManager;<a name="line.1028"></a>
-<span class="sourceLineNo">1029</span>  }<a name="line.1029"></a>
-<span class="sourceLineNo">1030</span><a name="line.1030"></a>
-<span class="sourceLineNo">1031</span>  /*<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span>   * Start up all services. If any of these threads gets an unhandled exception<a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>   * then they just die with a logged message.  This should be fine because<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span>   * in general, we do not expect the master to get such unhandled exceptions<a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>   *  as OOMEs; it should be lightly loaded. See what HRegionServer does if<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span>   *  need to install an unexpected exception handler.<a name="line.1036"></a>
-<span class="sourceLineNo">1037</span>   */<a name="line.1037"></a>
-<span class="sourceLineNo">1038</span>  private void startServiceThreads() throws IOException{<a name="line.1038"></a>
-<span class="sourceLineNo">1039</span>   // Start the executor service pools<a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>   this.service.startExecutorService(ExecutorType.MASTER_OPEN_REGION,<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span>      conf.getInt("hbase.master.executor.openregion.threads", 5));<a name="line.1041"></a>
-<span class="sourceLineNo">1042</span>   this.service.startExecutorService(ExecutorType.MASTER_CLOSE_REGION,<a name="line.1042"></a>
-<span class="sourceLineNo">1043</span>      conf.getInt("hbase.master.executor.closeregion.threads", 5));<a name="line.1043"></a>
-<span class="sourceLineNo">1044</span>   this.service.startExecutorService(ExecutorType.MASTER_SERVER_OPERATIONS,<a name="line.1044"></a>
-<span class="sourceLineNo">1045</span>      conf.getInt("hbase.master.executor.serverops.threads", 5));<a name="line.1045"></a>
-<span class="sourceLineNo">1046</span>   this.service.startExecutorService(ExecutorType.MASTER_META_SERVER_OPERATIONS,<a name="line.1046"></a>
-<span class="sourceLineNo">1047</span>      conf.getInt("hbase.master.executor.meta.serverops.threads", 5));<a name="line.1047"></a>
-<span class="sourceLineNo">1048</span>   this.service.startExecutorService(ExecutorType.M_LOG_REPLAY_OPS,<a name="line.1048"></a>
-<span class="sourceLineNo">1049</span>      conf.getInt("hbase.master.executor.logreplayops.threads", 10));<a name="line.1049"></a>
-<span class="sourceLineNo">1050</span><a name="line.1050"></a>
-<span class="sourceLineNo">1051</span>   // We depend on there being only one instance of this executor running<a name="line.1051"></a>
-<span class="sourceLineNo">1052</span>   // at a time.  To do concurrency, would need fencing of enable/disable of<a name="line.1052"></a>
-<span class="sourceLineNo">1053</span>   // tables.<a name="line.1053"></a>
-<span class="sourceLineNo">1054</span>   // Any time changing this maxThreads to &gt; 1, pls see the comment at<a name="line.1054"></a>
-<span class="sourceLineNo">1055</span>   // AccessController#postCompletedCreateTableAction<a name="line.1055"></a>
-<span class="sourceLineNo">1056</span>   this.service.startExecutorService(ExecutorType.MASTER_TABLE_OPERATIONS, 1);<a name="line.1056"></a>
-<span class="sourceLineNo">1057</span>   startProcedureExecutor();<a name="line.1057"></a>
-<span class="sourceLineNo">1058</span><a name="line.1058"></a>
-<span class="sourceLineNo">1059</span>   // Start log cleaner thread<a name="line.1059"></a>
-<span class="sourceLineNo">1060</span>   int cleanerInterval = conf.getInt("hbase.master.cleaner.interval", 60 * 1000);<a name="line.1060"></a>
-<span class="sourceLineNo">1061</span>   this.logCleaner =<a name="line.1061"></a>
-<span class="sourceLineNo">1062</span>      new LogCleaner(cleanerInterval,<a name="line.1062"></a>
-<span class="sourceLineNo">1063</span>         this, conf, getMasterWalManager().getFileSystem(),<a name="line.1063"></a>
-<span class="sourceLineNo">1064</span>         getMasterWalManager().getOldLogDir());<a name="line.1064"></a>
-<span class="sourceLineNo">1065</span>    getChoreService().scheduleChore(logCleaner);<a name="line.1065"></a>
-<span class="sourceLineNo">1066</span><a name="line.1066"></a>
-<span class="sourceLineNo">1067</span>   //start the hfile archive cleaner thread<a name="line.1067"></a>
-<span class="sourceLineNo">1068</span>    Path archiveDir = HFileArchiveUtil.getArchivePath(conf);<a name="line.1068"></a>
-<span class="sourceLineNo">1069</span>    Map&lt;String, Object&gt; params = new HashMap&lt;&gt;();<a name="line.1069"></a>
-<span class="sourceLineNo">1070</span>    params.put(MASTER, this);<a name="line.1070"></a>
-<span class="sourceLineNo">1071</span>    this.hfileCleaner = new HFileCleaner(cleanerInterval, this, conf, getMasterFileSystem()<a name="line.1071"></a>
-<span class="sourceLineNo">1072</span>        .getFileSystem(), archiveDir, params);<a name="line.1072"></a>
-<span class="sourceLineNo">1073</span>    getChoreService().scheduleChore(hfileCleaner);<a name="line.1073"></a>
-<span class="sourceLineNo">1074</span>    serviceStarted = true;<a name="line.1074"></a>
-<span class="sourceLineNo">1075</span>    if (LOG.isTraceEnabled()) {<a name="line.1075"></a>
-<span class="sourceLineNo">1076</span>      LOG.trace("Started service threads");<a name="line.1076"></a>
-<span class="sourceLineNo">1077</span>    }<a name="line.1077"></a>
-<span class="sourceLineNo">1078</span><a name="line.1078"></a>
-<span class="sourceLineNo">1079</span>    // Start replication zk node cleaner<a name="line.1079"></a>
-<span class="sourceLineNo">1080</span>    if (conf.getClass("hbase.region.replica.replication.replicationQueues.class",<a name="line.1080"></a>
-<span class="sourceLineNo">1081</span>      ReplicationFactory.defaultReplicationQueueClass) == ReplicationQueuesZKImpl.class) {<a name="line.1081"></a>
-<span class="sourceLineNo">1082</span>      try {<a name="line.1082"></a>
-<span class="sourceLineNo">1083</span>        replicationZKNodeCleanerChore = new ReplicationZKNodeCleanerChore(this, cleanerInterval,<a name="line.1083"></a>
-<span class="sourceLineNo">1084</span>            new ReplicationZKNodeCleaner(this.conf, this.getZooKeeper(), this));<a name="line.1084"></a>
-<span class="sourceLineNo">1085</span>        getChoreService().scheduleChore(replicationZKNodeCleanerChore);<a name="line.1085"></a>
-<span class="sourceLineNo">1086</span>      } catch (Exception e) {<a name="line.1086"></a>
-<span class="sourceLineNo">1087</span>        LOG.error("start replicationZKNodeCleanerChore failed", e);<a name="line.1087"></a>
-<span class="sourceLineNo">1088</span>      }<a name="line.1088"></a>
-<span class="sourceLineNo">1089</span>    }<a name="line.1089"></a>
-<span class="sourceLineNo">1090</span>    replicationMetaCleaner = new ReplicationMetaCleaner(this, this, cleanerInterval);<a name="line.1090"></a>
-<span class="sourceLineNo">1091</span>    getChoreService().scheduleChore(replicationMetaCleaner);<a name="line.1091"></a>
-<span class="sourceLineNo">1092</span>  }<a name="line.1092"></a>
-<span class="sourceLineNo">1093</span><a name="line.1093"></a>
-<span class="sourceLineNo">1094</span>  @Override<a name="line.1094"></a>
-<span class="sourceLineNo">1095</span>  protected void sendShutdownInterrupt() {<a name="line.1095"></a>
-<span class="sourceLineNo">1096</span>    super.sendShutdownInterrupt();<a name="line.1096"></a>
-<span class="sourceLineNo">1097</span>    stopProcedureExecutor();<a name="line.1097"></a>
-<span class="sourceLineNo">1098</span>  }<a name="line.1098"></a>
-<span class="sourceLineNo">1099</span><a name="line.1099"></a>
-<span class="sourceLineNo">1100</span>  @Override<a name="line.1100"></a>
-<span class="sourceLineNo">1101</span>  protected void stopServiceThreads() {<a name="line.1101"></a>
-<span class="sourceLineNo">1102</span>    if (masterJettyServer != null) {<a name="line.1102"></a>
-<span class="sourceLineNo">1103</span>      LOG.info("Stopping master jetty server");<a name="line.1103"></a>
-<span class="sourceLineNo">1104</span>      try {<a name="line.1104"></a>
-<span class="sourceLineNo">1105</span>        masterJettyServer.stop();<a name="line.1105"></a>
-<span class="sourceLineNo">1106</span>      } catch (Exception e) {<a name="line.1106"></a>
-<span class="sourceLineNo">1107</span>        LOG.error("Failed to stop master jetty server", e);<a name="line.1107"></a>
-<span class="sourceLineNo">1108</span>      }<a name="line.1108"></a>
-<span class="sourceLineNo">1109</span>    }<a name="line.1109"></a>
-<span class="sourceLineNo">1110</span>    super.stopServiceThreads();<a name="line.1110"></a>
-<span class="sourceLineNo">1111</span>    stopChores();<a name="line.1111"></a>
-<span class="sourceLineNo">1112</span><a name="line.1112"></a>
-<span class="sourceLineNo">1113</span>    // Wait for all the remaining region servers to report in IFF we were<a name="line.1113"></a>
-<span class="sourceLineNo">1114</span>    // running a cluster shutdown AND we were NOT aborting.<a name="line.1114"></a>
-<span class="sourceLineNo">1115</span>    if (!isAborted() &amp;&amp; this.serverManager != null &amp;&amp;<a name="line.1115"></a>
-<span class="sourceLineNo">1116</span>        this.serverManager.isClusterShutdown()) {<a name="line.1116"></a>
-<span class="sourceLineNo">1117</span>      this.serverManager.letRegionServersShutdown();<a name="line.1117"></a>
-<span class="sourceLineNo">1118</span>    }<a name="line.1118"></a>
-<span class="sourceLineNo">1119</span>    if (LOG.isDebugEnabled()) {<a name="line.1119"></a>
-<span class="sourceLineNo">1120</span>      LOG.debug("Stopping service threads");<a name="line.1120"></a>
-<span class="sourceLineNo">1121</span>    }<a name="line.1121"></a>
-<span class="sourceLineNo">1122</span>    // Clean up and close up shop<a name="line.1122"></a>
-<span class="sourceLineNo">1123</span>    if (this.logCleaner != null) this.logCleaner.cancel(true);<a name="line.1123"></a>
-<span class="sourceLineNo">1124</span>    if (this.hfileCleaner != null) this.hfileCleaner.cancel(true);<a name="line.1124"></a>
-<span class="sourceLineNo">1125</span>    if (this.replicationZKNodeCleanerChore != null) this.replicationZKNodeCleanerChore.cancel(true);<a name="line.1125"></a>
-<span class="sourceLineNo">1126</span>    if (this.replicationMetaCleaner != null) this.replicationMetaCleaner.cancel(true);<a name="line.1126"></a>
-<span class="sourceLineNo">1127</span>    if (this.quotaManager != null) this.quotaManager.stop();<a name="line.1127"></a>
-<span class="sourceLineNo">1128</span>    if (this.activeMasterManager != null) this.activeMasterManager.stop();<a name="line.1128"></a>
-<span class="sourceLineNo">1129</span>    if (this.serverManager != null) this.serverManager.stop();<a name="line.1129"></a>
-<span class="sourceLineNo">1130</span>    if (this.assignmentManager != null) this.assignmentManager.stop();<a name="line.1130"></a>
-<span class="sourceLineNo">1131</span>    if (this.walManager != null) this.walManager.stop();<a name="line.1131"></a>
-<span class="sourceLineNo">1132</span>    if (this.fileSystemManager != null) this.fileSystemManager.stop();<a name="line.1132"></a>
-<span class="sourceLineNo">1133</span>    if (this.mpmHost != null) this.mpmHost.stop("server shutting down.");<a name="line.1133"></a>
-<span class="sourceLineNo">1134</span>  }<a name="line.1134"></a>
-<span class="sourceLineNo">1135</span><a name="line.1135"></a>
-<span class="sourceLineNo">1136</span>  private void startProcedureExecutor() throws IOException {<a name="line.1136"></a>
-<span class="sourceLineNo">1137</span>    final MasterProcedureEnv procEnv = new MasterProcedureEnv(this);<a name="line.1137"></a>
-<span class="sourceLineNo">1138</span>    final Path walDir = new Path(FSUtils.getWALRootDir(this.conf),<a name="line.1138"></a>
-<span class="sourceLineNo">1139</span>        MasterProcedureConstants.MASTER_PROCEDURE_LOGDIR);<a name="line.1139"></a>
-<span class="sourceLineNo">1140</span><a name="line.1140"></a>
-<span class="sourceLineNo">1141</span>    procedureStore = new WALProcedureStore(conf, walDir.getFileSystem(conf), walDir,<a name="line.1141"></a>
-<span class="sourceLineNo">1142</span>        new MasterProcedureEnv.WALStoreLeaseRecovery(this));<a name="line.1142"></a>
-<span class="sourceLineNo">1143</span>    procedureStore.registerListener(new MasterProcedureEnv.MasterProcedureStoreListener(this));<a name="line.1143"></a>
-<span class="sourceLineNo">1144</span>    procedureExecutor = new ProcedureExecutor(conf, procEnv, procedureStore,<a name="line.1144"></a>
-<span class="sourceLineNo">1145</span>        procEnv.getProcedureScheduler());<a name="line.1145"></a>
-<span class="sourceLineNo">1146</span>    configurationManager.registerObserver(procEnv);<a name="line.1146"></a>
-<span class="sourceLineNo">1147</span><a name="line.1147"></a>
-<span class="sourceLineNo">1148</span>    final int numThreads = conf.getInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS,<a name="line.1148"></a>
-<span class="sourceLineNo">1149</span>        Math.max(Runtime.getRuntime().availableProcessors(),<a name="line.1149"></a>
-<span class="sourceLineNo">1150</span>          MasterProcedureConstants.DEFAULT_MIN_MASTER_PROCEDURE_THREADS));<a name="line.1150"></a>
-<span class="sourceLineNo">1151</span>    final boolean abortOnCorruption = conf.getBoolean(<a name="line.1151"></a>
-<span class="sourceLineNo">1152</span>        MasterProcedureConstants.EXECUTOR_ABORT_ON_CORRUPTION,<a name="line.1152"></a>
-<span class="sourceLineNo">1153</span>        MasterProcedureConstants.DEFAULT_EXECUTOR_ABORT_ON_CORRUPTION);<a name="line.1153"></a>
-<span class="sourceLineNo">1154</span>    procedureStore.start(numThreads);<a name="line.1154"></a>
-<span class="sourceLineNo">1155</span>    procedureExecutor.start(numThreads, abortOnCorruption);<a name="line.1155"></a>
-<span class="sourceLineNo">1156</span>  }<a name="line.1156"></a>
-<span class="sourceLineNo">1157</span><a name="line.1157"></a>
-<span class="sourceLineNo">1158</span>  private void stopProcedureExecutor() {<a name="line.1158"></a>
-<span class="sourceLineNo">1159</span>    if (procedureExecutor != null) {<a name="line.1159"></a>
-<span class="sourceLineNo">1160</span>      configurationManager.deregisterObserver(procedureExecutor.getEnvironment());<a name="line.1160"></a>
-<span class="sourceLineNo">1161</span>      procedureExecutor.stop();<a name="line.1161"></a>
-<span class="sourceLineNo">1162</span>    }<a name="line.1162"></a>
-<span class="sourceLineNo">1163</span><a name="line.1163"></a>
-<span class="sourceLineNo">1164</span>    if (procedureStore != null) {<a name="line.1164"></a>
-<span class="sourceLineNo">1165</span>      procedureStore.stop(isAborted());<a name="line.1165"></a>
-<span class="sourceLineNo">1166</span>    }<a name="line.1166"></a>
-<span class="sourceLineNo">1167</span>  }<a name="line.1167"></a>
-<span class="sourceLineNo">1168</span><a name="line.1168"></a>
-<span class="sourceLineNo">1169</span>  private void stopChores() {<a name="line.1169"></a>
-<span class="sourceLineNo">1170</span>    if (this.expiredMobFileCleanerChore != null) {<a name="line.1170"></a>
-<span class="sourceLineNo">1171</span>      this.expiredMobFileCleanerChore.cancel(true);<a name="line.1171"></a>
-<span class="sourceLineNo">1172</span>    }<a name="line.1172"></a>
-<span class="sourceLineNo">1173</span>    if (this.mobCompactChore != null) {<a name="line.1173"></a>
-<span class="sourceLineNo">1174</span>      this.mobCompactChore.cancel(true);<a name="line.1174"></a>
-<span class="sourceLineNo">1175</span>    }<a name="line.1175"></a>
-<span class="sourceLineNo">1176</span>    if (this.balancerChore != null) {<a name="line.1176"></a>
-<span class="sourceLineNo">1177</span>      this.balancerChore.cancel(true);<a name="line.1177"></a>
-<span class="sourceLineNo">1178</span>    }<a name="line.1178"></a>
-<span class="sourceLineNo">1179</span>    if (this.normalizerChore != null) {<a name="line.1179"></a>
-<span class="sourceLineNo">1180</span>      this.normalizerChore.cancel(true);<a name="line.1180"></a>
-<span class="sourceLineNo">1181</span>    }<a name="line.1181"></a>
-<span class="sourceLineNo">1182</span>    if (this.clusterStatusChore != null) {<a name="line.1182"></a>
-<span class="sourceLineNo">1183</span>      this.clusterStatusChore.cancel(true);<a name="line.1183"></a>
-<span class="sourceLineNo">1184</span>    }<a name="line.1184"></a>
-<span class="sourceLineNo">1185</span>    if (this.catalogJanitorChore != null) {<a name="line.1185"></a>
-<span class="sourceLineNo">1186</span>      this.catalogJanitorChore.cancel(true);<a name="line.1186"></a>
-<span class="sourceLineNo">1187</span>    }<a name="line.1187"></a>
-<span class="sourceLineNo">1188</span>    if (this.clusterStatusPublisherChore != null){<a name="line.1188"></a>
-<span class="sourceLineNo">1189</span>      clusterStatusPublisherChore.cancel(true);<a name="line.1189"></a>
-<span class="sourceLineNo">1190</span>    }<a name="line.1190"></a>
-<span class="sourceLineNo">1191</span>    if (this.mobCompactThread != null) {<a name="line.1191"></a>
-<span class="sourceLineNo">1192</span>      this.mobCompactThread.close();<a name="line.1192"></a>
-<span class="sourceLineNo">1193</span>    }<a name="line.1193"></a>
-<span class="sourceLineNo">1194</span><a name="line.1194"></a>
-<span class="sourceLineNo">1195</span>    if (this.periodicDoMetricsChore != null) {<a name="line.1195"></a>
-<span class="sourceLineNo">1196</span>      periodicDoMetricsChore.cancel();<a name="line.1196"></a>
-<span class="sourceLineNo">1197</span>    }<a name="line.1197"></a>
-<span class="sourceLineNo">1198</span>  }<a name="line.1198"></a>
-<span class="sourceLineNo">1199</span><a name="line.1199"></a>
-<span class="sourceLineNo">1200</span>  /**<a name="line.1200"></a>
-<span class="sourceLineNo">1201</span>   * @return Get remote side's InetAddress<a name="line.1201"></a>
-<span class="sourceLineNo">1202</span>   */<a name="line.1202"></a>
-<span class="sourceLineNo">1203</span>  InetAddress getRemoteInetAddress(final int port,<a name="line.1203"></a>
-<span class="sourceLineNo">1204</span>      final long serverStartCode) throws UnknownHostException {<a name="line.1204"></a>
-<span class="sourceLineNo">1205</span>    // Do it out here in its own little method so can fake an address when<a name="line.1205"></a>
-<span class="sourceLineNo">1206</span>    // mocking up in tests.<a name="line.1206"></a>
-<span class="sourceLineNo">1207</span>    InetAddress ia = RpcServer.getRemoteIp();<a name="line.1207"></a>
-<span class="sourceLineNo">1208</span><a name="line.1208"></a>
-<span class="sourceLineNo">1209</span>    // The call could be from the local regionserver,<a name="line.1209"></a>
-<span class="sourceLineNo">1210</span>    // in which case, there is no remote address.<a name="line.1210"></a>
-<span class="sourceLineNo">1211</span>    if (ia == null &amp;&amp; serverStartCode == startcode) {<a name="line.1211"></a>
-<span class="sourceLineNo">1212</span>      InetSocketAddress isa = rpcServices.getSocketAddress();<a name="line.1212"></a>
-<span class="sourceLineNo">1213</span>      if (isa != null &amp;&amp; isa.getPort() == port) {<a name="line.1213"></a>
-<span class="sourceLineNo">1214</span>        ia = isa.getAddress();<a name="line.1214"></a>
-<span class="sourceLineNo">1215</span>      }<a name="line.1215"></a>
-<span class="sourceLineNo">1216</span>    }<a name="line.1216"></a>
-<span class="sourceLineNo">1217</span>    return ia;<a name="line.1217"></a>
-<span class="sourceLineNo">1218</span>  }<a name="line.1218"></a>
-<span class="sourceLineNo">1219</span><a name="line.1219"></a>
-<span class="sourceLineNo">1220</span>  /**<a name="line.1220"></a>
-<span class="sourceLineNo">1221</span>   * @return Maximum time we should run balancer for<a name="line.1221"></a>
-<span class="sourceLineNo">1222</span>   */<a name="line.1222"></a>
-<span class="sourceLineNo">1223</span>  private int getMaxBalancingTime() {<a name="line.1223"></a>
-<span class="sourceLineNo">1224</span>    int maxBalancingTime = getConfiguration().getInt(HConstants.HBASE_BALANCER_MAX_BALANCING, -1);<a name="line.1224"></a>
-<span class="sourceLineNo">1225</span>    if (maxBalancingTime == -1) {<a name="line.1225"></a>
-<span class="sourceLineNo">1226</span>      // if max balancing time isn't set, defaulting it to period time<a name="line.1226"></a>
-<span class="sourceLineNo">1227</span>      maxBalancingTime = getConfiguration().getInt(HConstants.HBASE_BALANCER_PERIOD,<a name="line.1227"></a>
-<span class="sourceLineNo">1228</span>        HConstants.DEFAULT_HBASE_BALANCER_PERIOD);<a name="line.1228"></a>
-<span class="sourceLineNo">1229</span>    }<a name="line.1229"></a>
-<span class="sourceLineNo">1230</span>    return maxBalancingTime;<a name="line.1230"></a>
-<span class="sourceLineNo">1231</span>  }<a name="line.1231"></a>
-<span class="sourceLineNo">1232</span><a name="line.1232"></a>
-<span class="sourceLineNo">1233</span>  /**<a name="line.1233"></a>
-<span class="sourceLineNo">1234</span>   * @return Maximum number of regions in transition<a name="line.1234"></a>
-<span class="sourceLineNo">1235</span>   */<a name="line.1235"></a>
-<span class="sourceLineNo">1236</span>  private int getMaxRegionsInTransition() {<a name="line.1236"></a>
-<span class="sourceLineNo">1237</span>    int numRegions = this.assignmentManager.getRegionStates().getRegionAssignments().size();<a name="line.1237"></a>
-<span class="sourceLineNo">1238</span>    return Math.max((int) Math.floor(numRegions * this.maxRitPercent), 1);<a name="line.1238"></a>
-<span class="sourceLineNo">1239</span>  }<a name="line.1239"></a>
-<span class="sourceLineNo">1240</span><a name="line.1240"></a>
-<span class="sourceLineNo">1241</span>  /**<a name="line.1241"></a>
-<span class="sourceLineNo">1242</span>   * It first sleep to the next balance plan start time. Meanwhile, throttling by the max<a name="line.1242"></a>
-<span class="sourceLineNo">1243</span>   * number regions in transition to protect availability.<a name="line.1243"></a>
-<span class="sourceLineNo">1244</span>   * @param nextBalanceStartTime The next balance plan start time<a name="line.1244"></a>
-<span class="sourceLineNo">1245</span>   * @param maxRegionsInTransition max number of regions in transition<a name="line.1245"></a>
-<span class="sourceLineNo">1246</span>   * @param cutoffTime when to exit balancer<a name="line.1246"></a>
-<span class="sourceLineNo">1247</span>   */<a name="line.1247"></a>
-<span class="sourceLineNo">1248</span>  private void balanceThrottling(long nextBalanceStartTime, int maxRegionsInTransition,<a name="line.1248"></a>
-<span class="sourceLineNo">1249</span>      long cutoffTime) {<a name="line.1249"></a>
-<span class="sourceLineNo">1250</span>    boolean interrupted = false;<a name="line.1250"></a>
-<span class="sourceLineNo">1251</span><a name="line.1251"></a>
-<span class="sourceLineNo">1252</span>    // Sleep to next balance plan start time<a name="line.1252"></a>
-<span class="sourceLineNo">1253</span>    // But if there are zero regions in transition, it can skip sleep to speed up.<a name="line.1253"></a>
-<span class="sourceLineNo">1254</span>    while (!interrupted &amp;&amp; System.currentTimeMillis() &lt; nextBalanceStartTime<a name="line.1254"></a>
-<span class="sourceLineNo">1255</span>        &amp;&amp; this.assignmentManager.getRegionStates().getRegionsInTransitionCount() != 0) {<a name="line.1255"></a>
-<span class="sourceLineNo">1256</span>      try {<a name="line.1256"></a>
-<span class="sourceLineNo">1257</span>        Thread.sleep(100);<a name="line.1257"></a>
-<span class="sourceLineNo">1258</span>      } catch (InterruptedException ie) {<a name="line.1258"></a>
-<span class="sourceLineNo">1259</span>        interrupted = true;<a name="line.1259"></a>
-<span class="sourceLineNo">1260</span>      }<a name="line.1260"></a>
-<span class="sourceLineNo">1261</span>    }<a name="line.1261"></a>
-<span class="sourceLineNo">1262</span><a name="line.1262"></a>
-<span class="sourceLineNo">1263</span>    // Throttling by max number regions in transition<a name="line.1263"></a>
-<span class="sourceLineNo">1264</span>    while (!interrupted<a name="line.1264"></a>
-<span class="sourceLineNo">1265</span>        &amp;&amp; maxRegionsInTransition &gt; 0<a name="line.1265"></a>
-<span class="sourceLineNo">1266</span>        &amp;&amp; this.assignmentManager.getRegionStates().getRegionsInTransitionCount()<a name="line.1266"></a>
-<span class="sourceLineNo">1267</span>        &gt;= maxRegionsInTransition &amp;&amp; System.currentTimeMillis() &lt;= cutoffTime) {<a name="line.1267"></a>
-<span class="sourceLineNo">1268</span>      try {<a name="line.1268"></a>
-<span class="sourceLineNo">1269</span>        // sleep if the number of regions in transition exceeds the limit<a name="line.1269"></a>
-<span class="sourceLineNo">1270</span>        Thread.sleep(100);<a name="line.1270"></a>
-<span class="sourceLineNo">1271</span>      } catch (InterruptedException ie) {<a name="line.1271"></a>
-<span class="sourceLineNo">1272</span>        interrupted = true;<a name="line.1272"></a>
-<span class="sourceLineNo">1273</span>      }<a name="line.1273"></a>
-<span class="sourceLineNo">1274</span>    }<a name="line.1274"></a>
-<span class="sourceLineNo">1275</span><a name="line.1275"></a>
-<span class="sourceLineNo">1276</span>    if (interrupted) Thread.currentThread().interrupt();<a name="line.1276"></a>
-<span class="sourceLineNo">1277</span>  }<a name="line.1277"></a>
-<span class="sourceLineNo">1278</span><a name="line.1278"></a>
-<span class="sourceLineNo">1279</span>  public boolean balance() throws IOException {<a name="line.1279"></a>
-<span class="sourceLineNo">1280</span>    return balance(false);<a name="line.1280"></a>
-<span class="sourceLineNo">1281</span>  }<a name="line.1281"></a>
-<span class="sourceLineNo">1282</span><a name="line.1282"></a>
-<span class="sourceLineNo">1283</span>  public boolean balance(boolean force) throws IOException {<a name="line.1283"></a>
-<span class="sourceLineNo">1284</span>    // if master not initialized, don't run balancer.<a name="line.1284"></a>
-<span class="sourceLineNo">1285</span>    if (!isInitialized()) {<a name="line.1285"></a>
-<span class="sourceLineNo">1286</span>      LOG.debug("Master has not been initialized, don't run balancer.");<a name="line.1286"></a>
-<span class="sourceLineNo">1287</span>      return false;<a name="line.1287"></a>
-<span class="sourceLineNo">1288</span>    }<a name="line.1288"></a>
-<span class="sourceLineNo">1289</span><a name="line.1289"></a>
-<span class="sourceLineNo">1290</span>    if (isInMaintenanceMode()) {<a name="line.1290"></a>
-<span class="sourceLineNo">1291</span>      LOG.info("Master is in maintenanceMode mode, don't run balancer.");<a name="line.1291"></a>
-<span class="sourceLineNo">1292</span>      return false;<a name="line.1292"></a>
-<span class="sourceLineNo">1293</span>    }<a name="line.1293"></a>
-<span class="sourceLineNo">1294</span><a name="line.1294"></a>
-<span class="sourceLineNo">1295</span>    int maxRegionsInTransition = getMaxRegionsInTransition();<a name="line.1295"></a>
-<span class="sourceLineNo">1296</span>    synchronized (this.balancer) {<a name="line.1296"></a>
-<span class="sourceLineNo">1297</span>      // If balance not true, don't run balancer.<a name="line.1297"></a>
-<span class="sourceLineNo">1298</span>      if (!this.loadBalancerTracker.isBalancerOn()) return false;<a name="line.1298"></a>
-<span class="sourceLineNo">1299</span>      // Only allow one balance run at at time.<a name="line.1299"></a>
-<span class="sourceLineNo">1300</span>      if (this.assignmentManager.getRegionStates().isRegionsInTransition()) {<a name="line.1300"></a>
-<span class="sourceLineNo">1301</span>        Set&lt;RegionState&gt; regionsInTransition =<a name="line.1301"></a>
-<span class="sourceLineNo">1302</span>          this.assignmentManager.getRegionStates().getRegionsInTransition();<a name="line.1302"></a>
-<span class="sourceLineNo">1303</span>        // if hbase:meta region is in transition, result of assignment cannot be recorded<a name="line.1303"></a>
-<span class="sourceLineNo">1304</span>        // ignore the force flag in that case<a name="line.1304"></a>
-<span class="sourceLineNo">1305</span>        boolean metaInTransition = assignmentManager.getRegionStates().isMetaRegionInTransition();<a name="line.1305"></a>
-<span class="sourceLineNo">1306</span>        String prefix = force &amp;&amp; !metaInTransition ? "R" : "Not r";<a name="line.1306"></a>
-<span class="sourceLineNo">1307</span>        LOG.debug(prefix + "unning balancer because " + regionsInTransition.size() +<a name="line.1307"></a>
-<span class="sourceLineNo">1308</span>          " region(s) in transition: " + org.apache.commons.lang.StringUtils.<a name="line.1308"></a>
-<span class="sourceLineNo">1309</span>            abbreviate(regionsInTransition.toString(), 256));<a name="line.1309"></a>
-<span class="sourceLineNo">1310</span>        if (!force || metaInTransition) return false;<a name="line.1310"></a>
-<span class="sourceLineNo">1311</span>      }<a name="line.1311"></a>
-<span class="sourceLineNo">1312</span>      if (this.serverManager.areDeadServersInProgress()) {<a name="line.1312"></a>
-<span class="sourceLineNo">1313</span>        LOG.debug("Not running balancer because processing dead regionserver(s): " +<a name="line.1313"></a>
-<span class="sourceLineNo">1314</span>          this.serverManager.getDeadServers());<a name="line.1314"></a>
-<span class="sourceLineNo">1315</span>        return false;<a name="line.1315"></a>
-<span class="sourceLineNo">1316</span>      }<a name="line.1316"></a>
-<span class="sourceLineNo">1317</span><a name="line.1317"></a>
-<span class="sourceLineNo">1318</span>      if (this.cpHost != null) {<a name="line.1318"></a>
-<span class="sourceLineNo">1319</span>        try {<a name="line.1319"></a>
-<span class="sourceLineNo">1320</span>          if (this.cpHost.preBalance()) {<a name="line.1320"></a>
-<span class="sourceLineNo">1321</span>            LOG.debug("Coprocessor bypassing balancer request");<a name="line.1321"></a>
-<span class="sourceLineNo">1322</span>            return false;<a name="line.1322"></a>
-<span class="sourceLineNo">1323</span>          }<a name="line.1323"></a>
-<span class="sourceLineNo">1324</span>        } catch (IOException ioe) {<a name="line.1324"></a>
-<span class="sourceLineNo">1325</span>          LOG.error("Error invoking master coprocessor preBalance()", ioe);<a name="line.1325"></a>
-<span class="sourceLineNo">1326</span>          return false;<a name="line.1326"></a>
-<span class="sourceLineNo">1327</span>        }<a name="line.1327"></a>
-<span class="sourceLineNo">1328</span>      }<a name="line.1328"></a>
-<span class="sourceLineNo">1329</span><a name="line.1329"></a>
-<span class="sourceLineNo">1330</span>      Map&lt;TableName, Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt;&gt; assignmentsByTable =<a name="line.1330"></a>
-<span class="sourceLineNo">1331</span>        this.assignmentManager.getRegionStates().getAssignmentsByTable();<a name="line.1331"></a>
+<span class="sourceLineNo">807</span>    if (this.balancer instanceof FavoredNodesPromoter) {<a name="line.807"></a>
+<span class="sourceLineNo">808</span>      favoredNodesManager = new FavoredNodesManager(this);<a name="line.808"></a>
+<span class="sourceLineNo">809</span>    }<a name="line.809"></a>
+<span class="sourceLineNo">810</span>    // Wait for regionserver to finish initialization.<a name="line.810"></a>
+<span class="sourceLineNo">811</span>    if (BaseLoadBalancer.tablesOnMaster(conf)) {<a name="line.811"></a>
+<span class="sourceLineNo">812</span>      waitForServerOnline();<a name="line.812"></a>
+<span class="sourceLineNo">813</span>    }<a name="line.813"></a>
+<span class="sourceLineNo">814</span><a name="line.814"></a>
+<span class="sourceLineNo">815</span>    //initialize load balancer<a name="line.815"></a>
+<span class="sourceLineNo">816</span>    this.balancer.setMasterServices(this);<a name="line.816"></a>
+<span class="sourceLineNo">817</span>    this.balancer.setClusterStatus(getClusterStatus());<a name="line.817"></a>
+<span class="sourceLineNo">818</span>    this.balancer.initialize();<a name="line.818"></a>
+<span class="sourceLineNo">819</span><a name="line.819"></a>
+<span class="sourceLineNo">820</span>    // Check if master is shutting down because of some issue<a name="line.820"></a>
+<span class="sourceLineNo">821</span>    // in initializing the regionserver or the balancer.<a name="line.821"></a>
+<span class="sourceLineNo">822</span>    if (isStopped()) return;<a name="line.822"></a>
+<span class="sourceLineNo">823</span><a name="line.823"></a>
+<span class="sourceLineNo">824</span>    // Make sure meta assigned before proceeding.<a name="line.824"></a>
+<span class="sourceLineNo">825</span>    status.setStatus("Assigning Meta Region");<a name="line.825"></a>
+<span class="sourceLineNo">826</span>    metaBootstrap.assignMeta();<a name="line.826"></a>
+<span class="sourceLineNo">827</span><a name="line.827"></a>
+<span class="sourceLineNo">828</span>    // check if master is shutting down because above assignMeta could return even hbase:meta isn't<a name="line.828"></a>
+<span class="sourceLineNo">829</span>    // assigned when master is shutting down<a name="line.829"></a>
+<span class="sourceLineNo">830</span>    if (isStopped()) return;<a name="line.830"></a>
+<span class="sourceLineNo">831</span><a name="line.831"></a>
+<span class="sourceLineNo">832</span>    //Initialize after meta as it scans meta<a name="line.832"></a>
+<span class="sourceLineNo">833</span>    if (favoredNodesManager != null) {<a name="line.833"></a>
+<span class="sourceLineNo">834</span>      SnapshotOfRegionAssignmentFromMeta snapshotOfRegionAssignment =<a name="line.834"></a>
+<span class="sourceLineNo">835</span>          new SnapshotOfRegionAssignmentFromMeta(getConnection());<a name="line.835"></a>
+<span class="sourceLineNo">836</span>      snapshotOfRegionAssignment.initialize();<a name="line.836"></a>
+<span class="sourceLineNo">837</span>      favoredNodesManager.initialize(snapshotOfRegionAssignment);<a name="line.837"></a>
+<span class="sourceLineNo">838</span>    }<a name="line.838"></a>
+<span class="sourceLineNo">839</span><a name="line.839"></a>
+<span class="sourceLineNo">840</span>    // migrating existent table state from zk, so splitters<a name="line.840"></a>
+<span class="sourceLineNo">841</span>    // and recovery process treat states properly.<a name="line.841"></a>
+<span class="sourceLineNo">842</span>    for (Map.Entry&lt;TableName, TableState.State&gt; entry : ZKDataMigrator<a name="line.842"></a>
+<span class="sourceLineNo">843</span>        .queryForTableStates(getZooKeeper()).entrySet()) {<a name="line.843"></a>
+<span class="sourceLineNo">844</span>      LOG.info("Converting state from zk to new states:" + entry);<a name="line.844"></a>
+<span class="sourceLineNo">845</span>      tableStateManager.setTableState(entry.getKey(), entry.getValue());<a name="line.845"></a>
+<span class="sourceLineNo">846</span>    }<a name="line.846"></a>
+<span class="sourceLineNo">847</span>    ZKUtil.deleteChildrenRecursively(getZooKeeper(), getZooKeeper().znodePaths.tableZNode);<a name="line.847"></a>
+<span class="sourceLineNo">848</span><a name="line.848"></a>
+<span class="sourceLineNo">849</span>    status.setStatus("Submitting log splitting work for previously failed region servers");<a name="line.849"></a>
+<span class="sourceLineNo">850</span>    metaBootstrap.processDeadServers();<a name="line.850"></a>
+<span class="sourceLineNo">851</span><a name="line.851"></a>
+<span class="sourceLineNo">852</span>    // Fix up assignment manager status<a name="line.852"></a>
+<span class="sourceLineNo">853</span>    status.setStatus("Starting assignment manager");<a name="line.853"></a>
+<span class="sourceLineNo">854</span>    this.assignmentManager.joinCluster();<a name="line.854"></a>
+<span class="sourceLineNo">855</span><a name="line.855"></a>
+<span class="sourceLineNo">856</span>    // set cluster status again after user regions are assigned<a name="line.856"></a>
+<span class="sourceLineNo">857</span>    this.balancer.setClusterStatus(getClusterStatus());<a name="line.857"></a>
+<span class="sourceLineNo">858</span><a name="line.858"></a>
+<span class="sourceLineNo">859</span>    // Start balancer and meta catalog janitor after meta and regions have been assigned.<a name="line.859"></a>
+<span class="sourceLineNo">860</span>    status.setStatus("Starting balancer and catalog janitor");<a name="line.860"></a>
+<span class="sourceLineNo">861</span>    this.clusterStatusChore = new ClusterStatusChore(this, balancer);<a name="line.861"></a>
+<span class="sourceLineNo">862</span>    getChoreService().scheduleChore(clusterStatusChore);<a name="line.862"></a>
+<span class="sourceLineNo">863</span>    this.balancerChore = new BalancerChore(this);<a name="line.863"></a>
+<span class="sourceLineNo">864</span>    getChoreService().scheduleChore(balancerChore);<a name="line.864"></a>
+<span class="sourceLineNo">865</span>    this.normalizerChore = new RegionNormalizerChore(this);<a name="line.865"></a>
+<span class="sourceLineNo">866</span>    getChoreService().scheduleChore(normalizerChore);<a name="line.866"></a>
+<span class="sourceLineNo">867</span>    this.catalogJanitorChore = new CatalogJanitor(this);<a name="line.867"></a>
+<span class="sourceLineNo">868</span>    getChoreService().scheduleChore(catalogJanitorChore);<a name="line.868"></a>
+<span class="sourceLineNo">869</span><a name="line.869"></a>
+<span class="sourceLineNo">870</span>    // Do Metrics periodically<a name="line.870"></a>
+<span class="sourceLineNo">871</span>    periodicDoMetricsChore = new PeriodicDoMetrics(msgInterval, this);<a name="line.871"></a>
+<span class="sourceLineNo">872</span>    getChoreService().scheduleChore(periodicDoMetricsChore);<a name="line.872"></a>
+<span class="sourceLineNo">873</span><a name="line.873"></a>
+<span class="sourceLineNo">874</span>    status.setStatus("Starting cluster schema service");<a name="line.874"></a>
+<span class="sourceLineNo">875</span>    initClusterSchemaService();<a name="line.875"></a>
+<span class="sourceLineNo">876</span><a name="line.876"></a>
+<span class="sourceLineNo">877</span>    if (this.cpHost != null) {<a name="line.877"></a>
+<span class="sourceLineNo">878</span>      try {<a name="line.878"></a>
+<span class="sourceLineNo">879</span>        this.cpHost.preMasterInitialization();<a name="line.879"></a>
+<span class="sourceLineNo">880</span>      } catch (IOException e) {<a name="line.880"></a>
+<span class="sourceLineNo">881</span>        LOG.error("Coprocessor preMasterInitialization() hook failed", e);<a name="line.881"></a>
+<span class="sourceLineNo">882</span>      }<a name="line.882"></a>
+<span class="sourceLineNo">883</span>    }<a name="line.883"></a>
+<span class="sourceLineNo">884</span><a name="line.884"></a>
+<span class="sourceLineNo">885</span>    status.markComplete("Initialization successful");<a name="line.885"></a>
+<span class="sourceLineNo">886</span>    LOG.info("Master has completed initialization");<a name="line.886"></a>
+<span class="sourceLineNo">887</span>    configurationManager.registerObserver(this.balancer);<a name="line.887"></a>
+<span class="sourceLineNo">888</span>    configurationManager.registerObserver(this.hfileCleaner);<a name="line.888"></a>
+<span class="sourceLineNo">889</span><a name="line.889"></a>
+<span class="sourceLineNo">890</span>    // Set master as 'initialized'.<a name="line.890"></a>
+<span class="sourceLineNo">891</span>    setInitialized(true);<a name="line.891"></a>
+<span class="sourceLineNo">892</span><a name="line.892"></a>
+<span class="sourceLineNo">893</span>    status.setStatus("Assign meta replicas");<a name="line.893"></a>
+<span class="sourceLineNo">894</span>    metaBootstrap.assignMetaReplicas();<a name="line.894"></a>
+<span class="sourceLineNo">895</span><a name="line.895"></a>
+<span class="sourceLineNo">896</span>    status.setStatus("Starting quota manager");<a name="line.896"></a>
+<span class="sourceLineNo">897</span>    initQuotaManager();<a name="line.897"></a>
+<span class="sourceLineNo">898</span><a name="line.898"></a>
+<span class="sourceLineNo">899</span>    // clear the dead servers with same host name and port of online server because we are not<a name="line.899"></a>
+<span class="sourceLineNo">900</span>    // removing dead server with same hostname and port of rs which is trying to check in before<a name="line.900"></a>
+<span class="sourceLineNo">901</span>    // master initialization. See HBASE-5916.<a name="line.901"></a>
+<span class="sourceLineNo">902</span>    this.serverManager.clearDeadServersWithSameHostNameAndPortOfOnlineServer();<a name="line.902"></a>
+<span class="sourceLineNo">903</span><a name="line.903"></a>
+<span class="sourceLineNo">904</span>    // Check and set the znode ACLs if needed in case we are overtaking a non-secure configuration<a name="line.904"></a>
+<span class="sourceLineNo">905</span>    status.setStatus("Checking ZNode ACLs");<a name="line.905"></a>
+<span class="sourceLineNo">906</span>    zooKeeper.checkAndSetZNodeAcls();<a name="line.906"></a>
+<span class="sourceLineNo">907</span><a name="line.907"></a>
+<span class="sourceLineNo">908</span>    status.setStatus("Initializing MOB Cleaner");<a name="line.908"></a>
+<span class="sourceLineNo">909</span>    initMobCleaner();<a name="line.909"></a>
+<span class="sourceLineNo">910</span><a name="line.910"></a>
+<span class="sourceLineNo">911</span>    status.setStatus("Calling postStartMaster coprocessors");<a name="line.911"></a>
+<span class="sourceLineNo">912</span>    if (this.cpHost != null) {<a name="line.912"></a>
+<span class="sourceLineNo">913</span>      // don't let cp initialization errors kill the master<a name="line.913"></a>
+<span class="sourceLineNo">914</span>      try {<a name="line.914"></a>
+<span class="sourceLineNo">915</span>        this.cpHost.postStartMaster();<a name="line.915"></a>
+<span class="sourceLineNo">916</span>      } catch (IOException ioe) {<a name="line.916"></a>
+<span class="sourceLineNo">917</span>        LOG.error("Coprocessor postStartMaster() hook failed", ioe);<a name="line.917"></a>
+<span class="sourceLineNo">918</span>      }<a name="line.918"></a>
+<span class="sourceLineNo">919</span>    }<a name="line.919"></a>
+<span class="sourceLineNo">920</span><a name="line.920"></a>
+<span class="sourceLineNo">921</span>    zombieDetector.interrupt();<a name="line.921"></a>
+<span class="sourceLineNo">922</span>  }<a name="line.922"></a>
+<span class="sourceLineNo">923</span><a name="line.923"></a>
+<span class="sourceLineNo">924</span>  private void initMobCleaner() {<a name="line.924"></a>
+<span class="sourceLineNo">925</span>    this.expiredMobFileCleanerChore = new ExpiredMobFileCleanerChore(this);<a name="line.925"></a>
+<span class="sourceLineNo">926</span>    getChoreService().scheduleChore(expiredMobFileCleanerChore);<a name="line.926"></a>
+<span class="sourceLineNo">927</span><a name="line.927"></a>
+<span class="sourceLineNo">928</span>    int mobCompactionPeriod = conf.getInt(MobConstants.MOB_COMPACTION_CHORE_PERIOD,<a name="line.928"></a>
+<span class="sourceLineNo">929</span>        MobConstants.DEFAULT_MOB_COMPACTION_CHORE_PERIOD);<a name="line.929"></a>
+<span class="sourceLineNo">930</span>    if (mobCompactionPeriod &gt; 0) {<a name="line.930"></a>
+<span class="sourceLineNo">931</span>      this.mobCompactChore = new MobCompactionChore(this, mobCompactionPeriod);<a name="line.931"></a>
+<span class="sourceLineNo">932</span>      getChoreService().scheduleChore(mobCompactChore);<a name="line.932"></a>
+<span class="sourceLineNo">933</span>    } else {<a name="line.933"></a>
+<span class="sourceLineNo">934</span>      LOG<a name="line.934"></a>
+<span class="sourceLineNo">935</span>        .info("The period is " + mobCompactionPeriod + " seconds, MobCompactionChore is disabled");<a name="line.935"></a>
+<span class="sourceLineNo">936</span>    }<a name="line.936"></a>
+<span class="sourceLineNo">937</span>    this.mobCompactThread = new MasterMobCompactionThread(this);<a name="line.937"></a>
+<span class="sourceLineNo">938</span>  }<a name="line.938"></a>
+<span class="sourceLineNo">939</span><a name="line.939"></a>
+<span class="sourceLineNo">940</span>  /**<a name="line.940"></a>
+<span class="sourceLineNo">941</span>   * Create a {@link MasterMetaBootstrap} instance.<a name="line.941"></a>
+<span class="sourceLineNo">942</span>   */<a name="line.942"></a>
+<span class="sourceLineNo">943</span>  MasterMetaBootstrap createMetaBootstrap(final HMaster master, final MonitoredTask status) {<a name="line.943"></a>
+<span class="sourceLineNo">944</span>    // We put this out here in a method so can do a Mockito.spy and stub it out<a name="line.944"></a>
+<span class="sourceLineNo">945</span>    // w/ a mocked up MasterMetaBootstrap.<a name="line.945"></a>
+<span class="sourceLineNo">946</span>    return new MasterMetaBootstrap(master, status);<a name="line.946"></a>
+<span class="sourceLineNo">947</span>  }<a name="line.947"></a>
+<span class="sourceLineNo">948</span><a name="line.948"></a>
+<span class="sourceLineNo">949</span>  /**<a name="line.949"></a>
+<span class="sourceLineNo">950</span>   * Create a {@link ServerManager} instance.<a name="line.950"></a>
+<span class="sourceLineNo">951</span>   */<a name="line.951"></a>
+<span class="sourceLineNo">952</span>  ServerManager createServerManager(final MasterServices master) throws IOException {<a name="line.952"></a>
+<span class="sourceLineNo">953</span>    // We put this out here in a method so can do a Mockito.spy and stub it out<a name="line.953"></a>
+<span class="sourceLineNo">954</span>    // w/ a mocked up ServerManager.<a name="line.954"></a>
+<span class="sourceLineNo">955</span>    setupClusterConnection();<a name="line.955"></a>
+<span class="sourceLineNo">956</span>    return new ServerManager(master);<a name="line.956"></a>
+<span class="sourceLineNo">957</span>  }<a name="line.957"></a>
+<span class="sourceLineNo">958</span><a name="line.958"></a>
+<span class="sourceLineNo">959</span>  private void waitForRegionServers(final MonitoredTask status)<a name="line.959"></a>
+<span class="sourceLineNo">960</span>      throws IOException, InterruptedException {<a name="line.960"></a>
+<span class="sourceLineNo">961</span>    this.serverManager.waitForRegionServers(status);<a name="line.961"></a>
+<span class="sourceLineNo">962</span>    // Check zk for region servers that are up but didn't register<a name="line.962"></a>
+<span class="sourceLineNo">963</span>    for (ServerName sn: this.regionServerTracker.getOnlineServers()) {<a name="line.963"></a>
+<span class="sourceLineNo">964</span>      // The isServerOnline check is opportunistic, correctness is handled inside<a name="line.964"></a>
+<span class="sourceLineNo">965</span>      if (!this.serverManager.isServerOnline(sn)<a name="line.965"></a>
+<span class="sourceLineNo">966</span>          &amp;&amp; serverManager.checkAndRecordNewServer(sn, ServerLoad.EMPTY_SERVERLOAD)) {<a name="line.966"></a>
+<span class="sourceLineNo">967</span>        LOG.info("Registered server found up in zk but who has not yet reported in: " + sn);<a name="line.967"></a>
+<span class="sourceLineNo">968</span>      }<a name="line.968"></a>
+<span class="sourceLineNo">969</span>    }<a name="line.969"></a>
+<span class="sourceLineNo">970</span>  }<a name="line.970"></a>
+<span class="sourceLineNo">971</span><a name="line.971"></a>
+<span class="sourceLineNo">972</span>  void initClusterSchemaService() throws IOException, InterruptedException {<a name="line.972"></a>
+<span class="sourceLineNo">973</span>    this.clusterSchemaService = new ClusterSchemaServiceImpl(this);<a name="line.973"></a>
+<span class="sourceLineNo">974</span>    this.clusterSchemaService.startAndWait();<a name="line.974"></a>
+<span class="sourceLineNo">975</span>    if (!this.clusterSchemaService.isRunning()) throw new HBaseIOException("Failed start");<a name="line.975"></a>
+<span class="sourceLineNo">976</span>  }<a name="line.976"></a>
+<span class="sourceLineNo">977</span><a name="line.977"></a>
+<span class="sourceLineNo">978</span>  void initQuotaManager() throws IOException {<a name="line.978"></a>
+<span class="sourceLineNo">979</span>    MasterQuotaManager quotaManager = new MasterQuotaManager(this);<a name="line.979"></a>
+<span class="sourceLineNo">980</span>    this.assignmentManager.setRegionStateListener((RegionStateListener)quotaManager);<a name="line.980"></a>
+<span class="sourceLineNo">981</span>    quotaManager.start();<a name="line.981"></a>
+<span class="sourceLineNo">982</span>    this.quotaManager = quotaManager;<a name="line.982"></a>
+<span class="sourceLineNo">983</span>  }<a name="line.983"></a>
+<span class="sourceLineNo">984</span><a name="line.984"></a>
+<span class="sourceLineNo">985</span>  boolean isCatalogJanitorEnabled() {<a name="line.985"></a>
+<span class="sourceLineNo">986</span>    return catalogJanitorChore != null ?<a name="line.986"></a>
+<span class="sourceLineNo">987</span>      catalogJanitorChore.getEnabled() : false;<a name="line.987"></a>
+<span class="sourceLineNo">988</span>  }<a name="line.988"></a>
+<span class="sourceLineNo">989</span><a name="line.989"></a>
+<span class="sourceLineNo">990</span>  boolean isCleanerChoreEnabled() {<a name="line.990"></a>
+<span class="sourceLineNo">991</span>    boolean hfileCleanerFlag = true, logCleanerFlag = true;<a name="line.991"></a>
+<span class="sourceLineNo">992</span><a name="line.992"></a>
+<span class="sourceLineNo">993</span>    if (hfileCleaner != null) {<a name="line.993"></a>
+<span class="sourceLineNo">994</span>      hfileCleanerFlag = hfileCleaner.getEnabled();<a name="line.994"></a>
+<span class="sourceLineNo">995</span>    }<a name="line.995"></a>
+<span class="sourceLineNo">996</span><a name="line.996"></a>
+<span class="sourceLineNo">997</span>    if (logCleaner != null) {<a name="line.997"></a>
+<span class="sourceLineNo">998</span>      logCleanerFlag = logCleaner.getEnabled();<a name="line.998"></a>
+<span class="sourceLineNo">999</span>    }<a name="line.999"></a>
+<span class="sourceLineNo">1000</span><a name="line.1000"></a>
+<span class="sourceLineNo">1001</span>    return (hfileCleanerFlag &amp;&amp; logCleanerFlag);<a name="line.1001"></a>
+<span class="sourceLineNo">1002</span>  }<a name="line.1002"></a>
+<span class="sourceLineNo">1003</span><a name="line.1003"></a>
+<span class="sourceLineNo">1004</span>  @Override<a name="line.1004"></a>
+<span class="sourceLineNo">1005</span>  public TableDescriptors getTableDescriptors() {<a name="line.1005"></a>
+<span class="sourceLineNo">1006</span>    return this.tableDescriptors;<a name="line.1006"></a>
+<span class="sourceLineNo">1007</span>  }<a name="line.1007"></a>
+<span class="sourceLineNo">1008</span><a name="line.1008"></a>
+<span class="sourceLineNo">1009</span>  @Override<a name="line.1009"></a>
+<span class="sourceLineNo">1010</span>  public ServerManager getServerManager() {<a name="line.1010"></a>
+<span class="sourceLineNo">1011</span>    return this.serverManager;<a name="line.1011"></a>
+<span class="sourceLineNo">1012</span>  }<a name="line.1012"></a>
+<span class="sourceLineNo">1013</span><a name="line.1013"></a>
+<span class="sourceLineNo">1014</span>  @Override<a name="line.1014"></a>
+<span class="sourceLineNo">1015</span>  public MasterFileSystem getMasterFileSystem() {<a name="line.1015"></a>
+<span class="sourceLineNo">1016</span>    return this.fileSystemManager;<a name="line.1016"></a>
+<span class="sourceLineNo">1017</span>  }<a name="line.1017"></a>
+<span class="sourceLineNo">1018</span><a name="line.1018"></a>
+<span class="sourceLineNo">1019</span>  @Override<a name="line.1019"></a>
+<span class="sourceLineNo">1020</span>  public MasterWalManager getMasterWalManager() {<a name="line.1020"></a>
+<span class="sourceLineNo">1021</span>    return this.walManager;<a name="line.1021"></a>
+<span class="sourceLineNo">1022</span>  }<a name="line.1022"></a>
+<span class="sourceLineNo">1023</span><a name="line.1023"></a>
+<span class="sourceLineNo">1024</span>  @Override<a name="line.1024"></a>
+<span class="sourceLineNo">1025</span>  public TableStateManager getTableStateManager() {<a name="line.1025"></a>
+<span class="sourceLineNo">1026</span>    return tableStateManager;<a name="line.1026"></a>
+<span class="sourceLineNo">1027</span>  }<a name="line.1027"></a>
+<span class="sourceLineNo">1028</span><a name="line.1028"></a>
+<span class="sourceLineNo">1029</span>  /*<a name="line.1029"></a>
+<span class="sourceLineNo">1030</span>   * Start up all services. If any of these threads gets an unhandled exception<a name="line.1030"></a>
+<span class="sourceLineNo">1031</span>   * then they just die with a logged message.  This should be fine because<a name="line.1031"></a>
+<span class="sourceLineNo">1032</span>   * in general, we do not expect the master to get such unhandled exceptions<a name="line.1032"></a>
+<span class="sourceLineNo">1033</span>   *  as OOMEs; it should be lightly loaded. See what HRegionServer does if<a name="line.1033"></a>
+<span class="sourceLineNo">1034</span>   *  need to install an unexpected exception handler.<a name="line.1034"></a>
+<span class="sourceLineNo">1035</span>   */<a name="line.1035"></a>
+<span class="sourceLineNo">1036</span>  private void startServiceThreads() throws IOException{<a name="line.1036"></a>
+<span class="sourceLineNo">1037</span>   // Start the executor service pools<a name="line.1037"></a>
+<span class="sourceLineNo">1038</span>   this.service.startExecutorService(ExecutorType.MASTER_OPEN_REGION,<a name="line.1038"></a>
+<span class="sourceLineNo">1039</span>      conf.getInt("hbase.master.executor.openregion.threads", 5));<a name="line.1039"></a>
+<span class="sourceLineNo">1040</span>   this.service.startExecutorService(ExecutorType.MASTER_CLOSE_REGION,<a name="line.1040"></a>
+<span class="sourceLineNo">1041</span>      conf.getInt("hbase.master.executor.closeregion.threads", 5));<a name="line.1041"></a>
+<span class="sourceLineNo">1042</span>   this.service.startExecutorService(ExecutorType.MASTER_SERVER_OPERATIONS,<a name="line.1042"></a>
+<span class="sourceLineNo">1043</span>      conf.getInt("hbase.master.executor.serverops.threads", 5));<a name="line.1043"></a>
+<span class="sourceLineNo">1044</span>   this.service.startExecutorService(ExecutorType.MASTER_META_SERVER_OPERATIONS,<a name="line.1044"></a>
+<span class="sourceLineNo">1045</span>      conf.getInt("hbase.master.executor.meta.serverops.threads", 5));<a name="line.1045"></a>
+<span class="sourceLineNo">1046</span>   this.service.startExecutorService(ExecutorType.M_LOG_REPLAY_OPS,<a name="line.1046"></a>
+<span class="sourceLineNo">1047</span>      conf.getInt("hbase.master.executor.logreplayops.threads", 10));<a name="line.1047"></a>
+<span class="sourceLineNo">1048</span><a name="line.1048"></a>
+<span class="sourceLineNo">1049</span>   // We depend on there being only one instan

<TRUNCATED>

Mime
View raw message