hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [03/51] [partial] hbase-site git commit: Published site at b7b86839250bf9b295ebc1948826f43a88736d6c.
Date Mon, 05 Mar 2018 14:53:36 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/6b94a2f2/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 c751af0..7f98047 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
@@ -7,48 +7,48 @@
 <body>
 <div class="sourceContainer">
 <pre><span class="sourceLineNo">001</span>/**<a name="line.1"></a>
-<span class="sourceLineNo">002</span> *<a name="line.2"></a>
-<span class="sourceLineNo">003</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.3"></a>
-<span class="sourceLineNo">004</span> * or more contributor license agreements.  See the NOTICE file<a name="line.4"></a>
-<span class="sourceLineNo">005</span> * distributed with this work for additional information<a name="line.5"></a>
-<span class="sourceLineNo">006</span> * regarding copyright ownership.  The ASF licenses this file<a name="line.6"></a>
-<span class="sourceLineNo">007</span> * to you under the Apache License, Version 2.0 (the<a name="line.7"></a>
-<span class="sourceLineNo">008</span> * "License"); you may not use this file except in compliance<a name="line.8"></a>
-<span class="sourceLineNo">009</span> * with the License.  You may obtain a copy of the License at<a name="line.9"></a>
-<span class="sourceLineNo">010</span> *<a name="line.10"></a>
-<span class="sourceLineNo">011</span> *     http://www.apache.org/licenses/LICENSE-2.0<a name="line.11"></a>
-<span class="sourceLineNo">012</span> *<a name="line.12"></a>
-<span class="sourceLineNo">013</span> * Unless required by applicable law or agreed to in writing, software<a name="line.13"></a>
-<span class="sourceLineNo">014</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.14"></a>
-<span class="sourceLineNo">015</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.15"></a>
-<span class="sourceLineNo">016</span> * See the License for the specific language governing permissions and<a name="line.16"></a>
-<span class="sourceLineNo">017</span> * limitations under the License.<a name="line.17"></a>
-<span class="sourceLineNo">018</span> */<a name="line.18"></a>
+<span class="sourceLineNo">002</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.2"></a>
+<span class="sourceLineNo">003</span> * or more contributor license agreements.  See the NOTICE file<a name="line.3"></a>
+<span class="sourceLineNo">004</span> * distributed with this work for additional information<a name="line.4"></a>
+<span class="sourceLineNo">005</span> * regarding copyright ownership.  The ASF licenses this file<a name="line.5"></a>
+<span class="sourceLineNo">006</span> * to you under the Apache License, Version 2.0 (the<a name="line.6"></a>
+<span class="sourceLineNo">007</span> * "License"); you may not use this file except in compliance<a name="line.7"></a>
+<span class="sourceLineNo">008</span> * with the License.  You may obtain a copy of the License at<a name="line.8"></a>
+<span class="sourceLineNo">009</span> *<a name="line.9"></a>
+<span class="sourceLineNo">010</span> *     http://www.apache.org/licenses/LICENSE-2.0<a name="line.10"></a>
+<span class="sourceLineNo">011</span> *<a name="line.11"></a>
+<span class="sourceLineNo">012</span> * Unless required by applicable law or agreed to in writing, software<a name="line.12"></a>
+<span class="sourceLineNo">013</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.13"></a>
+<span class="sourceLineNo">014</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.14"></a>
+<span class="sourceLineNo">015</span> * See the License for the specific language governing permissions and<a name="line.15"></a>
+<span class="sourceLineNo">016</span> * limitations under the License.<a name="line.16"></a>
+<span class="sourceLineNo">017</span> */<a name="line.17"></a>
+<span class="sourceLineNo">018</span>package org.apache.hadoop.hbase.master.assignment;<a name="line.18"></a>
 <span class="sourceLineNo">019</span><a name="line.19"></a>
-<span class="sourceLineNo">020</span>package org.apache.hadoop.hbase.master.assignment;<a name="line.20"></a>
-<span class="sourceLineNo">021</span><a name="line.21"></a>
-<span class="sourceLineNo">022</span>import java.io.IOException;<a name="line.22"></a>
-<span class="sourceLineNo">023</span>import java.util.Collections;<a name="line.23"></a>
-<span class="sourceLineNo">024</span>import java.util.List;<a name="line.24"></a>
-<span class="sourceLineNo">025</span>import org.apache.hadoop.hbase.Cell;<a name="line.25"></a>
-<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.CellBuilderFactory;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.CellBuilderType;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.HConstants;<a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.HRegionLocation;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.MetaTableAccessor;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.RegionLocations;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.ServerName;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.TableName;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.client.Put;<a name="line.34"></a>
-<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.35"></a>
-<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.client.Result;<a name="line.36"></a>
-<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.client.Table;<a name="line.37"></a>
-<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.client.TableDescriptor;<a name="line.38"></a>
-<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.master.MasterServices;<a name="line.39"></a>
-<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.master.RegionState.State;<a name="line.40"></a>
-<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.procedure2.util.StringUtils;<a name="line.41"></a>
-<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.42"></a>
-<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;<a name="line.43"></a>
+<span class="sourceLineNo">020</span>import java.io.IOException;<a name="line.20"></a>
+<span class="sourceLineNo">021</span>import java.util.Collections;<a name="line.21"></a>
+<span class="sourceLineNo">022</span>import java.util.List;<a name="line.22"></a>
+<span class="sourceLineNo">023</span>import org.apache.hadoop.hbase.Cell;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import org.apache.hadoop.hbase.CellBuilderFactory;<a name="line.24"></a>
+<span class="sourceLineNo">025</span>import org.apache.hadoop.hbase.CellBuilderType;<a name="line.25"></a>
+<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.HConstants;<a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.HRegionLocation;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.MetaTableAccessor;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.RegionLocations;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.ServerName;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.TableName;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.client.Put;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.client.Result;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.client.Table;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.client.TableDescriptor;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.master.MasterFileSystem;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.master.MasterServices;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.master.RegionState.State;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.procedure2.util.StringUtils;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.41"></a>
+<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;<a name="line.42"></a>
+<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.wal.WALSplitter;<a name="line.43"></a>
 <span class="sourceLineNo">044</span>import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;<a name="line.44"></a>
 <span class="sourceLineNo">045</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.45"></a>
 <span class="sourceLineNo">046</span>import org.apache.zookeeper.KeeperException;<a name="line.46"></a>
@@ -171,152 +171,182 @@
 <span class="sourceLineNo">163</span>      Preconditions.checkArgument(state == State.OPEN &amp;&amp; regionLocation != null,<a name="line.163"></a>
 <span class="sourceLineNo">164</span>          "Open region should be on a server");<a name="line.164"></a>
 <span class="sourceLineNo">165</span>      MetaTableAccessor.addLocation(put, regionLocation, openSeqNum, replicaId);<a name="line.165"></a>
-<span class="sourceLineNo">166</span>      info.append(", openSeqNum=").append(openSeqNum);<a name="line.166"></a>
-<span class="sourceLineNo">167</span>      info.append(", regionLocation=").append(regionLocation);<a name="line.167"></a>
-<span class="sourceLineNo">168</span>    } else if (regionLocation != null &amp;&amp; !regionLocation.equals(lastHost)) {<a name="line.168"></a>
-<span class="sourceLineNo">169</span>      // Ideally, if no regionLocation, write null to the hbase:meta but this will confuse clients<a name="line.169"></a>
-<span class="sourceLineNo">170</span>      // currently; they want a server to hit. TODO: Make clients wait if no location.<a name="line.170"></a>
-<span class="sourceLineNo">171</span>      put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a name="line.171"></a>
-<span class="sourceLineNo">172</span>          .setRow(put.getRow())<a name="line.172"></a>
-<span class="sourceLineNo">173</span>          .setFamily(HConstants.CATALOG_FAMILY)<a name="line.173"></a>
-<span class="sourceLineNo">174</span>          .setQualifier(getServerNameColumn(replicaId))<a name="line.174"></a>
-<span class="sourceLineNo">175</span>          .setTimestamp(put.getTimeStamp())<a name="line.175"></a>
-<span class="sourceLineNo">176</span>          .setType(Cell.Type.Put)<a name="line.176"></a>
-<span class="sourceLineNo">177</span>          .setValue(Bytes.toBytes(regionLocation.getServerName()))<a name="line.177"></a>
-<span class="sourceLineNo">178</span>          .build());<a name="line.178"></a>
-<span class="sourceLineNo">179</span>      info.append(", regionLocation=").append(regionLocation);<a name="line.179"></a>
-<span class="sourceLineNo">180</span>    }<a name="line.180"></a>
-<span class="sourceLineNo">181</span>    put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a name="line.181"></a>
-<span class="sourceLineNo">182</span>        .setRow(put.getRow())<a name="line.182"></a>
-<span class="sourceLineNo">183</span>        .setFamily(HConstants.CATALOG_FAMILY)<a name="line.183"></a>
-<span class="sourceLineNo">184</span>        .setQualifier(getStateColumn(replicaId))<a name="line.184"></a>
-<span class="sourceLineNo">185</span>        .setTimestamp(put.getTimeStamp())<a name="line.185"></a>
-<span class="sourceLineNo">186</span>        .setType(Cell.Type.Put)<a name="line.186"></a>
-<span class="sourceLineNo">187</span>        .setValue(Bytes.toBytes(state.name()))<a name="line.187"></a>
-<span class="sourceLineNo">188</span>        .build());<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    LOG.info(info.toString());<a name="line.189"></a>
-<span class="sourceLineNo">190</span>    updateRegionLocation(regionInfo, state, put);<a name="line.190"></a>
-<span class="sourceLineNo">191</span>  }<a name="line.191"></a>
-<span class="sourceLineNo">192</span><a name="line.192"></a>
-<span class="sourceLineNo">193</span>  private void updateRegionLocation(RegionInfo regionInfo, State state, Put put)<a name="line.193"></a>
-<span class="sourceLineNo">194</span>      throws IOException {<a name="line.194"></a>
-<span class="sourceLineNo">195</span>    try (Table table = master.getConnection().getTable(TableName.META_TABLE_NAME)) {<a name="line.195"></a>
-<span class="sourceLineNo">196</span>      table.put(put);<a name="line.196"></a>
-<span class="sourceLineNo">197</span>    } catch (IOException e) {<a name="line.197"></a>
-<span class="sourceLineNo">198</span>      // TODO: Revist!!!! Means that if a server is loaded, then we will abort our host!<a name="line.198"></a>
-<span class="sourceLineNo">199</span>      // In tests we abort the Master!<a name="line.199"></a>
-<span class="sourceLineNo">200</span>      String msg = String.format("FAILED persisting region=%s state=%s",<a name="line.200"></a>
-<span class="sourceLineNo">201</span>        regionInfo.getShortNameToLog(), state);<a name="line.201"></a>
-<span class="sourceLineNo">202</span>      LOG.error(msg, e);<a name="line.202"></a>
-<span class="sourceLineNo">203</span>      master.abort(msg, e);<a name="line.203"></a>
-<span class="sourceLineNo">204</span>      throw e;<a name="line.204"></a>
-<span class="sourceLineNo">205</span>    }<a name="line.205"></a>
-<span class="sourceLineNo">206</span>  }<a name="line.206"></a>
-<span class="sourceLineNo">207</span><a name="line.207"></a>
-<span class="sourceLineNo">208</span>  // ============================================================================================<a name="line.208"></a>
-<span class="sourceLineNo">209</span>  //  Update Region Splitting State helpers<a name="line.209"></a>
-<span class="sourceLineNo">210</span>  // ============================================================================================<a name="line.210"></a>
-<span class="sourceLineNo">211</span>  public void splitRegion(final RegionInfo parent, final RegionInfo hriA,<a name="line.211"></a>
-<span class="sourceLineNo">212</span>      final RegionInfo hriB, final ServerName serverName)  throws IOException {<a name="line.212"></a>
-<span class="sourceLineNo">213</span>    final TableDescriptor htd = getTableDescriptor(parent.getTable());<a name="line.213"></a>
-<span class="sourceLineNo">214</span>    MetaTableAccessor.splitRegion(master.getConnection(), parent, hriA, hriB, serverName,<a name="line.214"></a>
-<span class="sourceLineNo">215</span>        getRegionReplication(htd));<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>  //  Update Region Merging State helpers<a name="line.219"></a>
+<span class="sourceLineNo">166</span>      // only update replication barrier for default replica<a name="line.166"></a>
+<span class="sourceLineNo">167</span>      if (regionInfo.getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID &amp;&amp;<a name="line.167"></a>
+<span class="sourceLineNo">168</span>        hasSerialReplicationScope(regionInfo.getTable())) {<a name="line.168"></a>
+<span class="sourceLineNo">169</span>        MetaTableAccessor.addReplicationBarrier(put, openSeqNum);<a name="line.169"></a>
+<span class="sourceLineNo">170</span>      }<a name="line.170"></a>
+<span class="sourceLineNo">171</span>      info.append(", openSeqNum=").append(openSeqNum);<a name="line.171"></a>
+<span class="sourceLineNo">172</span>      info.append(", regionLocation=").append(regionLocation);<a name="line.172"></a>
+<span class="sourceLineNo">173</span>    } else if (regionLocation != null &amp;&amp; !regionLocation.equals(lastHost)) {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>      // Ideally, if no regionLocation, write null to the hbase:meta but this will confuse clients<a name="line.174"></a>
+<span class="sourceLineNo">175</span>      // currently; they want a server to hit. TODO: Make clients wait if no location.<a name="line.175"></a>
+<span class="sourceLineNo">176</span>      put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a name="line.176"></a>
+<span class="sourceLineNo">177</span>          .setRow(put.getRow())<a name="line.177"></a>
+<span class="sourceLineNo">178</span>          .setFamily(HConstants.CATALOG_FAMILY)<a name="line.178"></a>
+<span class="sourceLineNo">179</span>          .setQualifier(getServerNameColumn(replicaId))<a name="line.179"></a>
+<span class="sourceLineNo">180</span>          .setTimestamp(put.getTimeStamp())<a name="line.180"></a>
+<span class="sourceLineNo">181</span>          .setType(Cell.Type.Put)<a name="line.181"></a>
+<span class="sourceLineNo">182</span>          .setValue(Bytes.toBytes(regionLocation.getServerName()))<a name="line.182"></a>
+<span class="sourceLineNo">183</span>          .build());<a name="line.183"></a>
+<span class="sourceLineNo">184</span>      info.append(", regionLocation=").append(regionLocation);<a name="line.184"></a>
+<span class="sourceLineNo">185</span>    }<a name="line.185"></a>
+<span class="sourceLineNo">186</span>    put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a name="line.186"></a>
+<span class="sourceLineNo">187</span>        .setRow(put.getRow())<a name="line.187"></a>
+<span class="sourceLineNo">188</span>        .setFamily(HConstants.CATALOG_FAMILY)<a name="line.188"></a>
+<span class="sourceLineNo">189</span>        .setQualifier(getStateColumn(replicaId))<a name="line.189"></a>
+<span class="sourceLineNo">190</span>        .setTimestamp(put.getTimeStamp())<a name="line.190"></a>
+<span class="sourceLineNo">191</span>        .setType(Cell.Type.Put)<a name="line.191"></a>
+<span class="sourceLineNo">192</span>        .setValue(Bytes.toBytes(state.name()))<a name="line.192"></a>
+<span class="sourceLineNo">193</span>        .build());<a name="line.193"></a>
+<span class="sourceLineNo">194</span>    LOG.info(info.toString());<a name="line.194"></a>
+<span class="sourceLineNo">195</span>    updateRegionLocation(regionInfo, state, put);<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>  private void updateRegionLocation(RegionInfo regionInfo, State state, Put put)<a name="line.198"></a>
+<span class="sourceLineNo">199</span>      throws IOException {<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    try (Table table = master.getConnection().getTable(TableName.META_TABLE_NAME)) {<a name="line.200"></a>
+<span class="sourceLineNo">201</span>      table.put(put);<a name="line.201"></a>
+<span class="sourceLineNo">202</span>    } catch (IOException e) {<a name="line.202"></a>
+<span class="sourceLineNo">203</span>      // TODO: Revist!!!! Means that if a server is loaded, then we will abort our host!<a name="line.203"></a>
+<span class="sourceLineNo">204</span>      // In tests we abort the Master!<a name="line.204"></a>
+<span class="sourceLineNo">205</span>      String msg = String.format("FAILED persisting region=%s state=%s",<a name="line.205"></a>
+<span class="sourceLineNo">206</span>        regionInfo.getShortNameToLog(), state);<a name="line.206"></a>
+<span class="sourceLineNo">207</span>      LOG.error(msg, e);<a name="line.207"></a>
+<span class="sourceLineNo">208</span>      master.abort(msg, e);<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      throw e;<a name="line.209"></a>
+<span class="sourceLineNo">210</span>    }<a name="line.210"></a>
+<span class="sourceLineNo">211</span>  }<a name="line.211"></a>
+<span class="sourceLineNo">212</span><a name="line.212"></a>
+<span class="sourceLineNo">213</span>  private long getOpenSeqNumForParentRegion(RegionInfo region) throws IOException {<a name="line.213"></a>
+<span class="sourceLineNo">214</span>    MasterFileSystem mfs = master.getMasterFileSystem();<a name="line.214"></a>
+<span class="sourceLineNo">215</span>    long maxSeqId =<a name="line.215"></a>
+<span class="sourceLineNo">216</span>        WALSplitter.getMaxRegionSequenceId(mfs.getFileSystem(), mfs.getRegionDir(region));<a name="line.216"></a>
+<span class="sourceLineNo">217</span>    return maxSeqId &gt; 0 ? maxSeqId + 1 : HConstants.NO_SEQNUM;<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>  // ============================================================================================<a name="line.220"></a>
-<span class="sourceLineNo">221</span>  public void mergeRegions(final RegionInfo parent, final RegionInfo hriA, final RegionInfo hriB,<a name="line.221"></a>
-<span class="sourceLineNo">222</span>      final ServerName serverName) throws IOException {<a name="line.222"></a>
-<span class="sourceLineNo">223</span>    final TableDescriptor htd = getTableDescriptor(parent.getTable());<a name="line.223"></a>
-<span class="sourceLineNo">224</span>    MetaTableAccessor.mergeRegions(master.getConnection(), parent, hriA, hriB, serverName,<a name="line.224"></a>
-<span class="sourceLineNo">225</span>      getRegionReplication(htd));<a name="line.225"></a>
-<span class="sourceLineNo">226</span>  }<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>  //  Delete Region State helpers<a name="line.229"></a>
-<span class="sourceLineNo">230</span>  // ============================================================================================<a name="line.230"></a>
-<span class="sourceLineNo">231</span>  public void deleteRegion(final RegionInfo regionInfo) throws IOException {<a name="line.231"></a>
-<span class="sourceLineNo">232</span>    deleteRegions(Collections.singletonList(regionInfo));<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>  public void deleteRegions(final List&lt;RegionInfo&gt; regions) throws IOException {<a name="line.235"></a>
-<span class="sourceLineNo">236</span>    MetaTableAccessor.deleteRegions(master.getConnection(), regions);<a name="line.236"></a>
-<span class="sourceLineNo">237</span>  }<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>  //  Table Descriptors helpers<a name="line.240"></a>
-<span class="sourceLineNo">241</span>  // ==========================================================================<a name="line.241"></a>
-<span class="sourceLineNo">242</span>  private int getRegionReplication(final TableDescriptor htd) {<a name="line.242"></a>
-<span class="sourceLineNo">243</span>    return (htd != null) ? htd.getRegionReplication() : 1;<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>  private TableDescriptor getTableDescriptor(final TableName tableName) throws IOException {<a name="line.246"></a>
-<span class="sourceLineNo">247</span>    return master.getTableDescriptors().get(tableName);<a name="line.247"></a>
+<span class="sourceLineNo">221</span>  //  Update Region Splitting State helpers<a name="line.221"></a>
+<span class="sourceLineNo">222</span>  // ============================================================================================<a name="line.222"></a>
+<span class="sourceLineNo">223</span>  public void splitRegion(RegionInfo parent, RegionInfo hriA, RegionInfo hriB,<a name="line.223"></a>
+<span class="sourceLineNo">224</span>      ServerName serverName) throws IOException {<a name="line.224"></a>
+<span class="sourceLineNo">225</span>    TableDescriptor htd = getTableDescriptor(parent.getTable());<a name="line.225"></a>
+<span class="sourceLineNo">226</span>    long parentOpenSeqNum = HConstants.NO_SEQNUM;<a name="line.226"></a>
+<span class="sourceLineNo">227</span>    if (htd.hasSerialReplicationScope()) {<a name="line.227"></a>
+<span class="sourceLineNo">228</span>      parentOpenSeqNum = getOpenSeqNumForParentRegion(parent);<a name="line.228"></a>
+<span class="sourceLineNo">229</span>    }<a name="line.229"></a>
+<span class="sourceLineNo">230</span>    MetaTableAccessor.splitRegion(master.getConnection(), parent, parentOpenSeqNum, hriA, hriB,<a name="line.230"></a>
+<span class="sourceLineNo">231</span>      serverName, getRegionReplication(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(RegionInfo child, RegionInfo hriA, RegionInfo hriB,<a name="line.237"></a>
+<span class="sourceLineNo">238</span>      ServerName serverName) throws IOException {<a name="line.238"></a>
+<span class="sourceLineNo">239</span>    TableDescriptor htd = getTableDescriptor(child.getTable());<a name="line.239"></a>
+<span class="sourceLineNo">240</span>    long regionAOpenSeqNum = -1L;<a name="line.240"></a>
+<span class="sourceLineNo">241</span>    long regionBOpenSeqNum = -1L;<a name="line.241"></a>
+<span class="sourceLineNo">242</span>    if (htd.hasSerialReplicationScope()) {<a name="line.242"></a>
+<span class="sourceLineNo">243</span>      regionAOpenSeqNum = getOpenSeqNumForParentRegion(hriA);<a name="line.243"></a>
+<span class="sourceLineNo">244</span>      regionBOpenSeqNum = getOpenSeqNumForParentRegion(hriB);<a name="line.244"></a>
+<span class="sourceLineNo">245</span>    }<a name="line.245"></a>
+<span class="sourceLineNo">246</span>    MetaTableAccessor.mergeRegions(master.getConnection(), child, hriA, regionAOpenSeqNum, hriB,<a name="line.246"></a>
+<span class="sourceLineNo">247</span>      regionBOpenSeqNum, serverName, getRegionReplication(htd));<a name="line.247"></a>
 <span class="sourceLineNo">248</span>  }<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>  //  Server Name<a name="line.251"></a>
-<span class="sourceLineNo">252</span>  // ==========================================================================<a name="line.252"></a>
-<span class="sourceLineNo">253</span><a name="line.253"></a>
-<span class="sourceLineNo">254</span>  /**<a name="line.254"></a>
-<span class="sourceLineNo">255</span>   * Returns the {@link ServerName} from catalog table {@link Result}<a name="line.255"></a>
-<span class="sourceLineNo">256</span>   * where the region is transitioning. It should be the same as<a name="line.256"></a>
-<span class="sourceLineNo">257</span>   * {@link MetaTableAccessor#getServerName(Result,int)} if the server is at OPEN state.<a name="line.257"></a>
-<span class="sourceLineNo">258</span>   * @param r Result to pull the transitioning server name from<a name="line.258"></a>
-<span class="sourceLineNo">259</span>   * @return A ServerName instance or {@link MetaTableAccessor#getServerName(Result,int)}<a name="line.259"></a>
-<span class="sourceLineNo">260</span>   * if necessary fields not found or empty.<a name="line.260"></a>
-<span class="sourceLineNo">261</span>   */<a name="line.261"></a>
-<span class="sourceLineNo">262</span>  static ServerName getRegionServer(final Result r, int replicaId) {<a name="line.262"></a>
-<span class="sourceLineNo">263</span>    final Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY,<a name="line.263"></a>
-<span class="sourceLineNo">264</span>        getServerNameColumn(replicaId));<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    if (cell == null || cell.getValueLength() == 0) {<a name="line.265"></a>
-<span class="sourceLineNo">266</span>      RegionLocations locations = MetaTableAccessor.getRegionLocations(r);<a name="line.266"></a>
-<span class="sourceLineNo">267</span>      if (locations != null) {<a name="line.267"></a>
-<span class="sourceLineNo">268</span>        HRegionLocation location = locations.getRegionLocation(replicaId);<a name="line.268"></a>
-<span class="sourceLineNo">269</span>        if (location != null) {<a name="line.269"></a>
-<span class="sourceLineNo">270</span>          return location.getServerName();<a name="line.270"></a>
-<span class="sourceLineNo">271</span>        }<a name="line.271"></a>
-<span class="sourceLineNo">272</span>      }<a name="line.272"></a>
-<span class="sourceLineNo">273</span>      return null;<a name="line.273"></a>
-<span class="sourceLineNo">274</span>    }<a name="line.274"></a>
-<span class="sourceLineNo">275</span>    return ServerName.parseServerName(Bytes.toString(cell.getValueArray(),<a name="line.275"></a>
-<span class="sourceLineNo">276</span>      cell.getValueOffset(), cell.getValueLength()));<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>  private static byte[] getServerNameColumn(int replicaId) {<a name="line.279"></a>
-<span class="sourceLineNo">280</span>    return replicaId == 0<a name="line.280"></a>
-<span class="sourceLineNo">281</span>        ? HConstants.SERVERNAME_QUALIFIER<a name="line.281"></a>
-<span class="sourceLineNo">282</span>        : Bytes.toBytes(HConstants.SERVERNAME_QUALIFIER_STR + META_REPLICA_ID_DELIMITER<a name="line.282"></a>
-<span class="sourceLineNo">283</span>          + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));<a name="line.283"></a>
-<span class="sourceLineNo">284</span>  }<a name="line.284"></a>
-<span class="sourceLineNo">285</span><a name="line.285"></a>
-<span class="sourceLineNo">286</span>  // ==========================================================================<a name="line.286"></a>
-<span class="sourceLineNo">287</span>  //  Region State<a name="line.287"></a>
-<span class="sourceLineNo">288</span>  // ==========================================================================<a name="line.288"></a>
-<span class="sourceLineNo">289</span><a name="line.289"></a>
-<span class="sourceLineNo">290</span>  /**<a name="line.290"></a>
-<span class="sourceLineNo">291</span>   * Pull the region state from a catalog table {@link Result}.<a name="line.291"></a>
-<span class="sourceLineNo">292</span>   * @param r Result to pull the region state from<a name="line.292"></a>
-<span class="sourceLineNo">293</span>   * @return the region state, or null if unknown.<a name="line.293"></a>
-<span class="sourceLineNo">294</span>   */<a name="line.294"></a>
-<span class="sourceLineNo">295</span>  @VisibleForTesting<a name="line.295"></a>
-<span class="sourceLineNo">296</span>  public static State getRegionState(final Result r, int replicaId) {<a name="line.296"></a>
-<span class="sourceLineNo">297</span>    Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, getStateColumn(replicaId));<a name="line.297"></a>
-<span class="sourceLineNo">298</span>    if (cell == null || cell.getValueLength() == 0) {<a name="line.298"></a>
-<span class="sourceLineNo">299</span>      return null;<a name="line.299"></a>
-<span class="sourceLineNo">300</span>    }<a name="line.300"></a>
-<span class="sourceLineNo">301</span>    return State.valueOf(Bytes.toString(cell.getValueArray(), cell.getValueOffset(),<a name="line.301"></a>
-<span class="sourceLineNo">302</span>        cell.getValueLength()));<a name="line.302"></a>
-<span class="sourceLineNo">303</span>  }<a name="line.303"></a>
-<span class="sourceLineNo">304</span><a name="line.304"></a>
-<span class="sourceLineNo">305</span>  private static byte[] getStateColumn(int replicaId) {<a name="line.305"></a>
-<span class="sourceLineNo">306</span>    return replicaId == 0<a name="line.306"></a>
-<span class="sourceLineNo">307</span>        ? HConstants.STATE_QUALIFIER<a name="line.307"></a>
-<span class="sourceLineNo">308</span>        : Bytes.toBytes(HConstants.STATE_QUALIFIER_STR + META_REPLICA_ID_DELIMITER<a name="line.308"></a>
-<span class="sourceLineNo">309</span>          + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));<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">250</span>  // ============================================================================================<a name="line.250"></a>
+<span class="sourceLineNo">251</span>  //  Delete Region State helpers<a name="line.251"></a>
+<span class="sourceLineNo">252</span>  // ============================================================================================<a name="line.252"></a>
+<span class="sourceLineNo">253</span>  public void deleteRegion(final RegionInfo regionInfo) throws IOException {<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    deleteRegions(Collections.singletonList(regionInfo));<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>  public void deleteRegions(final List&lt;RegionInfo&gt; regions) throws IOException {<a name="line.257"></a>
+<span class="sourceLineNo">258</span>    MetaTableAccessor.deleteRegions(master.getConnection(), regions);<a name="line.258"></a>
+<span class="sourceLineNo">259</span>  }<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>  //  Table Descriptors helpers<a name="line.262"></a>
+<span class="sourceLineNo">263</span>  // ==========================================================================<a name="line.263"></a>
+<span class="sourceLineNo">264</span>  private boolean hasSerialReplicationScope(TableName tableName) throws IOException {<a name="line.264"></a>
+<span class="sourceLineNo">265</span>    return hasSerialReplicationScope(getTableDescriptor(tableName));<a name="line.265"></a>
+<span class="sourceLineNo">266</span>  }<a name="line.266"></a>
+<span class="sourceLineNo">267</span><a name="line.267"></a>
+<span class="sourceLineNo">268</span>  private boolean hasSerialReplicationScope(TableDescriptor htd) {<a name="line.268"></a>
+<span class="sourceLineNo">269</span>    return htd != null ? htd.hasSerialReplicationScope() : false;<a name="line.269"></a>
+<span class="sourceLineNo">270</span>  }<a name="line.270"></a>
+<span class="sourceLineNo">271</span><a name="line.271"></a>
+<span class="sourceLineNo">272</span>  private int getRegionReplication(TableDescriptor htd) {<a name="line.272"></a>
+<span class="sourceLineNo">273</span>    return htd != null ? htd.getRegionReplication() : 1;<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>  private TableDescriptor getTableDescriptor(TableName tableName) throws IOException {<a name="line.276"></a>
+<span class="sourceLineNo">277</span>    return master.getTableDescriptors().get(tableName);<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>  // ==========================================================================<a name="line.280"></a>
+<span class="sourceLineNo">281</span>  //  Server Name<a name="line.281"></a>
+<span class="sourceLineNo">282</span>  // ==========================================================================<a name="line.282"></a>
+<span class="sourceLineNo">283</span><a name="line.283"></a>
+<span class="sourceLineNo">284</span>  /**<a name="line.284"></a>
+<span class="sourceLineNo">285</span>   * Returns the {@link ServerName} from catalog table {@link Result}<a name="line.285"></a>
+<span class="sourceLineNo">286</span>   * where the region is transitioning. It should be the same as<a name="line.286"></a>
+<span class="sourceLineNo">287</span>   * {@link MetaTableAccessor#getServerName(Result,int)} if the server is at OPEN state.<a name="line.287"></a>
+<span class="sourceLineNo">288</span>   * @param r Result to pull the transitioning server name from<a name="line.288"></a>
+<span class="sourceLineNo">289</span>   * @return A ServerName instance or {@link MetaTableAccessor#getServerName(Result,int)}<a name="line.289"></a>
+<span class="sourceLineNo">290</span>   * if necessary fields not found or empty.<a name="line.290"></a>
+<span class="sourceLineNo">291</span>   */<a name="line.291"></a>
+<span class="sourceLineNo">292</span>  static ServerName getRegionServer(final Result r, int replicaId) {<a name="line.292"></a>
+<span class="sourceLineNo">293</span>    final Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY,<a name="line.293"></a>
+<span class="sourceLineNo">294</span>        getServerNameColumn(replicaId));<a name="line.294"></a>
+<span class="sourceLineNo">295</span>    if (cell == null || cell.getValueLength() == 0) {<a name="line.295"></a>
+<span class="sourceLineNo">296</span>      RegionLocations locations = MetaTableAccessor.getRegionLocations(r);<a name="line.296"></a>
+<span class="sourceLineNo">297</span>      if (locations != null) {<a name="line.297"></a>
+<span class="sourceLineNo">298</span>        HRegionLocation location = locations.getRegionLocation(replicaId);<a name="line.298"></a>
+<span class="sourceLineNo">299</span>        if (location != null) {<a name="line.299"></a>
+<span class="sourceLineNo">300</span>          return location.getServerName();<a name="line.300"></a>
+<span class="sourceLineNo">301</span>        }<a name="line.301"></a>
+<span class="sourceLineNo">302</span>      }<a name="line.302"></a>
+<span class="sourceLineNo">303</span>      return null;<a name="line.303"></a>
+<span class="sourceLineNo">304</span>    }<a name="line.304"></a>
+<span class="sourceLineNo">305</span>    return ServerName.parseServerName(Bytes.toString(cell.getValueArray(),<a name="line.305"></a>
+<span class="sourceLineNo">306</span>      cell.getValueOffset(), cell.getValueLength()));<a name="line.306"></a>
+<span class="sourceLineNo">307</span>  }<a name="line.307"></a>
+<span class="sourceLineNo">308</span><a name="line.308"></a>
+<span class="sourceLineNo">309</span>  private static byte[] getServerNameColumn(int replicaId) {<a name="line.309"></a>
+<span class="sourceLineNo">310</span>    return replicaId == 0<a name="line.310"></a>
+<span class="sourceLineNo">311</span>        ? HConstants.SERVERNAME_QUALIFIER<a name="line.311"></a>
+<span class="sourceLineNo">312</span>        : Bytes.toBytes(HConstants.SERVERNAME_QUALIFIER_STR + META_REPLICA_ID_DELIMITER<a name="line.312"></a>
+<span class="sourceLineNo">313</span>          + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));<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>  // ==========================================================================<a name="line.316"></a>
+<span class="sourceLineNo">317</span>  //  Region State<a name="line.317"></a>
+<span class="sourceLineNo">318</span>  // ==========================================================================<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>   * Pull the region state from a catalog table {@link Result}.<a name="line.321"></a>
+<span class="sourceLineNo">322</span>   * @param r Result to pull the region state from<a name="line.322"></a>
+<span class="sourceLineNo">323</span>   * @return the region state, or null if unknown.<a name="line.323"></a>
+<span class="sourceLineNo">324</span>   */<a name="line.324"></a>
+<span class="sourceLineNo">325</span>  @VisibleForTesting<a name="line.325"></a>
+<span class="sourceLineNo">326</span>  public static State getRegionState(final Result r, int replicaId) {<a name="line.326"></a>
+<span class="sourceLineNo">327</span>    Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, getStateColumn(replicaId));<a name="line.327"></a>
+<span class="sourceLineNo">328</span>    if (cell == null || cell.getValueLength() == 0) {<a name="line.328"></a>
+<span class="sourceLineNo">329</span>      return null;<a name="line.329"></a>
+<span class="sourceLineNo">330</span>    }<a name="line.330"></a>
+<span class="sourceLineNo">331</span>    return State.valueOf(Bytes.toString(cell.getValueArray(), cell.getValueOffset(),<a name="line.331"></a>
+<span class="sourceLineNo">332</span>        cell.getValueLength()));<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>
+<span class="sourceLineNo">335</span>  private static byte[] getStateColumn(int replicaId) {<a name="line.335"></a>
+<span class="sourceLineNo">336</span>    return replicaId == 0<a name="line.336"></a>
+<span class="sourceLineNo">337</span>        ? HConstants.STATE_QUALIFIER<a name="line.337"></a>
+<span class="sourceLineNo">338</span>        : Bytes.toBytes(HConstants.STATE_QUALIFIER_STR + META_REPLICA_ID_DELIMITER<a name="line.338"></a>
+<span class="sourceLineNo">339</span>          + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));<a name="line.339"></a>
+<span class="sourceLineNo">340</span>  }<a name="line.340"></a>
+<span class="sourceLineNo">341</span>}<a name="line.341"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/6b94a2f2/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateStore.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateStore.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateStore.html
index c751af0..7f98047 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateStore.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateStore.html
@@ -7,48 +7,48 @@
 <body>
 <div class="sourceContainer">
 <pre><span class="sourceLineNo">001</span>/**<a name="line.1"></a>
-<span class="sourceLineNo">002</span> *<a name="line.2"></a>
-<span class="sourceLineNo">003</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.3"></a>
-<span class="sourceLineNo">004</span> * or more contributor license agreements.  See the NOTICE file<a name="line.4"></a>
-<span class="sourceLineNo">005</span> * distributed with this work for additional information<a name="line.5"></a>
-<span class="sourceLineNo">006</span> * regarding copyright ownership.  The ASF licenses this file<a name="line.6"></a>
-<span class="sourceLineNo">007</span> * to you under the Apache License, Version 2.0 (the<a name="line.7"></a>
-<span class="sourceLineNo">008</span> * "License"); you may not use this file except in compliance<a name="line.8"></a>
-<span class="sourceLineNo">009</span> * with the License.  You may obtain a copy of the License at<a name="line.9"></a>
-<span class="sourceLineNo">010</span> *<a name="line.10"></a>
-<span class="sourceLineNo">011</span> *     http://www.apache.org/licenses/LICENSE-2.0<a name="line.11"></a>
-<span class="sourceLineNo">012</span> *<a name="line.12"></a>
-<span class="sourceLineNo">013</span> * Unless required by applicable law or agreed to in writing, software<a name="line.13"></a>
-<span class="sourceLineNo">014</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.14"></a>
-<span class="sourceLineNo">015</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.15"></a>
-<span class="sourceLineNo">016</span> * See the License for the specific language governing permissions and<a name="line.16"></a>
-<span class="sourceLineNo">017</span> * limitations under the License.<a name="line.17"></a>
-<span class="sourceLineNo">018</span> */<a name="line.18"></a>
+<span class="sourceLineNo">002</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.2"></a>
+<span class="sourceLineNo">003</span> * or more contributor license agreements.  See the NOTICE file<a name="line.3"></a>
+<span class="sourceLineNo">004</span> * distributed with this work for additional information<a name="line.4"></a>
+<span class="sourceLineNo">005</span> * regarding copyright ownership.  The ASF licenses this file<a name="line.5"></a>
+<span class="sourceLineNo">006</span> * to you under the Apache License, Version 2.0 (the<a name="line.6"></a>
+<span class="sourceLineNo">007</span> * "License"); you may not use this file except in compliance<a name="line.7"></a>
+<span class="sourceLineNo">008</span> * with the License.  You may obtain a copy of the License at<a name="line.8"></a>
+<span class="sourceLineNo">009</span> *<a name="line.9"></a>
+<span class="sourceLineNo">010</span> *     http://www.apache.org/licenses/LICENSE-2.0<a name="line.10"></a>
+<span class="sourceLineNo">011</span> *<a name="line.11"></a>
+<span class="sourceLineNo">012</span> * Unless required by applicable law or agreed to in writing, software<a name="line.12"></a>
+<span class="sourceLineNo">013</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.13"></a>
+<span class="sourceLineNo">014</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.14"></a>
+<span class="sourceLineNo">015</span> * See the License for the specific language governing permissions and<a name="line.15"></a>
+<span class="sourceLineNo">016</span> * limitations under the License.<a name="line.16"></a>
+<span class="sourceLineNo">017</span> */<a name="line.17"></a>
+<span class="sourceLineNo">018</span>package org.apache.hadoop.hbase.master.assignment;<a name="line.18"></a>
 <span class="sourceLineNo">019</span><a name="line.19"></a>
-<span class="sourceLineNo">020</span>package org.apache.hadoop.hbase.master.assignment;<a name="line.20"></a>
-<span class="sourceLineNo">021</span><a name="line.21"></a>
-<span class="sourceLineNo">022</span>import java.io.IOException;<a name="line.22"></a>
-<span class="sourceLineNo">023</span>import java.util.Collections;<a name="line.23"></a>
-<span class="sourceLineNo">024</span>import java.util.List;<a name="line.24"></a>
-<span class="sourceLineNo">025</span>import org.apache.hadoop.hbase.Cell;<a name="line.25"></a>
-<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.CellBuilderFactory;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.CellBuilderType;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.HConstants;<a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.HRegionLocation;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.MetaTableAccessor;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.RegionLocations;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.ServerName;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.TableName;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.client.Put;<a name="line.34"></a>
-<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.35"></a>
-<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.client.Result;<a name="line.36"></a>
-<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.client.Table;<a name="line.37"></a>
-<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.client.TableDescriptor;<a name="line.38"></a>
-<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.master.MasterServices;<a name="line.39"></a>
-<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.master.RegionState.State;<a name="line.40"></a>
-<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.procedure2.util.StringUtils;<a name="line.41"></a>
-<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.42"></a>
-<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;<a name="line.43"></a>
+<span class="sourceLineNo">020</span>import java.io.IOException;<a name="line.20"></a>
+<span class="sourceLineNo">021</span>import java.util.Collections;<a name="line.21"></a>
+<span class="sourceLineNo">022</span>import java.util.List;<a name="line.22"></a>
+<span class="sourceLineNo">023</span>import org.apache.hadoop.hbase.Cell;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import org.apache.hadoop.hbase.CellBuilderFactory;<a name="line.24"></a>
+<span class="sourceLineNo">025</span>import org.apache.hadoop.hbase.CellBuilderType;<a name="line.25"></a>
+<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.HConstants;<a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.HRegionLocation;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.MetaTableAccessor;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.RegionLocations;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.ServerName;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.TableName;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.client.Put;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.client.Result;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.client.Table;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.client.TableDescriptor;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.master.MasterFileSystem;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.master.MasterServices;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.master.RegionState.State;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.procedure2.util.StringUtils;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.41"></a>
+<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;<a name="line.42"></a>
+<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.wal.WALSplitter;<a name="line.43"></a>
 <span class="sourceLineNo">044</span>import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;<a name="line.44"></a>
 <span class="sourceLineNo">045</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.45"></a>
 <span class="sourceLineNo">046</span>import org.apache.zookeeper.KeeperException;<a name="line.46"></a>
@@ -171,152 +171,182 @@
 <span class="sourceLineNo">163</span>      Preconditions.checkArgument(state == State.OPEN &amp;&amp; regionLocation != null,<a name="line.163"></a>
 <span class="sourceLineNo">164</span>          "Open region should be on a server");<a name="line.164"></a>
 <span class="sourceLineNo">165</span>      MetaTableAccessor.addLocation(put, regionLocation, openSeqNum, replicaId);<a name="line.165"></a>
-<span class="sourceLineNo">166</span>      info.append(", openSeqNum=").append(openSeqNum);<a name="line.166"></a>
-<span class="sourceLineNo">167</span>      info.append(", regionLocation=").append(regionLocation);<a name="line.167"></a>
-<span class="sourceLineNo">168</span>    } else if (regionLocation != null &amp;&amp; !regionLocation.equals(lastHost)) {<a name="line.168"></a>
-<span class="sourceLineNo">169</span>      // Ideally, if no regionLocation, write null to the hbase:meta but this will confuse clients<a name="line.169"></a>
-<span class="sourceLineNo">170</span>      // currently; they want a server to hit. TODO: Make clients wait if no location.<a name="line.170"></a>
-<span class="sourceLineNo">171</span>      put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a name="line.171"></a>
-<span class="sourceLineNo">172</span>          .setRow(put.getRow())<a name="line.172"></a>
-<span class="sourceLineNo">173</span>          .setFamily(HConstants.CATALOG_FAMILY)<a name="line.173"></a>
-<span class="sourceLineNo">174</span>          .setQualifier(getServerNameColumn(replicaId))<a name="line.174"></a>
-<span class="sourceLineNo">175</span>          .setTimestamp(put.getTimeStamp())<a name="line.175"></a>
-<span class="sourceLineNo">176</span>          .setType(Cell.Type.Put)<a name="line.176"></a>
-<span class="sourceLineNo">177</span>          .setValue(Bytes.toBytes(regionLocation.getServerName()))<a name="line.177"></a>
-<span class="sourceLineNo">178</span>          .build());<a name="line.178"></a>
-<span class="sourceLineNo">179</span>      info.append(", regionLocation=").append(regionLocation);<a name="line.179"></a>
-<span class="sourceLineNo">180</span>    }<a name="line.180"></a>
-<span class="sourceLineNo">181</span>    put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a name="line.181"></a>
-<span class="sourceLineNo">182</span>        .setRow(put.getRow())<a name="line.182"></a>
-<span class="sourceLineNo">183</span>        .setFamily(HConstants.CATALOG_FAMILY)<a name="line.183"></a>
-<span class="sourceLineNo">184</span>        .setQualifier(getStateColumn(replicaId))<a name="line.184"></a>
-<span class="sourceLineNo">185</span>        .setTimestamp(put.getTimeStamp())<a name="line.185"></a>
-<span class="sourceLineNo">186</span>        .setType(Cell.Type.Put)<a name="line.186"></a>
-<span class="sourceLineNo">187</span>        .setValue(Bytes.toBytes(state.name()))<a name="line.187"></a>
-<span class="sourceLineNo">188</span>        .build());<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    LOG.info(info.toString());<a name="line.189"></a>
-<span class="sourceLineNo">190</span>    updateRegionLocation(regionInfo, state, put);<a name="line.190"></a>
-<span class="sourceLineNo">191</span>  }<a name="line.191"></a>
-<span class="sourceLineNo">192</span><a name="line.192"></a>
-<span class="sourceLineNo">193</span>  private void updateRegionLocation(RegionInfo regionInfo, State state, Put put)<a name="line.193"></a>
-<span class="sourceLineNo">194</span>      throws IOException {<a name="line.194"></a>
-<span class="sourceLineNo">195</span>    try (Table table = master.getConnection().getTable(TableName.META_TABLE_NAME)) {<a name="line.195"></a>
-<span class="sourceLineNo">196</span>      table.put(put);<a name="line.196"></a>
-<span class="sourceLineNo">197</span>    } catch (IOException e) {<a name="line.197"></a>
-<span class="sourceLineNo">198</span>      // TODO: Revist!!!! Means that if a server is loaded, then we will abort our host!<a name="line.198"></a>
-<span class="sourceLineNo">199</span>      // In tests we abort the Master!<a name="line.199"></a>
-<span class="sourceLineNo">200</span>      String msg = String.format("FAILED persisting region=%s state=%s",<a name="line.200"></a>
-<span class="sourceLineNo">201</span>        regionInfo.getShortNameToLog(), state);<a name="line.201"></a>
-<span class="sourceLineNo">202</span>      LOG.error(msg, e);<a name="line.202"></a>
-<span class="sourceLineNo">203</span>      master.abort(msg, e);<a name="line.203"></a>
-<span class="sourceLineNo">204</span>      throw e;<a name="line.204"></a>
-<span class="sourceLineNo">205</span>    }<a name="line.205"></a>
-<span class="sourceLineNo">206</span>  }<a name="line.206"></a>
-<span class="sourceLineNo">207</span><a name="line.207"></a>
-<span class="sourceLineNo">208</span>  // ============================================================================================<a name="line.208"></a>
-<span class="sourceLineNo">209</span>  //  Update Region Splitting State helpers<a name="line.209"></a>
-<span class="sourceLineNo">210</span>  // ============================================================================================<a name="line.210"></a>
-<span class="sourceLineNo">211</span>  public void splitRegion(final RegionInfo parent, final RegionInfo hriA,<a name="line.211"></a>
-<span class="sourceLineNo">212</span>      final RegionInfo hriB, final ServerName serverName)  throws IOException {<a name="line.212"></a>
-<span class="sourceLineNo">213</span>    final TableDescriptor htd = getTableDescriptor(parent.getTable());<a name="line.213"></a>
-<span class="sourceLineNo">214</span>    MetaTableAccessor.splitRegion(master.getConnection(), parent, hriA, hriB, serverName,<a name="line.214"></a>
-<span class="sourceLineNo">215</span>        getRegionReplication(htd));<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>  //  Update Region Merging State helpers<a name="line.219"></a>
+<span class="sourceLineNo">166</span>      // only update replication barrier for default replica<a name="line.166"></a>
+<span class="sourceLineNo">167</span>      if (regionInfo.getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID &amp;&amp;<a name="line.167"></a>
+<span class="sourceLineNo">168</span>        hasSerialReplicationScope(regionInfo.getTable())) {<a name="line.168"></a>
+<span class="sourceLineNo">169</span>        MetaTableAccessor.addReplicationBarrier(put, openSeqNum);<a name="line.169"></a>
+<span class="sourceLineNo">170</span>      }<a name="line.170"></a>
+<span class="sourceLineNo">171</span>      info.append(", openSeqNum=").append(openSeqNum);<a name="line.171"></a>
+<span class="sourceLineNo">172</span>      info.append(", regionLocation=").append(regionLocation);<a name="line.172"></a>
+<span class="sourceLineNo">173</span>    } else if (regionLocation != null &amp;&amp; !regionLocation.equals(lastHost)) {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>      // Ideally, if no regionLocation, write null to the hbase:meta but this will confuse clients<a name="line.174"></a>
+<span class="sourceLineNo">175</span>      // currently; they want a server to hit. TODO: Make clients wait if no location.<a name="line.175"></a>
+<span class="sourceLineNo">176</span>      put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a name="line.176"></a>
+<span class="sourceLineNo">177</span>          .setRow(put.getRow())<a name="line.177"></a>
+<span class="sourceLineNo">178</span>          .setFamily(HConstants.CATALOG_FAMILY)<a name="line.178"></a>
+<span class="sourceLineNo">179</span>          .setQualifier(getServerNameColumn(replicaId))<a name="line.179"></a>
+<span class="sourceLineNo">180</span>          .setTimestamp(put.getTimeStamp())<a name="line.180"></a>
+<span class="sourceLineNo">181</span>          .setType(Cell.Type.Put)<a name="line.181"></a>
+<span class="sourceLineNo">182</span>          .setValue(Bytes.toBytes(regionLocation.getServerName()))<a name="line.182"></a>
+<span class="sourceLineNo">183</span>          .build());<a name="line.183"></a>
+<span class="sourceLineNo">184</span>      info.append(", regionLocation=").append(regionLocation);<a name="line.184"></a>
+<span class="sourceLineNo">185</span>    }<a name="line.185"></a>
+<span class="sourceLineNo">186</span>    put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)<a name="line.186"></a>
+<span class="sourceLineNo">187</span>        .setRow(put.getRow())<a name="line.187"></a>
+<span class="sourceLineNo">188</span>        .setFamily(HConstants.CATALOG_FAMILY)<a name="line.188"></a>
+<span class="sourceLineNo">189</span>        .setQualifier(getStateColumn(replicaId))<a name="line.189"></a>
+<span class="sourceLineNo">190</span>        .setTimestamp(put.getTimeStamp())<a name="line.190"></a>
+<span class="sourceLineNo">191</span>        .setType(Cell.Type.Put)<a name="line.191"></a>
+<span class="sourceLineNo">192</span>        .setValue(Bytes.toBytes(state.name()))<a name="line.192"></a>
+<span class="sourceLineNo">193</span>        .build());<a name="line.193"></a>
+<span class="sourceLineNo">194</span>    LOG.info(info.toString());<a name="line.194"></a>
+<span class="sourceLineNo">195</span>    updateRegionLocation(regionInfo, state, put);<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>  private void updateRegionLocation(RegionInfo regionInfo, State state, Put put)<a name="line.198"></a>
+<span class="sourceLineNo">199</span>      throws IOException {<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    try (Table table = master.getConnection().getTable(TableName.META_TABLE_NAME)) {<a name="line.200"></a>
+<span class="sourceLineNo">201</span>      table.put(put);<a name="line.201"></a>
+<span class="sourceLineNo">202</span>    } catch (IOException e) {<a name="line.202"></a>
+<span class="sourceLineNo">203</span>      // TODO: Revist!!!! Means that if a server is loaded, then we will abort our host!<a name="line.203"></a>
+<span class="sourceLineNo">204</span>      // In tests we abort the Master!<a name="line.204"></a>
+<span class="sourceLineNo">205</span>      String msg = String.format("FAILED persisting region=%s state=%s",<a name="line.205"></a>
+<span class="sourceLineNo">206</span>        regionInfo.getShortNameToLog(), state);<a name="line.206"></a>
+<span class="sourceLineNo">207</span>      LOG.error(msg, e);<a name="line.207"></a>
+<span class="sourceLineNo">208</span>      master.abort(msg, e);<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      throw e;<a name="line.209"></a>
+<span class="sourceLineNo">210</span>    }<a name="line.210"></a>
+<span class="sourceLineNo">211</span>  }<a name="line.211"></a>
+<span class="sourceLineNo">212</span><a name="line.212"></a>
+<span class="sourceLineNo">213</span>  private long getOpenSeqNumForParentRegion(RegionInfo region) throws IOException {<a name="line.213"></a>
+<span class="sourceLineNo">214</span>    MasterFileSystem mfs = master.getMasterFileSystem();<a name="line.214"></a>
+<span class="sourceLineNo">215</span>    long maxSeqId =<a name="line.215"></a>
+<span class="sourceLineNo">216</span>        WALSplitter.getMaxRegionSequenceId(mfs.getFileSystem(), mfs.getRegionDir(region));<a name="line.216"></a>
+<span class="sourceLineNo">217</span>    return maxSeqId &gt; 0 ? maxSeqId + 1 : HConstants.NO_SEQNUM;<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>  // ============================================================================================<a name="line.220"></a>
-<span class="sourceLineNo">221</span>  public void mergeRegions(final RegionInfo parent, final RegionInfo hriA, final RegionInfo hriB,<a name="line.221"></a>
-<span class="sourceLineNo">222</span>      final ServerName serverName) throws IOException {<a name="line.222"></a>
-<span class="sourceLineNo">223</span>    final TableDescriptor htd = getTableDescriptor(parent.getTable());<a name="line.223"></a>
-<span class="sourceLineNo">224</span>    MetaTableAccessor.mergeRegions(master.getConnection(), parent, hriA, hriB, serverName,<a name="line.224"></a>
-<span class="sourceLineNo">225</span>      getRegionReplication(htd));<a name="line.225"></a>
-<span class="sourceLineNo">226</span>  }<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>  //  Delete Region State helpers<a name="line.229"></a>
-<span class="sourceLineNo">230</span>  // ============================================================================================<a name="line.230"></a>
-<span class="sourceLineNo">231</span>  public void deleteRegion(final RegionInfo regionInfo) throws IOException {<a name="line.231"></a>
-<span class="sourceLineNo">232</span>    deleteRegions(Collections.singletonList(regionInfo));<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>  public void deleteRegions(final List&lt;RegionInfo&gt; regions) throws IOException {<a name="line.235"></a>
-<span class="sourceLineNo">236</span>    MetaTableAccessor.deleteRegions(master.getConnection(), regions);<a name="line.236"></a>
-<span class="sourceLineNo">237</span>  }<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>  //  Table Descriptors helpers<a name="line.240"></a>
-<span class="sourceLineNo">241</span>  // ==========================================================================<a name="line.241"></a>
-<span class="sourceLineNo">242</span>  private int getRegionReplication(final TableDescriptor htd) {<a name="line.242"></a>
-<span class="sourceLineNo">243</span>    return (htd != null) ? htd.getRegionReplication() : 1;<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>  private TableDescriptor getTableDescriptor(final TableName tableName) throws IOException {<a name="line.246"></a>
-<span class="sourceLineNo">247</span>    return master.getTableDescriptors().get(tableName);<a name="line.247"></a>
+<span class="sourceLineNo">221</span>  //  Update Region Splitting State helpers<a name="line.221"></a>
+<span class="sourceLineNo">222</span>  // ============================================================================================<a name="line.222"></a>
+<span class="sourceLineNo">223</span>  public void splitRegion(RegionInfo parent, RegionInfo hriA, RegionInfo hriB,<a name="line.223"></a>
+<span class="sourceLineNo">224</span>      ServerName serverName) throws IOException {<a name="line.224"></a>
+<span class="sourceLineNo">225</span>    TableDescriptor htd = getTableDescriptor(parent.getTable());<a name="line.225"></a>
+<span class="sourceLineNo">226</span>    long parentOpenSeqNum = HConstants.NO_SEQNUM;<a name="line.226"></a>
+<span class="sourceLineNo">227</span>    if (htd.hasSerialReplicationScope()) {<a name="line.227"></a>
+<span class="sourceLineNo">228</span>      parentOpenSeqNum = getOpenSeqNumForParentRegion(parent);<a name="line.228"></a>
+<span class="sourceLineNo">229</span>    }<a name="line.229"></a>
+<span class="sourceLineNo">230</span>    MetaTableAccessor.splitRegion(master.getConnection(), parent, parentOpenSeqNum, hriA, hriB,<a name="line.230"></a>
+<span class="sourceLineNo">231</span>      serverName, getRegionReplication(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(RegionInfo child, RegionInfo hriA, RegionInfo hriB,<a name="line.237"></a>
+<span class="sourceLineNo">238</span>      ServerName serverName) throws IOException {<a name="line.238"></a>
+<span class="sourceLineNo">239</span>    TableDescriptor htd = getTableDescriptor(child.getTable());<a name="line.239"></a>
+<span class="sourceLineNo">240</span>    long regionAOpenSeqNum = -1L;<a name="line.240"></a>
+<span class="sourceLineNo">241</span>    long regionBOpenSeqNum = -1L;<a name="line.241"></a>
+<span class="sourceLineNo">242</span>    if (htd.hasSerialReplicationScope()) {<a name="line.242"></a>
+<span class="sourceLineNo">243</span>      regionAOpenSeqNum = getOpenSeqNumForParentRegion(hriA);<a name="line.243"></a>
+<span class="sourceLineNo">244</span>      regionBOpenSeqNum = getOpenSeqNumForParentRegion(hriB);<a name="line.244"></a>
+<span class="sourceLineNo">245</span>    }<a name="line.245"></a>
+<span class="sourceLineNo">246</span>    MetaTableAccessor.mergeRegions(master.getConnection(), child, hriA, regionAOpenSeqNum, hriB,<a name="line.246"></a>
+<span class="sourceLineNo">247</span>      regionBOpenSeqNum, serverName, getRegionReplication(htd));<a name="line.247"></a>
 <span class="sourceLineNo">248</span>  }<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>  //  Server Name<a name="line.251"></a>
-<span class="sourceLineNo">252</span>  // ==========================================================================<a name="line.252"></a>
-<span class="sourceLineNo">253</span><a name="line.253"></a>
-<span class="sourceLineNo">254</span>  /**<a name="line.254"></a>
-<span class="sourceLineNo">255</span>   * Returns the {@link ServerName} from catalog table {@link Result}<a name="line.255"></a>
-<span class="sourceLineNo">256</span>   * where the region is transitioning. It should be the same as<a name="line.256"></a>
-<span class="sourceLineNo">257</span>   * {@link MetaTableAccessor#getServerName(Result,int)} if the server is at OPEN state.<a name="line.257"></a>
-<span class="sourceLineNo">258</span>   * @param r Result to pull the transitioning server name from<a name="line.258"></a>
-<span class="sourceLineNo">259</span>   * @return A ServerName instance or {@link MetaTableAccessor#getServerName(Result,int)}<a name="line.259"></a>
-<span class="sourceLineNo">260</span>   * if necessary fields not found or empty.<a name="line.260"></a>
-<span class="sourceLineNo">261</span>   */<a name="line.261"></a>
-<span class="sourceLineNo">262</span>  static ServerName getRegionServer(final Result r, int replicaId) {<a name="line.262"></a>
-<span class="sourceLineNo">263</span>    final Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY,<a name="line.263"></a>
-<span class="sourceLineNo">264</span>        getServerNameColumn(replicaId));<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    if (cell == null || cell.getValueLength() == 0) {<a name="line.265"></a>
-<span class="sourceLineNo">266</span>      RegionLocations locations = MetaTableAccessor.getRegionLocations(r);<a name="line.266"></a>
-<span class="sourceLineNo">267</span>      if (locations != null) {<a name="line.267"></a>
-<span class="sourceLineNo">268</span>        HRegionLocation location = locations.getRegionLocation(replicaId);<a name="line.268"></a>
-<span class="sourceLineNo">269</span>        if (location != null) {<a name="line.269"></a>
-<span class="sourceLineNo">270</span>          return location.getServerName();<a name="line.270"></a>
-<span class="sourceLineNo">271</span>        }<a name="line.271"></a>
-<span class="sourceLineNo">272</span>      }<a name="line.272"></a>
-<span class="sourceLineNo">273</span>      return null;<a name="line.273"></a>
-<span class="sourceLineNo">274</span>    }<a name="line.274"></a>
-<span class="sourceLineNo">275</span>    return ServerName.parseServerName(Bytes.toString(cell.getValueArray(),<a name="line.275"></a>
-<span class="sourceLineNo">276</span>      cell.getValueOffset(), cell.getValueLength()));<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>  private static byte[] getServerNameColumn(int replicaId) {<a name="line.279"></a>
-<span class="sourceLineNo">280</span>    return replicaId == 0<a name="line.280"></a>
-<span class="sourceLineNo">281</span>        ? HConstants.SERVERNAME_QUALIFIER<a name="line.281"></a>
-<span class="sourceLineNo">282</span>        : Bytes.toBytes(HConstants.SERVERNAME_QUALIFIER_STR + META_REPLICA_ID_DELIMITER<a name="line.282"></a>
-<span class="sourceLineNo">283</span>          + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));<a name="line.283"></a>
-<span class="sourceLineNo">284</span>  }<a name="line.284"></a>
-<span class="sourceLineNo">285</span><a name="line.285"></a>
-<span class="sourceLineNo">286</span>  // ==========================================================================<a name="line.286"></a>
-<span class="sourceLineNo">287</span>  //  Region State<a name="line.287"></a>
-<span class="sourceLineNo">288</span>  // ==========================================================================<a name="line.288"></a>
-<span class="sourceLineNo">289</span><a name="line.289"></a>
-<span class="sourceLineNo">290</span>  /**<a name="line.290"></a>
-<span class="sourceLineNo">291</span>   * Pull the region state from a catalog table {@link Result}.<a name="line.291"></a>
-<span class="sourceLineNo">292</span>   * @param r Result to pull the region state from<a name="line.292"></a>
-<span class="sourceLineNo">293</span>   * @return the region state, or null if unknown.<a name="line.293"></a>
-<span class="sourceLineNo">294</span>   */<a name="line.294"></a>
-<span class="sourceLineNo">295</span>  @VisibleForTesting<a name="line.295"></a>
-<span class="sourceLineNo">296</span>  public static State getRegionState(final Result r, int replicaId) {<a name="line.296"></a>
-<span class="sourceLineNo">297</span>    Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, getStateColumn(replicaId));<a name="line.297"></a>
-<span class="sourceLineNo">298</span>    if (cell == null || cell.getValueLength() == 0) {<a name="line.298"></a>
-<span class="sourceLineNo">299</span>      return null;<a name="line.299"></a>
-<span class="sourceLineNo">300</span>    }<a name="line.300"></a>
-<span class="sourceLineNo">301</span>    return State.valueOf(Bytes.toString(cell.getValueArray(), cell.getValueOffset(),<a name="line.301"></a>
-<span class="sourceLineNo">302</span>        cell.getValueLength()));<a name="line.302"></a>
-<span class="sourceLineNo">303</span>  }<a name="line.303"></a>
-<span class="sourceLineNo">304</span><a name="line.304"></a>
-<span class="sourceLineNo">305</span>  private static byte[] getStateColumn(int replicaId) {<a name="line.305"></a>
-<span class="sourceLineNo">306</span>    return replicaId == 0<a name="line.306"></a>
-<span class="sourceLineNo">307</span>        ? HConstants.STATE_QUALIFIER<a name="line.307"></a>
-<span class="sourceLineNo">308</span>        : Bytes.toBytes(HConstants.STATE_QUALIFIER_STR + META_REPLICA_ID_DELIMITER<a name="line.308"></a>
-<span class="sourceLineNo">309</span>          + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));<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">250</span>  // ============================================================================================<a name="line.250"></a>
+<span class="sourceLineNo">251</span>  //  Delete Region State helpers<a name="line.251"></a>
+<span class="sourceLineNo">252</span>  // ============================================================================================<a name="line.252"></a>
+<span class="sourceLineNo">253</span>  public void deleteRegion(final RegionInfo regionInfo) throws IOException {<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    deleteRegions(Collections.singletonList(regionInfo));<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>  public void deleteRegions(final List&lt;RegionInfo&gt; regions) throws IOException {<a name="line.257"></a>
+<span class="sourceLineNo">258</span>    MetaTableAccessor.deleteRegions(master.getConnection(), regions);<a name="line.258"></a>
+<span class="sourceLineNo">259</span>  }<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>  //  Table Descriptors helpers<a name="line.262"></a>
+<span class="sourceLineNo">263</span>  // ==========================================================================<a name="line.263"></a>
+<span class="sourceLineNo">264</span>  private boolean hasSerialReplicationScope(TableName tableName) throws IOException {<a name="line.264"></a>
+<span class="sourceLineNo">265</span>    return hasSerialReplicationScope(getTableDescriptor(tableName));<a name="line.265"></a>
+<span class="sourceLineNo">266</span>  }<a name="line.266"></a>
+<span class="sourceLineNo">267</span><a name="line.267"></a>
+<span class="sourceLineNo">268</span>  private boolean hasSerialReplicationScope(TableDescriptor htd) {<a name="line.268"></a>
+<span class="sourceLineNo">269</span>    return htd != null ? htd.hasSerialReplicationScope() : false;<a name="line.269"></a>
+<span class="sourceLineNo">270</span>  }<a name="line.270"></a>
+<span class="sourceLineNo">271</span><a name="line.271"></a>
+<span class="sourceLineNo">272</span>  private int getRegionReplication(TableDescriptor htd) {<a name="line.272"></a>
+<span class="sourceLineNo">273</span>    return htd != null ? htd.getRegionReplication() : 1;<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>  private TableDescriptor getTableDescriptor(TableName tableName) throws IOException {<a name="line.276"></a>
+<span class="sourceLineNo">277</span>    return master.getTableDescriptors().get(tableName);<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>  // ==========================================================================<a name="line.280"></a>
+<span class="sourceLineNo">281</span>  //  Server Name<a name="line.281"></a>
+<span class="sourceLineNo">282</span>  // ==========================================================================<a name="line.282"></a>
+<span class="sourceLineNo">283</span><a name="line.283"></a>
+<span class="sourceLineNo">284</span>  /**<a name="line.284"></a>
+<span class="sourceLineNo">285</span>   * Returns the {@link ServerName} from catalog table {@link Result}<a name="line.285"></a>
+<span class="sourceLineNo">286</span>   * where the region is transitioning. It should be the same as<a name="line.286"></a>
+<span class="sourceLineNo">287</span>   * {@link MetaTableAccessor#getServerName(Result,int)} if the server is at OPEN state.<a name="line.287"></a>
+<span class="sourceLineNo">288</span>   * @param r Result to pull the transitioning server name from<a name="line.288"></a>
+<span class="sourceLineNo">289</span>   * @return A ServerName instance or {@link MetaTableAccessor#getServerName(Result,int)}<a name="line.289"></a>
+<span class="sourceLineNo">290</span>   * if necessary fields not found or empty.<a name="line.290"></a>
+<span class="sourceLineNo">291</span>   */<a name="line.291"></a>
+<span class="sourceLineNo">292</span>  static ServerName getRegionServer(final Result r, int replicaId) {<a name="line.292"></a>
+<span class="sourceLineNo">293</span>    final Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY,<a name="line.293"></a>
+<span class="sourceLineNo">294</span>        getServerNameColumn(replicaId));<a name="line.294"></a>
+<span class="sourceLineNo">295</span>    if (cell == null || cell.getValueLength() == 0) {<a name="line.295"></a>
+<span class="sourceLineNo">296</span>      RegionLocations locations = MetaTableAccessor.getRegionLocations(r);<a name="line.296"></a>
+<span class="sourceLineNo">297</span>      if (locations != null) {<a name="line.297"></a>
+<span class="sourceLineNo">298</span>        HRegionLocation location = locations.getRegionLocation(replicaId);<a name="line.298"></a>
+<span class="sourceLineNo">299</span>        if (location != null) {<a name="line.299"></a>
+<span class="sourceLineNo">300</span>          return location.getServerName();<a name="line.300"></a>
+<span class="sourceLineNo">301</span>        }<a name="line.301"></a>
+<span class="sourceLineNo">302</span>      }<a name="line.302"></a>
+<span class="sourceLineNo">303</span>      return null;<a name="line.303"></a>
+<span class="sourceLineNo">304</span>    }<a name="line.304"></a>
+<span class="sourceLineNo">305</span>    return ServerName.parseServerName(Bytes.toString(cell.getValueArray(),<a name="line.305"></a>
+<span class="sourceLineNo">306</span>      cell.getValueOffset(), cell.getValueLength()));<a name="line.306"></a>
+<span class="sourceLineNo">307</span>  }<a name="line.307"></a>
+<span class="sourceLineNo">308</span><a name="line.308"></a>
+<span class="sourceLineNo">309</span>  private static byte[] getServerNameColumn(int replicaId) {<a name="line.309"></a>
+<span class="sourceLineNo">310</span>    return replicaId == 0<a name="line.310"></a>
+<span class="sourceLineNo">311</span>        ? HConstants.SERVERNAME_QUALIFIER<a name="line.311"></a>
+<span class="sourceLineNo">312</span>        : Bytes.toBytes(HConstants.SERVERNAME_QUALIFIER_STR + META_REPLICA_ID_DELIMITER<a name="line.312"></a>
+<span class="sourceLineNo">313</span>          + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));<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>  // ==========================================================================<a name="line.316"></a>
+<span class="sourceLineNo">317</span>  //  Region State<a name="line.317"></a>
+<span class="sourceLineNo">318</span>  // ==========================================================================<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>   * Pull the region state from a catalog table {@link Result}.<a name="line.321"></a>
+<span class="sourceLineNo">322</span>   * @param r Result to pull the region state from<a name="line.322"></a>
+<span class="sourceLineNo">323</span>   * @return the region state, or null if unknown.<a name="line.323"></a>
+<span class="sourceLineNo">324</span>   */<a name="line.324"></a>
+<span class="sourceLineNo">325</span>  @VisibleForTesting<a name="line.325"></a>
+<span class="sourceLineNo">326</span>  public static State getRegionState(final Result r, int replicaId) {<a name="line.326"></a>
+<span class="sourceLineNo">327</span>    Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, getStateColumn(replicaId));<a name="line.327"></a>
+<span class="sourceLineNo">328</span>    if (cell == null || cell.getValueLength() == 0) {<a name="line.328"></a>
+<span class="sourceLineNo">329</span>      return null;<a name="line.329"></a>
+<span class="sourceLineNo">330</span>    }<a name="line.330"></a>
+<span class="sourceLineNo">331</span>    return State.valueOf(Bytes.toString(cell.getValueArray(), cell.getValueOffset(),<a name="line.331"></a>
+<span class="sourceLineNo">332</span>        cell.getValueLength()));<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>
+<span class="sourceLineNo">335</span>  private static byte[] getStateColumn(int replicaId) {<a name="line.335"></a>
+<span class="sourceLineNo">336</span>    return replicaId == 0<a name="line.336"></a>
+<span class="sourceLineNo">337</span>        ? HConstants.STATE_QUALIFIER<a name="line.337"></a>
+<span class="sourceLineNo">338</span>        : Bytes.toBytes(HConstants.STATE_QUALIFIER_STR + META_REPLICA_ID_DELIMITER<a name="line.338"></a>
+<span class="sourceLineNo">339</span>          + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));<a name="line.339"></a>
+<span class="sourceLineNo">340</span>  }<a name="line.340"></a>
+<span class="sourceLineNo">341</span>}<a name="line.341"></a>
 
 
 


Mime
View raw message