hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [26/51] [partial] hbase-site git commit: Published site at .
Date Fri, 10 Nov 2017 15:30:13 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/a108018f/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateStore.RegionStateVisitor.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateStore.RegionStateVisitor.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateStore.RegionStateVisitor.html
index 845f5e6..84e9e52 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateStore.RegionStateVisitor.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateStore.RegionStateVisitor.html
@@ -98,241 +98,248 @@
 <span class="sourceLineNo">090</span>      @Override<a name="line.90"></a>
 <span class="sourceLineNo">091</span>      public boolean visit(final Result r) throws IOException {<a name="line.91"></a>
 <span class="sourceLineNo">092</span>        if (r !=  null &amp;&amp; !r.isEmpty()) {<a name="line.92"></a>
-<span class="sourceLineNo">093</span>          long st = System.currentTimeMillis();<a name="line.93"></a>
-<span class="sourceLineNo">094</span>          visitMetaEntry(visitor, r);<a name="line.94"></a>
-<span class="sourceLineNo">095</span>          long et = System.currentTimeMillis();<a name="line.95"></a>
-<span class="sourceLineNo">096</span>          LOG.info("[T] LOAD META PERF " + StringUtils.humanTimeDiff(et - st));<a name="line.96"></a>
-<span class="sourceLineNo">097</span>        } else if (isDebugEnabled) {<a name="line.97"></a>
-<span class="sourceLineNo">098</span>          LOG.debug("NULL result from meta - ignoring but this is strange.");<a name="line.98"></a>
-<span class="sourceLineNo">099</span>        }<a name="line.99"></a>
-<span class="sourceLineNo">100</span>        return true;<a name="line.100"></a>
-<span class="sourceLineNo">101</span>      }<a name="line.101"></a>
-<span class="sourceLineNo">102</span>    });<a name="line.102"></a>
-<span class="sourceLineNo">103</span>  }<a name="line.103"></a>
-<span class="sourceLineNo">104</span><a name="line.104"></a>
-<span class="sourceLineNo">105</span>  private void visitMetaEntry(final RegionStateVisitor visitor, final Result result)<a name="line.105"></a>
-<span class="sourceLineNo">106</span>      throws IOException {<a name="line.106"></a>
-<span class="sourceLineNo">107</span>    final RegionLocations rl = MetaTableAccessor.getRegionLocations(result);<a name="line.107"></a>
-<span class="sourceLineNo">108</span>    if (rl == null) return;<a name="line.108"></a>
+<span class="sourceLineNo">093</span>          long st = 0;<a name="line.93"></a>
+<span class="sourceLineNo">094</span>          if (LOG.isTraceEnabled()) {<a name="line.94"></a>
+<span class="sourceLineNo">095</span>            st = System.currentTimeMillis();<a name="line.95"></a>
+<span class="sourceLineNo">096</span>          }<a name="line.96"></a>
+<span class="sourceLineNo">097</span>          visitMetaEntry(visitor, r);<a name="line.97"></a>
+<span class="sourceLineNo">098</span>          if (LOG.isTraceEnabled()) {<a name="line.98"></a>
+<span class="sourceLineNo">099</span>            long et = System.currentTimeMillis();<a name="line.99"></a>
+<span class="sourceLineNo">100</span>            LOG.trace("[T] LOAD META PERF " + StringUtils.humanTimeDiff(et - st));<a name="line.100"></a>
+<span class="sourceLineNo">101</span>          }<a name="line.101"></a>
+<span class="sourceLineNo">102</span>        } else if (isDebugEnabled) {<a name="line.102"></a>
+<span class="sourceLineNo">103</span>          LOG.debug("NULL result from meta - ignoring but this is strange.");<a name="line.103"></a>
+<span class="sourceLineNo">104</span>        }<a name="line.104"></a>
+<span class="sourceLineNo">105</span>        return true;<a name="line.105"></a>
+<span class="sourceLineNo">106</span>      }<a name="line.106"></a>
+<span class="sourceLineNo">107</span>    });<a name="line.107"></a>
+<span class="sourceLineNo">108</span>  }<a name="line.108"></a>
 <span class="sourceLineNo">109</span><a name="line.109"></a>
-<span class="sourceLineNo">110</span>    final HRegionLocation[] locations = rl.getRegionLocations();<a name="line.110"></a>
-<span class="sourceLineNo">111</span>    if (locations == null) return;<a name="line.111"></a>
-<span class="sourceLineNo">112</span><a name="line.112"></a>
-<span class="sourceLineNo">113</span>    for (int i = 0; i &lt; locations.length; ++i) {<a name="line.113"></a>
-<span class="sourceLineNo">114</span>      final HRegionLocation hrl = locations[i];<a name="line.114"></a>
-<span class="sourceLineNo">115</span>      if (hrl == null) continue;<a name="line.115"></a>
-<span class="sourceLineNo">116</span><a name="line.116"></a>
-<span class="sourceLineNo">117</span>      final RegionInfo regionInfo = hrl.getRegionInfo();<a name="line.117"></a>
-<span class="sourceLineNo">118</span>      if (regionInfo == null) continue;<a name="line.118"></a>
-<span class="sourceLineNo">119</span><a name="line.119"></a>
-<span class="sourceLineNo">120</span>      final int replicaId = regionInfo.getReplicaId();<a name="line.120"></a>
-<span class="sourceLineNo">121</span>      final State state = getRegionState(result, replicaId);<a name="line.121"></a>
-<span class="sourceLineNo">122</span><a name="line.122"></a>
-<span class="sourceLineNo">123</span>      final ServerName lastHost = hrl.getServerName();<a name="line.123"></a>
-<span class="sourceLineNo">124</span>      final ServerName regionLocation = getRegionServer(result, replicaId);<a name="line.124"></a>
-<span class="sourceLineNo">125</span>      final long openSeqNum = -1;<a name="line.125"></a>
-<span class="sourceLineNo">126</span><a name="line.126"></a>
-<span class="sourceLineNo">127</span>      // TODO: move under trace, now is visible for debugging<a name="line.127"></a>
-<span class="sourceLineNo">128</span>      LOG.info(String.format("Load hbase:meta entry region=%s regionState=%s lastHost=%s regionLocation=%s",<a name="line.128"></a>
-<span class="sourceLineNo">129</span>        regionInfo, state, lastHost, regionLocation));<a name="line.129"></a>
-<span class="sourceLineNo">130</span><a name="line.130"></a>
-<span class="sourceLineNo">131</span>      visitor.visitRegionState(regionInfo, state, regionLocation, lastHost, openSeqNum);<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    }<a name="line.132"></a>
-<span class="sourceLineNo">133</span>  }<a name="line.133"></a>
-<span class="sourceLineNo">134</span><a name="line.134"></a>
-<span class="sourceLineNo">135</span>  public void updateRegionLocation(final RegionInfo regionInfo, final State state,<a name="line.135"></a>
-<span class="sourceLineNo">136</span>      final ServerName regionLocation, final ServerName lastHost, final long openSeqNum,<a name="line.136"></a>
-<span class="sourceLineNo">137</span>      final long pid)<a name="line.137"></a>
-<span class="sourceLineNo">138</span>      throws IOException {<a name="line.138"></a>
-<span class="sourceLineNo">139</span>    if (regionInfo.isMetaRegion()) {<a name="line.139"></a>
-<span class="sourceLineNo">140</span>      updateMetaLocation(regionInfo, regionLocation);<a name="line.140"></a>
-<span class="sourceLineNo">141</span>    } else {<a name="line.141"></a>
-<span class="sourceLineNo">142</span>      updateUserRegionLocation(regionInfo, state, regionLocation, lastHost, openSeqNum, pid);<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    }<a name="line.143"></a>
-<span class="sourceLineNo">144</span>  }<a name="line.144"></a>
-<span class="sourceLineNo">145</span><a name="line.145"></a>
-<span class="sourceLineNo">146</span>  public void updateRegionState(final long openSeqNum, final long pid,<a name="line.146"></a>
-<span class="sourceLineNo">147</span>      final RegionState newState, final RegionState oldState) throws IOException {<a name="line.147"></a>
-<span class="sourceLineNo">148</span>    updateRegionLocation(newState.getRegion(), newState.getState(), newState.getServerName(),<a name="line.148"></a>
-<span class="sourceLineNo">149</span>        oldState != null ? oldState.getServerName() : null, openSeqNum, pid);<a name="line.149"></a>
-<span class="sourceLineNo">150</span>  }<a name="line.150"></a>
-<span class="sourceLineNo">151</span><a name="line.151"></a>
-<span class="sourceLineNo">152</span>  protected void updateMetaLocation(final RegionInfo regionInfo, final ServerName serverName)<a name="line.152"></a>
-<span class="sourceLineNo">153</span>      throws IOException {<a name="line.153"></a>
-<span class="sourceLineNo">154</span>    try {<a name="line.154"></a>
-<span class="sourceLineNo">155</span>      MetaTableLocator.setMetaLocation(master.getZooKeeper(), serverName,<a name="line.155"></a>
-<span class="sourceLineNo">156</span>        regionInfo.getReplicaId(), State.OPEN);<a name="line.156"></a>
-<span class="sourceLineNo">157</span>    } catch (KeeperException e) {<a name="line.157"></a>
-<span class="sourceLineNo">158</span>      throw new IOException(e);<a name="line.158"></a>
-<span class="sourceLineNo">159</span>    }<a name="line.159"></a>
-<span class="sourceLineNo">160</span>  }<a name="line.160"></a>
-<span class="sourceLineNo">161</span><a name="line.161"></a>
-<span class="sourceLineNo">162</span>  protected void updateUserRegionLocation(final RegionInfo regionInfo, final State state,<a name="line.162"></a>
-<span class="sourceLineNo">163</span>      final ServerName regionLocation, final ServerName lastHost, final long openSeqNum,<a name="line.163"></a>
-<span class="sourceLineNo">164</span>      final long pid)<a name="line.164"></a>
-<span class="sourceLineNo">165</span>      throws IOException {<a name="line.165"></a>
-<span class="sourceLineNo">166</span>    final int replicaId = regionInfo.getReplicaId();<a name="line.166"></a>
-<span class="sourceLineNo">167</span>    final Put put = new Put(MetaTableAccessor.getMetaKeyForRegion(regionInfo));<a name="line.167"></a>
-<span class="sourceLineNo">168</span>    MetaTableAccessor.addRegionInfo(put, regionInfo);<a name="line.168"></a>
-<span class="sourceLineNo">169</span>    final StringBuilder info = new StringBuilder("pid=" + pid + " updating hbase:meta row=");<a name="line.169"></a>
-<span class="sourceLineNo">170</span>    info.append(regionInfo.getRegionNameAsString()).append(", regionState=").append(state);<a name="line.170"></a>
-<span class="sourceLineNo">171</span>    if (openSeqNum &gt;= 0) {<a name="line.171"></a>
-<span class="sourceLineNo">172</span>      Preconditions.checkArgument(state == State.OPEN &amp;&amp; regionLocation != null,<a name="line.172"></a>
-<span class="sourceLineNo">173</span>          "Open region should be on a server");<a name="line.173"></a>
-<span class="sourceLineNo">174</span>      MetaTableAccessor.addLocation(put, regionLocation, openSeqNum, -1, replicaId);<a name="line.174"></a>
-<span class="sourceLineNo">175</span>      info.append(", openSeqNum=").append(openSeqNum);<a name="line.175"></a>
-<span class="sourceLineNo">176</span>      info.append(", regionLocation=").append(regionLocation);<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    } else if (regionLocation != null &amp;&amp; !regionLocation.equals(lastHost)) {<a name="line.177"></a>
-<span class="sourceLineNo">178</span>      // Ideally, if no regionLocation, write null to the hbase:meta but this will confuse clients<a name="line.178"></a>
-<span class="sourceLineNo">179</span>      // currently; they want a server to hit. TODO: Make clients wait if no location.<a name="line.179"></a>
-<span class="sourceLineNo">180</span>      put.addImmutable(HConstants.CATALOG_FAMILY, getServerNameColumn(replicaId),<a name="line.180"></a>
-<span class="sourceLineNo">181</span>          Bytes.toBytes(regionLocation.getServerName()));<a name="line.181"></a>
-<span class="sourceLineNo">182</span>      info.append(", regionLocation=").append(regionLocation);<a name="line.182"></a>
-<span class="sourceLineNo">183</span>    }<a name="line.183"></a>
-<span class="sourceLineNo">184</span>    put.addImmutable(HConstants.CATALOG_FAMILY, getStateColumn(replicaId),<a name="line.184"></a>
-<span class="sourceLineNo">185</span>      Bytes.toBytes(state.name()));<a name="line.185"></a>
-<span class="sourceLineNo">186</span>    LOG.info(info);<a name="line.186"></a>
-<span class="sourceLineNo">187</span><a name="line.187"></a>
-<span class="sourceLineNo">188</span>    final boolean serialReplication = hasSerialReplicationScope(regionInfo.getTable());<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    if (serialReplication &amp;&amp; state == State.OPEN) {<a name="line.189"></a>
-<span class="sourceLineNo">190</span>      Put barrierPut = MetaTableAccessor.makeBarrierPut(regionInfo.getEncodedNameAsBytes(),<a name="line.190"></a>
-<span class="sourceLineNo">191</span>          openSeqNum, regionInfo.getTable().getName());<a name="line.191"></a>
-<span class="sourceLineNo">192</span>      updateRegionLocation(regionInfo, state, put, barrierPut);<a name="line.192"></a>
-<span class="sourceLineNo">193</span>    } else {<a name="line.193"></a>
-<span class="sourceLineNo">194</span>      updateRegionLocation(regionInfo, state, put);<a name="line.194"></a>
-<span class="sourceLineNo">195</span>    }<a name="line.195"></a>
-<span class="sourceLineNo">196</span>  }<a name="line.196"></a>
-<span class="sourceLineNo">197</span><a name="line.197"></a>
-<span class="sourceLineNo">198</span>  protected void updateRegionLocation(final RegionInfo regionInfo, final State state,<a name="line.198"></a>
-<span class="sourceLineNo">199</span>      final Put... put) throws IOException {<a name="line.199"></a>
-<span class="sourceLineNo">200</span>    synchronized (this) {<a name="line.200"></a>
-<span class="sourceLineNo">201</span>      if (multiHConnection == null) {<a name="line.201"></a>
-<span class="sourceLineNo">202</span>        multiHConnection = new MultiHConnection(master.getConfiguration(), 1);<a name="line.202"></a>
-<span class="sourceLineNo">203</span>      }<a name="line.203"></a>
-<span class="sourceLineNo">204</span>    }<a name="line.204"></a>
-<span class="sourceLineNo">205</span><a name="line.205"></a>
-<span class="sourceLineNo">206</span>    try {<a name="line.206"></a>
-<span class="sourceLineNo">207</span>      multiHConnection.processBatchCallback(Arrays.asList(put), TableName.META_TABLE_NAME, null, null);<a name="line.207"></a>
-<span class="sourceLineNo">208</span>    } catch (IOException e) {<a name="line.208"></a>
-<span class="sourceLineNo">209</span>      // TODO: Revist!!!! Means that if a server is loaded, then we will abort our host!<a name="line.209"></a>
-<span class="sourceLineNo">210</span>      // In tests we abort the Master!<a name="line.210"></a>
-<span class="sourceLineNo">211</span>      String msg = String.format("FAILED persisting region=%s state=%s",<a name="line.211"></a>
-<span class="sourceLineNo">212</span>          regionInfo.getShortNameToLog(), state);<a name="line.212"></a>
-<span class="sourceLineNo">213</span>      LOG.error(msg, e);<a name="line.213"></a>
-<span class="sourceLineNo">214</span>      master.abort(msg, e);<a name="line.214"></a>
-<span class="sourceLineNo">215</span>      throw e;<a name="line.215"></a>
-<span class="sourceLineNo">216</span>    }<a name="line.216"></a>
-<span class="sourceLineNo">217</span>  }<a name="line.217"></a>
-<span class="sourceLineNo">218</span><a name="line.218"></a>
-<span class="sourceLineNo">219</span>  // ============================================================================================<a name="line.219"></a>
-<span class="sourceLineNo">220</span>  //  Update Region Splitting State helpers<a name="line.220"></a>
-<span class="sourceLineNo">221</span>  // ============================================================================================<a name="line.221"></a>
-<span class="sourceLineNo">222</span>  public void splitRegion(final RegionInfo parent, final RegionInfo hriA,<a name="line.222"></a>
-<span class="sourceLineNo">223</span>      final RegionInfo hriB, final ServerName serverName)  throws IOException {<a name="line.223"></a>
-<span class="sourceLineNo">224</span>    final TableDescriptor htd = getTableDescriptor(parent.getTable());<a name="line.224"></a>
-<span class="sourceLineNo">225</span>    MetaTableAccessor.splitRegion(master.getConnection(), parent, hriA, hriB, serverName,<a name="line.225"></a>
-<span class="sourceLineNo">226</span>        getRegionReplication(htd), hasSerialReplicationScope(htd));<a name="line.226"></a>
-<span class="sourceLineNo">227</span>  }<a name="line.227"></a>
-<span class="sourceLineNo">228</span><a name="line.228"></a>
-<span class="sourceLineNo">229</span>  // ============================================================================================<a name="line.229"></a>
-<span class="sourceLineNo">230</span>  //  Update Region Merging State helpers<a name="line.230"></a>
-<span class="sourceLineNo">231</span>  // ============================================================================================<a name="line.231"></a>
-<span class="sourceLineNo">232</span>  public void mergeRegions(final RegionInfo parent, final RegionInfo hriA,<a name="line.232"></a>
-<span class="sourceLineNo">233</span>      final RegionInfo hriB, final ServerName serverName)  throws IOException {<a name="line.233"></a>
-<span class="sourceLineNo">234</span>    final TableDescriptor htd = getTableDescriptor(parent.getTable());<a name="line.234"></a>
-<span class="sourceLineNo">235</span>    MetaTableAccessor.mergeRegions(master.getConnection(), parent, hriA, hriB, serverName,<a name="line.235"></a>
-<span class="sourceLineNo">236</span>        getRegionReplication(htd), EnvironmentEdgeManager.currentTime(),<a name="line.236"></a>
-<span class="sourceLineNo">237</span>        hasSerialReplicationScope(htd));<a name="line.237"></a>
-<span class="sourceLineNo">238</span>  }<a name="line.238"></a>
-<span class="sourceLineNo">239</span><a name="line.239"></a>
-<span class="sourceLineNo">240</span>  // ============================================================================================<a name="line.240"></a>
-<span class="sourceLineNo">241</span>  //  Delete Region State helpers<a name="line.241"></a>
-<span class="sourceLineNo">242</span>  // ============================================================================================<a name="line.242"></a>
-<span class="sourceLineNo">243</span>  public void deleteRegion(final RegionInfo regionInfo) throws IOException {<a name="line.243"></a>
-<span class="sourceLineNo">244</span>    deleteRegions(Collections.singletonList(regionInfo));<a name="line.244"></a>
-<span class="sourceLineNo">245</span>  }<a name="line.245"></a>
-<span class="sourceLineNo">246</span><a name="line.246"></a>
-<span class="sourceLineNo">247</span>  public void deleteRegions(final List&lt;RegionInfo&gt; regions) throws IOException {<a name="line.247"></a>
-<span class="sourceLineNo">248</span>    MetaTableAccessor.deleteRegions(master.getConnection(), regions);<a name="line.248"></a>
-<span class="sourceLineNo">249</span>  }<a name="line.249"></a>
-<span class="sourceLineNo">250</span><a name="line.250"></a>
-<span class="sourceLineNo">251</span>  // ==========================================================================<a name="line.251"></a>
-<span class="sourceLineNo">252</span>  //  Table Descriptors helpers<a name="line.252"></a>
-<span class="sourceLineNo">253</span>  // ==========================================================================<a name="line.253"></a>
-<span class="sourceLineNo">254</span>  private boolean hasSerialReplicationScope(final TableName tableName) throws IOException {<a name="line.254"></a>
-<span class="sourceLineNo">255</span>    return hasSerialReplicationScope(getTableDescriptor(tableName));<a name="line.255"></a>
-<span class="sourceLineNo">256</span>  }<a name="line.256"></a>
-<span class="sourceLineNo">257</span><a name="line.257"></a>
-<span class="sourceLineNo">258</span>  private boolean hasSerialReplicationScope(final TableDescriptor htd) {<a name="line.258"></a>
-<span class="sourceLineNo">259</span>    return (htd != null)? htd.hasSerialReplicationScope(): false;<a name="line.259"></a>
-<span class="sourceLineNo">260</span>  }<a name="line.260"></a>
-<span class="sourceLineNo">261</span><a name="line.261"></a>
-<span class="sourceLineNo">262</span>  private int getRegionReplication(final TableDescriptor htd) {<a name="line.262"></a>
-<span class="sourceLineNo">263</span>    return (htd != null) ? htd.getRegionReplication() : 1;<a name="line.263"></a>
-<span class="sourceLineNo">264</span>  }<a name="line.264"></a>
-<span class="sourceLineNo">265</span><a name="line.265"></a>
-<span class="sourceLineNo">266</span>  private TableDescriptor getTableDescriptor(final TableName tableName) throws IOException {<a name="line.266"></a>
-<span class="sourceLineNo">267</span>    return master.getTableDescriptors().get(tableName);<a name="line.267"></a>
-<span class="sourceLineNo">268</span>  }<a name="line.268"></a>
-<span class="sourceLineNo">269</span><a name="line.269"></a>
-<span class="sourceLineNo">270</span>  // ==========================================================================<a name="line.270"></a>
-<span class="sourceLineNo">271</span>  //  Server Name<a name="line.271"></a>
-<span class="sourceLineNo">272</span>  // ==========================================================================<a name="line.272"></a>
-<span class="sourceLineNo">273</span><a name="line.273"></a>
-<span class="sourceLineNo">274</span>  /**<a name="line.274"></a>
-<span class="sourceLineNo">275</span>   * Returns the {@link ServerName} from catalog table {@link Result}<a name="line.275"></a>
-<span class="sourceLineNo">276</span>   * where the region is transitioning. It should be the same as<a name="line.276"></a>
-<span class="sourceLineNo">277</span>   * {@link MetaTableAccessor#getServerName(Result,int)} if the server is at OPEN state.<a name="line.277"></a>
-<span class="sourceLineNo">278</span>   * @param r Result to pull the transitioning server name from<a name="line.278"></a>
-<span class="sourceLineNo">279</span>   * @return A ServerName instance or {@link MetaTableAccessor#getServerName(Result,int)}<a name="line.279"></a>
-<span class="sourceLineNo">280</span>   * if necessary fields not found or empty.<a name="line.280"></a>
-<span class="sourceLineNo">281</span>   */<a name="line.281"></a>
-<span class="sourceLineNo">282</span>  static ServerName getRegionServer(final Result r, int replicaId) {<a name="line.282"></a>
-<span class="sourceLineNo">283</span>    final Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY,<a name="line.283"></a>
-<span class="sourceLineNo">284</span>        getServerNameColumn(replicaId));<a name="line.284"></a>
-<span class="sourceLineNo">285</span>    if (cell == null || cell.getValueLength() == 0) {<a name="line.285"></a>
-<span class="sourceLineNo">286</span>      RegionLocations locations = MetaTableAccessor.getRegionLocations(r);<a name="line.286"></a>
-<span class="sourceLineNo">287</span>      if (locations != null) {<a name="line.287"></a>
-<span class="sourceLineNo">288</span>        HRegionLocation location = locations.getRegionLocation(replicaId);<a name="line.288"></a>
-<span class="sourceLineNo">289</span>        if (location != null) {<a name="line.289"></a>
-<span class="sourceLineNo">290</span>          return location.getServerName();<a name="line.290"></a>
-<span class="sourceLineNo">291</span>        }<a name="line.291"></a>
-<span class="sourceLineNo">292</span>      }<a name="line.292"></a>
-<span class="sourceLineNo">293</span>      return null;<a name="line.293"></a>
-<span class="sourceLineNo">294</span>    }<a name="line.294"></a>
-<span class="sourceLineNo">295</span>    return ServerName.parseServerName(Bytes.toString(cell.getValueArray(),<a name="line.295"></a>
-<span class="sourceLineNo">296</span>      cell.getValueOffset(), cell.getValueLength()));<a name="line.296"></a>
-<span class="sourceLineNo">297</span>  }<a name="line.297"></a>
-<span class="sourceLineNo">298</span><a name="line.298"></a>
-<span class="sourceLineNo">299</span>  private static byte[] getServerNameColumn(int replicaId) {<a name="line.299"></a>
-<span class="sourceLineNo">300</span>    return replicaId == 0<a name="line.300"></a>
-<span class="sourceLineNo">301</span>        ? HConstants.SERVERNAME_QUALIFIER<a name="line.301"></a>
-<span class="sourceLineNo">302</span>        : Bytes.toBytes(HConstants.SERVERNAME_QUALIFIER_STR + META_REPLICA_ID_DELIMITER<a name="line.302"></a>
-<span class="sourceLineNo">303</span>          + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));<a name="line.303"></a>
-<span class="sourceLineNo">304</span>  }<a name="line.304"></a>
-<span class="sourceLineNo">305</span><a name="line.305"></a>
-<span class="sourceLineNo">306</span>  // ==========================================================================<a name="line.306"></a>
-<span class="sourceLineNo">307</span>  //  Region State<a name="line.307"></a>
-<span class="sourceLineNo">308</span>  // ==========================================================================<a name="line.308"></a>
-<span class="sourceLineNo">309</span><a name="line.309"></a>
-<span class="sourceLineNo">310</span>  /**<a name="line.310"></a>
-<span class="sourceLineNo">311</span>   * Pull the region state from a catalog table {@link Result}.<a name="line.311"></a>
-<span class="sourceLineNo">312</span>   * @param r Result to pull the region state from<a name="line.312"></a>
-<span class="sourceLineNo">313</span>   * @return the region state, or OPEN if there's no value written.<a name="line.313"></a>
-<span class="sourceLineNo">314</span>   */<a name="line.314"></a>
-<span class="sourceLineNo">315</span>  protected State getRegionState(final Result r, int replicaId) {<a name="line.315"></a>
-<span class="sourceLineNo">316</span>    Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, getStateColumn(replicaId));<a name="line.316"></a>
-<span class="sourceLineNo">317</span>    if (cell == null || cell.getValueLength() == 0) return State.OPENING;<a name="line.317"></a>
-<span class="sourceLineNo">318</span>    return State.valueOf(Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));<a name="line.318"></a>
-<span class="sourceLineNo">319</span>  }<a name="line.319"></a>
-<span class="sourceLineNo">320</span><a name="line.320"></a>
-<span class="sourceLineNo">321</span>  private static byte[] getStateColumn(int replicaId) {<a name="line.321"></a>
-<span class="sourceLineNo">322</span>    return replicaId == 0<a name="line.322"></a>
-<span class="sourceLineNo">323</span>        ? HConstants.STATE_QUALIFIER<a name="line.323"></a>
-<span class="sourceLineNo">324</span>        : Bytes.toBytes(HConstants.STATE_QUALIFIER_STR + META_REPLICA_ID_DELIMITER<a name="line.324"></a>
-<span class="sourceLineNo">325</span>          + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));<a name="line.325"></a>
+<span class="sourceLineNo">110</span>  private void visitMetaEntry(final RegionStateVisitor visitor, final Result result)<a name="line.110"></a>
+<span class="sourceLineNo">111</span>      throws IOException {<a name="line.111"></a>
+<span class="sourceLineNo">112</span>    final RegionLocations rl = MetaTableAccessor.getRegionLocations(result);<a name="line.112"></a>
+<span class="sourceLineNo">113</span>    if (rl == null) return;<a name="line.113"></a>
+<span class="sourceLineNo">114</span><a name="line.114"></a>
+<span class="sourceLineNo">115</span>    final HRegionLocation[] locations = rl.getRegionLocations();<a name="line.115"></a>
+<span class="sourceLineNo">116</span>    if (locations == null) return;<a name="line.116"></a>
+<span class="sourceLineNo">117</span><a name="line.117"></a>
+<span class="sourceLineNo">118</span>    for (int i = 0; i &lt; locations.length; ++i) {<a name="line.118"></a>
+<span class="sourceLineNo">119</span>      final HRegionLocation hrl = locations[i];<a name="line.119"></a>
+<span class="sourceLineNo">120</span>      if (hrl == null) continue;<a name="line.120"></a>
+<span class="sourceLineNo">121</span><a name="line.121"></a>
+<span class="sourceLineNo">122</span>      final RegionInfo regionInfo = hrl.getRegionInfo();<a name="line.122"></a>
+<span class="sourceLineNo">123</span>      if (regionInfo == null) continue;<a name="line.123"></a>
+<span class="sourceLineNo">124</span><a name="line.124"></a>
+<span class="sourceLineNo">125</span>      final int replicaId = regionInfo.getReplicaId();<a name="line.125"></a>
+<span class="sourceLineNo">126</span>      final State state = getRegionState(result, replicaId);<a name="line.126"></a>
+<span class="sourceLineNo">127</span><a name="line.127"></a>
+<span class="sourceLineNo">128</span>      final ServerName lastHost = hrl.getServerName();<a name="line.128"></a>
+<span class="sourceLineNo">129</span>      final ServerName regionLocation = getRegionServer(result, replicaId);<a name="line.129"></a>
+<span class="sourceLineNo">130</span>      final long openSeqNum = -1;<a name="line.130"></a>
+<span class="sourceLineNo">131</span><a name="line.131"></a>
+<span class="sourceLineNo">132</span>      // TODO: move under trace, now is visible for debugging<a name="line.132"></a>
+<span class="sourceLineNo">133</span>      LOG.info(String.format("Load hbase:meta entry region=%s regionState=%s lastHost=%s regionLocation=%s",<a name="line.133"></a>
+<span class="sourceLineNo">134</span>        regionInfo, state, lastHost, regionLocation));<a name="line.134"></a>
+<span class="sourceLineNo">135</span><a name="line.135"></a>
+<span class="sourceLineNo">136</span>      visitor.visitRegionState(regionInfo, state, regionLocation, lastHost, openSeqNum);<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    }<a name="line.137"></a>
+<span class="sourceLineNo">138</span>  }<a name="line.138"></a>
+<span class="sourceLineNo">139</span><a name="line.139"></a>
+<span class="sourceLineNo">140</span>  public void updateRegionLocation(final RegionInfo regionInfo, final State state,<a name="line.140"></a>
+<span class="sourceLineNo">141</span>      final ServerName regionLocation, final ServerName lastHost, final long openSeqNum,<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      final long pid)<a name="line.142"></a>
+<span class="sourceLineNo">143</span>      throws IOException {<a name="line.143"></a>
+<span class="sourceLineNo">144</span>    if (regionInfo.isMetaRegion()) {<a name="line.144"></a>
+<span class="sourceLineNo">145</span>      updateMetaLocation(regionInfo, regionLocation);<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    } else {<a name="line.146"></a>
+<span class="sourceLineNo">147</span>      updateUserRegionLocation(regionInfo, state, regionLocation, lastHost, openSeqNum, pid);<a name="line.147"></a>
+<span class="sourceLineNo">148</span>    }<a name="line.148"></a>
+<span class="sourceLineNo">149</span>  }<a name="line.149"></a>
+<span class="sourceLineNo">150</span><a name="line.150"></a>
+<span class="sourceLineNo">151</span>  public void updateRegionState(final long openSeqNum, final long pid,<a name="line.151"></a>
+<span class="sourceLineNo">152</span>      final RegionState newState, final RegionState oldState) throws IOException {<a name="line.152"></a>
+<span class="sourceLineNo">153</span>    updateRegionLocation(newState.getRegion(), newState.getState(), newState.getServerName(),<a name="line.153"></a>
+<span class="sourceLineNo">154</span>        oldState != null ? oldState.getServerName() : null, openSeqNum, pid);<a name="line.154"></a>
+<span class="sourceLineNo">155</span>  }<a name="line.155"></a>
+<span class="sourceLineNo">156</span><a name="line.156"></a>
+<span class="sourceLineNo">157</span>  protected void updateMetaLocation(final RegionInfo regionInfo, final ServerName serverName)<a name="line.157"></a>
+<span class="sourceLineNo">158</span>      throws IOException {<a name="line.158"></a>
+<span class="sourceLineNo">159</span>    try {<a name="line.159"></a>
+<span class="sourceLineNo">160</span>      MetaTableLocator.setMetaLocation(master.getZooKeeper(), serverName,<a name="line.160"></a>
+<span class="sourceLineNo">161</span>        regionInfo.getReplicaId(), State.OPEN);<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    } catch (KeeperException e) {<a name="line.162"></a>
+<span class="sourceLineNo">163</span>      throw new IOException(e);<a name="line.163"></a>
+<span class="sourceLineNo">164</span>    }<a name="line.164"></a>
+<span class="sourceLineNo">165</span>  }<a name="line.165"></a>
+<span class="sourceLineNo">166</span><a name="line.166"></a>
+<span class="sourceLineNo">167</span>  protected void updateUserRegionLocation(final RegionInfo regionInfo, final State state,<a name="line.167"></a>
+<span class="sourceLineNo">168</span>      final ServerName regionLocation, final ServerName lastHost, final long openSeqNum,<a name="line.168"></a>
+<span class="sourceLineNo">169</span>      final long pid)<a name="line.169"></a>
+<span class="sourceLineNo">170</span>      throws IOException {<a name="line.170"></a>
+<span class="sourceLineNo">171</span>    final int replicaId = regionInfo.getReplicaId();<a name="line.171"></a>
+<span class="sourceLineNo">172</span>    final Put put = new Put(MetaTableAccessor.getMetaKeyForRegion(regionInfo));<a name="line.172"></a>
+<span class="sourceLineNo">173</span>    MetaTableAccessor.addRegionInfo(put, regionInfo);<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    final StringBuilder info = new StringBuilder("pid=" + pid + " updating hbase:meta row=");<a name="line.174"></a>
+<span class="sourceLineNo">175</span>    info.append(regionInfo.getRegionNameAsString()).append(", regionState=").append(state);<a name="line.175"></a>
+<span class="sourceLineNo">176</span>    if (openSeqNum &gt;= 0) {<a name="line.176"></a>
+<span class="sourceLineNo">177</span>      Preconditions.checkArgument(state == State.OPEN &amp;&amp; regionLocation != null,<a name="line.177"></a>
+<span class="sourceLineNo">178</span>          "Open region should be on a server");<a name="line.178"></a>
+<span class="sourceLineNo">179</span>      MetaTableAccessor.addLocation(put, regionLocation, openSeqNum, -1, replicaId);<a name="line.179"></a>
+<span class="sourceLineNo">180</span>      info.append(", openSeqNum=").append(openSeqNum);<a name="line.180"></a>
+<span class="sourceLineNo">181</span>      info.append(", regionLocation=").append(regionLocation);<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    } else if (regionLocation != null &amp;&amp; !regionLocation.equals(lastHost)) {<a name="line.182"></a>
+<span class="sourceLineNo">183</span>      // Ideally, if no regionLocation, write null to the hbase:meta but this will confuse clients<a name="line.183"></a>
+<span class="sourceLineNo">184</span>      // currently; they want a server to hit. TODO: Make clients wait if no location.<a name="line.184"></a>
+<span class="sourceLineNo">185</span>      put.addImmutable(HConstants.CATALOG_FAMILY, getServerNameColumn(replicaId),<a name="line.185"></a>
+<span class="sourceLineNo">186</span>          Bytes.toBytes(regionLocation.getServerName()));<a name="line.186"></a>
+<span class="sourceLineNo">187</span>      info.append(", regionLocation=").append(regionLocation);<a name="line.187"></a>
+<span class="sourceLineNo">188</span>    }<a name="line.188"></a>
+<span class="sourceLineNo">189</span>    put.addImmutable(HConstants.CATALOG_FAMILY, getStateColumn(replicaId),<a name="line.189"></a>
+<span class="sourceLineNo">190</span>      Bytes.toBytes(state.name()));<a name="line.190"></a>
+<span class="sourceLineNo">191</span>    LOG.info(info);<a name="line.191"></a>
+<span class="sourceLineNo">192</span><a name="line.192"></a>
+<span class="sourceLineNo">193</span>    final boolean serialReplication = hasSerialReplicationScope(regionInfo.getTable());<a name="line.193"></a>
+<span class="sourceLineNo">194</span>    if (serialReplication &amp;&amp; state == State.OPEN) {<a name="line.194"></a>
+<span class="sourceLineNo">195</span>      Put barrierPut = MetaTableAccessor.makeBarrierPut(regionInfo.getEncodedNameAsBytes(),<a name="line.195"></a>
+<span class="sourceLineNo">196</span>          openSeqNum, regionInfo.getTable().getName());<a name="line.196"></a>
+<span class="sourceLineNo">197</span>      updateRegionLocation(regionInfo, state, put, barrierPut);<a name="line.197"></a>
+<span class="sourceLineNo">198</span>    } else {<a name="line.198"></a>
+<span class="sourceLineNo">199</span>      updateRegionLocation(regionInfo, state, put);<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    }<a name="line.200"></a>
+<span class="sourceLineNo">201</span>  }<a name="line.201"></a>
+<span class="sourceLineNo">202</span><a name="line.202"></a>
+<span class="sourceLineNo">203</span>  protected void updateRegionLocation(final RegionInfo regionInfo, final State state,<a name="line.203"></a>
+<span class="sourceLineNo">204</span>      final Put... put) throws IOException {<a name="line.204"></a>
+<span class="sourceLineNo">205</span>    synchronized (this) {<a name="line.205"></a>
+<span class="sourceLineNo">206</span>      if (multiHConnection == null) {<a name="line.206"></a>
+<span class="sourceLineNo">207</span>        multiHConnection = new MultiHConnection(master.getConfiguration(), 1);<a name="line.207"></a>
+<span class="sourceLineNo">208</span>      }<a name="line.208"></a>
+<span class="sourceLineNo">209</span>    }<a name="line.209"></a>
+<span class="sourceLineNo">210</span><a name="line.210"></a>
+<span class="sourceLineNo">211</span>    try {<a name="line.211"></a>
+<span class="sourceLineNo">212</span>      multiHConnection.processBatchCallback(Arrays.asList(put), TableName.META_TABLE_NAME, null, null);<a name="line.212"></a>
+<span class="sourceLineNo">213</span>    } catch (IOException e) {<a name="line.213"></a>
+<span class="sourceLineNo">214</span>      // TODO: Revist!!!! Means that if a server is loaded, then we will abort our host!<a name="line.214"></a>
+<span class="sourceLineNo">215</span>      // In tests we abort the Master!<a name="line.215"></a>
+<span class="sourceLineNo">216</span>      String msg = String.format("FAILED persisting region=%s state=%s",<a name="line.216"></a>
+<span class="sourceLineNo">217</span>          regionInfo.getShortNameToLog(), state);<a name="line.217"></a>
+<span class="sourceLineNo">218</span>      LOG.error(msg, e);<a name="line.218"></a>
+<span class="sourceLineNo">219</span>      master.abort(msg, e);<a name="line.219"></a>
+<span class="sourceLineNo">220</span>      throw e;<a name="line.220"></a>
+<span class="sourceLineNo">221</span>    }<a name="line.221"></a>
+<span class="sourceLineNo">222</span>  }<a name="line.222"></a>
+<span class="sourceLineNo">223</span><a name="line.223"></a>
+<span class="sourceLineNo">224</span>  // ============================================================================================<a name="line.224"></a>
+<span class="sourceLineNo">225</span>  //  Update Region Splitting State helpers<a name="line.225"></a>
+<span class="sourceLineNo">226</span>  // ============================================================================================<a name="line.226"></a>
+<span class="sourceLineNo">227</span>  public void splitRegion(final RegionInfo parent, final RegionInfo hriA,<a name="line.227"></a>
+<span class="sourceLineNo">228</span>      final RegionInfo hriB, final ServerName serverName)  throws IOException {<a name="line.228"></a>
+<span class="sourceLineNo">229</span>    final TableDescriptor htd = getTableDescriptor(parent.getTable());<a name="line.229"></a>
+<span class="sourceLineNo">230</span>    MetaTableAccessor.splitRegion(master.getConnection(), parent, hriA, hriB, serverName,<a name="line.230"></a>
+<span class="sourceLineNo">231</span>        getRegionReplication(htd), hasSerialReplicationScope(htd));<a name="line.231"></a>
+<span class="sourceLineNo">232</span>  }<a name="line.232"></a>
+<span class="sourceLineNo">233</span><a name="line.233"></a>
+<span class="sourceLineNo">234</span>  // ============================================================================================<a name="line.234"></a>
+<span class="sourceLineNo">235</span>  //  Update Region Merging State helpers<a name="line.235"></a>
+<span class="sourceLineNo">236</span>  // ============================================================================================<a name="line.236"></a>
+<span class="sourceLineNo">237</span>  public void mergeRegions(final RegionInfo parent, final RegionInfo hriA,<a name="line.237"></a>
+<span class="sourceLineNo">238</span>      final RegionInfo hriB, final ServerName serverName)  throws IOException {<a name="line.238"></a>
+<span class="sourceLineNo">239</span>    final TableDescriptor htd = getTableDescriptor(parent.getTable());<a name="line.239"></a>
+<span class="sourceLineNo">240</span>    MetaTableAccessor.mergeRegions(master.getConnection(), parent, hriA, hriB, serverName,<a name="line.240"></a>
+<span class="sourceLineNo">241</span>        getRegionReplication(htd), EnvironmentEdgeManager.currentTime(),<a name="line.241"></a>
+<span class="sourceLineNo">242</span>        hasSerialReplicationScope(htd));<a name="line.242"></a>
+<span class="sourceLineNo">243</span>  }<a name="line.243"></a>
+<span class="sourceLineNo">244</span><a name="line.244"></a>
+<span class="sourceLineNo">245</span>  // ============================================================================================<a name="line.245"></a>
+<span class="sourceLineNo">246</span>  //  Delete Region State helpers<a name="line.246"></a>
+<span class="sourceLineNo">247</span>  // ============================================================================================<a name="line.247"></a>
+<span class="sourceLineNo">248</span>  public void deleteRegion(final RegionInfo regionInfo) throws IOException {<a name="line.248"></a>
+<span class="sourceLineNo">249</span>    deleteRegions(Collections.singletonList(regionInfo));<a name="line.249"></a>
+<span class="sourceLineNo">250</span>  }<a name="line.250"></a>
+<span class="sourceLineNo">251</span><a name="line.251"></a>
+<span class="sourceLineNo">252</span>  public void deleteRegions(final List&lt;RegionInfo&gt; regions) throws IOException {<a name="line.252"></a>
+<span class="sourceLineNo">253</span>    MetaTableAccessor.deleteRegions(master.getConnection(), regions);<a name="line.253"></a>
+<span class="sourceLineNo">254</span>  }<a name="line.254"></a>
+<span class="sourceLineNo">255</span><a name="line.255"></a>
+<span class="sourceLineNo">256</span>  // ==========================================================================<a name="line.256"></a>
+<span class="sourceLineNo">257</span>  //  Table Descriptors helpers<a name="line.257"></a>
+<span class="sourceLineNo">258</span>  // ==========================================================================<a name="line.258"></a>
+<span class="sourceLineNo">259</span>  private boolean hasSerialReplicationScope(final TableName tableName) throws IOException {<a name="line.259"></a>
+<span class="sourceLineNo">260</span>    return hasSerialReplicationScope(getTableDescriptor(tableName));<a name="line.260"></a>
+<span class="sourceLineNo">261</span>  }<a name="line.261"></a>
+<span class="sourceLineNo">262</span><a name="line.262"></a>
+<span class="sourceLineNo">263</span>  private boolean hasSerialReplicationScope(final TableDescriptor htd) {<a name="line.263"></a>
+<span class="sourceLineNo">264</span>    return (htd != null)? htd.hasSerialReplicationScope(): false;<a name="line.264"></a>
+<span class="sourceLineNo">265</span>  }<a name="line.265"></a>
+<span class="sourceLineNo">266</span><a name="line.266"></a>
+<span class="sourceLineNo">267</span>  private int getRegionReplication(final TableDescriptor htd) {<a name="line.267"></a>
+<span class="sourceLineNo">268</span>    return (htd != null) ? htd.getRegionReplication() : 1;<a name="line.268"></a>
+<span class="sourceLineNo">269</span>  }<a name="line.269"></a>
+<span class="sourceLineNo">270</span><a name="line.270"></a>
+<span class="sourceLineNo">271</span>  private TableDescriptor getTableDescriptor(final TableName tableName) throws IOException {<a name="line.271"></a>
+<span class="sourceLineNo">272</span>    return master.getTableDescriptors().get(tableName);<a name="line.272"></a>
+<span class="sourceLineNo">273</span>  }<a name="line.273"></a>
+<span class="sourceLineNo">274</span><a name="line.274"></a>
+<span class="sourceLineNo">275</span>  // ==========================================================================<a name="line.275"></a>
+<span class="sourceLineNo">276</span>  //  Server Name<a name="line.276"></a>
+<span class="sourceLineNo">277</span>  // ==========================================================================<a name="line.277"></a>
+<span class="sourceLineNo">278</span><a name="line.278"></a>
+<span class="sourceLineNo">279</span>  /**<a name="line.279"></a>
+<span class="sourceLineNo">280</span>   * Returns the {@link ServerName} from catalog table {@link Result}<a name="line.280"></a>
+<span class="sourceLineNo">281</span>   * where the region is transitioning. It should be the same as<a name="line.281"></a>
+<span class="sourceLineNo">282</span>   * {@link MetaTableAccessor#getServerName(Result,int)} if the server is at OPEN state.<a name="line.282"></a>
+<span class="sourceLineNo">283</span>   * @param r Result to pull the transitioning server name from<a name="line.283"></a>
+<span class="sourceLineNo">284</span>   * @return A ServerName instance or {@link MetaTableAccessor#getServerName(Result,int)}<a name="line.284"></a>
+<span class="sourceLineNo">285</span>   * if necessary fields not found or empty.<a name="line.285"></a>
+<span class="sourceLineNo">286</span>   */<a name="line.286"></a>
+<span class="sourceLineNo">287</span>  static ServerName getRegionServer(final Result r, int replicaId) {<a name="line.287"></a>
+<span class="sourceLineNo">288</span>    final Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY,<a name="line.288"></a>
+<span class="sourceLineNo">289</span>        getServerNameColumn(replicaId));<a name="line.289"></a>
+<span class="sourceLineNo">290</span>    if (cell == null || cell.getValueLength() == 0) {<a name="line.290"></a>
+<span class="sourceLineNo">291</span>      RegionLocations locations = MetaTableAccessor.getRegionLocations(r);<a name="line.291"></a>
+<span class="sourceLineNo">292</span>      if (locations != null) {<a name="line.292"></a>
+<span class="sourceLineNo">293</span>        HRegionLocation location = locations.getRegionLocation(replicaId);<a name="line.293"></a>
+<span class="sourceLineNo">294</span>        if (location != null) {<a name="line.294"></a>
+<span class="sourceLineNo">295</span>          return location.getServerName();<a name="line.295"></a>
+<span class="sourceLineNo">296</span>        }<a name="line.296"></a>
+<span class="sourceLineNo">297</span>      }<a name="line.297"></a>
+<span class="sourceLineNo">298</span>      return null;<a name="line.298"></a>
+<span class="sourceLineNo">299</span>    }<a name="line.299"></a>
+<span class="sourceLineNo">300</span>    return ServerName.parseServerName(Bytes.toString(cell.getValueArray(),<a name="line.300"></a>
+<span class="sourceLineNo">301</span>      cell.getValueOffset(), cell.getValueLength()));<a name="line.301"></a>
+<span class="sourceLineNo">302</span>  }<a name="line.302"></a>
+<span class="sourceLineNo">303</span><a name="line.303"></a>
+<span class="sourceLineNo">304</span>  private static byte[] getServerNameColumn(int replicaId) {<a name="line.304"></a>
+<span class="sourceLineNo">305</span>    return replicaId == 0<a name="line.305"></a>
+<span class="sourceLineNo">306</span>        ? HConstants.SERVERNAME_QUALIFIER<a name="line.306"></a>
+<span class="sourceLineNo">307</span>        : Bytes.toBytes(HConstants.SERVERNAME_QUALIFIER_STR + META_REPLICA_ID_DELIMITER<a name="line.307"></a>
+<span class="sourceLineNo">308</span>          + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));<a name="line.308"></a>
+<span class="sourceLineNo">309</span>  }<a name="line.309"></a>
+<span class="sourceLineNo">310</span><a name="line.310"></a>
+<span class="sourceLineNo">311</span>  // ==========================================================================<a name="line.311"></a>
+<span class="sourceLineNo">312</span>  //  Region State<a name="line.312"></a>
+<span class="sourceLineNo">313</span>  // ==========================================================================<a name="line.313"></a>
+<span class="sourceLineNo">314</span><a name="line.314"></a>
+<span class="sourceLineNo">315</span>  /**<a name="line.315"></a>
+<span class="sourceLineNo">316</span>   * Pull the region state from a catalog table {@link Result}.<a name="line.316"></a>
+<span class="sourceLineNo">317</span>   * @param r Result to pull the region state from<a name="line.317"></a>
+<span class="sourceLineNo">318</span>   * @return the region state, or null if unknown.<a name="line.318"></a>
+<span class="sourceLineNo">319</span>   */<a name="line.319"></a>
+<span class="sourceLineNo">320</span>  protected State getRegionState(final Result r, int replicaId) {<a name="line.320"></a>
+<span class="sourceLineNo">321</span>    Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, getStateColumn(replicaId));<a name="line.321"></a>
+<span class="sourceLineNo">322</span>    if (cell == null || cell.getValueLength() == 0) {<a name="line.322"></a>
+<span class="sourceLineNo">323</span>      return null;<a name="line.323"></a>
+<span class="sourceLineNo">324</span>    }<a name="line.324"></a>
+<span class="sourceLineNo">325</span>    return State.valueOf(Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));<a name="line.325"></a>
 <span class="sourceLineNo">326</span>  }<a name="line.326"></a>
-<span class="sourceLineNo">327</span>}<a name="line.327"></a>
+<span class="sourceLineNo">327</span><a name="line.327"></a>
+<span class="sourceLineNo">328</span>  private static byte[] getStateColumn(int replicaId) {<a name="line.328"></a>
+<span class="sourceLineNo">329</span>    return replicaId == 0<a name="line.329"></a>
+<span class="sourceLineNo">330</span>        ? HConstants.STATE_QUALIFIER<a name="line.330"></a>
+<span class="sourceLineNo">331</span>        : Bytes.toBytes(HConstants.STATE_QUALIFIER_STR + META_REPLICA_ID_DELIMITER<a name="line.331"></a>
+<span class="sourceLineNo">332</span>          + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));<a name="line.332"></a>
+<span class="sourceLineNo">333</span>  }<a name="line.333"></a>
+<span class="sourceLineNo">334</span>}<a name="line.334"></a>
 
 
 


Mime
View raw message