hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1711891 [30/50] - in /hbase/hbase.apache.org/trunk: ./ apidocs/ apidocs/org/apache/hadoop/hbase/ apidocs/org/apache/hadoop/hbase/class-use/ apidocs/org/apache/hadoop/hbase/client/ apidocs/org/apache/hadoop/hbase/client/class-use/ apidocs/o...
Date Mon, 02 Nov 2015 03:51:05 GMT
Modified: hbase/hbase.apache.org/trunk/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.html
URL: http://svn.apache.org/viewvc/hbase/hbase.apache.org/trunk/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.html?rev=1711891&r1=1711890&r2=1711891&view=diff
==============================================================================
--- hbase/hbase.apache.org/trunk/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.html (original)
+++ hbase/hbase.apache.org/trunk/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.html Mon Nov  2 03:51:02 2015
@@ -1957,838 +1957,840 @@
 <span class="sourceLineNo">1949</span>          if (data == null || data.size() &lt;= 0) {<a name="line.1949"></a>
 <span class="sourceLineNo">1950</span>            return true;<a name="line.1950"></a>
 <span class="sourceLineNo">1951</span>          }<a name="line.1951"></a>
-<span class="sourceLineNo">1952</span>          Pair&lt;HRegionInfo, ServerName&gt; pair = HRegionInfo.getHRegionInfoAndServerName(data);<a name="line.1952"></a>
-<span class="sourceLineNo">1953</span>          if (pair == null) {<a name="line.1953"></a>
-<span class="sourceLineNo">1954</span>            return false;<a name="line.1954"></a>
-<span class="sourceLineNo">1955</span>          }<a name="line.1955"></a>
-<span class="sourceLineNo">1956</span>          if (!pair.getFirst().getTable().equals(tableName)) {<a name="line.1956"></a>
-<span class="sourceLineNo">1957</span>            return false;<a name="line.1957"></a>
-<span class="sourceLineNo">1958</span>          }<a name="line.1958"></a>
-<span class="sourceLineNo">1959</span>          result.set(pair);<a name="line.1959"></a>
-<span class="sourceLineNo">1960</span>          return true;<a name="line.1960"></a>
-<span class="sourceLineNo">1961</span>        }<a name="line.1961"></a>
-<span class="sourceLineNo">1962</span>    };<a name="line.1962"></a>
-<span class="sourceLineNo">1963</span><a name="line.1963"></a>
-<span class="sourceLineNo">1964</span>    MetaTableAccessor.scanMeta(clusterConnection, visitor, tableName, rowKey, 1);<a name="line.1964"></a>
-<span class="sourceLineNo">1965</span>    return result.get();<a name="line.1965"></a>
-<span class="sourceLineNo">1966</span>  }<a name="line.1966"></a>
-<span class="sourceLineNo">1967</span><a name="line.1967"></a>
-<span class="sourceLineNo">1968</span>  @Override<a name="line.1968"></a>
-<span class="sourceLineNo">1969</span>  public long modifyTable(<a name="line.1969"></a>
-<span class="sourceLineNo">1970</span>      final TableName tableName,<a name="line.1970"></a>
-<span class="sourceLineNo">1971</span>      final HTableDescriptor descriptor,<a name="line.1971"></a>
-<span class="sourceLineNo">1972</span>      final long nonceGroup,<a name="line.1972"></a>
-<span class="sourceLineNo">1973</span>      final long nonce)<a name="line.1973"></a>
-<span class="sourceLineNo">1974</span>      throws IOException {<a name="line.1974"></a>
-<span class="sourceLineNo">1975</span>    checkInitialized();<a name="line.1975"></a>
-<span class="sourceLineNo">1976</span>    sanityCheckTableDescriptor(descriptor);<a name="line.1976"></a>
-<span class="sourceLineNo">1977</span>    if (cpHost != null) {<a name="line.1977"></a>
-<span class="sourceLineNo">1978</span>      cpHost.preModifyTable(tableName, descriptor);<a name="line.1978"></a>
-<span class="sourceLineNo">1979</span>    }<a name="line.1979"></a>
-<span class="sourceLineNo">1980</span><a name="line.1980"></a>
-<span class="sourceLineNo">1981</span>    LOG.info(getClientIdAuditPrefix() + " modify " + tableName);<a name="line.1981"></a>
+<span class="sourceLineNo">1952</span>          Pair&lt;HRegionInfo, ServerName&gt; pair =<a name="line.1952"></a>
+<span class="sourceLineNo">1953</span>              new Pair(MetaTableAccessor.getHRegionInfo(data),<a name="line.1953"></a>
+<span class="sourceLineNo">1954</span>                  MetaTableAccessor.getServerName(data,0));<a name="line.1954"></a>
+<span class="sourceLineNo">1955</span>          if (pair == null) {<a name="line.1955"></a>
+<span class="sourceLineNo">1956</span>            return false;<a name="line.1956"></a>
+<span class="sourceLineNo">1957</span>          }<a name="line.1957"></a>
+<span class="sourceLineNo">1958</span>          if (!pair.getFirst().getTable().equals(tableName)) {<a name="line.1958"></a>
+<span class="sourceLineNo">1959</span>            return false;<a name="line.1959"></a>
+<span class="sourceLineNo">1960</span>          }<a name="line.1960"></a>
+<span class="sourceLineNo">1961</span>          result.set(pair);<a name="line.1961"></a>
+<span class="sourceLineNo">1962</span>          return true;<a name="line.1962"></a>
+<span class="sourceLineNo">1963</span>        }<a name="line.1963"></a>
+<span class="sourceLineNo">1964</span>    };<a name="line.1964"></a>
+<span class="sourceLineNo">1965</span><a name="line.1965"></a>
+<span class="sourceLineNo">1966</span>    MetaTableAccessor.scanMeta(clusterConnection, visitor, tableName, rowKey, 1);<a name="line.1966"></a>
+<span class="sourceLineNo">1967</span>    return result.get();<a name="line.1967"></a>
+<span class="sourceLineNo">1968</span>  }<a name="line.1968"></a>
+<span class="sourceLineNo">1969</span><a name="line.1969"></a>
+<span class="sourceLineNo">1970</span>  @Override<a name="line.1970"></a>
+<span class="sourceLineNo">1971</span>  public long modifyTable(<a name="line.1971"></a>
+<span class="sourceLineNo">1972</span>      final TableName tableName,<a name="line.1972"></a>
+<span class="sourceLineNo">1973</span>      final HTableDescriptor descriptor,<a name="line.1973"></a>
+<span class="sourceLineNo">1974</span>      final long nonceGroup,<a name="line.1974"></a>
+<span class="sourceLineNo">1975</span>      final long nonce)<a name="line.1975"></a>
+<span class="sourceLineNo">1976</span>      throws IOException {<a name="line.1976"></a>
+<span class="sourceLineNo">1977</span>    checkInitialized();<a name="line.1977"></a>
+<span class="sourceLineNo">1978</span>    sanityCheckTableDescriptor(descriptor);<a name="line.1978"></a>
+<span class="sourceLineNo">1979</span>    if (cpHost != null) {<a name="line.1979"></a>
+<span class="sourceLineNo">1980</span>      cpHost.preModifyTable(tableName, descriptor);<a name="line.1980"></a>
+<span class="sourceLineNo">1981</span>    }<a name="line.1981"></a>
 <span class="sourceLineNo">1982</span><a name="line.1982"></a>
-<span class="sourceLineNo">1983</span>    // Execute the operation synchronously - wait for the operation completes before continuing.<a name="line.1983"></a>
-<span class="sourceLineNo">1984</span>    long procId = this.procedureExecutor.submitProcedure(<a name="line.1984"></a>
-<span class="sourceLineNo">1985</span>      new ModifyTableProcedure(procedureExecutor.getEnvironment(), descriptor),<a name="line.1985"></a>
-<span class="sourceLineNo">1986</span>      nonceGroup,<a name="line.1986"></a>
-<span class="sourceLineNo">1987</span>      nonce);<a name="line.1987"></a>
-<span class="sourceLineNo">1988</span><a name="line.1988"></a>
-<span class="sourceLineNo">1989</span>    ProcedureSyncWait.waitForProcedureToComplete(procedureExecutor, procId);<a name="line.1989"></a>
+<span class="sourceLineNo">1983</span>    LOG.info(getClientIdAuditPrefix() + " modify " + tableName);<a name="line.1983"></a>
+<span class="sourceLineNo">1984</span><a name="line.1984"></a>
+<span class="sourceLineNo">1985</span>    // Execute the operation synchronously - wait for the operation completes before continuing.<a name="line.1985"></a>
+<span class="sourceLineNo">1986</span>    long procId = this.procedureExecutor.submitProcedure(<a name="line.1986"></a>
+<span class="sourceLineNo">1987</span>      new ModifyTableProcedure(procedureExecutor.getEnvironment(), descriptor),<a name="line.1987"></a>
+<span class="sourceLineNo">1988</span>      nonceGroup,<a name="line.1988"></a>
+<span class="sourceLineNo">1989</span>      nonce);<a name="line.1989"></a>
 <span class="sourceLineNo">1990</span><a name="line.1990"></a>
-<span class="sourceLineNo">1991</span>    if (cpHost != null) {<a name="line.1991"></a>
-<span class="sourceLineNo">1992</span>      cpHost.postModifyTable(tableName, descriptor);<a name="line.1992"></a>
-<span class="sourceLineNo">1993</span>    }<a name="line.1993"></a>
-<span class="sourceLineNo">1994</span><a name="line.1994"></a>
-<span class="sourceLineNo">1995</span>    return procId;<a name="line.1995"></a>
-<span class="sourceLineNo">1996</span>  }<a name="line.1996"></a>
-<span class="sourceLineNo">1997</span><a name="line.1997"></a>
-<span class="sourceLineNo">1998</span>  @Override<a name="line.1998"></a>
-<span class="sourceLineNo">1999</span>  public void checkTableModifiable(final TableName tableName)<a name="line.1999"></a>
-<span class="sourceLineNo">2000</span>      throws IOException, TableNotFoundException, TableNotDisabledException {<a name="line.2000"></a>
-<span class="sourceLineNo">2001</span>    if (isCatalogTable(tableName)) {<a name="line.2001"></a>
-<span class="sourceLineNo">2002</span>      throw new IOException("Can't modify catalog tables");<a name="line.2002"></a>
-<span class="sourceLineNo">2003</span>    }<a name="line.2003"></a>
-<span class="sourceLineNo">2004</span>    if (!MetaTableAccessor.tableExists(getConnection(), tableName)) {<a name="line.2004"></a>
-<span class="sourceLineNo">2005</span>      throw new TableNotFoundException(tableName);<a name="line.2005"></a>
-<span class="sourceLineNo">2006</span>    }<a name="line.2006"></a>
-<span class="sourceLineNo">2007</span>    if (!getAssignmentManager().getTableStateManager().<a name="line.2007"></a>
-<span class="sourceLineNo">2008</span>        isTableState(tableName, TableState.State.DISABLED)) {<a name="line.2008"></a>
-<span class="sourceLineNo">2009</span>      throw new TableNotDisabledException(tableName);<a name="line.2009"></a>
-<span class="sourceLineNo">2010</span>    }<a name="line.2010"></a>
-<span class="sourceLineNo">2011</span>  }<a name="line.2011"></a>
-<span class="sourceLineNo">2012</span><a name="line.2012"></a>
-<span class="sourceLineNo">2013</span>  /**<a name="line.2013"></a>
-<span class="sourceLineNo">2014</span>   * @return cluster status<a name="line.2014"></a>
-<span class="sourceLineNo">2015</span>   */<a name="line.2015"></a>
-<span class="sourceLineNo">2016</span>  public ClusterStatus getClusterStatus() throws InterruptedIOException {<a name="line.2016"></a>
-<span class="sourceLineNo">2017</span>    // Build Set of backup masters from ZK nodes<a name="line.2017"></a>
-<span class="sourceLineNo">2018</span>    List&lt;String&gt; backupMasterStrings;<a name="line.2018"></a>
-<span class="sourceLineNo">2019</span>    try {<a name="line.2019"></a>
-<span class="sourceLineNo">2020</span>      backupMasterStrings = ZKUtil.listChildrenNoWatch(this.zooKeeper,<a name="line.2020"></a>
-<span class="sourceLineNo">2021</span>        this.zooKeeper.backupMasterAddressesZNode);<a name="line.2021"></a>
-<span class="sourceLineNo">2022</span>    } catch (KeeperException e) {<a name="line.2022"></a>
-<span class="sourceLineNo">2023</span>      LOG.warn(this.zooKeeper.prefix("Unable to list backup servers"), e);<a name="line.2023"></a>
-<span class="sourceLineNo">2024</span>      backupMasterStrings = null;<a name="line.2024"></a>
-<span class="sourceLineNo">2025</span>    }<a name="line.2025"></a>
-<span class="sourceLineNo">2026</span><a name="line.2026"></a>
-<span class="sourceLineNo">2027</span>    List&lt;ServerName&gt; backupMasters = null;<a name="line.2027"></a>
-<span class="sourceLineNo">2028</span>    if (backupMasterStrings != null &amp;&amp; !backupMasterStrings.isEmpty()) {<a name="line.2028"></a>
-<span class="sourceLineNo">2029</span>      backupMasters = new ArrayList&lt;ServerName&gt;(backupMasterStrings.size());<a name="line.2029"></a>
-<span class="sourceLineNo">2030</span>      for (String s: backupMasterStrings) {<a name="line.2030"></a>
-<span class="sourceLineNo">2031</span>        try {<a name="line.2031"></a>
-<span class="sourceLineNo">2032</span>          byte [] bytes;<a name="line.2032"></a>
-<span class="sourceLineNo">2033</span>          try {<a name="line.2033"></a>
-<span class="sourceLineNo">2034</span>            bytes = ZKUtil.getData(this.zooKeeper, ZKUtil.joinZNode(<a name="line.2034"></a>
-<span class="sourceLineNo">2035</span>                this.zooKeeper.backupMasterAddressesZNode, s));<a name="line.2035"></a>
-<span class="sourceLineNo">2036</span>          } catch (InterruptedException e) {<a name="line.2036"></a>
-<span class="sourceLineNo">2037</span>            throw new InterruptedIOException();<a name="line.2037"></a>
-<span class="sourceLineNo">2038</span>          }<a name="line.2038"></a>
-<span class="sourceLineNo">2039</span>          if (bytes != null) {<a name="line.2039"></a>
-<span class="sourceLineNo">2040</span>            ServerName sn;<a name="line.2040"></a>
-<span class="sourceLineNo">2041</span>            try {<a name="line.2041"></a>
-<span class="sourceLineNo">2042</span>              sn = ServerName.parseFrom(bytes);<a name="line.2042"></a>
-<span class="sourceLineNo">2043</span>            } catch (DeserializationException e) {<a name="line.2043"></a>
-<span class="sourceLineNo">2044</span>              LOG.warn("Failed parse, skipping registering backup server", e);<a name="line.2044"></a>
-<span class="sourceLineNo">2045</span>              continue;<a name="line.2045"></a>
-<span class="sourceLineNo">2046</span>            }<a name="line.2046"></a>
-<span class="sourceLineNo">2047</span>            backupMasters.add(sn);<a name="line.2047"></a>
-<span class="sourceLineNo">2048</span>          }<a name="line.2048"></a>
-<span class="sourceLineNo">2049</span>        } catch (KeeperException e) {<a name="line.2049"></a>
-<span class="sourceLineNo">2050</span>          LOG.warn(this.zooKeeper.prefix("Unable to get information about " +<a name="line.2050"></a>
-<span class="sourceLineNo">2051</span>                   "backup servers"), e);<a name="line.2051"></a>
-<span class="sourceLineNo">2052</span>        }<a name="line.2052"></a>
-<span class="sourceLineNo">2053</span>      }<a name="line.2053"></a>
-<span class="sourceLineNo">2054</span>      Collections.sort(backupMasters, new Comparator&lt;ServerName&gt;() {<a name="line.2054"></a>
-<span class="sourceLineNo">2055</span>        @Override<a name="line.2055"></a>
-<span class="sourceLineNo">2056</span>        public int compare(ServerName s1, ServerName s2) {<a name="line.2056"></a>
-<span class="sourceLineNo">2057</span>          return s1.getServerName().compareTo(s2.getServerName());<a name="line.2057"></a>
-<span class="sourceLineNo">2058</span>        }});<a name="line.2058"></a>
-<span class="sourceLineNo">2059</span>    }<a name="line.2059"></a>
-<span class="sourceLineNo">2060</span><a name="line.2060"></a>
-<span class="sourceLineNo">2061</span>    String clusterId = fileSystemManager != null ?<a name="line.2061"></a>
-<span class="sourceLineNo">2062</span>      fileSystemManager.getClusterId().toString() : null;<a name="line.2062"></a>
-<span class="sourceLineNo">2063</span>    Map&lt;String, RegionState&gt; regionsInTransition = assignmentManager != null ?<a name="line.2063"></a>
-<span class="sourceLineNo">2064</span>      assignmentManager.getRegionStates().getRegionsInTransition() : null;<a name="line.2064"></a>
-<span class="sourceLineNo">2065</span>    String[] coprocessors = cpHost != null ? getMasterCoprocessors() : null;<a name="line.2065"></a>
-<span class="sourceLineNo">2066</span>    boolean balancerOn = loadBalancerTracker != null ?<a name="line.2066"></a>
-<span class="sourceLineNo">2067</span>      loadBalancerTracker.isBalancerOn() : false;<a name="line.2067"></a>
-<span class="sourceLineNo">2068</span>    Map&lt;ServerName, ServerLoad&gt; onlineServers = null;<a name="line.2068"></a>
-<span class="sourceLineNo">2069</span>    Set&lt;ServerName&gt; deadServers = null;<a name="line.2069"></a>
-<span class="sourceLineNo">2070</span>    if (serverManager != null) {<a name="line.2070"></a>
-<span class="sourceLineNo">2071</span>      deadServers = serverManager.getDeadServers().copyServerNames();<a name="line.2071"></a>
-<span class="sourceLineNo">2072</span>      onlineServers = serverManager.getOnlineServers();<a name="line.2072"></a>
-<span class="sourceLineNo">2073</span>    }<a name="line.2073"></a>
-<span class="sourceLineNo">2074</span>    return new ClusterStatus(VersionInfo.getVersion(), clusterId,<a name="line.2074"></a>
-<span class="sourceLineNo">2075</span>      onlineServers, deadServers, serverName, backupMasters,<a name="line.2075"></a>
-<span class="sourceLineNo">2076</span>      regionsInTransition, coprocessors, balancerOn);<a name="line.2076"></a>
-<span class="sourceLineNo">2077</span>  }<a name="line.2077"></a>
-<span class="sourceLineNo">2078</span><a name="line.2078"></a>
-<span class="sourceLineNo">2079</span>  /**<a name="line.2079"></a>
-<span class="sourceLineNo">2080</span>   * The set of loaded coprocessors is stored in a static set. Since it's<a name="line.2080"></a>
-<span class="sourceLineNo">2081</span>   * statically allocated, it does not require that HMaster's cpHost be<a name="line.2081"></a>
-<span class="sourceLineNo">2082</span>   * initialized prior to accessing it.<a name="line.2082"></a>
-<span class="sourceLineNo">2083</span>   * @return a String representation of the set of names of the loaded<a name="line.2083"></a>
-<span class="sourceLineNo">2084</span>   * coprocessors.<a name="line.2084"></a>
-<span class="sourceLineNo">2085</span>   */<a name="line.2085"></a>
-<span class="sourceLineNo">2086</span>  public static String getLoadedCoprocessors() {<a name="line.2086"></a>
-<span class="sourceLineNo">2087</span>    return CoprocessorHost.getLoadedCoprocessors().toString();<a name="line.2087"></a>
-<span class="sourceLineNo">2088</span>  }<a name="line.2088"></a>
-<span class="sourceLineNo">2089</span><a name="line.2089"></a>
-<span class="sourceLineNo">2090</span>  /**<a name="line.2090"></a>
-<span class="sourceLineNo">2091</span>   * @return timestamp in millis when HMaster was started.<a name="line.2091"></a>
-<span class="sourceLineNo">2092</span>   */<a name="line.2092"></a>
-<span class="sourceLineNo">2093</span>  public long getMasterStartTime() {<a name="line.2093"></a>
-<span class="sourceLineNo">2094</span>    return startcode;<a name="line.2094"></a>
-<span class="sourceLineNo">2095</span>  }<a name="line.2095"></a>
-<span class="sourceLineNo">2096</span><a name="line.2096"></a>
-<span class="sourceLineNo">2097</span>  /**<a name="line.2097"></a>
-<span class="sourceLineNo">2098</span>   * @return timestamp in millis when HMaster became the active master.<a name="line.2098"></a>
-<span class="sourceLineNo">2099</span>   */<a name="line.2099"></a>
-<span class="sourceLineNo">2100</span>  public long getMasterActiveTime() {<a name="line.2100"></a>
-<span class="sourceLineNo">2101</span>    return masterActiveTime;<a name="line.2101"></a>
-<span class="sourceLineNo">2102</span>  }<a name="line.2102"></a>
-<span class="sourceLineNo">2103</span><a name="line.2103"></a>
-<span class="sourceLineNo">2104</span>  public int getRegionServerInfoPort(final ServerName sn) {<a name="line.2104"></a>
-<span class="sourceLineNo">2105</span>    RegionServerInfo info = this.regionServerTracker.getRegionServerInfo(sn);<a name="line.2105"></a>
-<span class="sourceLineNo">2106</span>    if (info == null || info.getInfoPort() == 0) {<a name="line.2106"></a>
-<span class="sourceLineNo">2107</span>      return conf.getInt(HConstants.REGIONSERVER_INFO_PORT,<a name="line.2107"></a>
-<span class="sourceLineNo">2108</span>        HConstants.DEFAULT_REGIONSERVER_INFOPORT);<a name="line.2108"></a>
-<span class="sourceLineNo">2109</span>    }<a name="line.2109"></a>
-<span class="sourceLineNo">2110</span>    return info.getInfoPort();<a name="line.2110"></a>
-<span class="sourceLineNo">2111</span>  }<a name="line.2111"></a>
-<span class="sourceLineNo">2112</span><a name="line.2112"></a>
-<span class="sourceLineNo">2113</span>  public String getRegionServerVersion(final ServerName sn) {<a name="line.2113"></a>
-<span class="sourceLineNo">2114</span>    RegionServerInfo info = this.regionServerTracker.getRegionServerInfo(sn);<a name="line.2114"></a>
-<span class="sourceLineNo">2115</span>    if (info != null &amp;&amp; info.hasVersionInfo()) {<a name="line.2115"></a>
-<span class="sourceLineNo">2116</span>      return info.getVersionInfo().getVersion();<a name="line.2116"></a>
-<span class="sourceLineNo">2117</span>    }<a name="line.2117"></a>
-<span class="sourceLineNo">2118</span>    return "Unknown";<a name="line.2118"></a>
-<span class="sourceLineNo">2119</span>  }<a name="line.2119"></a>
-<span class="sourceLineNo">2120</span><a name="line.2120"></a>
-<span class="sourceLineNo">2121</span>  /**<a name="line.2121"></a>
-<span class="sourceLineNo">2122</span>   * @return array of coprocessor SimpleNames.<a name="line.2122"></a>
-<span class="sourceLineNo">2123</span>   */<a name="line.2123"></a>
-<span class="sourceLineNo">2124</span>  public String[] getMasterCoprocessors() {<a name="line.2124"></a>
-<span class="sourceLineNo">2125</span>    Set&lt;String&gt; masterCoprocessors = getMasterCoprocessorHost().getCoprocessors();<a name="line.2125"></a>
-<span class="sourceLineNo">2126</span>    return masterCoprocessors.toArray(new String[masterCoprocessors.size()]);<a name="line.2126"></a>
-<span class="sourceLineNo">2127</span>  }<a name="line.2127"></a>
-<span class="sourceLineNo">2128</span><a name="line.2128"></a>
-<span class="sourceLineNo">2129</span>  @Override<a name="line.2129"></a>
-<span class="sourceLineNo">2130</span>  public void abort(final String msg, final Throwable t) {<a name="line.2130"></a>
-<span class="sourceLineNo">2131</span>    if (isAborted() || isStopped()) {<a name="line.2131"></a>
-<span class="sourceLineNo">2132</span>      return;<a name="line.2132"></a>
-<span class="sourceLineNo">2133</span>    }<a name="line.2133"></a>
-<span class="sourceLineNo">2134</span>    if (cpHost != null) {<a name="line.2134"></a>
-<span class="sourceLineNo">2135</span>      // HBASE-4014: dump a list of loaded coprocessors.<a name="line.2135"></a>
-<span class="sourceLineNo">2136</span>      LOG.fatal("Master server abort: loaded coprocessors are: " +<a name="line.2136"></a>
-<span class="sourceLineNo">2137</span>          getLoadedCoprocessors());<a name="line.2137"></a>
-<span class="sourceLineNo">2138</span>    }<a name="line.2138"></a>
-<span class="sourceLineNo">2139</span>    if (t != null) LOG.fatal(msg, t);<a name="line.2139"></a>
-<span class="sourceLineNo">2140</span>    stopMaster();<a name="line.2140"></a>
-<span class="sourceLineNo">2141</span>  }<a name="line.2141"></a>
-<span class="sourceLineNo">2142</span><a name="line.2142"></a>
-<span class="sourceLineNo">2143</span>  @Override<a name="line.2143"></a>
-<span class="sourceLineNo">2144</span>  public ZooKeeperWatcher getZooKeeper() {<a name="line.2144"></a>
-<span class="sourceLineNo">2145</span>    return zooKeeper;<a name="line.2145"></a>
-<span class="sourceLineNo">2146</span>  }<a name="line.2146"></a>
-<span class="sourceLineNo">2147</span><a name="line.2147"></a>
-<span class="sourceLineNo">2148</span>  @Override<a name="line.2148"></a>
-<span class="sourceLineNo">2149</span>  public MasterCoprocessorHost getMasterCoprocessorHost() {<a name="line.2149"></a>
-<span class="sourceLineNo">2150</span>    return cpHost;<a name="line.2150"></a>
-<span class="sourceLineNo">2151</span>  }<a name="line.2151"></a>
-<span class="sourceLineNo">2152</span><a name="line.2152"></a>
-<span class="sourceLineNo">2153</span>  @Override<a name="line.2153"></a>
-<span class="sourceLineNo">2154</span>  public MasterQuotaManager getMasterQuotaManager() {<a name="line.2154"></a>
-<span class="sourceLineNo">2155</span>    return quotaManager;<a name="line.2155"></a>
-<span class="sourceLineNo">2156</span>  }<a name="line.2156"></a>
-<span class="sourceLineNo">2157</span><a name="line.2157"></a>
-<span class="sourceLineNo">2158</span>  @Override<a name="line.2158"></a>
-<span class="sourceLineNo">2159</span>  public ProcedureExecutor&lt;MasterProcedureEnv&gt; getMasterProcedureExecutor() {<a name="line.2159"></a>
-<span class="sourceLineNo">2160</span>    return procedureExecutor;<a name="line.2160"></a>
-<span class="sourceLineNo">2161</span>  }<a name="line.2161"></a>
-<span class="sourceLineNo">2162</span><a name="line.2162"></a>
-<span class="sourceLineNo">2163</span>  @Override<a name="line.2163"></a>
-<span class="sourceLineNo">2164</span>  public ServerName getServerName() {<a name="line.2164"></a>
-<span class="sourceLineNo">2165</span>    return this.serverName;<a name="line.2165"></a>
-<span class="sourceLineNo">2166</span>  }<a name="line.2166"></a>
-<span class="sourceLineNo">2167</span><a name="line.2167"></a>
-<span class="sourceLineNo">2168</span>  @Override<a name="line.2168"></a>
-<span class="sourceLineNo">2169</span>  public AssignmentManager getAssignmentManager() {<a name="line.2169"></a>
-<span class="sourceLineNo">2170</span>    return this.assignmentManager;<a name="line.2170"></a>
-<span class="sourceLineNo">2171</span>  }<a name="line.2171"></a>
-<span class="sourceLineNo">2172</span><a name="line.2172"></a>
-<span class="sourceLineNo">2173</span>  public MemoryBoundedLogMessageBuffer getRegionServerFatalLogBuffer() {<a name="line.2173"></a>
-<span class="sourceLineNo">2174</span>    return rsFatals;<a name="line.2174"></a>
-<span class="sourceLineNo">2175</span>  }<a name="line.2175"></a>
-<span class="sourceLineNo">2176</span><a name="line.2176"></a>
-<span class="sourceLineNo">2177</span>  public void shutdown() {<a name="line.2177"></a>
-<span class="sourceLineNo">2178</span>    if (cpHost != null) {<a name="line.2178"></a>
-<span class="sourceLineNo">2179</span>      try {<a name="line.2179"></a>
-<span class="sourceLineNo">2180</span>        cpHost.preShutdown();<a name="line.2180"></a>
-<span class="sourceLineNo">2181</span>      } catch (IOException ioe) {<a name="line.2181"></a>
-<span class="sourceLineNo">2182</span>        LOG.error("Error call master coprocessor preShutdown()", ioe);<a name="line.2182"></a>
-<span class="sourceLineNo">2183</span>      }<a name="line.2183"></a>
-<span class="sourceLineNo">2184</span>    }<a name="line.2184"></a>
-<span class="sourceLineNo">2185</span><a name="line.2185"></a>
-<span class="sourceLineNo">2186</span>    if (this.serverManager != null) {<a name="line.2186"></a>
-<span class="sourceLineNo">2187</span>      this.serverManager.shutdownCluster();<a name="line.2187"></a>
-<span class="sourceLineNo">2188</span>    }<a name="line.2188"></a>
-<span class="sourceLineNo">2189</span>    if (this.clusterStatusTracker != null){<a name="line.2189"></a>
-<span class="sourceLineNo">2190</span>      try {<a name="line.2190"></a>
-<span class="sourceLineNo">2191</span>        this.clusterStatusTracker.setClusterDown();<a name="line.2191"></a>
-<span class="sourceLineNo">2192</span>      } catch (KeeperException e) {<a name="line.2192"></a>
-<span class="sourceLineNo">2193</span>        LOG.error("ZooKeeper exception trying to set cluster as down in ZK", e);<a name="line.2193"></a>
-<span class="sourceLineNo">2194</span>      }<a name="line.2194"></a>
-<span class="sourceLineNo">2195</span>    }<a name="line.2195"></a>
-<span class="sourceLineNo">2196</span>  }<a name="line.2196"></a>
-<span class="sourceLineNo">2197</span><a name="line.2197"></a>
-<span class="sourceLineNo">2198</span>  public void stopMaster() {<a name="line.2198"></a>
-<span class="sourceLineNo">2199</span>    if (cpHost != null) {<a name="line.2199"></a>
-<span class="sourceLineNo">2200</span>      try {<a name="line.2200"></a>
-<span class="sourceLineNo">2201</span>        cpHost.preStopMaster();<a name="line.2201"></a>
-<span class="sourceLineNo">2202</span>      } catch (IOException ioe) {<a name="line.2202"></a>
-<span class="sourceLineNo">2203</span>        LOG.error("Error call master coprocessor preStopMaster()", ioe);<a name="line.2203"></a>
-<span class="sourceLineNo">2204</span>      }<a name="line.2204"></a>
-<span class="sourceLineNo">2205</span>    }<a name="line.2205"></a>
-<span class="sourceLineNo">2206</span>    stop("Stopped by " + Thread.currentThread().getName());<a name="line.2206"></a>
-<span class="sourceLineNo">2207</span>  }<a name="line.2207"></a>
-<span class="sourceLineNo">2208</span><a name="line.2208"></a>
-<span class="sourceLineNo">2209</span>  void checkServiceStarted() throws ServerNotRunningYetException {<a name="line.2209"></a>
-<span class="sourceLineNo">2210</span>    if (!serviceStarted) {<a name="line.2210"></a>
-<span class="sourceLineNo">2211</span>      throw new ServerNotRunningYetException("Server is not running yet");<a name="line.2211"></a>
-<span class="sourceLineNo">2212</span>    }<a name="line.2212"></a>
-<span class="sourceLineNo">2213</span>  }<a name="line.2213"></a>
-<span class="sourceLineNo">2214</span><a name="line.2214"></a>
-<span class="sourceLineNo">2215</span>  void checkInitialized() throws PleaseHoldException, ServerNotRunningYetException {<a name="line.2215"></a>
-<span class="sourceLineNo">2216</span>    checkServiceStarted();<a name="line.2216"></a>
-<span class="sourceLineNo">2217</span>    if (!this.initialized) {<a name="line.2217"></a>
-<span class="sourceLineNo">2218</span>      throw new PleaseHoldException("Master is initializing");<a name="line.2218"></a>
-<span class="sourceLineNo">2219</span>    }<a name="line.2219"></a>
-<span class="sourceLineNo">2220</span>  }<a name="line.2220"></a>
-<span class="sourceLineNo">2221</span><a name="line.2221"></a>
-<span class="sourceLineNo">2222</span>  void checkNamespaceManagerReady() throws IOException {<a name="line.2222"></a>
-<span class="sourceLineNo">2223</span>    checkInitialized();<a name="line.2223"></a>
-<span class="sourceLineNo">2224</span>    if (tableNamespaceManager == null ||<a name="line.2224"></a>
-<span class="sourceLineNo">2225</span>        !tableNamespaceManager.isTableAvailableAndInitialized(true)) {<a name="line.2225"></a>
-<span class="sourceLineNo">2226</span>      throw new IOException("Table Namespace Manager not ready yet, try again later");<a name="line.2226"></a>
-<span class="sourceLineNo">2227</span>    }<a name="line.2227"></a>
-<span class="sourceLineNo">2228</span>  }<a name="line.2228"></a>
-<span class="sourceLineNo">2229</span>  /**<a name="line.2229"></a>
-<span class="sourceLineNo">2230</span>   * Report whether this master is currently the active master or not.<a name="line.2230"></a>
-<span class="sourceLineNo">2231</span>   * If not active master, we are parked on ZK waiting to become active.<a name="line.2231"></a>
-<span class="sourceLineNo">2232</span>   *<a name="line.2232"></a>
-<span class="sourceLineNo">2233</span>   * This method is used for testing.<a name="line.2233"></a>
+<span class="sourceLineNo">1991</span>    ProcedureSyncWait.waitForProcedureToComplete(procedureExecutor, procId);<a name="line.1991"></a>
+<span class="sourceLineNo">1992</span><a name="line.1992"></a>
+<span class="sourceLineNo">1993</span>    if (cpHost != null) {<a name="line.1993"></a>
+<span class="sourceLineNo">1994</span>      cpHost.postModifyTable(tableName, descriptor);<a name="line.1994"></a>
+<span class="sourceLineNo">1995</span>    }<a name="line.1995"></a>
+<span class="sourceLineNo">1996</span><a name="line.1996"></a>
+<span class="sourceLineNo">1997</span>    return procId;<a name="line.1997"></a>
+<span class="sourceLineNo">1998</span>  }<a name="line.1998"></a>
+<span class="sourceLineNo">1999</span><a name="line.1999"></a>
+<span class="sourceLineNo">2000</span>  @Override<a name="line.2000"></a>
+<span class="sourceLineNo">2001</span>  public void checkTableModifiable(final TableName tableName)<a name="line.2001"></a>
+<span class="sourceLineNo">2002</span>      throws IOException, TableNotFoundException, TableNotDisabledException {<a name="line.2002"></a>
+<span class="sourceLineNo">2003</span>    if (isCatalogTable(tableName)) {<a name="line.2003"></a>
+<span class="sourceLineNo">2004</span>      throw new IOException("Can't modify catalog tables");<a name="line.2004"></a>
+<span class="sourceLineNo">2005</span>    }<a name="line.2005"></a>
+<span class="sourceLineNo">2006</span>    if (!MetaTableAccessor.tableExists(getConnection(), tableName)) {<a name="line.2006"></a>
+<span class="sourceLineNo">2007</span>      throw new TableNotFoundException(tableName);<a name="line.2007"></a>
+<span class="sourceLineNo">2008</span>    }<a name="line.2008"></a>
+<span class="sourceLineNo">2009</span>    if (!getAssignmentManager().getTableStateManager().<a name="line.2009"></a>
+<span class="sourceLineNo">2010</span>        isTableState(tableName, TableState.State.DISABLED)) {<a name="line.2010"></a>
+<span class="sourceLineNo">2011</span>      throw new TableNotDisabledException(tableName);<a name="line.2011"></a>
+<span class="sourceLineNo">2012</span>    }<a name="line.2012"></a>
+<span class="sourceLineNo">2013</span>  }<a name="line.2013"></a>
+<span class="sourceLineNo">2014</span><a name="line.2014"></a>
+<span class="sourceLineNo">2015</span>  /**<a name="line.2015"></a>
+<span class="sourceLineNo">2016</span>   * @return cluster status<a name="line.2016"></a>
+<span class="sourceLineNo">2017</span>   */<a name="line.2017"></a>
+<span class="sourceLineNo">2018</span>  public ClusterStatus getClusterStatus() throws InterruptedIOException {<a name="line.2018"></a>
+<span class="sourceLineNo">2019</span>    // Build Set of backup masters from ZK nodes<a name="line.2019"></a>
+<span class="sourceLineNo">2020</span>    List&lt;String&gt; backupMasterStrings;<a name="line.2020"></a>
+<span class="sourceLineNo">2021</span>    try {<a name="line.2021"></a>
+<span class="sourceLineNo">2022</span>      backupMasterStrings = ZKUtil.listChildrenNoWatch(this.zooKeeper,<a name="line.2022"></a>
+<span class="sourceLineNo">2023</span>        this.zooKeeper.backupMasterAddressesZNode);<a name="line.2023"></a>
+<span class="sourceLineNo">2024</span>    } catch (KeeperException e) {<a name="line.2024"></a>
+<span class="sourceLineNo">2025</span>      LOG.warn(this.zooKeeper.prefix("Unable to list backup servers"), e);<a name="line.2025"></a>
+<span class="sourceLineNo">2026</span>      backupMasterStrings = null;<a name="line.2026"></a>
+<span class="sourceLineNo">2027</span>    }<a name="line.2027"></a>
+<span class="sourceLineNo">2028</span><a name="line.2028"></a>
+<span class="sourceLineNo">2029</span>    List&lt;ServerName&gt; backupMasters = null;<a name="line.2029"></a>
+<span class="sourceLineNo">2030</span>    if (backupMasterStrings != null &amp;&amp; !backupMasterStrings.isEmpty()) {<a name="line.2030"></a>
+<span class="sourceLineNo">2031</span>      backupMasters = new ArrayList&lt;ServerName&gt;(backupMasterStrings.size());<a name="line.2031"></a>
+<span class="sourceLineNo">2032</span>      for (String s: backupMasterStrings) {<a name="line.2032"></a>
+<span class="sourceLineNo">2033</span>        try {<a name="line.2033"></a>
+<span class="sourceLineNo">2034</span>          byte [] bytes;<a name="line.2034"></a>
+<span class="sourceLineNo">2035</span>          try {<a name="line.2035"></a>
+<span class="sourceLineNo">2036</span>            bytes = ZKUtil.getData(this.zooKeeper, ZKUtil.joinZNode(<a name="line.2036"></a>
+<span class="sourceLineNo">2037</span>                this.zooKeeper.backupMasterAddressesZNode, s));<a name="line.2037"></a>
+<span class="sourceLineNo">2038</span>          } catch (InterruptedException e) {<a name="line.2038"></a>
+<span class="sourceLineNo">2039</span>            throw new InterruptedIOException();<a name="line.2039"></a>
+<span class="sourceLineNo">2040</span>          }<a name="line.2040"></a>
+<span class="sourceLineNo">2041</span>          if (bytes != null) {<a name="line.2041"></a>
+<span class="sourceLineNo">2042</span>            ServerName sn;<a name="line.2042"></a>
+<span class="sourceLineNo">2043</span>            try {<a name="line.2043"></a>
+<span class="sourceLineNo">2044</span>              sn = ServerName.parseFrom(bytes);<a name="line.2044"></a>
+<span class="sourceLineNo">2045</span>            } catch (DeserializationException e) {<a name="line.2045"></a>
+<span class="sourceLineNo">2046</span>              LOG.warn("Failed parse, skipping registering backup server", e);<a name="line.2046"></a>
+<span class="sourceLineNo">2047</span>              continue;<a name="line.2047"></a>
+<span class="sourceLineNo">2048</span>            }<a name="line.2048"></a>
+<span class="sourceLineNo">2049</span>            backupMasters.add(sn);<a name="line.2049"></a>
+<span class="sourceLineNo">2050</span>          }<a name="line.2050"></a>
+<span class="sourceLineNo">2051</span>        } catch (KeeperException e) {<a name="line.2051"></a>
+<span class="sourceLineNo">2052</span>          LOG.warn(this.zooKeeper.prefix("Unable to get information about " +<a name="line.2052"></a>
+<span class="sourceLineNo">2053</span>                   "backup servers"), e);<a name="line.2053"></a>
+<span class="sourceLineNo">2054</span>        }<a name="line.2054"></a>
+<span class="sourceLineNo">2055</span>      }<a name="line.2055"></a>
+<span class="sourceLineNo">2056</span>      Collections.sort(backupMasters, new Comparator&lt;ServerName&gt;() {<a name="line.2056"></a>
+<span class="sourceLineNo">2057</span>        @Override<a name="line.2057"></a>
+<span class="sourceLineNo">2058</span>        public int compare(ServerName s1, ServerName s2) {<a name="line.2058"></a>
+<span class="sourceLineNo">2059</span>          return s1.getServerName().compareTo(s2.getServerName());<a name="line.2059"></a>
+<span class="sourceLineNo">2060</span>        }});<a name="line.2060"></a>
+<span class="sourceLineNo">2061</span>    }<a name="line.2061"></a>
+<span class="sourceLineNo">2062</span><a name="line.2062"></a>
+<span class="sourceLineNo">2063</span>    String clusterId = fileSystemManager != null ?<a name="line.2063"></a>
+<span class="sourceLineNo">2064</span>      fileSystemManager.getClusterId().toString() : null;<a name="line.2064"></a>
+<span class="sourceLineNo">2065</span>    Map&lt;String, RegionState&gt; regionsInTransition = assignmentManager != null ?<a name="line.2065"></a>
+<span class="sourceLineNo">2066</span>      assignmentManager.getRegionStates().getRegionsInTransition() : null;<a name="line.2066"></a>
+<span class="sourceLineNo">2067</span>    String[] coprocessors = cpHost != null ? getMasterCoprocessors() : null;<a name="line.2067"></a>
+<span class="sourceLineNo">2068</span>    boolean balancerOn = loadBalancerTracker != null ?<a name="line.2068"></a>
+<span class="sourceLineNo">2069</span>      loadBalancerTracker.isBalancerOn() : false;<a name="line.2069"></a>
+<span class="sourceLineNo">2070</span>    Map&lt;ServerName, ServerLoad&gt; onlineServers = null;<a name="line.2070"></a>
+<span class="sourceLineNo">2071</span>    Set&lt;ServerName&gt; deadServers = null;<a name="line.2071"></a>
+<span class="sourceLineNo">2072</span>    if (serverManager != null) {<a name="line.2072"></a>
+<span class="sourceLineNo">2073</span>      deadServers = serverManager.getDeadServers().copyServerNames();<a name="line.2073"></a>
+<span class="sourceLineNo">2074</span>      onlineServers = serverManager.getOnlineServers();<a name="line.2074"></a>
+<span class="sourceLineNo">2075</span>    }<a name="line.2075"></a>
+<span class="sourceLineNo">2076</span>    return new ClusterStatus(VersionInfo.getVersion(), clusterId,<a name="line.2076"></a>
+<span class="sourceLineNo">2077</span>      onlineServers, deadServers, serverName, backupMasters,<a name="line.2077"></a>
+<span class="sourceLineNo">2078</span>      regionsInTransition, coprocessors, balancerOn);<a name="line.2078"></a>
+<span class="sourceLineNo">2079</span>  }<a name="line.2079"></a>
+<span class="sourceLineNo">2080</span><a name="line.2080"></a>
+<span class="sourceLineNo">2081</span>  /**<a name="line.2081"></a>
+<span class="sourceLineNo">2082</span>   * The set of loaded coprocessors is stored in a static set. Since it's<a name="line.2082"></a>
+<span class="sourceLineNo">2083</span>   * statically allocated, it does not require that HMaster's cpHost be<a name="line.2083"></a>
+<span class="sourceLineNo">2084</span>   * initialized prior to accessing it.<a name="line.2084"></a>
+<span class="sourceLineNo">2085</span>   * @return a String representation of the set of names of the loaded<a name="line.2085"></a>
+<span class="sourceLineNo">2086</span>   * coprocessors.<a name="line.2086"></a>
+<span class="sourceLineNo">2087</span>   */<a name="line.2087"></a>
+<span class="sourceLineNo">2088</span>  public static String getLoadedCoprocessors() {<a name="line.2088"></a>
+<span class="sourceLineNo">2089</span>    return CoprocessorHost.getLoadedCoprocessors().toString();<a name="line.2089"></a>
+<span class="sourceLineNo">2090</span>  }<a name="line.2090"></a>
+<span class="sourceLineNo">2091</span><a name="line.2091"></a>
+<span class="sourceLineNo">2092</span>  /**<a name="line.2092"></a>
+<span class="sourceLineNo">2093</span>   * @return timestamp in millis when HMaster was started.<a name="line.2093"></a>
+<span class="sourceLineNo">2094</span>   */<a name="line.2094"></a>
+<span class="sourceLineNo">2095</span>  public long getMasterStartTime() {<a name="line.2095"></a>
+<span class="sourceLineNo">2096</span>    return startcode;<a name="line.2096"></a>
+<span class="sourceLineNo">2097</span>  }<a name="line.2097"></a>
+<span class="sourceLineNo">2098</span><a name="line.2098"></a>
+<span class="sourceLineNo">2099</span>  /**<a name="line.2099"></a>
+<span class="sourceLineNo">2100</span>   * @return timestamp in millis when HMaster became the active master.<a name="line.2100"></a>
+<span class="sourceLineNo">2101</span>   */<a name="line.2101"></a>
+<span class="sourceLineNo">2102</span>  public long getMasterActiveTime() {<a name="line.2102"></a>
+<span class="sourceLineNo">2103</span>    return masterActiveTime;<a name="line.2103"></a>
+<span class="sourceLineNo">2104</span>  }<a name="line.2104"></a>
+<span class="sourceLineNo">2105</span><a name="line.2105"></a>
+<span class="sourceLineNo">2106</span>  public int getRegionServerInfoPort(final ServerName sn) {<a name="line.2106"></a>
+<span class="sourceLineNo">2107</span>    RegionServerInfo info = this.regionServerTracker.getRegionServerInfo(sn);<a name="line.2107"></a>
+<span class="sourceLineNo">2108</span>    if (info == null || info.getInfoPort() == 0) {<a name="line.2108"></a>
+<span class="sourceLineNo">2109</span>      return conf.getInt(HConstants.REGIONSERVER_INFO_PORT,<a name="line.2109"></a>
+<span class="sourceLineNo">2110</span>        HConstants.DEFAULT_REGIONSERVER_INFOPORT);<a name="line.2110"></a>
+<span class="sourceLineNo">2111</span>    }<a name="line.2111"></a>
+<span class="sourceLineNo">2112</span>    return info.getInfoPort();<a name="line.2112"></a>
+<span class="sourceLineNo">2113</span>  }<a name="line.2113"></a>
+<span class="sourceLineNo">2114</span><a name="line.2114"></a>
+<span class="sourceLineNo">2115</span>  public String getRegionServerVersion(final ServerName sn) {<a name="line.2115"></a>
+<span class="sourceLineNo">2116</span>    RegionServerInfo info = this.regionServerTracker.getRegionServerInfo(sn);<a name="line.2116"></a>
+<span class="sourceLineNo">2117</span>    if (info != null &amp;&amp; info.hasVersionInfo()) {<a name="line.2117"></a>
+<span class="sourceLineNo">2118</span>      return info.getVersionInfo().getVersion();<a name="line.2118"></a>
+<span class="sourceLineNo">2119</span>    }<a name="line.2119"></a>
+<span class="sourceLineNo">2120</span>    return "Unknown";<a name="line.2120"></a>
+<span class="sourceLineNo">2121</span>  }<a name="line.2121"></a>
+<span class="sourceLineNo">2122</span><a name="line.2122"></a>
+<span class="sourceLineNo">2123</span>  /**<a name="line.2123"></a>
+<span class="sourceLineNo">2124</span>   * @return array of coprocessor SimpleNames.<a name="line.2124"></a>
+<span class="sourceLineNo">2125</span>   */<a name="line.2125"></a>
+<span class="sourceLineNo">2126</span>  public String[] getMasterCoprocessors() {<a name="line.2126"></a>
+<span class="sourceLineNo">2127</span>    Set&lt;String&gt; masterCoprocessors = getMasterCoprocessorHost().getCoprocessors();<a name="line.2127"></a>
+<span class="sourceLineNo">2128</span>    return masterCoprocessors.toArray(new String[masterCoprocessors.size()]);<a name="line.2128"></a>
+<span class="sourceLineNo">2129</span>  }<a name="line.2129"></a>
+<span class="sourceLineNo">2130</span><a name="line.2130"></a>
+<span class="sourceLineNo">2131</span>  @Override<a name="line.2131"></a>
+<span class="sourceLineNo">2132</span>  public void abort(final String msg, final Throwable t) {<a name="line.2132"></a>
+<span class="sourceLineNo">2133</span>    if (isAborted() || isStopped()) {<a name="line.2133"></a>
+<span class="sourceLineNo">2134</span>      return;<a name="line.2134"></a>
+<span class="sourceLineNo">2135</span>    }<a name="line.2135"></a>
+<span class="sourceLineNo">2136</span>    if (cpHost != null) {<a name="line.2136"></a>
+<span class="sourceLineNo">2137</span>      // HBASE-4014: dump a list of loaded coprocessors.<a name="line.2137"></a>
+<span class="sourceLineNo">2138</span>      LOG.fatal("Master server abort: loaded coprocessors are: " +<a name="line.2138"></a>
+<span class="sourceLineNo">2139</span>          getLoadedCoprocessors());<a name="line.2139"></a>
+<span class="sourceLineNo">2140</span>    }<a name="line.2140"></a>
+<span class="sourceLineNo">2141</span>    if (t != null) LOG.fatal(msg, t);<a name="line.2141"></a>
+<span class="sourceLineNo">2142</span>    stopMaster();<a name="line.2142"></a>
+<span class="sourceLineNo">2143</span>  }<a name="line.2143"></a>
+<span class="sourceLineNo">2144</span><a name="line.2144"></a>
+<span class="sourceLineNo">2145</span>  @Override<a name="line.2145"></a>
+<span class="sourceLineNo">2146</span>  public ZooKeeperWatcher getZooKeeper() {<a name="line.2146"></a>
+<span class="sourceLineNo">2147</span>    return zooKeeper;<a name="line.2147"></a>
+<span class="sourceLineNo">2148</span>  }<a name="line.2148"></a>
+<span class="sourceLineNo">2149</span><a name="line.2149"></a>
+<span class="sourceLineNo">2150</span>  @Override<a name="line.2150"></a>
+<span class="sourceLineNo">2151</span>  public MasterCoprocessorHost getMasterCoprocessorHost() {<a name="line.2151"></a>
+<span class="sourceLineNo">2152</span>    return cpHost;<a name="line.2152"></a>
+<span class="sourceLineNo">2153</span>  }<a name="line.2153"></a>
+<span class="sourceLineNo">2154</span><a name="line.2154"></a>
+<span class="sourceLineNo">2155</span>  @Override<a name="line.2155"></a>
+<span class="sourceLineNo">2156</span>  public MasterQuotaManager getMasterQuotaManager() {<a name="line.2156"></a>
+<span class="sourceLineNo">2157</span>    return quotaManager;<a name="line.2157"></a>
+<span class="sourceLineNo">2158</span>  }<a name="line.2158"></a>
+<span class="sourceLineNo">2159</span><a name="line.2159"></a>
+<span class="sourceLineNo">2160</span>  @Override<a name="line.2160"></a>
+<span class="sourceLineNo">2161</span>  public ProcedureExecutor&lt;MasterProcedureEnv&gt; getMasterProcedureExecutor() {<a name="line.2161"></a>
+<span class="sourceLineNo">2162</span>    return procedureExecutor;<a name="line.2162"></a>
+<span class="sourceLineNo">2163</span>  }<a name="line.2163"></a>
+<span class="sourceLineNo">2164</span><a name="line.2164"></a>
+<span class="sourceLineNo">2165</span>  @Override<a name="line.2165"></a>
+<span class="sourceLineNo">2166</span>  public ServerName getServerName() {<a name="line.2166"></a>
+<span class="sourceLineNo">2167</span>    return this.serverName;<a name="line.2167"></a>
+<span class="sourceLineNo">2168</span>  }<a name="line.2168"></a>
+<span class="sourceLineNo">2169</span><a name="line.2169"></a>
+<span class="sourceLineNo">2170</span>  @Override<a name="line.2170"></a>
+<span class="sourceLineNo">2171</span>  public AssignmentManager getAssignmentManager() {<a name="line.2171"></a>
+<span class="sourceLineNo">2172</span>    return this.assignmentManager;<a name="line.2172"></a>
+<span class="sourceLineNo">2173</span>  }<a name="line.2173"></a>
+<span class="sourceLineNo">2174</span><a name="line.2174"></a>
+<span class="sourceLineNo">2175</span>  public MemoryBoundedLogMessageBuffer getRegionServerFatalLogBuffer() {<a name="line.2175"></a>
+<span class="sourceLineNo">2176</span>    return rsFatals;<a name="line.2176"></a>
+<span class="sourceLineNo">2177</span>  }<a name="line.2177"></a>
+<span class="sourceLineNo">2178</span><a name="line.2178"></a>
+<span class="sourceLineNo">2179</span>  public void shutdown() {<a name="line.2179"></a>
+<span class="sourceLineNo">2180</span>    if (cpHost != null) {<a name="line.2180"></a>
+<span class="sourceLineNo">2181</span>      try {<a name="line.2181"></a>
+<span class="sourceLineNo">2182</span>        cpHost.preShutdown();<a name="line.2182"></a>
+<span class="sourceLineNo">2183</span>      } catch (IOException ioe) {<a name="line.2183"></a>
+<span class="sourceLineNo">2184</span>        LOG.error("Error call master coprocessor preShutdown()", ioe);<a name="line.2184"></a>
+<span class="sourceLineNo">2185</span>      }<a name="line.2185"></a>
+<span class="sourceLineNo">2186</span>    }<a name="line.2186"></a>
+<span class="sourceLineNo">2187</span><a name="line.2187"></a>
+<span class="sourceLineNo">2188</span>    if (this.serverManager != null) {<a name="line.2188"></a>
+<span class="sourceLineNo">2189</span>      this.serverManager.shutdownCluster();<a name="line.2189"></a>
+<span class="sourceLineNo">2190</span>    }<a name="line.2190"></a>
+<span class="sourceLineNo">2191</span>    if (this.clusterStatusTracker != null){<a name="line.2191"></a>
+<span class="sourceLineNo">2192</span>      try {<a name="line.2192"></a>
+<span class="sourceLineNo">2193</span>        this.clusterStatusTracker.setClusterDown();<a name="line.2193"></a>
+<span class="sourceLineNo">2194</span>      } catch (KeeperException e) {<a name="line.2194"></a>
+<span class="sourceLineNo">2195</span>        LOG.error("ZooKeeper exception trying to set cluster as down in ZK", e);<a name="line.2195"></a>
+<span class="sourceLineNo">2196</span>      }<a name="line.2196"></a>
+<span class="sourceLineNo">2197</span>    }<a name="line.2197"></a>
+<span class="sourceLineNo">2198</span>  }<a name="line.2198"></a>
+<span class="sourceLineNo">2199</span><a name="line.2199"></a>
+<span class="sourceLineNo">2200</span>  public void stopMaster() {<a name="line.2200"></a>
+<span class="sourceLineNo">2201</span>    if (cpHost != null) {<a name="line.2201"></a>
+<span class="sourceLineNo">2202</span>      try {<a name="line.2202"></a>
+<span class="sourceLineNo">2203</span>        cpHost.preStopMaster();<a name="line.2203"></a>
+<span class="sourceLineNo">2204</span>      } catch (IOException ioe) {<a name="line.2204"></a>
+<span class="sourceLineNo">2205</span>        LOG.error("Error call master coprocessor preStopMaster()", ioe);<a name="line.2205"></a>
+<span class="sourceLineNo">2206</span>      }<a name="line.2206"></a>
+<span class="sourceLineNo">2207</span>    }<a name="line.2207"></a>
+<span class="sourceLineNo">2208</span>    stop("Stopped by " + Thread.currentThread().getName());<a name="line.2208"></a>
+<span class="sourceLineNo">2209</span>  }<a name="line.2209"></a>
+<span class="sourceLineNo">2210</span><a name="line.2210"></a>
+<span class="sourceLineNo">2211</span>  void checkServiceStarted() throws ServerNotRunningYetException {<a name="line.2211"></a>
+<span class="sourceLineNo">2212</span>    if (!serviceStarted) {<a name="line.2212"></a>
+<span class="sourceLineNo">2213</span>      throw new ServerNotRunningYetException("Server is not running yet");<a name="line.2213"></a>
+<span class="sourceLineNo">2214</span>    }<a name="line.2214"></a>
+<span class="sourceLineNo">2215</span>  }<a name="line.2215"></a>
+<span class="sourceLineNo">2216</span><a name="line.2216"></a>
+<span class="sourceLineNo">2217</span>  void checkInitialized() throws PleaseHoldException, ServerNotRunningYetException {<a name="line.2217"></a>
+<span class="sourceLineNo">2218</span>    checkServiceStarted();<a name="line.2218"></a>
+<span class="sourceLineNo">2219</span>    if (!this.initialized) {<a name="line.2219"></a>
+<span class="sourceLineNo">2220</span>      throw new PleaseHoldException("Master is initializing");<a name="line.2220"></a>
+<span class="sourceLineNo">2221</span>    }<a name="line.2221"></a>
+<span class="sourceLineNo">2222</span>  }<a name="line.2222"></a>
+<span class="sourceLineNo">2223</span><a name="line.2223"></a>
+<span class="sourceLineNo">2224</span>  void checkNamespaceManagerReady() throws IOException {<a name="line.2224"></a>
+<span class="sourceLineNo">2225</span>    checkInitialized();<a name="line.2225"></a>
+<span class="sourceLineNo">2226</span>    if (tableNamespaceManager == null ||<a name="line.2226"></a>
+<span class="sourceLineNo">2227</span>        !tableNamespaceManager.isTableAvailableAndInitialized(true)) {<a name="line.2227"></a>
+<span class="sourceLineNo">2228</span>      throw new IOException("Table Namespace Manager not ready yet, try again later");<a name="line.2228"></a>
+<span class="sourceLineNo">2229</span>    }<a name="line.2229"></a>
+<span class="sourceLineNo">2230</span>  }<a name="line.2230"></a>
+<span class="sourceLineNo">2231</span>  /**<a name="line.2231"></a>
+<span class="sourceLineNo">2232</span>   * Report whether this master is currently the active master or not.<a name="line.2232"></a>
+<span class="sourceLineNo">2233</span>   * If not active master, we are parked on ZK waiting to become active.<a name="line.2233"></a>
 <span class="sourceLineNo">2234</span>   *<a name="line.2234"></a>
-<span class="sourceLineNo">2235</span>   * @return true if active master, false if not.<a name="line.2235"></a>
-<span class="sourceLineNo">2236</span>   */<a name="line.2236"></a>
-<span class="sourceLineNo">2237</span>  public boolean isActiveMaster() {<a name="line.2237"></a>
-<span class="sourceLineNo">2238</span>    return isActiveMaster;<a name="line.2238"></a>
-<span class="sourceLineNo">2239</span>  }<a name="line.2239"></a>
-<span class="sourceLineNo">2240</span><a name="line.2240"></a>
-<span class="sourceLineNo">2241</span>  /**<a name="line.2241"></a>
-<span class="sourceLineNo">2242</span>   * Report whether this master has completed with its initialization and is<a name="line.2242"></a>
-<span class="sourceLineNo">2243</span>   * ready.  If ready, the master is also the active master.  A standby master<a name="line.2243"></a>
-<span class="sourceLineNo">2244</span>   * is never ready.<a name="line.2244"></a>
-<span class="sourceLineNo">2245</span>   *<a name="line.2245"></a>
-<span class="sourceLineNo">2246</span>   * This method is used for testing.<a name="line.2246"></a>
+<span class="sourceLineNo">2235</span>   * This method is used for testing.<a name="line.2235"></a>
+<span class="sourceLineNo">2236</span>   *<a name="line.2236"></a>
+<span class="sourceLineNo">2237</span>   * @return true if active master, false if not.<a name="line.2237"></a>
+<span class="sourceLineNo">2238</span>   */<a name="line.2238"></a>
+<span class="sourceLineNo">2239</span>  public boolean isActiveMaster() {<a name="line.2239"></a>
+<span class="sourceLineNo">2240</span>    return isActiveMaster;<a name="line.2240"></a>
+<span class="sourceLineNo">2241</span>  }<a name="line.2241"></a>
+<span class="sourceLineNo">2242</span><a name="line.2242"></a>
+<span class="sourceLineNo">2243</span>  /**<a name="line.2243"></a>
+<span class="sourceLineNo">2244</span>   * Report whether this master has completed with its initialization and is<a name="line.2244"></a>
+<span class="sourceLineNo">2245</span>   * ready.  If ready, the master is also the active master.  A standby master<a name="line.2245"></a>
+<span class="sourceLineNo">2246</span>   * is never ready.<a name="line.2246"></a>
 <span class="sourceLineNo">2247</span>   *<a name="line.2247"></a>
-<span class="sourceLineNo">2248</span>   * @return true if master is ready to go, false if not.<a name="line.2248"></a>
-<span class="sourceLineNo">2249</span>   */<a name="line.2249"></a>
-<span class="sourceLineNo">2250</span>  @Override<a name="line.2250"></a>
-<span class="sourceLineNo">2251</span>  public boolean isInitialized() {<a name="line.2251"></a>
-<span class="sourceLineNo">2252</span>    return initialized;<a name="line.2252"></a>
-<span class="sourceLineNo">2253</span>  }<a name="line.2253"></a>
-<span class="sourceLineNo">2254</span><a name="line.2254"></a>
-<span class="sourceLineNo">2255</span>  /**<a name="line.2255"></a>
-<span class="sourceLineNo">2256</span>   * ServerCrashProcessingEnabled is set false before completing assignMeta to prevent processing<a name="line.2256"></a>
-<span class="sourceLineNo">2257</span>   * of crashed servers.<a name="line.2257"></a>
-<span class="sourceLineNo">2258</span>   * @return true if assignMeta has completed;<a name="line.2258"></a>
-<span class="sourceLineNo">2259</span>   */<a name="line.2259"></a>
-<span class="sourceLineNo">2260</span>  @Override<a name="line.2260"></a>
-<span class="sourceLineNo">2261</span>  public boolean isServerCrashProcessingEnabled() {<a name="line.2261"></a>
-<span class="sourceLineNo">2262</span>    return this.serverCrashProcessingEnabled;<a name="line.2262"></a>
-<span class="sourceLineNo">2263</span>  }<a name="line.2263"></a>
-<span class="sourceLineNo">2264</span><a name="line.2264"></a>
-<span class="sourceLineNo">2265</span>  @VisibleForTesting<a name="line.2265"></a>
-<span class="sourceLineNo">2266</span>  public void setServerCrashProcessingEnabled(final boolean b) {<a name="line.2266"></a>
-<span class="sourceLineNo">2267</span>    this.serverCrashProcessingEnabled = b;<a name="line.2267"></a>
-<span class="sourceLineNo">2268</span>  }<a name="line.2268"></a>
-<span class="sourceLineNo">2269</span><a name="line.2269"></a>
-<span class="sourceLineNo">2270</span>  /**<a name="line.2270"></a>
-<span class="sourceLineNo">2271</span>   * Report whether this master has started initialization and is about to do meta region assignment<a name="line.2271"></a>
-<span class="sourceLineNo">2272</span>   * @return true if master is in initialization &amp;amp; about to assign hbase:meta regions<a name="line.2272"></a>
-<span class="sourceLineNo">2273</span>   */<a name="line.2273"></a>
-<span class="sourceLineNo">2274</span>  public boolean isInitializationStartsMetaRegionAssignment() {<a name="line.2274"></a>
-<span class="sourceLineNo">2275</span>    return this.initializationBeforeMetaAssignment;<a name="line.2275"></a>
-<span class="sourceLineNo">2276</span>  }<a name="line.2276"></a>
-<span class="sourceLineNo">2277</span><a name="line.2277"></a>
-<span class="sourceLineNo">2278</span>  public void assignRegion(HRegionInfo hri) {<a name="line.2278"></a>
-<span class="sourceLineNo">2279</span>    assignmentManager.assign(hri);<a name="line.2279"></a>
-<span class="sourceLineNo">2280</span>  }<a name="line.2280"></a>
-<span class="sourceLineNo">2281</span><a name="line.2281"></a>
-<span class="sourceLineNo">2282</span>  /**<a name="line.2282"></a>
-<span class="sourceLineNo">2283</span>   * Compute the average load across all region servers.<a name="line.2283"></a>
-<span class="sourceLineNo">2284</span>   * Currently, this uses a very naive computation - just uses the number of<a name="line.2284"></a>
-<span class="sourceLineNo">2285</span>   * regions being served, ignoring stats about number of requests.<a name="line.2285"></a>
-<span class="sourceLineNo">2286</span>   * @return the average load<a name="line.2286"></a>
-<span class="sourceLineNo">2287</span>   */<a name="line.2287"></a>
-<span class="sourceLineNo">2288</span>  public double getAverageLoad() {<a name="line.2288"></a>
-<span class="sourceLineNo">2289</span>    if (this.assignmentManager == null) {<a name="line.2289"></a>
-<span class="sourceLineNo">2290</span>      return 0;<a name="line.2290"></a>
-<span class="sourceLineNo">2291</span>    }<a name="line.2291"></a>
-<span class="sourceLineNo">2292</span><a name="line.2292"></a>
-<span class="sourceLineNo">2293</span>    RegionStates regionStates = this.assignmentManager.getRegionStates();<a name="line.2293"></a>
-<span class="sourceLineNo">2294</span>    if (regionStates == null) {<a name="line.2294"></a>
-<span class="sourceLineNo">2295</span>      return 0;<a name="line.2295"></a>
-<span class="sourceLineNo">2296</span>    }<a name="line.2296"></a>
-<span class="sourceLineNo">2297</span>    return regionStates.getAverageLoad();<a name="line.2297"></a>
-<span class="sourceLineNo">2298</span>  }<a name="line.2298"></a>
-<span class="sourceLineNo">2299</span><a name="line.2299"></a>
-<span class="sourceLineNo">2300</span>  @Override<a name="line.2300"></a>
-<span class="sourceLineNo">2301</span>  public boolean registerService(Service instance) {<a name="line.2301"></a>
-<span class="sourceLineNo">2302</span>    /*<a name="line.2302"></a>
-<span class="sourceLineNo">2303</span>     * No stacking of instances is allowed for a single service name<a name="line.2303"></a>
-<span class="sourceLineNo">2304</span>     */<a name="line.2304"></a>
-<span class="sourceLineNo">2305</span>    Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();<a name="line.2305"></a>
-<span class="sourceLineNo">2306</span>    if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {<a name="line.2306"></a>
-<span class="sourceLineNo">2307</span>      LOG.error("Coprocessor service "+serviceDesc.getFullName()+<a name="line.2307"></a>
-<span class="sourceLineNo">2308</span>          " already registered, rejecting request from "+instance<a name="line.2308"></a>
-<span class="sourceLineNo">2309</span>      );<a name="line.2309"></a>
-<span class="sourceLineNo">2310</span>      return false;<a name="line.2310"></a>
-<span class="sourceLineNo">2311</span>    }<a name="line.2311"></a>
-<span class="sourceLineNo">2312</span><a name="line.2312"></a>
-<span class="sourceLineNo">2313</span>    coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);<a name="line.2313"></a>
-<span class="sourceLineNo">2314</span>    if (LOG.isDebugEnabled()) {<a name="line.2314"></a>
-<span class="sourceLineNo">2315</span>      LOG.debug("Registered master coprocessor service: service="+serviceDesc.getFullName());<a name="line.2315"></a>
-<span class="sourceLineNo">2316</span>    }<a name="line.2316"></a>
-<span class="sourceLineNo">2317</span>    return true;<a name="line.2317"></a>
-<span class="sourceLineNo">2318</span>  }<a name="line.2318"></a>
-<span class="sourceLineNo">2319</span><a name="line.2319"></a>
-<span class="sourceLineNo">2320</span>  /**<a name="line.2320"></a>
-<span class="sourceLineNo">2321</span>   * Utility for constructing an instance of the passed HMaster class.<a name="line.2321"></a>
-<span class="sourceLineNo">2322</span>   * @param masterClass<a name="line.2322"></a>
-<span class="sourceLineNo">2323</span>   * @param conf<a name="line.2323"></a>
-<span class="sourceLineNo">2324</span>   * @return HMaster instance.<a name="line.2324"></a>
-<span class="sourceLineNo">2325</span>   */<a name="line.2325"></a>
-<span class="sourceLineNo">2326</span>  public static HMaster constructMaster(Class&lt;? extends HMaster&gt; masterClass,<a name="line.2326"></a>
-<span class="sourceLineNo">2327</span>      final Configuration conf, final CoordinatedStateManager cp)  {<a name="line.2327"></a>
-<span class="sourceLineNo">2328</span>    try {<a name="line.2328"></a>
-<span class="sourceLineNo">2329</span>      Constructor&lt;? extends HMaster&gt; c =<a name="line.2329"></a>
-<span class="sourceLineNo">2330</span>        masterClass.getConstructor(Configuration.class, CoordinatedStateManager.class);<a name="line.2330"></a>
-<span class="sourceLineNo">2331</span>      return c.newInstance(conf, cp);<a name="line.2331"></a>
-<span class="sourceLineNo">2332</span>    } catch(Exception e) {<a name="line.2332"></a>
-<span class="sourceLineNo">2333</span>      Throwable error = e;<a name="line.2333"></a>
-<span class="sourceLineNo">2334</span>      if (e instanceof InvocationTargetException &amp;&amp;<a name="line.2334"></a>
-<span class="sourceLineNo">2335</span>          ((InvocationTargetException)e).getTargetException() != null) {<a name="line.2335"></a>
-<span class="sourceLineNo">2336</span>        error = ((InvocationTargetException)e).getTargetException();<a name="line.2336"></a>
-<span class="sourceLineNo">2337</span>      }<a name="line.2337"></a>
-<span class="sourceLineNo">2338</span>      throw new RuntimeException("Failed construction of Master: " + masterClass.toString() + ". "<a name="line.2338"></a>
-<span class="sourceLineNo">2339</span>        , error);<a name="line.2339"></a>
-<span class="sourceLineNo">2340</span>    }<a name="line.2340"></a>
-<span class="sourceLineNo">2341</span>  }<a name="line.2341"></a>
-<span class="sourceLineNo">2342</span><a name="line.2342"></a>
-<span class="sourceLineNo">2343</span>  /**<a name="line.2343"></a>
-<span class="sourceLineNo">2344</span>   * @see org.apache.hadoop.hbase.master.HMasterCommandLine<a name="line.2344"></a>
-<span class="sourceLineNo">2345</span>   */<a name="line.2345"></a>
-<span class="sourceLineNo">2346</span>  public static void main(String [] args) {<a name="line.2346"></a>
-<span class="sourceLineNo">2347</span>    VersionInfo.logVersion();<a name="line.2347"></a>
-<span class="sourceLineNo">2348</span>    new HMasterCommandLine(HMaster.class).doMain(args);<a name="line.2348"></a>
-<span class="sourceLineNo">2349</span>  }<a name="line.2349"></a>
-<span class="sourceLineNo">2350</span><a name="line.2350"></a>
-<span class="sourceLineNo">2351</span>  public HFileCleaner getHFileCleaner() {<a name="line.2351"></a>
-<span class="sourceLineNo">2352</span>    return this.hfileCleaner;<a name="line.2352"></a>
-<span class="sourceLineNo">2353</span>  }<a name="line.2353"></a>
-<span class="sourceLineNo">2354</span><a name="line.2354"></a>
-<span class="sourceLineNo">2355</span>  /**<a name="line.2355"></a>
-<span class="sourceLineNo">2356</span>   * Exposed for TESTING!<a name="line.2356"></a>
-<span class="sourceLineNo">2357</span>   * @return the underlying snapshot manager<a name="line.2357"></a>
-<span class="sourceLineNo">2358</span>   */<a name="line.2358"></a>
-<span class="sourceLineNo">2359</span>  public SnapshotManager getSnapshotManagerForTesting() {<a name="line.2359"></a>
-<span class="sourceLineNo">2360</span>    return this.snapshotManager;<a name="line.2360"></a>
-<span class="sourceLineNo">2361</span>  }<a name="line.2361"></a>
-<span class="sourceLineNo">2362</span><a name="line.2362"></a>
-<span class="sourceLineNo">2363</span>  @Override<a name="line.2363"></a>
-<span class="sourceLineNo">2364</span>  public void createNamespace(<a name="line.2364"></a>
-<span class="sourceLineNo">2365</span>      final NamespaceDescriptor descriptor,<a name="line.2365"></a>
-<span class="sourceLineNo">2366</span>      final long nonceGroup,<a name="line.2366"></a>
-<span class="sourceLineNo">2367</span>      final long nonce) throws IOException {<a name="line.2367"></a>
-<span class="sourceLineNo">2368</span>    TableName.isLegalNamespaceName(Bytes.toBytes(descriptor.getName()));<a name="line.2368"></a>
-<span class="sourceLineNo">2369</span>    checkNamespaceManagerReady();<a name="line.2369"></a>
-<span class="sourceLineNo">2370</span>    if (cpHost != null) {<a name="line.2370"></a>
-<span class="sourceLineNo">2371</span>      if (cpHost.preCreateNamespace(descriptor)) {<a name="line.2371"></a>
-<span class="sourceLineNo">2372</span>        return;<a name="line.2372"></a>
-<span class="sourceLineNo">2373</span>      }<a name="line.2373"></a>
-<span class="sourceLineNo">2374</span>    }<a name="line.2374"></a>
-<span class="sourceLineNo">2375</span>    createNamespaceSync(descriptor, nonceGroup, nonce);<a name="line.2375"></a>
-<span class="sourceLineNo">2376</span>    if (cpHost != null) {<a name="line.2376"></a>
-<span class="sourceLineNo">2377</span>      cpHost.postCreateNamespace(descriptor);<a name="line.2377"></a>
-<span class="sourceLineNo">2378</span>    }<a name="line.2378"></a>
-<span class="sourceLineNo">2379</span>  }<a name="line.2379"></a>
-<span class="sourceLineNo">2380</span><a name="line.2380"></a>
-<span class="sourceLineNo">2381</span>  @Override<a name="line.2381"></a>
-<span class="sourceLineNo">2382</span>  public void createNamespaceSync(<a name="line.2382"></a>
-<span class="sourceLineNo">2383</span>      final NamespaceDescriptor descriptor,<a name="line.2383"></a>
-<span class="sourceLineNo">2384</span>      final long nonceGroup,<a name="line.2384"></a>
-<span class="sourceLineNo">2385</span>      final long nonce) throws IOException {<a name="line.2385"></a>
-<span class="sourceLineNo">2386</span>    LOG.info(getClientIdAuditPrefix() + " creating " + descriptor);<a name="line.2386"></a>
-<span class="sourceLineNo">2387</span>    // Execute the operation synchronously - wait for the operation to complete before continuing.<a name="line.2387"></a>
-<span class="sourceLineNo">2388</span>    long procId = this.procedureExecutor.submitProcedure(<a name="line.2388"></a>
-<span class="sourceLineNo">2389</span>      new CreateNamespaceProcedure(procedureExecutor.getEnvironment(), descriptor),<a name="line.2389"></a>
-<span class="sourceLineNo">2390</span>      nonceGroup,<a name="line.2390"></a>
-<span class="sourceLineNo">2391</span>      nonce);<a name="line.2391"></a>
-<span class="sourceLineNo">2392</span>    ProcedureSyncWait.waitForProcedureToComplete(procedureExecutor, procId);<a name="line.2392"></a>
-<span class="sourceLineNo">2393</span>  }<a name="line.2393"></a>
-<span class="sourceLineNo">2394</span><a name="line.2394"></a>
-<span class="sourceLineNo">2395</span>  @Override<a name="line.2395"></a>
-<span class="sourceLineNo">2396</span>  public void modifyNamespace(<a name="line.2396"></a>
-<span class="sourceLineNo">2397</span>      final NamespaceDescriptor descriptor,<a name="line.2397"></a>
-<span class="sourceLineNo">2398</span>      final long nonceGroup,<a name="line.2398"></a>
-<span class="sourceLineNo">2399</span>      final long nonce) throws IOException {<a name="line.2399"></a>
-<span class="sourceLineNo">2400</span>    TableName.isLegalNamespaceName(Bytes.toBytes(descriptor.getName()));<a name="line.2400"></a>
-<span class="sourceLineNo">2401</span>    checkNamespaceManagerReady();<a name="line.2401"></a>
-<span class="sourceLineNo">2402</span>    if (cpHost != null) {<a name="line.2402"></a>
-<span class="sourceLineNo">2403</span>      if (cpHost.preModifyNamespace(descriptor)) {<a name="line.2403"></a>
-<span class="sourceLineNo">2404</span>        return;<a name="line.2404"></a>
-<span class="sourceLineNo">2405</span>      }<a name="line.2405"></a>
-<span class="sourceLineNo">2406</span>    }<a name="line.2406"></a>
-<span class="sourceLineNo">2407</span>    LOG.info(getClientIdAuditPrefix() + " modify " + descriptor);<a name="line.2407"></a>
-<span class="sourceLineNo">2408</span>    // Execute the operation synchronously - wait for the operation to complete before continuing.<a name="line.2408"></a>
-<span class="sourceLineNo">2409</span>    long procId = this.procedureExecutor.submitProcedure(<a name="line.2409"></a>
-<span class="sourceLineNo">2410</span>      new ModifyNamespaceProcedure(procedureExecutor.getEnvironment(), descriptor),<a name="line.2410"></a>
-<span class="sourceLineNo">2411</span>      nonceGroup,<a name="line.2411"></a>
-<span class="sourceLineNo">2412</span>      nonce);<a name="line.2412"></a>
-<span class="sourceLineNo">2413</span>    ProcedureSyncWait.waitForProcedureToComplete(procedureExecutor, procId);<a name="line.2413"></a>
-<span class="sourceLineNo">2414</span>    if (cpHost != null) {<a name="line.2414"></a>
-<span class="sourceLineNo">2415</span>      cpHost.postModifyNamespace(descriptor);<a name="line.2415"></a>
-<span class="sourceLineNo">2416</span>    }<a name="line.2416"></a>
-<span class="sourceLineNo">2417</span>  }<a name="line.2417"></a>
-<span class="sourceLineNo">2418</span><a name="line.2418"></a>
-<span class="sourceLineNo">2419</span>  @Override<a name="line.2419"></a>
-<span class="sourceLineNo">2420</span>  public void deleteNamespace(<a name="line.2420"></a>
-<span class="sourceLineNo">2421</span>      final String name,<a name="line.2421"></a>
-<span class="sourceLineNo">2422</span>      final long nonceGroup,<a name="line.2422"></a>
-<span class="sourceLineNo">2423</span>      final long nonce) throws IOException {<a name="line.2423"></a>
-<span class="sourceLineNo">2424</span>    checkNamespaceManagerReady();<a name="line.2424"></a>
-<span class="sourceLineNo">2425</span>    if (cpHost != null) {<a name="line.2425"></a>
-<span class="sourceLineNo">2426</span>      if (cpHost.preDeleteNamespace(name)) {<a name="line.2426"></a>
-<span class="sourceLineNo">2427</span>        return;<a name="line.2427"></a>
-<span class="sourceLineNo">2428</span>      }<a name="line.2428"></a>
-<span class="sourceLineNo">2429</span>    }<a name="line.2429"></a>
-<span class="sourceLineNo">2430</span>    LOG.info(getClientIdAuditPrefix() + " delete " + name);<a name="line.2430"></a>
-<span class="sourceLineNo">2431</span>    // Execute the operation synchronously - wait for the operation to complete before continuing.<a name="line.2431"></a>
-<span class="sourceLineNo">2432</span>    long procId = this.procedureExecutor.submitProcedure(<a name="line.2432"></a>
-<span class="sourceLineNo">2433</span>      new DeleteNamespaceProcedure(procedureExecutor.getEnvironment(), name),<a name="line.2433"></a>
-<span class="sourceLineNo">2434</span>      nonceGroup,<a name="line.2434"></a>
-<span class="sourceLineNo">2435</span>      nonce);<a name="line.2435"></a>
-<span class="sourceLineNo">2436</span>    ProcedureSyncWait.waitForProcedureToComplete(procedureExecutor, procId);<a name="line.2436"></a>
-<span class="sourceLineNo">2437</span>    if (cpHost != null) {<a name="line.2437"></a>
-<span class="sourceLineNo">2438</span>      cpHost.postDeleteNamespace(name);<a name="line.2438"></a>
-<span class="sourceLineNo">2439</span>    }<a name="line.2439"></a>
-<span class="sourceLineNo">2440</span>  }<a name="line.2440"></a>
-<span class="sourceLineNo">2441</span><a name="line.2441"></a>
-<span class="sourceLineNo">2442</span>  /**<a name="line.2442"></a>
-<span class="sourceLineNo">2443</span>   * Ensure that the specified namespace exists, otherwise throws a NamespaceNotFoundException<a name="line.2443"></a>
-<span class="sourceLineNo">2444</span>   *<a name="line.2444"></a>
-<span class="sourceLineNo">2445</span>   * @param name the namespace to check<a name="line.2445"></a>
-<span class="sourceLineNo">2446</span>   * @throws IOException if the namespace manager is not ready yet.<a name="line.2446"></a>
-<span class="sourceLineNo">2447</span>   * @throws NamespaceNotFoundException if the namespace does not exists<a name="line.2447"></a>
-<span class="sourceLineNo">2448</span>   */<a name="line.2448"></a>
-<span class="sourceLineNo">2449</span>  private void ensureNamespaceExists(final String name)<a name="line.2449"></a>
-<span class="sourceLineNo">2450</span>      throws IOException, NamespaceNotFoundException {<a name="line.2450"></a>
-<span class="sourceLineNo">2451</span>    checkNamespaceManagerReady();<a name="line.2451"></a>
-<span class="sourceLineNo">2452</span>    NamespaceDescriptor nsd = tableNamespaceManager.get(name);<a name="line.2452"></a>
-<span class="sourceLineNo">2453</span>    if (nsd == null) {<a name="line.2453"></a>
-<span class="sourceLineNo">2454</span>      throw new NamespaceNotFoundException(name);<a name="line.2454"></a>
-<span class="sourceLineNo">2455</span>    }<a name="line.2455"></a>
-<span class="sourceLineNo">2456</span>  }<a name="line.2456"></a>
-<span class="sourceLineNo">2457</span><a name="line.2457"></a>
-<span class="sourceLineNo">2458</span>  @Override<a name="line.2458"></a>
-<span class="sourceLineNo">2459</span>  public NamespaceDescriptor getNamespaceDescriptor(String name) throws IOException {<a name="line.2459"></a>
-<span class="sourceLineNo">2460</span>    checkNamespaceManagerReady();<a name="line.2460"></a>
-<span class="sourceLineNo">2461</span><a name="line.2461"></a>
-<span class="sourceLineNo">2462</span>    if (cpHost != null) {<a name="line.2462"></a>
-<span class="sourceLineNo">2463</span>      cpHost.preGetNamespaceDescriptor(name);<a name="line.2463"></a>
-<span class="sourceLineNo">2464</span>    }<a name="line.2464"></a>
-<span class="sourceLineNo">2465</span><a name="line.2465"></a>
-<span class="sourceLineNo">2466</span>    NamespaceDescriptor nsd = tableNamespaceManager.get(name);<a name="line.2466"></a>
-<span class="sourceLineNo">2467</span>    if (nsd == null) {<a name="line.2467"></a>
-<span class="sourceLineNo">2468</span>      throw new NamespaceNotFoundException(name);<a name="line.2468"></a>
-<span class="sourceLineNo">2469</span>    }<a name="line.2469"></a>
-<span class="sourceLineNo">2470</span><a name="line.2470"></a>
-<span class="sourceLineNo">2471</span>    if (cpHost != null) {<a name="line.2471"></a>
-<span class="sourceLineNo">2472</span>      cpHost.postGetNamespaceDescriptor(nsd);<a name="line.2472"></a>
-<span class="sourceLineNo">2473</span>    }<a name="line.2473"></a>
-<span class="sourceLineNo">2474</span><a name="line.2474"></a>
-<span class="sourceLineNo">2475</span>    return nsd;<a name="line.2475"></a>
-<span class="sourceLineNo">2476</span>  }<a name="line.2476"></a>
-<span class="sourceLineNo">2477</span><a name="line.2477"></a>
-<span class="sourceLineNo">2478</span>  @Override<a name="line.2478"></a>
-<span class="sourceLineNo">2479</span>  public List&lt;NamespaceDescriptor&gt; listNamespaceDescriptors() throws IOException {<a name="line.2479"></a>
-<span class="sourceLineNo">2480</span>    checkNamespaceManagerReady();<a name="line.2480"></a>
-<span class="sourceLineNo">2481</span><a name="line.2481"></a>
-<span class="sourceLineNo">2482</span>    final List&lt;NamespaceDescriptor&gt; descriptors = new ArrayList&lt;NamespaceDescriptor&gt;();<a name="line.2482"></a>
-<span class="sourceLineNo">2483</span>    boolean bypass = false;<a name="line.2483"></a>
-<span class="sourceLineNo">2484</span>    if (cpHost != null) {<a name="line.2484"></a>
-<span class="sourceLineNo">2485</span>      bypass = cpHost.preListNamespaceDescriptors(descriptors);<a name="line.2485"></a>
-<span class="sourceLineNo">2486</span>    }<a name="line.2486"></a>
-<span class="sourceLineNo">2487</span><a name="line.2487"></a>
-<span class="sourceLineNo">2488</span>    if (!bypass) {<a name="line.2488"></a>
-<span class="sourceLineNo">2489</span>      descriptors.addAll(tableNamespaceManager.list());<a name="line.2489"></a>
-<span class="sourceLineNo">2490</span><a name="line.2490"></a>
-<span class="sourceLineNo">2491</span>      if (cpHost != null) {<a name="line.2491"></a>
-<span class="sourceLineNo">2492</span>        cpHost.postListNamespaceDescriptors(descriptors);<a name="line.2492"></a>
-<span class="sourceLineNo">2493</span>      }<a name="line.2493"></a>
-<span class="sourceLineNo">2494</span>    }<a name="line.2494"></a>
-<span class="sourceLineNo">2495</span>    return descriptors;<a name="line.2495"></a>
-<span class="sourceLineNo">2496</span>  }<a name="line.2496"></a>
-<span class="sourceLineNo">2497</span><a name="line.2497"></a>
-<span class="sourceLineNo">2498</span>  @Override<a name="line.2498"></a>
-<span class="sourceLineNo">2499</span>  public boolean abortProcedure(final long procId, final boolean mayInterruptIfRunning)<a name="line.2499"></a>
-<span class="sourceLineNo">2500</span>      throws IOException {<a name="line.2500"></a>
-<span class="sourceLineNo">2501</span>    if (cpHost != null) {<a name="line.2501"></a>
-<span class="sourceLineNo">2502</span>      cpHost.preAbortProcedure(this.procedureExecutor, procId);<a name="line.2502"></a>
-<span class="sourceLineNo">2503</span>    }<a name="line.2503"></a>
-<span class="sourceLineNo">2504</span><a name="line.2504"></a>
-<span class="sourceLineNo">2505</span>    final boolean result = this.procedureExecutor.abort(procId, mayInterruptIfRunning);<a name="line.2505"></a>
+<span class="sourceLineNo">2248</span>   * This method is used for testing.<a name="line.2248"></a>
+<span class="sourceLineNo">2249</span>   *<a name="line.2249"></a>
+<span class="sourceLineNo">2250</span>   * @return true if master is ready to go, false if not.<a name="line.2250"></a>
+<span class="sourceLineNo">2251</span>   */<a name="line.2251"></a>
+<span class="sourceLineNo">2252</span>  @Override<a name="line.2252"></a>
+<span class="sourceLineNo">2253</span>  public boolean isInitialized() {<a name="line.2253"></a>
+<span class="sourceLineNo">2254</span>    return initialized;<a name="line.2254"></a>
+<span class="sourceLineNo">2255</span>  }<a name="line.2255"></a>
+<span class="sourceLineNo">2256</span><a name="line.2256"></a>
+<span class="sourceLineNo">2257</span>  /**<a name="line.2257"></a>
+<span class="sourceLineNo">2258</span>   * ServerCrashProcessingEnabled is set false before completing assignMeta to prevent processing<a name="line.2258"></a>
+<span class="sourceLineNo">2259</span>   * of crashed servers.<a name="line.2259"></a>
+<span class="sourceLineNo">2260</span>   * @return true if assignMeta has completed;<a name="line.2260"></a>
+<span class="sourceLineNo">2261</span>   */<a name="line.2261"></a>
+<span class="sourceLineNo">2262</span>  @Override<a name="line.2262"></a>
+<span class="sourceLineNo">2263</span>  public boolean isServerCrashProcessingEnabled() {<a name="line.2263"></a>
+<span class="sourceLineNo">2264</span>    return this.serverCrashProcessingEnabled;<a name="line.2264"></a>
+<span class="sourceLineNo">2265</span>  }<a name="line.2265"></a>
+<span class="sourceLineNo">2266</span><a name="line.2266"></a>
+<span class="sourceLineNo">2267</span>  @VisibleForTesting<a name="line.2267"></a>
+<span class="sourceLineNo">2268</span>  public void setServerCrashProcessingEnabled(final boolean b) {<a name="line.2268"></a>
+<span class="sourceLineNo">2269</span>    this.serverCrashProcessingEnabled = b;<a name="line.2269"></a>
+<span class="sourceLineNo">2270</span>  }<a name="line.2270"></a>
+<span class="sourceLineNo">2271</span><a name="line.2271"></a>
+<span class="sourceLineNo">2272</span>  /**<a name="line.2272"></a>
+<span class="sourceLineNo">2273</span>   * Report whether this master has started initialization and is about to do meta region assignment<a name="line.2273"></a>
+<span class="sourceLineNo">2274</span>   * @return true if master is in initialization &amp;amp; about to assign hbase:meta regions<a name="line.2274"></a>
+<span class="sourceLineNo">2275</span>   */<a name="line.2275"></a>
+<span class="sourceLineNo">2276</span>  public boolean isInitializationStartsMetaRegionAssignment() {<a name="line.2276"></a>
+<span class="sourceLineNo">2277</span>    return this.initializationBeforeMetaAssignment;<a name="line.2277"></a>
+<span class="sourceLineNo">2278</span>  }<a name="line.2278"></a>
+<span class="sourceLineNo">2279</span><a name="line.2279"></a>
+<span class="sourceLineNo">2280</span>  public void assignRegion(HRegionInfo hri) {<a name="line.2280"></a>
+<span class="sourceLineNo">2281</span>    assignmentManager.assign(hri);<a name="line.2281"></a>
+<span class="sourceLineNo">2282</span>  }<a name="line.2282"></a>
+<span class="sourceLineNo">2283</span><a name="line.2283"></a>
+<span class="sourceLineNo">2284</span>  /**<a name="line.2284"></a>
+<span class="sourceLineNo">2285</span>   * Compute the average load across all region servers.<a name="line.2285"></a>
+<span class="sourceLineNo">2286</span>   * Currently, this uses a very naive computation - just uses the number of<a name="line.2286"></a>
+<span class="sourceLineNo">2287</span>   * regions being served, ignoring stats about number of requests.<a name="line.2287"></a>
+<span class="sourceLineNo">2288</span>   * @return the average load<a name="line.2288"></a>
+<span class="sourceLineNo">2289</span>   */<a name="line.2289"></a>
+<span class="sourceLineNo">2290</span>  public double getAverageLoad() {<a name="line.2290"></a>
+<span class="sourceLineNo">2291</span>    if (this.assignmentManager == null) {<a name="line.2291"></a>
+<span class="sourceLineNo">2292</span>      return 0;<a name="line.2292"></a>
+<span class="sourceLineNo">2293</span>    }<a name="line.2293"></a>
+<span class="sourceLineNo">2294</span><a name="line.2294"></a>
+<span class="sourceLineNo">2295</span>    RegionStates regionStates = this.assignmentManager.getRegionStates();<a name="line.2295"></a>
+<span class="sourceLineNo">2296</span>    if (regionStates == null) {<a name="line.2296"></a>
+<span class="sourceLineNo">2297</span>      return 0;<a name="line.2297"></a>
+<span class="sourceLineNo">2298</span>    }<a name="line.2298"></a>
+<span class="sourceLineNo">2299</span>    return regionStates.getAverageLoad();<a name="line.2299"></a>
+<span class="sourceLineNo">2300</span>  }<a name="line.2300"></a>
+<span class="sourceLineNo">2301</span><a name="line.2301"></a>
+<span class="sourceLineNo">2302</span>  @Override<a name="line.2302"></a>
+<span class="sourceLineNo">2303</span>  public boolean registerService(Service instance) {<a name="line.2303"></a>
+<span class="sourceLineNo">2304</span>    /*<a name="line.2304"></a>
+<span class="sourceLineNo">2305</span>     * No stacking of instances is allowed for a single service name<a name="line.2305"></a>
+<span class="sourceLineNo">2306</span>     */<a name="line.2306"></a>
+<span class="sourceLineNo">2307</span>    Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();<a name="line.2307"></a>
+<span class="sourceLineNo">2308</span>    if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {<a name="line.2308"></a>
+<span class="sourceLineNo">2309</span>      LOG.error("Coprocessor service "+serviceDesc.getFullName()+<a name="line.2309"></a>
+<span class="sourceLineNo">2310</span>          " already registered, rejecting request from "+instance<a name="line.2310"></a>
+<span class="sourceLineNo">2311</span>      );<a name="line.2311"></a>
+<span class="sourceLineNo">2312</span>      return false;<a name="line.2312"></a>
+<span class="sourceLineNo">2313</span>    }<a name="line.2313"></a>
+<span class="sourceLineNo">2314</span><a name="line.2314"></a>
+<span class="sourceLineNo">2315</span>    coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);<a name="line.2315"></a>
+<span class="sourceLineNo">2316</span>    if (LOG.isDebugEnabled()) {<a name="line.2316"></a>
+<span class="sourceLineNo">2317</span>      LOG.debug("Registered master coprocessor service: service="+serviceDesc.getFullName());<a name="line.2317"></a>
+<span class="sourceLineNo">2318</span>    }<a name="line.2318"></a>
+<span class="sourceLineNo">2319</span>    return true;<a name="line.2319"></a>
+<span class="sourceLineNo">2320</span>  }<a name="line.2320"></a>
+<span class="sourceLineNo">2321</span><a name="line.2321"></a>
+<span class="sourceLineNo">2322</span>  /**<a name="line.2322"></a>
+<span class="sourceLineNo">2323</span>   * Utility for constructing an instance of the passed HMaster class.<a name="line.2323"></a>
+<span class="sourceLineNo">2324</span>   * @param masterClass<a name="line.2324"></a>
+<span class="sourceLineNo">2325</span>   * @param conf<a name="line.2325"></a>
+<span class="sourceLineNo">2326</span>   * @return HMaster instance.<a name="line.2326"></a>
+<span class="sourceLineNo">2327</span>   */<a name="line.2327"></a>
+<span class="sourceLineNo">2328</span>  public static HMaster constructMaster(Class&lt;? extends HMaster&gt; masterClass,<a name="line.2328"></a>
+<span class="sourceLineNo">2329</span>      final Configuration conf, final CoordinatedStateManager cp)  {<a name="line.2329"></a>
+<span class="sourceLineNo">2330</span>    try {<a name="line.2330"></a>
+<span class="sourceLineNo">2331</span>      Constructor&lt;? extends HMaster&gt; c =<a name="line.2331"></a>
+<span class="sourceLineNo">2332</span>        masterClass.getConstructor(Configuration.class, CoordinatedStateManager.class);<a name="line.2332"></a>
+<span class="sourceLineNo">2333</span>      return c.newInstance(conf, cp);<a name="line.2333"></a>
+<span class="sourceLineNo">2334</span>    } catch(Exception e) {<a name="line.2334"></a>
+<span class="sourceLineNo">2335</span>      Throwable error = e;<a name="line.2335"></a>
+<span class="sourceLineNo">2336</span>      if (e instanceof InvocationTargetException &amp;&amp;<a name="line.2336"></a>
+<span class="sourceLineNo">2337</span>          ((InvocationTargetException)e).getTargetException() != null) {<a name="line.2337"></a>
+<span class="sourceLineNo">2338</span>        error = ((InvocationTargetException)e).getTargetException();<a name="line.2338"></a>
+<span class="sourceLineNo">2339</span>      }<a name="line.2339"></a>

[... 726 lines stripped ...]



Mime
View raw message