hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [15/25] hbase-site git commit: Published site at 9facfa550f1e7386be3a04d84f7e8013f5002965.
Date Sat, 01 Apr 2017 03:33:42 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/993199fc/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.PeriodicDoMetrics.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.PeriodicDoMetrics.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.PeriodicDoMetrics.html
index 99a5bb1..98b388b 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.PeriodicDoMetrics.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.PeriodicDoMetrics.html
@@ -893,2422 +893,2423 @@
 <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><a name="line.888"></a>
-<span class="sourceLineNo">889</span>    // Set master as 'initialized'.<a name="line.889"></a>
-<span class="sourceLineNo">890</span>    setInitialized(true);<a name="line.890"></a>
-<span class="sourceLineNo">891</span><a name="line.891"></a>
-<span class="sourceLineNo">892</span>    status.setStatus("Assign meta replicas");<a name="line.892"></a>
-<span class="sourceLineNo">893</span>    metaBootstrap.assignMetaReplicas();<a name="line.893"></a>
-<span class="sourceLineNo">894</span><a name="line.894"></a>
-<span class="sourceLineNo">895</span>    status.setStatus("Starting quota manager");<a name="line.895"></a>
-<span class="sourceLineNo">896</span>    initQuotaManager();<a name="line.896"></a>
-<span class="sourceLineNo">897</span><a name="line.897"></a>
-<span class="sourceLineNo">898</span>    // clear the dead servers with same host name and port of online server because we are not<a name="line.898"></a>
-<span class="sourceLineNo">899</span>    // removing dead server with same hostname and port of rs which is trying to check in before<a name="line.899"></a>
-<span class="sourceLineNo">900</span>    // master initialization. See HBASE-5916.<a name="line.900"></a>
-<span class="sourceLineNo">901</span>    this.serverManager.clearDeadServersWithSameHostNameAndPortOfOnlineServer();<a name="line.901"></a>
-<span class="sourceLineNo">902</span><a name="line.902"></a>
-<span class="sourceLineNo">903</span>    // Check and set the znode ACLs if needed in case we are overtaking a non-secure configuration<a name="line.903"></a>
-<span class="sourceLineNo">904</span>    status.setStatus("Checking ZNode ACLs");<a name="line.904"></a>
-<span class="sourceLineNo">905</span>    zooKeeper.checkAndSetZNodeAcls();<a name="line.905"></a>
-<span class="sourceLineNo">906</span><a name="line.906"></a>
-<span class="sourceLineNo">907</span>    status.setStatus("Initializing MOB Cleaner");<a name="line.907"></a>
-<span class="sourceLineNo">908</span>    initMobCleaner();<a name="line.908"></a>
-<span class="sourceLineNo">909</span><a name="line.909"></a>
-<span class="sourceLineNo">910</span>    status.setStatus("Calling postStartMaster coprocessors");<a name="line.910"></a>
-<span class="sourceLineNo">911</span>    if (this.cpHost != null) {<a name="line.911"></a>
-<span class="sourceLineNo">912</span>      // don't let cp initialization errors kill the master<a name="line.912"></a>
-<span class="sourceLineNo">913</span>      try {<a name="line.913"></a>
-<span class="sourceLineNo">914</span>        this.cpHost.postStartMaster();<a name="line.914"></a>
-<span class="sourceLineNo">915</span>      } catch (IOException ioe) {<a name="line.915"></a>
-<span class="sourceLineNo">916</span>        LOG.error("Coprocessor postStartMaster() hook failed", ioe);<a name="line.916"></a>
-<span class="sourceLineNo">917</span>      }<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>    zombieDetector.interrupt();<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>  private void initMobCleaner() {<a name="line.923"></a>
-<span class="sourceLineNo">924</span>    this.expiredMobFileCleanerChore = new ExpiredMobFileCleanerChore(this);<a name="line.924"></a>
-<span class="sourceLineNo">925</span>    getChoreService().scheduleChore(expiredMobFileCleanerChore);<a name="line.925"></a>
-<span class="sourceLineNo">926</span><a name="line.926"></a>
-<span class="sourceLineNo">927</span>    int mobCompactionPeriod = conf.getInt(MobConstants.MOB_COMPACTION_CHORE_PERIOD,<a name="line.927"></a>
-<span class="sourceLineNo">928</span>        MobConstants.DEFAULT_MOB_COMPACTION_CHORE_PERIOD);<a name="line.928"></a>
-<span class="sourceLineNo">929</span>    if (mobCompactionPeriod &gt; 0) {<a name="line.929"></a>
-<span class="sourceLineNo">930</span>      this.mobCompactChore = new MobCompactionChore(this, mobCompactionPeriod);<a name="line.930"></a>
-<span class="sourceLineNo">931</span>      getChoreService().scheduleChore(mobCompactChore);<a name="line.931"></a>
-<span class="sourceLineNo">932</span>    } else {<a name="line.932"></a>
-<span class="sourceLineNo">933</span>      LOG<a name="line.933"></a>
-<span class="sourceLineNo">934</span>        .info("The period is " + mobCompactionPeriod + " seconds, MobCompactionChore is disabled");<a name="line.934"></a>
-<span class="sourceLineNo">935</span>    }<a name="line.935"></a>
-<span class="sourceLineNo">936</span>    this.mobCompactThread = new MasterMobCompactionThread(this);<a name="line.936"></a>
-<span class="sourceLineNo">937</span>  }<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>   * Create a {@link MasterMetaBootstrap} instance.<a name="line.940"></a>
-<span class="sourceLineNo">941</span>   */<a name="line.941"></a>
-<span class="sourceLineNo">942</span>  MasterMetaBootstrap createMetaBootstrap(final HMaster master, final MonitoredTask status) {<a name="line.942"></a>
-<span class="sourceLineNo">943</span>    // We put this out here in a method so can do a Mockito.spy and stub it out<a name="line.943"></a>
-<span class="sourceLineNo">944</span>    // w/ a mocked up MasterMetaBootstrap.<a name="line.944"></a>
-<span class="sourceLineNo">945</span>    return new MasterMetaBootstrap(master, status);<a name="line.945"></a>
-<span class="sourceLineNo">946</span>  }<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>   * Create a {@link ServerManager} instance.<a name="line.949"></a>
-<span class="sourceLineNo">950</span>   */<a name="line.950"></a>
-<span class="sourceLineNo">951</span>  ServerManager createServerManager(final MasterServices master) throws IOException {<a name="line.951"></a>
-<span class="sourceLineNo">952</span>    // We put this out here in a method so can do a Mockito.spy and stub it out<a name="line.952"></a>
-<span class="sourceLineNo">953</span>    // w/ a mocked up ServerManager.<a name="line.953"></a>
-<span class="sourceLineNo">954</span>    setupClusterConnection();<a name="line.954"></a>
-<span class="sourceLineNo">955</span>    return new ServerManager(master);<a name="line.955"></a>
-<span class="sourceLineNo">956</span>  }<a name="line.956"></a>
-<span class="sourceLineNo">957</span><a name="line.957"></a>
-<span class="sourceLineNo">958</span>  private void waitForRegionServers(final MonitoredTask status)<a name="line.958"></a>
-<span class="sourceLineNo">959</span>      throws IOException, InterruptedException {<a name="line.959"></a>
-<span class="sourceLineNo">960</span>    this.serverManager.waitForRegionServers(status);<a name="line.960"></a>
-<span class="sourceLineNo">961</span>    // Check zk for region servers that are up but didn't register<a name="line.961"></a>
-<span class="sourceLineNo">962</span>    for (ServerName sn: this.regionServerTracker.getOnlineServers()) {<a name="line.962"></a>
-<span class="sourceLineNo">963</span>      // The isServerOnline check is opportunistic, correctness is handled inside<a name="line.963"></a>
-<span class="sourceLineNo">964</span>      if (!this.serverManager.isServerOnline(sn)<a name="line.964"></a>
-<span class="sourceLineNo">965</span>          &amp;&amp; serverManager.checkAndRecordNewServer(sn, ServerLoad.EMPTY_SERVERLOAD)) {<a name="line.965"></a>
-<span class="sourceLineNo">966</span>        LOG.info("Registered server found up in zk but who has not yet reported in: " + sn);<a name="line.966"></a>
-<span class="sourceLineNo">967</span>      }<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>  void initClusterSchemaService() throws IOException, InterruptedException {<a name="line.971"></a>
-<span class="sourceLineNo">972</span>    this.clusterSchemaService = new ClusterSchemaServiceImpl(this);<a name="line.972"></a>
-<span class="sourceLineNo">973</span>    this.clusterSchemaService.startAndWait();<a name="line.973"></a>
-<span class="sourceLineNo">974</span>    if (!this.clusterSchemaService.isRunning()) throw new HBaseIOException("Failed start");<a name="line.974"></a>
-<span class="sourceLineNo">975</span>  }<a name="line.975"></a>
-<span class="sourceLineNo">976</span><a name="line.976"></a>
-<span class="sourceLineNo">977</span>  void initQuotaManager() throws IOException {<a name="line.977"></a>
-<span class="sourceLineNo">978</span>    MasterQuotaManager quotaManager = new MasterQuotaManager(this);<a name="line.978"></a>
-<span class="sourceLineNo">979</span>    this.assignmentManager.setRegionStateListener((RegionStateListener)quotaManager);<a name="line.979"></a>
-<span class="sourceLineNo">980</span>    quotaManager.start();<a name="line.980"></a>
-<span class="sourceLineNo">981</span>    this.quotaManager = quotaManager;<a name="line.981"></a>
-<span class="sourceLineNo">982</span>  }<a name="line.982"></a>
-<span class="sourceLineNo">983</span><a name="line.983"></a>
-<span class="sourceLineNo">984</span>  boolean isCatalogJanitorEnabled() {<a name="line.984"></a>
-<span class="sourceLineNo">985</span>    return catalogJanitorChore != null ?<a name="line.985"></a>
-<span class="sourceLineNo">986</span>      catalogJanitorChore.getEnabled() : false;<a name="line.986"></a>
-<span class="sourceLineNo">987</span>  }<a name="line.987"></a>
-<span class="sourceLineNo">988</span><a name="line.988"></a>
-<span class="sourceLineNo">989</span>  boolean isCleanerChoreEnabled() {<a name="line.989"></a>
-<span class="sourceLineNo">990</span>    boolean hfileCleanerFlag = true, logCleanerFlag = true;<a name="line.990"></a>
-<span class="sourceLineNo">991</span><a name="line.991"></a>
-<span class="sourceLineNo">992</span>    if (hfileCleaner != null) {<a name="line.992"></a>
-<span class="sourceLineNo">993</span>      hfileCleanerFlag = hfileCleaner.getEnabled();<a name="line.993"></a>
-<span class="sourceLineNo">994</span>    }<a name="line.994"></a>
-<span class="sourceLineNo">995</span><a name="line.995"></a>
-<span class="sourceLineNo">996</span>    if (logCleaner != null) {<a name="line.996"></a>
-<span class="sourceLineNo">997</span>      logCleanerFlag = logCleaner.getEnabled();<a name="line.997"></a>
-<span class="sourceLineNo">998</span>    }<a name="line.998"></a>
-<span class="sourceLineNo">999</span><a name="line.999"></a>
-<span class="sourceLineNo">1000</span>    return (hfileCleanerFlag &amp;&amp; logCleanerFlag);<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>  @Override<a name="line.1003"></a>
-<span class="sourceLineNo">1004</span>  public TableDescriptors getTableDescriptors() {<a name="line.1004"></a>
-<span class="sourceLineNo">1005</span>    return this.tableDescriptors;<a name="line.1005"></a>
-<span class="sourceLineNo">1006</span>  }<a name="line.1006"></a>
-<span class="sourceLineNo">1007</span><a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>  @Override<a name="line.1008"></a>
-<span class="sourceLineNo">1009</span>  public ServerManager getServerManager() {<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span>    return this.serverManager;<a name="line.1010"></a>
-<span class="sourceLineNo">1011</span>  }<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span><a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>  @Override<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>  public MasterFileSystem getMasterFileSystem() {<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span>    return this.fileSystemManager;<a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>  }<a name="line.1016"></a>
-<span class="sourceLineNo">1017</span><a name="line.1017"></a>
-<span class="sourceLineNo">1018</span>  @Override<a name="line.1018"></a>
-<span class="sourceLineNo">1019</span>  public MasterWalManager getMasterWalManager() {<a name="line.1019"></a>
-<span class="sourceLineNo">1020</span>    return this.walManager;<a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>  }<a name="line.1021"></a>
-<span class="sourceLineNo">1022</span><a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>  @Override<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>  public TableStateManager getTableStateManager() {<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span>    return tableStateManager;<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>  }<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>   * Start up all services. If any of these threads gets an unhandled exception<a name="line.1029"></a>
-<span class="sourceLineNo">1030</span>   * then they just die with a logged message.  This should be fine because<a name="line.1030"></a>
-<span class="sourceLineNo">1031</span>   * in general, we do not expect the master to get such unhandled exceptions<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span>   *  as OOMEs; it should be lightly loaded. See what HRegionServer does if<a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>   *  need to install an unexpected exception handler.<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span>   */<a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>  private void startServiceThreads() throws IOException{<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span>   // Start the executor service pools<a name="line.1036"></a>
-<span class="sourceLineNo">1037</span>   this.service.startExecutorService(ExecutorType.MASTER_OPEN_REGION,<a name="line.1037"></a>
-<span class="sourceLineNo">1038</span>      conf.getInt("hbase.master.executor.openregion.threads", 5));<a name="line.1038"></a>
-<span class="sourceLineNo">1039</span>   this.service.startExecutorService(ExecutorType.MASTER_CLOSE_REGION,<a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>      conf.getInt("hbase.master.executor.closeregion.threads", 5));<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span>   this.service.startExecutorService(ExecutorType.MASTER_SERVER_OPERATIONS,<a name="line.1041"></a>
-<span class="sourceLineNo">1042</span>      conf.getInt("hbase.master.executor.serverops.threads", 5));<a name="line.1042"></a>
-<span class="sourceLineNo">1043</span>   this.service.startExecutorService(ExecutorType.MASTER_META_SERVER_OPERATIONS,<a name="line.1043"></a>
-<span class="sourceLineNo">1044</span>      conf.getInt("hbase.master.executor.meta.serverops.threads", 5));<a name="line.1044"></a>
-<span class="sourceLineNo">1045</span>   this.service.startExecutorService(ExecutorType.M_LOG_REPLAY_OPS,<a name="line.1045"></a>
-<span class="sourceLineNo">1046</span>      conf.getInt("hbase.master.executor.logreplayops.threads", 10));<a name="line.1046"></a>
-<span class="sourceLineNo">1047</span><a name="line.1047"></a>
-<span class="sourceLineNo">1048</span>   // We depend on there being only one instance of this executor running<a name="line.1048"></a>
-<span class="sourceLineNo">1049</span>   // at a time.  To do concurrency, would need fencing of enable/disable of<a name="line.1049"></a>
-<span class="sourceLineNo">1050</span>   // tables.<a name="line.1050"></a>
-<span class="sourceLineNo">1051</span>   // Any time changing this maxThreads to &gt; 1, pls see the comment at<a name="line.1051"></a>
-<span class="sourceLineNo">1052</span>   // AccessController#postCompletedCreateTableAction<a name="line.1052"></a>
-<span class="sourceLineNo">1053</span>   this.service.startExecutorService(ExecutorType.MASTER_TABLE_OPERATIONS, 1);<a name="line.1053"></a>
-<span class="sourceLineNo">1054</span>   startProcedureExecutor();<a name="line.1054"></a>
-<span class="sourceLineNo">1055</span><a name="line.1055"></a>
-<span class="sourceLineNo">1056</span>   // Start log cleaner thread<a name="line.1056"></a>
-<span class="sourceLineNo">1057</span>   int cleanerInterval = conf.getInt("hbase.master.cleaner.interval", 60 * 1000);<a name="line.1057"></a>
-<span class="sourceLineNo">1058</span>   this.logCleaner =<a name="line.1058"></a>
-<span class="sourceLineNo">1059</span>      new LogCleaner(cleanerInterval,<a name="line.1059"></a>
-<span class="sourceLineNo">1060</span>         this, conf, getMasterWalManager().getFileSystem(),<a name="line.1060"></a>
-<span class="sourceLineNo">1061</span>         getMasterWalManager().getOldLogDir());<a name="line.1061"></a>
-<span class="sourceLineNo">1062</span>    getChoreService().scheduleChore(logCleaner);<a name="line.1062"></a>
-<span class="sourceLineNo">1063</span><a name="line.1063"></a>
-<span class="sourceLineNo">1064</span>   //start the hfile archive cleaner thread<a name="line.1064"></a>
-<span class="sourceLineNo">1065</span>    Path archiveDir = HFileArchiveUtil.getArchivePath(conf);<a name="line.1065"></a>
-<span class="sourceLineNo">1066</span>    Map&lt;String, Object&gt; params = new HashMap&lt;&gt;();<a name="line.1066"></a>
-<span class="sourceLineNo">1067</span>    params.put(MASTER, this);<a name="line.1067"></a>
-<span class="sourceLineNo">1068</span>    this.hfileCleaner = new HFileCleaner(cleanerInterval, this, conf, getMasterFileSystem()<a name="line.1068"></a>
-<span class="sourceLineNo">1069</span>        .getFileSystem(), archiveDir, params);<a name="line.1069"></a>
-<span class="sourceLineNo">1070</span>    getChoreService().scheduleChore(hfileCleaner);<a name="line.1070"></a>
-<span class="sourceLineNo">1071</span>    serviceStarted = true;<a name="line.1071"></a>
-<span class="sourceLineNo">1072</span>    if (LOG.isTraceEnabled()) {<a name="line.1072"></a>
-<span class="sourceLineNo">1073</span>      LOG.trace("Started service threads");<a name="line.1073"></a>
-<span class="sourceLineNo">1074</span>    }<a name="line.1074"></a>
-<span class="sourceLineNo">1075</span><a name="line.1075"></a>
-<span class="sourceLineNo">1076</span>    // Start replication zk node cleaner<a name="line.1076"></a>
-<span class="sourceLineNo">1077</span>    if (conf.getClass("hbase.region.replica.replication.replicationQueues.class",<a name="line.1077"></a>
-<span class="sourceLineNo">1078</span>      ReplicationFactory.defaultReplicationQueueClass) == ReplicationQueuesZKImpl.class) {<a name="line.1078"></a>
-<span class="sourceLineNo">1079</span>      try {<a name="line.1079"></a>
-<span class="sourceLineNo">1080</span>        replicationZKNodeCleanerChore = new ReplicationZKNodeCleanerChore(this, cleanerInterval,<a name="line.1080"></a>
-<span class="sourceLineNo">1081</span>            new ReplicationZKNodeCleaner(this.conf, this.getZooKeeper(), this));<a name="line.1081"></a>
-<span class="sourceLineNo">1082</span>        getChoreService().scheduleChore(replicationZKNodeCleanerChore);<a name="line.1082"></a>
-<span class="sourceLineNo">1083</span>      } catch (Exception e) {<a name="line.1083"></a>
-<span class="sourceLineNo">1084</span>        LOG.error("start replicationZKNodeCleanerChore failed", e);<a name="line.1084"></a>
-<span class="sourceLineNo">1085</span>      }<a name="line.1085"></a>
-<span class="sourceLineNo">1086</span>    }<a name="line.1086"></a>
-<span class="sourceLineNo">1087</span>    replicationMetaCleaner = new ReplicationMetaCleaner(this, this, cleanerInterval);<a name="line.1087"></a>
-<span class="sourceLineNo">1088</span>    getChoreService().scheduleChore(replicationMetaCleaner);<a name="line.1088"></a>
-<span class="sourceLineNo">1089</span>  }<a name="line.1089"></a>
-<span class="sourceLineNo">1090</span><a name="line.1090"></a>
-<span class="sourceLineNo">1091</span>  @Override<a name="line.1091"></a>
-<span class="sourceLineNo">1092</span>  protected void sendShutdownInterrupt() {<a name="line.1092"></a>
-<span class="sourceLineNo">1093</span>    super.sendShutdownInterrupt();<a name="line.1093"></a>
-<span class="sourceLineNo">1094</span>    stopProcedureExecutor();<a name="line.1094"></a>
-<span class="sourceLineNo">1095</span>  }<a name="line.1095"></a>
-<span class="sourceLineNo">1096</span><a name="line.1096"></a>
-<span class="sourceLineNo">1097</span>  @Override<a name="line.1097"></a>
-<span class="sourceLineNo">1098</span>  protected void stopServiceThreads() {<a name="line.1098"></a>
-<span class="sourceLineNo">1099</span>    if (masterJettyServer != null) {<a name="line.1099"></a>
-<span class="sourceLineNo">1100</span>      LOG.info("Stopping master jetty server");<a name="line.1100"></a>
-<span class="sourceLineNo">1101</span>      try {<a name="line.1101"></a>
-<span class="sourceLineNo">1102</span>        masterJettyServer.stop();<a name="line.1102"></a>
-<span class="sourceLineNo">1103</span>      } catch (Exception e) {<a name="line.1103"></a>
-<span class="sourceLineNo">1104</span>        LOG.error("Failed to stop master jetty server", e);<a name="line.1104"></a>
-<span class="sourceLineNo">1105</span>      }<a name="line.1105"></a>
-<span class="sourceLineNo">1106</span>    }<a name="line.1106"></a>
-<span class="sourceLineNo">1107</span>    super.stopServiceThreads();<a name="line.1107"></a>
-<span class="sourceLineNo">1108</span>    stopChores();<a name="line.1108"></a>
-<span class="sourceLineNo">1109</span><a name="line.1109"></a>
-<span class="sourceLineNo">1110</span>    // Wait for all the remaining region servers to report in IFF we were<a name="line.1110"></a>
-<span class="sourceLineNo">1111</span>    // running a cluster shutdown AND we were NOT aborting.<a name="line.1111"></a>
-<span class="sourceLineNo">1112</span>    if (!isAborted() &amp;&amp; this.serverManager != null &amp;&amp;<a name="line.1112"></a>
-<span class="sourceLineNo">1113</span>        this.serverManager.isClusterShutdown()) {<a name="line.1113"></a>
-<span class="sourceLineNo">1114</span>      this.serverManager.letRegionServersShutdown();<a name="line.1114"></a>
-<span class="sourceLineNo">1115</span>    }<a name="line.1115"></a>
-<span class="sourceLineNo">1116</span>    if (LOG.isDebugEnabled()) {<a name="line.1116"></a>
-<span class="sourceLineNo">1117</span>      LOG.debug("Stopping service threads");<a name="line.1117"></a>
-<span class="sourceLineNo">1118</span>    }<a name="line.1118"></a>
-<span class="sourceLineNo">1119</span>    // Clean up and close up shop<a name="line.1119"></a>
-<span class="sourceLineNo">1120</span>    if (this.logCleaner != null) this.logCleaner.cancel(true);<a name="line.1120"></a>
-<span class="sourceLineNo">1121</span>    if (this.hfileCleaner != null) this.hfileCleaner.cancel(true);<a name="line.1121"></a>
-<span class="sourceLineNo">1122</span>    if (this.replicationZKNodeCleanerChore != null) this.replicationZKNodeCleanerChore.cancel(true);<a name="line.1122"></a>
-<span class="sourceLineNo">1123</span>    if (this.replicationMetaCleaner != null) this.replicationMetaCleaner.cancel(true);<a name="line.1123"></a>
-<span class="sourceLineNo">1124</span>    if (this.quotaManager != null) this.quotaManager.stop();<a name="line.1124"></a>
-<span class="sourceLineNo">1125</span>    if (this.activeMasterManager != null) this.activeMasterManager.stop();<a name="line.1125"></a>
-<span class="sourceLineNo">1126</span>    if (this.serverManager != null) this.serverManager.stop();<a name="line.1126"></a>
-<span class="sourceLineNo">1127</span>    if (this.assignmentManager != null) this.assignmentManager.stop();<a name="line.1127"></a>
-<span class="sourceLineNo">1128</span>    if (this.walManager != null) this.walManager.stop();<a name="line.1128"></a>
-<span class="sourceLineNo">1129</span>    if (this.fileSystemManager != null) this.fileSystemManager.stop();<a name="line.1129"></a>
-<span class="sourceLineNo">1130</span>    if (this.mpmHost != null) this.mpmHost.stop("server shutting down.");<a name="line.1130"></a>
-<span class="sourceLineNo">1131</span>  }<a name="line.1131"></a>
-<span class="sourceLineNo">1132</span><a name="line.1132"></a>
-<span class="sourceLineNo">1133</span>  private void startProcedureExecutor() throws IOException {<a name="line.1133"></a>
-<span class="sourceLineNo">1134</span>    final MasterProcedureEnv procEnv = new MasterProcedureEnv(this);<a name="line.1134"></a>
-<span class="sourceLineNo">1135</span>    final Path walDir = new Path(FSUtils.getWALRootDir(this.conf),<a name="line.1135"></a>
-<span class="sourceLineNo">1136</span>        MasterProcedureConstants.MASTER_PROCEDURE_LOGDIR);<a name="line.1136"></a>
-<span class="sourceLineNo">1137</span><a name="line.1137"></a>
-<span class="sourceLineNo">1138</span>    procedureStore = new WALProcedureStore(conf, walDir.getFileSystem(conf), walDir,<a name="line.1138"></a>
-<span class="sourceLineNo">1139</span>        new MasterProcedureEnv.WALStoreLeaseRecovery(this));<a name="line.1139"></a>
-<span class="sourceLineNo">1140</span>    procedureStore.registerListener(new MasterProcedureEnv.MasterProcedureStoreListener(this));<a name="line.1140"></a>
-<span class="sourceLineNo">1141</span>    procedureExecutor = new ProcedureExecutor(conf, procEnv, procedureStore,<a name="line.1141"></a>
-<span class="sourceLineNo">1142</span>        procEnv.getProcedureScheduler());<a name="line.1142"></a>
-<span class="sourceLineNo">1143</span>    configurationManager.registerObserver(procEnv);<a name="line.1143"></a>
-<span class="sourceLineNo">1144</span><a name="line.1144"></a>
-<span class="sourceLineNo">1145</span>    final int numThreads = conf.getInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS,<a name="line.1145"></a>
-<span class="sourceLineNo">1146</span>        Math.max(Runtime.getRuntime().availableProcessors(),<a name="line.1146"></a>
-<span class="sourceLineNo">1147</span>          MasterProcedureConstants.DEFAULT_MIN_MASTER_PROCEDURE_THREADS));<a name="line.1147"></a>
-<span class="sourceLineNo">1148</span>    final boolean abortOnCorruption = conf.getBoolean(<a name="line.1148"></a>
-<span class="sourceLineNo">1149</span>        MasterProcedureConstants.EXECUTOR_ABORT_ON_CORRUPTION,<a name="line.1149"></a>
-<span class="sourceLineNo">1150</span>        MasterProcedureConstants.DEFAULT_EXECUTOR_ABORT_ON_CORRUPTION);<a name="line.1150"></a>
-<span class="sourceLineNo">1151</span>    procedureStore.start(numThreads);<a name="line.1151"></a>
-<span class="sourceLineNo">1152</span>    procedureExecutor.start(numThreads, abortOnCorruption);<a name="line.1152"></a>
-<span class="sourceLineNo">1153</span>  }<a name="line.1153"></a>
-<span class="sourceLineNo">1154</span><a name="line.1154"></a>
-<span class="sourceLineNo">1155</span>  private void stopProcedureExecutor() {<a name="line.1155"></a>
-<span class="sourceLineNo">1156</span>    if (procedureExecutor != null) {<a name="line.1156"></a>
-<span class="sourceLineNo">1157</span>      configurationManager.deregisterObserver(procedureExecutor.getEnvironment());<a name="line.1157"></a>
-<span class="sourceLineNo">1158</span>      procedureExecutor.stop();<a name="line.1158"></a>
-<span class="sourceLineNo">1159</span>    }<a name="line.1159"></a>
-<span class="sourceLineNo">1160</span><a name="line.1160"></a>
-<span class="sourceLineNo">1161</span>    if (procedureStore != null) {<a name="line.1161"></a>
-<span class="sourceLineNo">1162</span>      procedureStore.stop(isAborted());<a name="line.1162"></a>
-<span class="sourceLineNo">1163</span>    }<a name="line.1163"></a>
-<span class="sourceLineNo">1164</span>  }<a name="line.1164"></a>
-<span class="sourceLineNo">1165</span><a name="line.1165"></a>
-<span class="sourceLineNo">1166</span>  private void stopChores() {<a name="line.1166"></a>
-<span class="sourceLineNo">1167</span>    if (this.expiredMobFileCleanerChore != null) {<a name="line.1167"></a>
-<span class="sourceLineNo">1168</span>      this.expiredMobFileCleanerChore.cancel(true);<a name="line.1168"></a>
-<span class="sourceLineNo">1169</span>    }<a name="line.1169"></a>
-<span class="sourceLineNo">1170</span>    if (this.mobCompactChore != null) {<a name="line.1170"></a>
-<span class="sourceLineNo">1171</span>      this.mobCompactChore.cancel(true);<a name="line.1171"></a>
-<span class="sourceLineNo">1172</span>    }<a name="line.1172"></a>
-<span class="sourceLineNo">1173</span>    if (this.balancerChore != null) {<a name="line.1173"></a>
-<span class="sourceLineNo">1174</span>      this.balancerChore.cancel(true);<a name="line.1174"></a>
-<span class="sourceLineNo">1175</span>    }<a name="line.1175"></a>
-<span class="sourceLineNo">1176</span>    if (this.normalizerChore != null) {<a name="line.1176"></a>
-<span class="sourceLineNo">1177</span>      this.normalizerChore.cancel(true);<a name="line.1177"></a>
-<span class="sourceLineNo">1178</span>    }<a name="line.1178"></a>
-<span class="sourceLineNo">1179</span>    if (this.clusterStatusChore != null) {<a name="line.1179"></a>
-<span class="sourceLineNo">1180</span>      this.clusterStatusChore.cancel(true);<a name="line.1180"></a>
-<span class="sourceLineNo">1181</span>    }<a name="line.1181"></a>
-<span class="sourceLineNo">1182</span>    if (this.catalogJanitorChore != null) {<a name="line.1182"></a>
-<span class="sourceLineNo">1183</span>      this.catalogJanitorChore.cancel(true);<a name="line.1183"></a>
-<span class="sourceLineNo">1184</span>    }<a name="line.1184"></a>
-<span class="sourceLineNo">1185</span>    if (this.clusterStatusPublisherChore != null){<a name="line.1185"></a>
-<span class="sourceLineNo">1186</span>      clusterStatusPublisherChore.cancel(true);<a name="line.1186"></a>
-<span class="sourceLineNo">1187</span>    }<a name="line.1187"></a>
-<span class="sourceLineNo">1188</span>    if (this.mobCompactThread != null) {<a name="line.1188"></a>
-<span class="sourceLineNo">1189</span>      this.mobCompactThread.close();<a name="line.1189"></a>
-<span class="sourceLineNo">1190</span>    }<a name="line.1190"></a>
-<span class="sourceLineNo">1191</span><a name="line.1191"></a>
-<span class="sourceLineNo">1192</span>    if (this.periodicDoMetricsChore != null) {<a name="line.1192"></a>
-<span class="sourceLineNo">1193</span>      periodicDoMetricsChore.cancel();<a name="line.1193"></a>
-<span class="sourceLineNo">1194</span>    }<a name="line.1194"></a>
-<span class="sourceLineNo">1195</span>  }<a name="line.1195"></a>
-<span class="sourceLineNo">1196</span><a name="line.1196"></a>
-<span class="sourceLineNo">1197</span>  /**<a name="line.1197"></a>
-<span class="sourceLineNo">1198</span>   * @return Get remote side's InetAddress<a name="line.1198"></a>
-<span class="sourceLineNo">1199</span>   */<a name="line.1199"></a>
-<span class="sourceLineNo">1200</span>  InetAddress getRemoteInetAddress(final int port,<a name="line.1200"></a>
-<span class="sourceLineNo">1201</span>      final long serverStartCode) throws UnknownHostException {<a name="line.1201"></a>
-<span class="sourceLineNo">1202</span>    // Do it out here in its own little method so can fake an address when<a name="line.1202"></a>
-<span class="sourceLineNo">1203</span>    // mocking up in tests.<a name="line.1203"></a>
-<span class="sourceLineNo">1204</span>    InetAddress ia = RpcServer.getRemoteIp();<a name="line.1204"></a>
-<span class="sourceLineNo">1205</span><a name="line.1205"></a>
-<span class="sourceLineNo">1206</span>    // The call could be from the local regionserver,<a name="line.1206"></a>
-<span class="sourceLineNo">1207</span>    // in which case, there is no remote address.<a name="line.1207"></a>
-<span class="sourceLineNo">1208</span>    if (ia == null &amp;&amp; serverStartCode == startcode) {<a name="line.1208"></a>
-<span class="sourceLineNo">1209</span>      InetSocketAddress isa = rpcServices.getSocketAddress();<a name="line.1209"></a>
-<span class="sourceLineNo">1210</span>      if (isa != null &amp;&amp; isa.getPort() == port) {<a name="line.1210"></a>
-<span class="sourceLineNo">1211</span>        ia = isa.getAddress();<a name="line.1211"></a>
-<span class="sourceLineNo">1212</span>      }<a name="line.1212"></a>
-<span class="sourceLineNo">1213</span>    }<a name="line.1213"></a>
-<span class="sourceLineNo">1214</span>    return ia;<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>  /**<a name="line.1217"></a>
-<span class="sourceLineNo">1218</span>   * @return Maximum time we should run balancer for<a name="line.1218"></a>
-<span class="sourceLineNo">1219</span>   */<a name="line.1219"></a>
-<span class="sourceLineNo">1220</span>  private int getMaxBalancingTime() {<a name="line.1220"></a>
-<span class="sourceLineNo">1221</span>    int maxBalancingTime = getConfiguration().getInt(HConstants.HBASE_BALANCER_MAX_BALANCING, -1);<a name="line.1221"></a>
-<span class="sourceLineNo">1222</span>    if (maxBalancingTime == -1) {<a name="line.1222"></a>
-<span class="sourceLineNo">1223</span>      // if max balancing time isn't set, defaulting it to period time<a name="line.1223"></a>
-<span class="sourceLineNo">1224</span>      maxBalancingTime = getConfiguration().getInt(HConstants.HBASE_BALANCER_PERIOD,<a name="line.1224"></a>
-<span class="sourceLineNo">1225</span>        HConstants.DEFAULT_HBASE_BALANCER_PERIOD);<a name="line.1225"></a>
-<span class="sourceLineNo">1226</span>    }<a name="line.1226"></a>
-<span class="sourceLineNo">1227</span>    return maxBalancingTime;<a name="line.1227"></a>
-<span class="sourceLineNo">1228</span>  }<a name="line.1228"></a>
-<span class="sourceLineNo">1229</span><a name="line.1229"></a>
-<span class="sourceLineNo">1230</span>  /**<a name="line.1230"></a>
-<span class="sourceLineNo">1231</span>   * @return Maximum number of regions in transition<a name="line.1231"></a>
-<span class="sourceLineNo">1232</span>   */<a name="line.1232"></a>
-<span class="sourceLineNo">1233</span>  private int getMaxRegionsInTransition() {<a name="line.1233"></a>
-<span class="sourceLineNo">1234</span>    int numRegions = this.assignmentManager.getRegionStates().getRegionAssignments().size();<a name="line.1234"></a>
-<span class="sourceLineNo">1235</span>    return Math.max((int) Math.floor(numRegions * this.maxRitPercent), 1);<a name="line.1235"></a>
-<span class="sourceLineNo">1236</span>  }<a name="line.1236"></a>
-<span class="sourceLineNo">1237</span><a name="line.1237"></a>
-<span class="sourceLineNo">1238</span>  /**<a name="line.1238"></a>
-<span class="sourceLineNo">1239</span>   * It first sleep to the next balance plan start time. Meanwhile, throttling by the max<a name="line.1239"></a>
-<span class="sourceLineNo">1240</span>   * number regions in transition to protect availability.<a name="line.1240"></a>
-<span class="sourceLineNo">1241</span>   * @param nextBalanceStartTime The next balance plan start time<a name="line.1241"></a>
-<span class="sourceLineNo">1242</span>   * @param maxRegionsInTransition max number of regions in transition<a name="line.1242"></a>
-<span class="sourceLineNo">1243</span>   * @param cutoffTime when to exit balancer<a name="line.1243"></a>
-<span class="sourceLineNo">1244</span>   */<a name="line.1244"></a>
-<span class="sourceLineNo">1245</span>  private void balanceThrottling(long nextBalanceStartTime, int maxRegionsInTransition,<a name="line.1245"></a>
-<span class="sourceLineNo">1246</span>      long cutoffTime) {<a name="line.1246"></a>
-<span class="sourceLineNo">1247</span>    boolean interrupted = false;<a name="line.1247"></a>
-<span class="sourceLineNo">1248</span><a name="line.1248"></a>
-<span class="sourceLineNo">1249</span>    // Sleep to next balance plan start time<a name="line.1249"></a>
-<span class="sourceLineNo">1250</span>    // But if there are zero regions in transition, it can skip sleep to speed up.<a name="line.1250"></a>
-<span class="sourceLineNo">1251</span>    while (!interrupted &amp;&amp; System.currentTimeMillis() &lt; nextBalanceStartTime<a name="line.1251"></a>
-<span class="sourceLineNo">1252</span>        &amp;&amp; this.assignmentManager.getRegionStates().getRegionsInTransitionCount() != 0) {<a name="line.1252"></a>
-<span class="sourceLineNo">1253</span>      try {<a name="line.1253"></a>
-<span class="sourceLineNo">1254</span>        Thread.sleep(100);<a name="line.1254"></a>
-<span class="sourceLineNo">1255</span>      } catch (InterruptedException ie) {<a name="line.1255"></a>
-<span class="sourceLineNo">1256</span>        interrupted = true;<a name="line.1256"></a>
-<span class="sourceLineNo">1257</span>      }<a name="line.1257"></a>
-<span class="sourceLineNo">1258</span>    }<a name="line.1258"></a>
-<span class="sourceLineNo">1259</span><a name="line.1259"></a>
-<span class="sourceLineNo">1260</span>    // Throttling by max number regions in transition<a name="line.1260"></a>
-<span class="sourceLineNo">1261</span>    while (!interrupted<a name="line.1261"></a>
-<span class="sourceLineNo">1262</span>        &amp;&amp; maxRegionsInTransition &gt; 0<a name="line.1262"></a>
-<span class="sourceLineNo">1263</span>        &amp;&amp; this.assignmentManager.getRegionStates().getRegionsInTransitionCount()<a name="line.1263"></a>
-<span class="sourceLineNo">1264</span>        &gt;= maxRegionsInTransition &amp;&amp; System.currentTimeMillis() &lt;= cutoffTime) {<a name="line.1264"></a>
-<span class="sourceLineNo">1265</span>      try {<a name="line.1265"></a>
-<span class="sourceLineNo">1266</span>        // sleep if the number of regions in transition exceeds the limit<a name="line.1266"></a>
-<span class="sourceLineNo">1267</span>        Thread.sleep(100);<a name="line.1267"></a>
-<span class="sourceLineNo">1268</span>      } catch (InterruptedException ie) {<a name="line.1268"></a>
-<span class="sourceLineNo">1269</span>        interrupted = true;<a name="line.1269"></a>
-<span class="sourceLineNo">1270</span>      }<a name="line.1270"></a>
-<span class="sourceLineNo">1271</span>    }<a name="line.1271"></a>
-<span class="sourceLineNo">1272</span><a name="line.1272"></a>
-<span class="sourceLineNo">1273</span>    if (interrupted) Thread.currentThread().interrupt();<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>  public boolean balance() throws IOException {<a name="line.1276"></a>
-<span class="sourceLineNo">1277</span>    return balance(false);<a name="line.1277"></a>
-<span class="sourceLineNo">1278</span>  }<a name="line.1278"></a>
-<span class="sourceLineNo">1279</span><a name="line.1279"></a>
-<span class="sourceLineNo">1280</span>  public boolean balance(boolean force) throws IOException {<a name="line.1280"></a>
-<span class="sourceLineNo">1281</span>    // if master not initialized, don't run balancer.<a name="line.1281"></a>
-<span class="sourceLineNo">1282</span>    if (!isInitialized()) {<a name="line.1282"></a>
-<span class="sourceLineNo">1283</span>      LOG.debug("Master has not been initialized, don't run balancer.");<a name="line.1283"></a>
-<span class="sourceLineNo">1284</span>      return false;<a name="line.1284"></a>
-<span class="sourceLineNo">1285</span>    }<a name="line.1285"></a>
-<span class="sourceLineNo">1286</span><a name="line.1286"></a>
-<span class="sourceLineNo">1287</span>    if (isInMaintenanceMode()) {<a name="line.1287"></a>
-<span class="sourceLineNo">1288</span>      LOG.info("Master is in maintenanceMode mode, don't run balancer.");<a name="line.1288"></a>
-<span class="sourceLineNo">1289</span>      return false;<a name="line.1289"></a>
-<span class="sourceLineNo">1290</span>    }<a name="line.1290"></a>
-<span class="sourceLineNo">1291</span><a name="line.1291"></a>
-<span class="sourceLineNo">1292</span>    int maxRegionsInTransition = getMaxRegionsInTransition();<a name="line.1292"></a>
-<span class="sourceLineNo">1293</span>    synchronized (this.balancer) {<a name="line.1293"></a>
-<span class="sourceLineNo">1294</span>      // If balance not true, don't run balancer.<a name="line.1294"></a>
-<span class="sourceLineNo">1295</span>      if (!this.loadBalancerTracker.isBalancerOn()) return false;<a name="line.1295"></a>
-<span class="sourceLineNo">1296</span>      // Only allow one balance run at at time.<a name="line.1296"></a>
-<span class="sourceLineNo">1297</span>      if (this.assignmentManager.getRegionStates().isRegionsInTransition()) {<a name="line.1297"></a>
-<span class="sourceLineNo">1298</span>        Set&lt;RegionState&gt; regionsInTransition =<a name="line.1298"></a>
-<span class="sourceLineNo">1299</span>          this.assignmentManager.getRegionStates().getRegionsInTransition();<a name="line.1299"></a>
-<span class="sourceLineNo">1300</span>        // if hbase:meta region is in transition, result of assignment cannot be recorded<a name="line.1300"></a>
-<span class="sourceLineNo">1301</span>        // ignore the force flag in that case<a name="line.1301"></a>
-<span class="sourceLineNo">1302</span>        boolean metaInTransition = assignmentManager.getRegionStates().isMetaRegionInTransition();<a name="line.1302"></a>
-<span class="sourceLineNo">1303</span>        String prefix = force &amp;&amp; !metaInTransition ? "R" : "Not r";<a name="line.1303"></a>
-<span class="sourceLineNo">1304</span>        LOG.debug(prefix + "unning balancer because " + regionsInTransition.size() +<a name="line.1304"></a>
-<span class="sourceLineNo">1305</span>          " region(s) in transition: " + org.apache.commons.lang.StringUtils.<a name="line.1305"></a>
-<span class="sourceLineNo">1306</span>            abbreviate(regionsInTransition.toString(), 256));<a name="line.1306"></a>
-<span class="sourceLineNo">1307</span>        if (!force || metaInTransition) return false;<a name="line.1307"></a>
-<span class="sourceLineNo">1308</span>      }<a name="line.1308"></a>
-<span class="sourceLineNo">1309</span>      if (this.serverManager.areDeadServersInProgress()) {<a name="line.1309"></a>
-<span class="sourceLineNo">1310</span>        LOG.debug("Not running balancer because processing dead regionserver(s): " +<a name="line.1310"></a>
-<span class="sourceLineNo">1311</span>          this.serverManager.getDeadServers());<a name="line.1311"></a>
-<span class="sourceLineNo">1312</span>        return false;<a name="line.1312"></a>
-<span class="sourceLineNo">1313</span>      }<a name="line.1313"></a>
-<span class="sourceLineNo">1314</span><a name="line.1314"></a>
-<span class="sourceLineNo">1315</span>      if (this.cpHost != null) {<a name="line.1315"></a>
-<span class="sourceLineNo">1316</span>        try {<a name="line.1316"></a>
-<span class="sourceLineNo">1317</span>          if (this.cpHost.preBalance()) {<a name="line.1317"></a>
-<span class="sourceLineNo">1318</span>            LOG.debug("Coprocessor bypassing balancer request");<a name="line.1318"></a>
-<span class="sourceLineNo">1319</span>            return false;<a name="line.1319"></a>
-<span class="sourceLineNo">1320</span>          }<a name="line.1320"></a>
-<span class="sourceLineNo">1321</span>        } catch (IOException ioe) {<a name="line.1321"></a>
-<span class="sourceLineNo">1322</span>          LOG.error("Error invoking master coprocessor preBalance()", ioe);<a name="line.1322"></a>
-<span class="sourceLineNo">1323</span>          return false;<a name="line.1323"></a>
-<span class="sourceLineNo">1324</span>        }<a name="line.1324"></a>
-<span class="sourceLineNo">1325</span>      }<a name="line.1325"></a>
-<span class="sourceLineNo">1326</span><a name="line.1326"></a>
-<span class="sourceLineNo">1327</span>      Map&lt;TableName, Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt;&gt; assignmentsByTable =<a name="line.1327"></a>
-<span class="sourceLineNo">1328</span>        this.assignmentManager.getRegionStates().getAssignmentsByTable();<a name="line.1328"></a>
-<span class="sourceLineNo">1329</span><a name="line.1329"></a>
-<span class="sourceLineNo">1330</span>      List&lt;RegionPlan&gt; plans = new ArrayList&lt;&gt;();<a name="line.1330"></a>
-<span class="sourceLineNo">1331</span><a name="line.1331"></a>
-<span class="sourceLineNo">1332</span>      //Give the balancer the current cluster state.<a name="line.1332"></a>
-<span class="sourceLineNo">1333</span>      this.balancer.setClusterStatus(getClusterStatus());<a name="line.1333"></a>
-<span class="sourceLineNo">1334</span>      this.balancer.setClusterLoad(<a name="line.1334"></a>
-<span class="sourceLineNo">1335</span>              this.assignmentManager.getRegionStates().getAssignmentsByTable(true));<a name="line.1335"></a>
-<span class="sourceLineNo">1336</span><a name="line.1336"></a>
-<span class="sourceLineNo">1337</span>      for (Entry&lt;TableName, Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt;&gt; e : assignmentsByTable.entrySet()) {<a name="line.1337"></a>
-<span class="sourceLineNo">1338</span>        List&lt;RegionPlan&gt; partialPlans = this.balancer.balanceCluster(e.getKey(), e.getValue());<a name="line.1338"></a>
-<span class="sourceLineNo">1339</span>        if (partialPlans != null) plans.addAll(partialPlans);<a name="line.1339"></a>
-<span class="sourceLineNo">1340</span>      }<a name="line.1340"></a>
-<span class="sourceLineNo">1341</span><a name="line.1341"></a>
-<span class="sourceLineNo">1342</span>      long balanceStartTime = System.currentTimeMillis();<a name="line.1342"></a>
-<span class="sourceLineNo">1343</span>      long cutoffTime = balanceStartTime + this.maxBlancingTime;<a name="line.1343"></a>
-<span class="sourceLineNo">1344</span>      int rpCount = 0;  // number of RegionPlans balanced so far<a name="line.1344"></a>
-<span class="sourceLineNo">1345</span>      if (plans != null &amp;&amp; !plans.isEmpty()) {<a name="line.1345"></a>
-<span class="sourceLineNo">1346</span>        int balanceInterval = this.maxBlancingTime / plans.size();<a name="line.1346"></a>
-<span class="sourceLineNo">1347</span>        LOG.info("Balancer plans size is " + plans.size() + ", the balance interval is "<a name="line.1347"></a>
-<span class="sourceLineNo">1348</span>            + balanceInterval + " ms, and the max number regions in transition is "<a name="line.1348"></a>
-<span class="sourceLineNo">1349</span>            + maxRegionsInTransition);<a name="line.1349"></a>
-<span class="sourceLineNo">1350</span><a name="line.1350"></a>
-<span class="sourceLineNo">1351</span>        for (RegionPlan plan: plans) {<a name="line.1351"></a>
-<span class="sourceLineNo">1352</span>          LOG.info("balance " + plan);<a name="line.1352"></a>
-<span class="sourceLineNo">1353</span>          //TODO: bulk assign<a name="line.1353"></a>
-<span class="sourceLineNo">1354</span>          this.assignmentManager.balance(plan);<a name="line.1354"></a>
-<span class="sourceLineNo">1355</span>          rpCount++;<a name="line.1355"></a>
-<span class="sourceLineNo">1356</span><a name="line.1356"></a>
-<span class="sourceLineNo">1357</span>          balanceThrottling(balanceStartTime + rpCount * balanceInterval, maxRegionsInTransition,<a name="line.1357"></a>
-<span class="sourceLineNo">1358</span>            cutoffTime);<a name="line.1358"></a>
-<span class="sourceLineNo">1359</span><a name="line.1359"></a>
-<span class="sourceLineNo">1360</span>          // if performing next balance exceeds cutoff time, exit the loop<a name="line.1360"></a>
-<span class="sourceLineNo">1361</span>          if (rpCount &lt; plans.size() &amp;&amp; System.currentTimeMillis() &gt; cutoffTime) {<a name="line.1361"></a>
-<span class="sourceLineNo">1362</span>            // TODO: After balance, there should not be a cutoff time (keeping it as<a name="line.1362"></a>
-<span class="sourceLineNo">1363</span>            // a security net for now)<a name="line.1363"></a>
-<span class="sourceLineNo">1364</span>            LOG.debug("No more balancing till next balance run; maxBalanceTime="<a name="line.1364"></a>
-<span class="sourceLineNo">1365</span>                + this.maxBlancingTime);<a name="line.1365"></a>
-<span class="sourceLineNo">1366</span>            break;<a name="line.1366"></a>
-<span class="sourceLineNo">1367</span>          }<a name="line.1367"></a>
-<span class="sourceLineNo">1368</span>        }<a name="line.1368"></a>
-<span class="sourceLineNo">1369</span>      }<a name="line.1369"></a>
-<span class="sourceLineNo">1370</span><a name="line.1370"></a>
-<span class="sourceLineNo">1371</span>      if (this.cpHost != null) {<a name="line.1371"></a>
-<span class="sourceLineNo">1372</span>        try {<a name="line.1372"></a>
-<span class="sourceLineNo">1373</span>          this.cpHost.postBalance(rpCount &lt; plans.size() ? plans.subList(0, rpCount) : plans);<a name="line.1373"></a>
-<span class="sourceLineNo">1374</span>        } catch (IOException ioe) {<a name="line.1374"></a>
-<span class="sourceLineNo">1375</span>          // balancing already succeeded so don't change the result<a name="line.1375"></a>
-<span class="sourceLineNo">1376</span>          LOG.error("Error invoking master coprocessor postBalance()", ioe);<a name="line.1376"></a>
-<span class="sourceLineNo">1377</span>        }<a name="line.1377"></a>
-<span class="sourceLineNo">1378</span>      }<a name="line.1378"></a>
-<span class="sourceLineNo">1379</span>    }<a name="line.1379"></a>
-<span class="sourceLineNo">1380</span>    // If LoadBalancer did not generate any plans, it means the cluster is already balanced.<a name="line.1380"></a>
-<span class="sourceLineNo">1381</span>    // Return true indicating a success.<a name="line.1381"></a>
-<span class="sourceLineNo">1382</span>    return true;<a name="line.1382"></a>
-<span class="sourceLineNo">1383</span>  }<a name="line.1383"></a>
-<span class="sourceLineNo">1384</span><a name="line.1384"></a>
-<span class="sourceLineNo">1385</span>  @Override<a name="line.1385"></a>
-<span class="sourceLineNo">1386</span>  @VisibleForTesting<a name="line.1386"></a>
-<span class="sourceLineNo">1387</span>  public RegionNormalizer getRegionNormalizer() {<a name="line.1387"></a>
-<span class="sourceLineNo">1388</span>    return this.normalizer;<a name="line.1388"></a>
-<span class="sourceLineNo">1389</span>  }<a name="line.1389"></a>
-<span class="sourceLineNo">1390</span><a name="line.1390"></a>
-<span class="sourceLineNo">1391</span>  /**<a name="line.1391"></a>
-<span class="sourceLineNo">1392</span>   * Perform normalization of cluster (invoked by {@link RegionNormalizerChore}).<a name="line.1392"></a>
-<span class="sourceLineNo">1393</span>   *<a name="line.1393"></a>
-<span class="sourceLineNo">1394</span>   * @return true if normalization step was performed successfully, false otherwise<a name="line.1394"></a>
-<span class="sourceLineNo">1395</span>   *    (specifically, if HMaster hasn't been initialized properly or normalization<a name="line.1395"></a>
-<span class="sourceLineNo">1396</span>   *    is globally disabled)<a name="line.1396"></a>
-<span class="sourceLineNo">1397</span>   */<a name="line.1397"></a>
-<span class="sourceLineNo">1398</span>  public boolean normalizeRegions() throws IOException {<a name="line.1398"></a>
-<span class="sourceLineNo">1399</span>    if (!isInitialized()) {<a name="line.1399"></a>
-<span class="sourceLineNo">1400</span>      LOG.debug("Master has not been initialized, don't run region normalizer.");<a name="line.1400"></a>
-<span class="sourceLineNo">1401</span>      return false;<a name="line.1401"></a>
-<span class="sourceLineNo">1402</span>    }<a name="line.1402"></a>
-<span class="sourceLineNo">1403</span><a name="line.1403"></a>
-<span class="sourceLineNo">1404</span>    if (isInMaintenanceMode()) {<a name="line.1404"></a>
-<span class="sourceLineNo">1405</span>      LOG.info("Master is in maintenance mode, don't run region normalizer.");<a name="line.1405"></a>
-<span class="sourceLineNo">1406</span>      return false;<a name="line.1406"></a>
-<span class="sourceLineNo">1407</span>    }<a name="line.1407"></a>
-<span class="sourceLineNo">1408</span><a name="line.1408"></a>
-<span class="sourceLineNo">1409</span>    if (!this.regionNormalizerTracker.isNormalizerOn()) {<a name="line.1409"></a>
-<span class="sourceLineNo">1410</span>      LOG.debug("Region normalization is disabled, don't run region normalizer.");<a name="line.1410"></a>
-<span class="sourceLineNo">1411</span>      return false;<a name="line.1411"></a>
-<span class="sourceLineNo">1412</span>    }<a name="line.1412"></a>
-<span class="sourceLineNo">1413</span><a name="line.1413"></a>
-<span class="sourceLineNo">1414</span>    synchronized (this.normalizer) {<a name="line.1414"></a>
-<span class="sourceLineNo">1415</span>      // Don't run the normalizer concurrently<a name="line.1415"></a>
-<span class="sourceLineNo">1416</span>      List&lt;TableName&gt; allEnabledTables = new ArrayList&lt;&gt;(<a name="line.1416"></a>
-<span class="sourceLineNo">1417</span>        this.tableStateManager.getTablesInStates(TableState.State.ENABLED));<a name="line.1417"></a>
-<span class="sourceLineNo">1418</span><a name="line.1418"></a>
-<span class="sourceLineNo">1419</span>      Collections.shuffle(allEnabledTables);<a name="line.1419"></a>
-<span class="sourceLineNo">1420</span><a name="line.1420"></a>
-<span class="sourceLineNo">1421</span>      for (TableName table : allEnabledTables) {<a name="line.1421"></a>
-<span class="sourceLineNo">1422</span>        if (isInMaintenanceMode()) {<a name="line.1422"></a>
-<span class="sourceLineNo">1423</span>          LOG.debug("Master is in maintenance mode, stop running region normalizer.");<a name="line.1423"></a>
-<span class="sourceLineNo">1424</span>          return false;<a name="line.1424"></a>
-<span class="sourceLineNo">1425</span>        }<a name="line.1425"></a>
-<span class="sourceLineNo">1426</span><a name="line.1426"></a>
-<span class="sourceLineNo">1427</span>        HTableDescriptor tblDesc = getTableDescriptors().get(table);<a name="line.1427"></a>
-<span class="sourceLineNo">1428</span>        if (table.isSystemTable() || (tblDesc != null &amp;&amp;<a name="line.1428"></a>
-<span class="sourceLineNo">1429</span>            !tblDesc.isNormalizationEnabled())) {<a name="line.1429"></a>
-<span class="sourceLineNo">1430</span>          LOG.debug("Skipping normalization for table: " + table + ", as it's either system"<a name="line.1430"></a>
-<span class="sourceLineNo">1431</span>              + " table or doesn't have auto normalization turned on");<a name="line.1431"></a>
-<span class="sourceLineNo">1432</span>          continue;<a name="line.1432"></a>
-<span class="sourceLineNo">1433</span>        }<a name="line.1433"></a>
-<span class="sourceLineNo">1434</span>        List&lt;NormalizationPlan&gt; plans = this.normalizer.computePlanForTable(table);<a name="line.1434"></a>
-<span class="sourceLineNo">1435</span>        if (plans != null) {<a name="line.1435"></a>
-<span class="sourceLineNo">1436</span>          for (NormalizationPlan plan : plans) {<a name="line.1436"></a>
-<span class="sourceLineNo">1437</span>            plan.execute(clusterConnection.getAdmin());<a name="line.1437"></a>
-<span class="sourceLineNo">1438</span>            if (plan.getType() == PlanType.SPLIT) {<a name="line.1438"></a>
-<span class="sourceLineNo">1439</span>              splitPlanCount++;<a name="line.1439"></a>
-<span class="sourceLineNo">1440</span>            } else if (plan.getType() == PlanType.MERGE) {<a name="line.1440"></a>
-<span class="sourceLineNo">1441</span>              mergePlanCount++;<a name="line.1441"></a>
-<span class="sourceLineNo">1442</span>            }<a name="line.1442"></a>
-<span class="sourceLineNo">1443</span>          }<a name="line.1443"></a>
-<span class="sourceLineNo">1444</span>        }<a name="line.1444"></a>
-<span class="sourceLineNo">1445</span>      }<a name="line.1445"></a>
-<span class="sourceLineNo">1446</span>    }<a name="line.1446"></a>
-<span class="sourceLineNo">1447</span>    // If Region did not generate any plans, it means the cluster is already balanced.<a name="line.1447"></a>
-<span class="sourceLineNo">1448</span>    // Return true indicating a success.<a name="line.1448"></a>
-<span class="sourceLineNo">1449</span>    return true;<a name="line.1449"></a>
-<span class="sourceLineNo">1450</span>  }<a name="line.1450"></a>
-<span class="sourceLineNo">1451</span><a name="line.1451"></a>
-<span class="sourceLineNo">1452</span>  /**<a name="line.1452"></a>
-<span class="sourceLineNo">1453</span>   * @return Client info for use as prefix on an audit log string; who did an action<a name="line.1453"></a>
-<span class="sourceLineNo">1454</span>   */<a name="line.1454"></a>
-<span class="sourceLineNo">1455</span>  String getClientIdAuditPrefix() {<a name="line.1455"></a>
-<span class="sourceLineNo">1456</span>    return "Client=" + RpcServer.getRequestUserName() + "/" + RpcServer.getRemoteAddress();<a name="line.1456"></a>
-<span class="sourceLineNo">1457</span>  }<a name="line.1457"></a>
-<span class="sourceLineNo">1458</span><a name="line.1458"></a>
-<span class="sourceLineNo">1459</span>  /**<a name="line.1459"></a>
-<span class="sourceLineNo">1460</span>   * Switch for the background CatalogJanitor thread.<a name="line.1460"></a>
-<span class="sourceLineNo">1461</span>   * Used for testing.  The thread will continue to run.  It will just be a noop<a name="line.1461"></a>
-<span class="sourceLineNo">1462</span>   * if disabled.<a name="line.1462"></a>
-<span class="sourceLineNo">1463</span>   * @param b If false, the catalog janitor won't do anything.<a name="line.1463"></a>
-<span class="sourceLineNo">1464</span>   */<a name="line.1464"></a>
-<span class="sourceLineNo">1465</span>  public void setCatalogJanitorEnabled(final boolean b) {<a name="line.1465"></a>
-<span class="sourceLineNo">1466</span>    this.catalogJanitorChore.setEnabled(b);<a name="line.1466"></a>
-<span class="sourceLineNo">1467</span>  }<a name="line.1467"></a>
-<span class="sourceLineNo">1468</span><a name="line.1468"></a>
-<span class="sourceLineNo">1469</span>  @Override<a name="line.1469"></a>
-<span class="sourceLineNo">1470</span>  public long mergeRegions(<a name="line.1470"></a>
-<span class="sourceLineNo">1471</span>      final HRegionInfo[] regionsToMerge,<a name="line.1471"></a>
-<span class="sourceLineNo">1472</span>      final boolean forcible,<a name="line.1472"></a>
-<span class="sourceLineNo">1473</span>      final long nonceGroup,<a name="line.1473"></a>
-<span class="sourceLineNo">1474</span>      final long nonce) throws IOException {<a name="line.1474"></a>
-<span class="sourceLineNo">1475</span>    checkInitialized();<a name="line.1475"></a>
-<span class="sourceLineNo">1476</span><a name="line.1476"></a>
-<span class="sourceLineNo">1477</span>    assert(regionsToMerge.length == 2);<a name="line.1477"></a>
-<span class="sourceLineNo">1478</span><a name="line.1478"></a>
-<span class="sourceLineNo">1479</span>    TableName tableName = regionsToMerge[0].getTable();<a name="line.1479"></a>
-<span class="sourceLineNo">1480</span>    if (tableName == null || regionsToMerge[1].getTable() == null) {<a name="line.1480"></a>
-<span class="sourceLineNo">1481</span>      throw new UnknownRegionException ("Can't merge regions without table associated");<a name="line.1481"></a>
-<span class="sourceLineNo">1482</span>    }<a name="line.1482"></a>
-<span class="sourceLineNo">1483</span><a name="line.1483"></a>
-<span class="sourceLineNo">1484</span>    if (!tableName.equals(regionsToMerge[1].getTable())) {<a name="line.1484"></a>
-<span class="sourceLineNo">1485</span>      throw new IOException (<a name="line.1485"></a>
-<span class="sourceLineNo">1486</span>        "Cannot merge regions from two different tables " + regionsToMerge[0].getTable()<a name="line.1486"></a>
-<span class="sourceLineNo">1487</span>        + " and " + regionsToMerge[1].getTable());<a name="line.1487"></a>
-<span class="sourceLineNo">1488</span>    }<a name="line.1488"></a>
-<span class="sourceLineNo">1489</span><a name="line.1489"></a>
-<span class="sourceLineNo">1490</span>    if (regionsToMerge[0].compareTo(regionsToMerge[1]) == 0) {<a name="line.1490"></a>
-<span class="sourceLineNo">1491</span>      throw new MergeRegionException(<a name="line.1491"></a>
-<span class="sourceLineNo">1492</span>        "Cannot merge a region to itself " + regionsToMerge[0] + ", " + regionsToMerge[1]);<a name="line.1492"></a>
-<span class="sourceLineNo">1493</span>    }<a name="line.1493"></a>
-<span class="sourceLineNo">1494</span><a name="line.1494"></a>
-<span class="sourceLineNo">1495</span>    return MasterProcedureUtil.submitProcedure(<a name="line.1495"></a>
-<span class="sourceLineNo">1496</span>        new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {<a name="line.1496"></a>
-<span class="sourceLineNo">1497</span>      @Override<a name="line.1497"></a>
-<span class="sourceLineNo">1498</span>      protected void run() throws IOException {<a name="line.1498"></a>
-<span class="sourceLineNo">1499</span>        getMaster().getMasterCoprocessorHost().preMergeRegions(regionsToMerge);<a name="line.1499"></a>
-<span class="sourceLineNo">1500</span><a name="line.1500"></a>
-<span class="sourceLineNo">1501</span>        LOG.info(getClientIdAuditPrefix() + " Merge regions " +<a name="line.1501"></a>
-<span class="sourceLineNo">1502</span>          regionsToMerge[0].getEncodedName() + " and " + regionsToMerge[1].getEncodedName());<a name="line.1502"></a>
-<span class="sourceLineNo">1503</span><a name="line.1503"></a>
-<span class="sourceLineNo">1504</span>        submitProcedure(new MergeTableRegionsProcedure(procedureExecutor.getEnvironment(),<a name="line.1504"></a>
-<span class="sourceLineNo">1505</span>          regionsToMerge, forcible));<a name="line.1505"></a>
-<span class="sourceLineNo">1506</span><a name="line.1506"></a>
-<span class="sourceLineNo">1507</span>        getMaster().getMasterCoprocessorHost().postMergeRegions(regionsToMerge);<a name="line.1507"></a>
-<span class="sourceLineNo">1508</span>      }<a name="line.1508"></a>
-<span class="sourceLineNo">1509</span><a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>      @Override<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>      protected String getDescription() {<a name="line.1511"></a>
-<span class="sourceLineNo">1512</span>        return "DisableTableProcedure";<a name="line.1512"></a>
-<span class="sourceLineNo">1513</span>      }<a name="line.1513"></a>
-<span class="sourceLineNo">1514</span>    });<a name="line.1514"></a>
-<span class="sourceLineNo">1515</span>  }<a name="line.1515"></a>
-<span class="sourceLineNo">1516</span><a name="line.1516"></a>
-<span class="sourceLineNo">1517</span>  @Override<a name="line.1517"></a>
-<span class="sourceLineNo">1518</span>  public long splitRegion(<a name="line.1518"></a>
-<span class="sourceLineNo">1519</span>      final HRegionInfo regionInfo,<a name="line.1519"></a>
-<span class="sourceLineNo">1520</span>      final byte[] splitRow,<a name="line.1520"></a>
-<span class="sourceLineNo">1521</span>      final long nonceGroup,<a name="line.1521"></a>
-<span class="sourceLineNo">1522</span>      final long nonce) throws IOException {<a name="line.1522"></a>
-<span class="sourceLineNo">1523</span>    checkInitialized();<a name="line.1523"></a>
-<span class="sourceLineNo">1524</span><a name="line.1524"></a>
-<span class="sourceLineNo">1525</span>    return MasterProcedureUtil.submitProcedure(<a name="line.1525"></a>
-<span class="sourceLineNo">1526</span>        new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {<a name="line.1526"></a>
-<span class="sourceLineNo">1527</span>      @Override<a name="line.1527"></a>
-<span class="sourceLineNo">1528</span>      protected void run() throws IOException {<a name="line.1528"></a>
-<span class="sourceLineNo">1529</span>        getMaster().getMasterCoprocessorHost().preSplitRegion(regionInfo.getTable(), splitRow);<a name="line.1529"></a>
-<span class="sourceLineNo">1530</span><a name="line.1530"></a>
-<span class="sourceLineNo">1531</span>        LOG.info(getClientIdAuditPrefix() + " Split region " + regionInfo);<a name="line.1531"></a>
-<span class="sourceLineNo">1532</span><a name="line.1532"></a>
-<span class="sourceLineNo">1533</span>        // Execute the operation asynchronously<a name="line.1533"></a>
-<span class="sourceLineNo">1534</span>        submitProcedure(new SplitTableRegionProcedure(procedureExecutor.getEnvironment(),<a name="line.1534"></a>
-<span class="sourceLineNo">1535</span>            regionInfo, splitRow));<a name="line.1535"></a>
-<span class="sourceLineNo">1536</span>      }<a name="line.1536"></a>
-<span class="sourceLineNo">1537</span><a name="line.1537"></a>
-<span class="sourceLineNo">1538</span>      @Override<a name="line.1538"></a>
-<span class="sourceLineNo">1539</span>      protected String getDescription() {<a name="line.1539"></a>
-<span class="sourceLineNo">1540</span>        return "DisableTableProcedure";<a name="line.1540"></a>
-<span class="sourceLineNo">1541</span>      }<a name="line.1541"></a>
-<span class="sourceLineNo">1542</span>    });<a name="line.1542"></a>
-<span class="sourceLineNo">1543</span>  }<a name="line.1543"></a>
-<span class="sourceLineNo">1544</span><a name="line.1544"></a>
-<span class="sourceLineNo">1545</span>  @VisibleForTesting // Public so can be accessed by tests.<a name="line.1545"></a>
-<span class="sourceLineNo">1546</span>  public void move(final byte[] encodedRegionName,<a name="line.1546"></a>
-<span class="sourceLineNo">1547</span>      final byte[] destServerName) throws HBaseIOException {<a name="line.1547"></a>
-<span class="sourceLineNo">1548</span>    RegionState regionState = assignmentManager.getRegionStates().<a name="line.1548"></a>
-<span class="sourceLineNo">1549</span>      getRegionState(Bytes.toString(encodedRegionName));<a name="line.1549"></a>
-<span class="sourceLineNo">1550</span><a name="line.1550"></a>
-<span class="sourceLineNo">1551</span>    HRegionInfo hri;<a name="line.1551"></a>
-<span class="sourceLineNo">1552</span>    if (regionState != null) {<a name="line.1552"></a>
-<span class="sourceLineNo">1553</span>      hri = regionState.getRegion();<a name="line.1553"></a>
-<span class="sourceLineNo">1554</span>    } else {<a name="line.1554"></a>
-<span class="sourceLineNo">1555</span>      throw new UnknownRegionException(Bytes.toStringBinary(encodedRegionName));<a name="line.1555"></a>
-<span class="sourceLineNo">1556</span>    }<a name="line.1556"></a>
-<span class="sourceLineNo">1557</span><a name="line.1557"></a>
-<span class="sourceLineNo">1558</span>    ServerName dest;<a name="line.1558"></a>
-<span class="sourceLineNo">1559</span>    if (destServerName == null || destServerName.length == 0) {<a name="line.1559"></a>
-<span class="sourceLineNo">1560</span>      LOG.info("Passed destination servername is null/empty so " +<a name="line.1560"></a>
-<span class="sourceLineNo">1561</span>        "choosing a server at random");<a name="line.1561"></a>
-<span class="sourceLineNo">1562</span>      final List&lt;ServerName&gt; destServers = this.serverManager.createDestinationServersList(<a name="line.1562"></a>
-<span class="sourceLineNo">1563</span>        regionState.getServerName());<a name="line.1563"></a>
-<span class="sourceLineNo">1564</span>      dest = balancer.randomAssignment(hri, destServers);<a name="line.1564"></a>
-<span class="sourceLineNo">1565</span>      if (dest == null) {<a name="line.1565"></a>
-<span class="sourceLineNo">1566</span>        LOG.debug("Unable to determine a plan to assign " + hri);<a name="line.1566"></a>
-<span class="sourceLineNo">1567</span>        return;<a name="line.1567"></a>
-<span class="sourceLineNo">1568</span>      }<a name="line.1568"></a>
-<span class="sourceLineNo">1569</span>    } else {<a name="line.1569"></a>
-<span class="sourceLineNo">1570</span>      ServerName candidate = ServerName.valueOf(Bytes.toString(destServerName));<a name="line.1570"></a>
-<span class="sourceLineNo">1571</span>      dest = balancer.randomAssignment(hri, Lists.newArrayList(candidate));<a name="line.1571"></a>
-<span class="sourceLineNo">1572</span>      if (dest == null) {<a name="line.1572"></a>
-<span class="sourceLineNo">1573</span>        LOG.debug("Unable to determine a plan to assign " + hri);<a name="line.1573"></a>
-<span class="sourceLineNo">1574</span>        return;<a name="line.1574"></a>
-<span class="sourceLineNo">1575</span>      }<a name="line.1575"></a>
-<span class="sourceLineNo">1576</span>      if (dest.equals(serverName) &amp;&amp; balancer instanceof BaseLoadBalancer<a name="line.1576"></a>
-<span class="sourceLineNo">1577</span>          &amp;&amp; !((BaseLoadBalancer)balancer).shouldBeOnMaster(hri)) {<a name="line.1577"></a>
-<span class="sourceLineNo">1578</span>        // To avoid unnecessary region moving later by balancer. Don't put user<a name="line.1578"></a>
-<span class="sourceLineNo">1579</span>        // regions on master. Regions on master could be put on other region<a name="line.1579"></a>
-<span class="sourceLineNo">1580</span>        // server intentionally by test however.<a name="line.1580"></a>
-<span class="sourceLineNo">1581</span>        LOG.debug("Skipping move of region " + hri.getRegionNameAsString()<a name="line.1581"></a>
-<span class="sourceLineNo">1582</span>          + " to avoid unnecessary region moving later by load balancer,"<a name="line.1582"></a>
-<span class="sourceLineNo">1583</span>          + " because it should not be on master");<a name="line.1583"></a>
-<span class="sourceLineNo">1584</span>        return;<a name="line.1584"></a>
-<span class="sourceLineNo">1585</span>      }<a name="line.1585"></a>
-<span class="sourceLineNo">1586</span>    }<a name="line.1586"></a>
-<span class="sourceLineNo">1587</span><a name="line.1587"></a>
-<span class="sourceLineNo">1588</span>    if (dest.equals(regionState.getServerName())) {<a name="line.1588"></a>
-<span class="sourceLineNo">1589</span>      LOG.debug("Skipping move of region " + hri.getRegionNameAsString()<a name="line.1589"></a>
-<span class="sourceLineNo">1590</span>        + " because region already assigned to the same server " + dest + ".");<a name="line.1590"></a>
-<span class="sourceLineNo">1591</span>      return;<a name="line.1591"></a>
-<span class="sourceLineNo">1592</span>    }<a name="line.1592"></a>
-<span class="sourceLineNo">1593</span><a name="line.1593"></a>
-<span class="sourceLineNo">1594</span>    // Now we can do the move<a name="line.1594"></a>
-<span class="sourceLineNo">1595</span>    RegionPlan rp = new RegionPlan(hri, regionState.getServerName(), dest);<a name="line.1595"></a>
-<span class="sourceLineNo">1596</span><a name="line.1596"></a>
-<span class="sourceLineNo">1597</span>    try {<a name="line.1597"></a>
-<span class="sourceLineNo">1598</span>      checkInitialized();<a name="line.1598"></a>
-<span class="sourceLineNo">1599</span>      if (this.cpHost != null) {<a name="line.1599"></a>
-<span class="sourceLineNo">1600</span>        if (this.cpHost.preMove(hri, rp.getSource(), rp.getDestination())) {<a name="line.1600"></a>
-<span class="sourceLineNo">1601</span>          return;<a name="line.1601"></a>
-<span class="sourceLineNo">1602</span>        }<a name="line.1602"></a>
-<span class="sourceLineNo">1603</span>      }<a name="line.1603"></a>
-<span class="sourceLineNo">1604</span>      // warmup the region on the destination before initiating the move. this call<a name="line.1604"></a>
-<span class="sourceLineNo">1605</span>      // is synchronous and takes some time. doing it before the source region gets<a name="line.1605"></a>
-<span class="sourceLineNo">1606</span>      // closed<a name="line.1606"></a>
-<span class="sourceLineNo">1607</span>      serverManager.sendRegionWarmup(rp.getDestination(), hri);<a name="line.1607"></a>
-<span class="sourceLineNo">1608</span><a name="line.1608"></a>
-<span class="sourceLineNo">1609</span>      LOG.info(getClientIdAuditPrefix() + " move " + rp + ", running balancer");<a name="line.1609"></a>
-<span class="sourceLineNo">1610</span>      this.assignmentManager.balance(rp);<a name="line.1610"></a>
-<span class="sourceLineNo">1611</span>      if (this.cpHost != null) {<a name="line.1611"></a>
-<span class="sourceLineNo">1612</span>        this.cpHost.postMove(hri, rp.getSource(), rp.getDestination());<a name="line.1612"></a>
-<span class="sourceLineNo">1613</span>      }<a name="line.1613"></a>
-<span class="sourceLineNo">1614</span>    } catch (IOException ioe) {<a name="line.1614"></a>
-<span class="sourceLineNo">1615</span>      if (ioe instanceof HBaseIOException) {<a name="line.1615"></a>
-<span class="sourceLineNo">1616</span>        throw (HBaseIOException)ioe;<a name="line.1616"></a>
-<span class="sourceLineNo">1617</span>      }<a name="line.1617"></a>
-<span class="sourceLineNo">1618</span>      throw new HBaseIOException(ioe);<a name="line.1618"></a>
-<span class="sourceLineNo">1619</span>    }<a name="line.1619"></a>
-<span class="sourceLineNo">1620</span>  }<a name="line.1620"></a>
-<span class="sourceLineNo">1621</span><a name="line.1621"></a>
-<span class="sourceLineNo">1622</span>  @Override<a name="line.1622"></a>
-<span class="sourceLineNo">1623</span>  public long createTable(<a name="line.1623"></a>
-<span class="sourceLineNo">1624</span>      final HTableDescriptor hTableDescriptor,<a name="line.1624"></a>
-<span class="sourceLineNo">1625</span>      final byte [][] splitKeys,<a name="line.1625"></a>
-<span class="sourceLineNo">1626</span>      final long nonceGroup,<a name="line.1626"></a>
-<span class="sourceLineNo">1627</span>      final long nonce) throws IOException {<a name="line.1627"></a>
-<span class="sourceLineNo">1628</span>    checkInitialized();<a name="line.1628"></a>
-<span class="sourceLineNo">1629</span><a name="line.1629"></a>
-<span class="sourceLineNo">1630</span>    String namespace = hTableDescriptor.getTableName().getNamespaceAsString();<a name="line.1630"></a>
-<span class="sourceLineNo">1631</span>    this.clusterSchemaService.getNamespace(namespace);<a name="line.1631"></a>
-<span class="sourceLineNo">1632</span><a name="line.1632"></a>
-<span class="sourceLineNo">1633</span>    HRegionInfo[] newRegions = ModifyRegionUtils.createHRegionInfos(hTableDescriptor, splitKeys);<a name="line.1633"></a>
-<span class="sourceLineNo">1634</span>    sanityCheckTableDescriptor(hTableDescriptor);<a name="line.1634"></a>
-<span class="sourceLineNo">1635</span><a name="line.1635"></a>
-<span class="sourceLineNo">1636</span>    return MasterProcedureUtil.submitProcedure(<a name="line.1636"></a>
-<span class="sourceLineNo">1637</span>        new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {<a name="line.1637"></a>
-<span class="sourceLineNo">1638</span>      @Override<a name="line.1638"></a>
-<span class="sourceLineNo">1639</span>      protected void run() throws IOException {<a name="line.1639"></a>
-<span class="sourceLineNo">1640</span>        getMaster().getMasterCoprocessorHost().preCreateTable(hTableDescriptor, newRegions);<a name="line.1640"></a>
-<span class="sourceLineNo">1641</span><a name="line.1641"></a>
-<span class="sourceLineNo">1642</span>        LOG.info(getClientIdAuditPrefix() + " create " + hTableDescriptor);<a name="line.1642"></a>
-<span class="sourceLineNo">1643</span><a name="line.1643"></a>
-<span class="sourceLineNo">1644</span>        // TODO: We can handle/merge duplicate requests, and differentiate the case of<a name="line.1644"></a>
-<span class="sourceLineNo">1645</span>        //       TableExistsException by saying if the schema is the same or not.<a name="line.1645"></a>
-<span class="sourceLineNo">1646</span>        ProcedurePrepareLatch latch = ProcedurePrepareLatch.createLatch();<a name="line.1646"></a>
-<span class="sourceLineNo">1647</span>        submitProcedure(new CreateTableProcedure(<a name="line.1647"></a>
-<span class="sourceLineNo">1648</span>            procedureExecutor.getEnvironment(), hTableDescriptor, newRegions, latch));<a name="line.1648"></a>
-<span class="sourceLineNo">1649</span>        latch.await();<a name="line.1649"></a>
-<span class="sourceLineNo">1650</span><a name="line.1650"></a>
-<span class="sourceLineNo">1651</span>        getMaster().getMasterCoprocessorHost().postCreateTable(hTableDescriptor, newRegions);<a name="line.1651"></a>
-<span class="sourceLineNo">1652</span>      }<a name="line.1652"></a>
-<span class="sourceLineNo">1653</span><a name="line.1653"></a>
-<span class="sourceLineNo">1654</span>      @Override<a name="line.1654"></a>
-<span class="sourceLineNo">1655</span>      protected String getDescription() {<a name="line.1655"></a>
-<span class="sourceLineNo">1656</span>        return "CreateTableProcedure";<a name="line.1656"></a>
-<span class="sourceLineNo">1657</span>      }<a name="line.1657"></a>
-<span class="sourceLineNo">1658</span>    });<a name="line.1658"></a>
-<span class="sourceLineNo">1659</span>  }<a name="line.1659"></a>
-<span class="sourceLineNo">1660</span><a name="line.1660"></a>
-<span class="sourceLineNo">1661</span>  @Override<a name="line.1661"></a>
-<span class="sourceLineNo">1662</span>  public long createSystemTable(final HTableDescriptor hTableDescriptor) throws IOException {<a name="line.1662"></a>
-<span class="sourceLineNo">1663</span>    if (isStopped()) {<a name="line.1663"></a>
-<span class="sourceLineNo">1664</span>      throw new MasterNotRunningException();<a name="line.1664"></a>
-<span class="sourceLineNo">1665</span>    }<a name="line.1665"></a>
-<span class="sourceLineNo">1666</span><a name="line.1666"></a>
-<span class="sourceLineNo">1667</span>    TableName tableName = hTableDescriptor.getTableName();<a name="line.1667"></a>
-<span class="sourceLineNo">1668</span>    if (!(tableName.isSystemTable())) {<a name="line.1668"></a>
-<span class="sourceLineNo">1669</span>      throw new IllegalArgumentException(<a name="line.1669"></a>
-<span class="sourceLineNo">1670</span>        "Only system table creation can use this createSystemTable API");<a name="line.1670"></a>
-<span class="sourceLineNo">1671</span>    }<a name="line.1671"></a>
-<span class="sourceLineNo">1672</span><a name="line.1672"></a>
-<span class="sourceLineNo">1673</span>    HRegionInfo[] newRegions = ModifyRegionUtils.createHRegionInfos(hTableDescriptor, null);<a name="line.1673"></a>
-<span class="sourceLineNo">1674</span><a name="line.1674"></a>
-<span class="sourceLineNo">1675</span>    LOG.info(getClientIdAuditPrefix() + " create " + hTableDescriptor);<a name="line.1675"></a>
-<span class="sourceLineNo">1676</span><a name="line.1676"></a>
-<span class="sourceLineNo">1677</span>    // This special create table is called locally to master.  Therefore, no RPC means no need<a name="line.1677"></a>
-<span class="sourceLineNo">1678</span>    // to use nonce to detect duplicated RPC call.<a name="line.1678"></a>
-<span class="sourceLineNo">1679</span>    long procId = this.procedureExecutor.submitProcedure(<a name="line.1679"></a>
-<span class="sourceLineNo">1680</span>      new CreateTableProcedure(procedureExecutor.getEnvironment(), hTableDescriptor, newRegions));<a name="line.1680"></a>
-<span class="sourceLineNo">1681</span><a name="line.1681"></a>
-<span class="sourceLineNo">1682</span>    return procId;<a name="line.1682"></a>
-<span class="sourceLineNo">1683</span>  }<a name="line.1683"></a>
-<span class="sourceLineNo">1684</span><a name="line.1684"></a>
-<span class="sourceLineNo">1685</span>  /**<a name="line.1685"></a>
-<span class="sourceLineNo">1686</span>   * Checks whether the table conforms to some sane limits, and configured<a name="line.1686"></a>
-<span class="sourceLineNo">1687</span>   * values (compression, etc) work. Throws an exception if something is wrong.<a name="line.1687"></a>
-<span class="sourceLineNo">1688</span>   * @throws IOException<a name="line.1688"></a>
-<span class="sourceLineNo">1689</span>   */<a name="line.1689"></a>
-<span class="sourceLineNo">1690</span>  private void sanityCheckTableDescriptor(final HTableDescriptor htd) throws IOException {<a name="line.1690"></a>
-<span class="sourceLineNo">1691</span>    final String CONF_KEY = "hbase.table.sanity.checks";<a name="line.1691"></a>
-<span class="sourceLineNo">1692</span>    boolean logWarn = false;<a name="line.1692"></a>
-<span class="sourceLineNo">1693</span>    if (!conf.getBoolean(CONF_KEY, true)) {<a name="line.1693"></a>
-<span class="sourceLineNo">1694</span>      logWarn = true;<a name="line.1694"></a>
-<span class="sourceLineNo">1695</span>    }<a name="line.1695"></a>
-<span class="sourceLineNo">1696</span>    String tableVal = htd.getConfigurationValue(CONF_KEY);<a name="line.1696"></a>
-<span class="sourceLineNo">1697</span>    if (tableVal != null &amp;&amp; !Boolean.valueOf(tableVal)) {<a name="line.1697"></a>
-<span class="sourceLineNo">1698</span>      logWarn = true;<a name="line.1698"></a>
-<span class="sourceLineNo">1699</span>    }<a name="line.1699"></a>
-<span class="sourceLineNo">1700</span><a name="line.1700"></a>
-<span class="sourceLineNo">1701</span>    // check max file size<a name="line.1701"></a>
-<span class="sourceLineNo">1702</span>    long maxFileSizeLowerLimit = 2 * 1024 * 1024L; // 2M is the default lower limit<a name="line.1702"></a>
-<span class="sourceLineNo">1703</span>    long maxFileSize = htd.getMaxFileSize();<a name="line.1703"></a>
-<span class="sourceLineNo">1704</span>    if (maxFileSize &lt; 0) {<a name="line.1704"></a>
-<span class="sourceLineNo">1705</span>      maxFileSize = conf.getLong(HConstants.HREGION_MAX_FILESIZE, maxFileSizeLowerLimit);<a name="line.1705"></a>
-<span class="sourceLineNo">1706</span>    }<a name="line.1706"></a>
-<span class="sourceLineNo">1707</span>    if (maxFileSize &lt; conf.getLong("hbase.hregion.max.filesize.limit", maxFileSizeLowerLimit)) {<a name="line.1707"></a>
-<span class="sourceLineNo">1708</span>      String message = "MAX_FILESIZE for table descriptor or "<a name="line.1708"></a>
-<span class="sourceLineNo">1709</span>          + "\"hbase.hregion.max.filesize\" (" + maxFileSize<a name="line.1709"></a>
-<span class="sourceLineNo">1710</span>          + ") is too small, which might cause over splitting into unmanageable "<a name="line.1710"></a>
-<span class="sourceLineNo">1711</span>          + "number of regions.";<a name="line.1711"></a>
-<span class="sourceLineNo">1712</span>      warnOrThrowExceptionForFailure(logWarn, CONF_KEY, message, null);<a name="line.1712"></a>
-<span class="sourceLineNo">1713</span>    }<a name="line.1713"></a>
-<span class="sourceLineNo">1714</span><a name="line.1714"></a>
-<span class="sourceLineNo">1715</span>    // check flush size<a name="line.1715"></a>
-<span class="sourceLineNo">1716</span>    long flushSizeLowerLimit = 1024 * 1024L; // 1M is the default lower limit<a name="line.1716"></a>
-<span class="sourceLineNo">1717</span>    long flushSize = htd.getMemStoreFlushSize();<a name="line.1717"></a>
-<span class="sourceLineNo">1718</span>    if (flushSize &lt; 0) {<a name="line.1718"></a>
-<span class="sourceLineNo">1719</span>      flushSize = conf.getLong(HConstants.HREGION_MEMSTORE_FLUSH_SIZE, flushSizeLowerLimit);<a name="line.1719"></a>
-<span class="sourceLineNo">1720</span>    }<a name="line.1720"></a>
-<span class="sourceLineNo">1721</span>    if (flushSize &lt; conf.getLong("hbase.hregion.memstore.flush.size.limit", flushSizeLowerLimit)) {<a name="line.1721"></a>
-<span class="sourceLineNo">1722</span>      String message = "MEMSTORE_FLUSHSIZE for table descriptor or "<a name="line.1722"></a>
-<span class="sourceLineNo">1723</span>          + "\"hbase.hregion.memstore.flush.size\" ("+flushSize+") is too small, which might cause"<a name="line.1723"></a>
-<span class="sourceLineNo">1724</span>          + " very frequent flushing.";<a name="line.1724"></a>
-<span class="sourceLineNo">1725</span>      warnOrThrowExceptionForFailure(logWarn, CONF_KEY, message, null);<a name="line.1725"></a>
-<span class="sourceLineNo">1726</span>    }<a name="line.1726"></a>
-<span class="sourceLineNo">1727</span><a name="line.1727"></a>
-<span class="sourceLineNo">1728</span>    // check that coprocessors and other specified plugin classes can be loaded<a name="line.1728"></a>
-<span class="sourceLineNo">1729</span>    try {<a name="line.1729"></a>
-<span class="sourceLineNo">1730</span>      checkClassLoading(conf, htd);<a name="line.1730"></a>
-<span class="sourceLineNo">1731</span>    } catch (Exception ex) {<a name="line.1731"></a>
-<span class="sourceLineNo">1732</span>      warnOrThrowExceptionForFailure(logWarn, CONF_KEY, ex.getMessage(), null);<a name="line.1732"></a>
-<span class="sourceLineNo">1733</span>    }<a name="line.1733"></a>
-<span class="sourceLineNo">1734</span><a name="line.1734"></a>
-<span class="sourceLineNo">1735</span>    // check compression can be loaded<a name="line.1735"></a>
-<span class="sourceLineNo">1736</span>    try {<a name="line.1736"></a>
-<span class="sourceLineNo">1737</span>      checkCompression(htd);<a name="line.1737"></a>
-<span class="sourceLineNo">1738</span>    } catch (IOException e) {<a name="line.1738"></a>
-<span class="sourceLineNo">1739</span>      warnOrThrowExceptionForFailure(logWarn, CONF_KEY, e.getMessage(), e);<a name="line.1739"></a>
-<span class="sourceLineNo">1740</span>    }<a name="line.1740"></a>
-<span class="sourceLineNo">1741</span><a name="line.1741"></a>
-<span class="sourceLineNo">1742</span>    // check encryption can be loaded<a name="line.1742"></a>
-<span class="sourceLineNo">1743</span>    try {<a name="line.1743"></a>
-<span class="sourceLineNo">1744</span>      checkEncryption(conf, htd);<a name="line.1744"></a>
-<span class="sourceLineNo">1745</span>    } catch (IOException e) {<a name="line.1745"></a>
-<span class="sourceLineNo">1746</span>      warnOrThrowExceptionForFailure(logWarn, CONF_KEY, e.getMessage(), e);<a name="line.1746"></a>
-<span class="sourceLineNo">1747</span>    }<a name="line.1747"></a>
-<span class="sourceLineNo">1748</span>    // Verify compaction policy<a name="line.1748"></a>
-<span class="sourceLineNo">1749</span>    try{<a name="line.1749"></a>
-<span class="sourceLineNo">1750</span>      checkCompactionPolicy(conf, htd);<a name="line.1750"></a>
-<span class="sourceLineNo">1751</span>    } catch(IOException e){<a name="line.1751"></a>
-<span class="sourceLineNo">1752</span>      warnOrThrowExceptionForFailure(false, CONF_KEY, e.getMessage(), e);<a name="line.1752"></a>
-<span class="sourceLineNo">1753</span>    }<a name="line.1753"></a>
-<span class="sourceLineNo">1754</span>    // check that we have at least 1 CF<a name="line.1754"></a>
-<span class="sourceLineNo">1755</span>    if (htd.getColumnFamilyCount() == 0) {<a name="line.1755"></a>
-<span class="sourceLineNo">1756</span>      String message = "Table should have at least one column family.";<a name="line.1756"></a>
-<span class="sourceLineNo">1757</span>      warnOrThrowExceptionForFailure(logWarn, CONF_KEY, message, null);<a name="line.1757"></a>
-<span class="sourceLineNo">1758</span>    }<a name="line.1758"></a>
-<span class="sourceLineNo">1759</span><a name="line.1759"></a>
-<span class="sourceLineNo">1760</span>    for (HColumnDescriptor hcd : htd.getColumnFamilies()) {<a name="line.1760"></a>
-<span class="sourceLineNo">1761</span>      if (hcd.getTimeToLive() &lt;= 0) {<a name="line.1761"></a>
-<span class="sourceLineNo">1762</span>        String message = "TTL for column family " + hcd.getNameAsString() + " must be positive.";<a name="line.1762"></a>
-<span class="so

<TRUNCATED>

Mime
View raw message