hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [05/51] [partial] hbase-site git commit: Published site at .
Date Wed, 11 Oct 2017 15:13:10 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/c0571676/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionsCleaner.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionsCleaner.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionsCleaner.html
index a9dd1e3..ea14609 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionsCleaner.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionsCleaner.html
@@ -298,7 +298,7 @@
 <span class="sourceLineNo">290</span>   * Map of regions currently being served by this region server. Key is the<a name="line.290"></a>
 <span class="sourceLineNo">291</span>   * encoded region name.  All access should be synchronized.<a name="line.291"></a>
 <span class="sourceLineNo">292</span>   */<a name="line.292"></a>
-<span class="sourceLineNo">293</span>  protected final Map&lt;String, Region&gt; onlineRegions = new ConcurrentHashMap&lt;&gt;();<a name="line.293"></a>
+<span class="sourceLineNo">293</span>  protected final Map&lt;String, HRegion&gt; onlineRegions = new ConcurrentHashMap&lt;&gt;();<a name="line.293"></a>
 <span class="sourceLineNo">294</span><a name="line.294"></a>
 <span class="sourceLineNo">295</span>  /**<a name="line.295"></a>
 <span class="sourceLineNo">296</span>   * Map of encoded region names to the DataNode locations they should be hosted on<a name="line.296"></a>
@@ -316,8 +316,8 @@
 <span class="sourceLineNo">308</span>   * Set of regions currently being in recovering state which means it can accept writes(edits from<a name="line.308"></a>
 <span class="sourceLineNo">309</span>   * previous failed region server) but not reads. A recovering region is also an online region.<a name="line.309"></a>
 <span class="sourceLineNo">310</span>   */<a name="line.310"></a>
-<span class="sourceLineNo">311</span>  protected final Map&lt;String, Region&gt; recoveringRegions = Collections<a name="line.311"></a>
-<span class="sourceLineNo">312</span>      .synchronizedMap(new HashMap&lt;String, Region&gt;());<a name="line.312"></a>
+<span class="sourceLineNo">311</span>  protected final Map&lt;String, HRegion&gt; recoveringRegions = Collections<a name="line.311"></a>
+<span class="sourceLineNo">312</span>      .synchronizedMap(new HashMap&lt;String, HRegion&gt;());<a name="line.312"></a>
 <span class="sourceLineNo">313</span><a name="line.313"></a>
 <span class="sourceLineNo">314</span>  // Leases<a name="line.314"></a>
 <span class="sourceLineNo">315</span>  protected Leases leases;<a name="line.315"></a>
@@ -1243,7 +1243,7 @@
 <span class="sourceLineNo">1235</span>  private boolean areAllUserRegionsOffline() {<a name="line.1235"></a>
 <span class="sourceLineNo">1236</span>    if (getNumberOfOnlineRegions() &gt; 2) return false;<a name="line.1236"></a>
 <span class="sourceLineNo">1237</span>    boolean allUserRegionsOffline = true;<a name="line.1237"></a>
-<span class="sourceLineNo">1238</span>    for (Map.Entry&lt;String, Region&gt; e: this.onlineRegions.entrySet()) {<a name="line.1238"></a>
+<span class="sourceLineNo">1238</span>    for (Map.Entry&lt;String, HRegion&gt; e: this.onlineRegions.entrySet()) {<a name="line.1238"></a>
 <span class="sourceLineNo">1239</span>      if (!e.getValue().getRegionInfo().isMetaTable()) {<a name="line.1239"></a>
 <span class="sourceLineNo">1240</span>        allUserRegionsOffline = false;<a name="line.1240"></a>
 <span class="sourceLineNo">1241</span>        break;<a name="line.1241"></a>
@@ -1257,7 +1257,7 @@
 <span class="sourceLineNo">1249</span>   */<a name="line.1249"></a>
 <span class="sourceLineNo">1250</span>  private long getWriteRequestCount() {<a name="line.1250"></a>
 <span class="sourceLineNo">1251</span>    long writeCount = 0;<a name="line.1251"></a>
-<span class="sourceLineNo">1252</span>    for (Map.Entry&lt;String, Region&gt; e: this.onlineRegions.entrySet()) {<a name="line.1252"></a>
+<span class="sourceLineNo">1252</span>    for (Map.Entry&lt;String, HRegion&gt; e: this.onlineRegions.entrySet()) {<a name="line.1252"></a>
 <span class="sourceLineNo">1253</span>      writeCount += e.getValue().getWriteRequestsCount();<a name="line.1253"></a>
 <span class="sourceLineNo">1254</span>    }<a name="line.1254"></a>
 <span class="sourceLineNo">1255</span>    return writeCount;<a name="line.1255"></a>
@@ -1377,7 +1377,7 @@
 <span class="sourceLineNo">1369</span>    // improved; Additionally the load balancer will be able to take advantage of a more complete<a name="line.1369"></a>
 <span class="sourceLineNo">1370</span>    // history.<a name="line.1370"></a>
 <span class="sourceLineNo">1371</span>    MetricsRegionServerWrapper regionServerWrapper = metricsRegionServer.getRegionServerWrapper();<a name="line.1371"></a>
-<span class="sourceLineNo">1372</span>    Collection&lt;Region&gt; regions = getOnlineRegionsLocalContext();<a name="line.1372"></a>
+<span class="sourceLineNo">1372</span>    Collection&lt;HRegion&gt; regions = getOnlineRegionsLocalContext();<a name="line.1372"></a>
 <span class="sourceLineNo">1373</span>    long usedMemory = -1L;<a name="line.1373"></a>
 <span class="sourceLineNo">1374</span>    long maxMemory = -1L;<a name="line.1374"></a>
 <span class="sourceLineNo">1375</span>    final MemoryUsage usage = MemorySizeUtil.safeGetHeapMemoryUsage();<a name="line.1375"></a>
@@ -1399,7 +1399,7 @@
 <span class="sourceLineNo">1391</span>    }<a name="line.1391"></a>
 <span class="sourceLineNo">1392</span>    RegionLoad.Builder regionLoadBldr = RegionLoad.newBuilder();<a name="line.1392"></a>
 <span class="sourceLineNo">1393</span>    RegionSpecifier.Builder regionSpecifier = RegionSpecifier.newBuilder();<a name="line.1393"></a>
-<span class="sourceLineNo">1394</span>    for (Region region : regions) {<a name="line.1394"></a>
+<span class="sourceLineNo">1394</span>    for (HRegion region : regions) {<a name="line.1394"></a>
 <span class="sourceLineNo">1395</span>      if (region.getCoprocessorHost() != null) {<a name="line.1395"></a>
 <span class="sourceLineNo">1396</span>        Set&lt;String&gt; regionCoprocessors = region.getCoprocessorHost().getCoprocessors();<a name="line.1396"></a>
 <span class="sourceLineNo">1397</span>        Iterator&lt;String&gt; iterator = regionCoprocessors.iterator();<a name="line.1397"></a>
@@ -1477,7 +1477,7 @@
 <span class="sourceLineNo">1469</span>        // Ensure all user regions have been sent a close. Use this to<a name="line.1469"></a>
 <span class="sourceLineNo">1470</span>        // protect against the case where an open comes in after we start the<a name="line.1470"></a>
 <span class="sourceLineNo">1471</span>        // iterator of onlineRegions to close all user regions.<a name="line.1471"></a>
-<span class="sourceLineNo">1472</span>        for (Map.Entry&lt;String, Region&gt; e : this.onlineRegions.entrySet()) {<a name="line.1472"></a>
+<span class="sourceLineNo">1472</span>        for (Map.Entry&lt;String, HRegion&gt; e : this.onlineRegions.entrySet()) {<a name="line.1472"></a>
 <span class="sourceLineNo">1473</span>          RegionInfo hri = e.getValue().getRegionInfo();<a name="line.1473"></a>
 <span class="sourceLineNo">1474</span>          if (!this.regionsInTransitionInRS.containsKey(hri.getEncodedNameAsBytes())<a name="line.1474"></a>
 <span class="sourceLineNo">1475</span>              &amp;&amp; !closedRegions.contains(hri.getEncodedName())) {<a name="line.1475"></a>
@@ -1680,7 +1680,7 @@
 <span class="sourceLineNo">1672</span>   *<a name="line.1672"></a>
 <span class="sourceLineNo">1673</span>   * @throws IOException<a name="line.1673"></a>
 <span class="sourceLineNo">1674</span>   */<a name="line.1674"></a>
-<span class="sourceLineNo">1675</span>  RegionLoad createRegionLoad(final Region r, RegionLoad.Builder regionLoadBldr,<a name="line.1675"></a>
+<span class="sourceLineNo">1675</span>  RegionLoad createRegionLoad(final HRegion r, RegionLoad.Builder regionLoadBldr,<a name="line.1675"></a>
 <span class="sourceLineNo">1676</span>      RegionSpecifier.Builder regionSpecifier) throws IOException {<a name="line.1676"></a>
 <span class="sourceLineNo">1677</span>    byte[] name = r.getRegionInfo().getRegionName();<a name="line.1677"></a>
 <span class="sourceLineNo">1678</span>    int stores = 0;<a name="line.1678"></a>
@@ -1748,7 +1748,7 @@
 <span class="sourceLineNo">1740</span>   * @return An instance of RegionLoad.<a name="line.1740"></a>
 <span class="sourceLineNo">1741</span>   */<a name="line.1741"></a>
 <span class="sourceLineNo">1742</span>  public RegionLoad createRegionLoad(final String encodedRegionName) throws IOException {<a name="line.1742"></a>
-<span class="sourceLineNo">1743</span>    Region r = onlineRegions.get(encodedRegionName);<a name="line.1743"></a>
+<span class="sourceLineNo">1743</span>    HRegion r = onlineRegions.get(encodedRegionName);<a name="line.1743"></a>
 <span class="sourceLineNo">1744</span>    return r != null ? createRegionLoad(r, null, null) : null;<a name="line.1744"></a>
 <span class="sourceLineNo">1745</span>  }<a name="line.1745"></a>
 <span class="sourceLineNo">1746</span><a name="line.1746"></a>
@@ -1829,9 +1829,9 @@
 <span class="sourceLineNo">1821</span>    @Override<a name="line.1821"></a>
 <span class="sourceLineNo">1822</span>    protected void chore() {<a name="line.1822"></a>
 <span class="sourceLineNo">1823</span>      final StringBuffer whyFlush = new StringBuffer();<a name="line.1823"></a>
-<span class="sourceLineNo">1824</span>      for (Region r : this.server.onlineRegions.values()) {<a name="line.1824"></a>
+<span class="sourceLineNo">1824</span>      for (HRegion r : this.server.onlineRegions.values()) {<a name="line.1824"></a>
 <span class="sourceLineNo">1825</span>        if (r == null) continue;<a name="line.1825"></a>
-<span class="sourceLineNo">1826</span>        if (((HRegion)r).shouldFlush(whyFlush)) {<a name="line.1826"></a>
+<span class="sourceLineNo">1826</span>        if (r.shouldFlush(whyFlush)) {<a name="line.1826"></a>
 <span class="sourceLineNo">1827</span>          FlushRequester requester = server.getFlushRequester();<a name="line.1827"></a>
 <span class="sourceLineNo">1828</span>          if (requester != null) {<a name="line.1828"></a>
 <span class="sourceLineNo">1829</span>            long randomDelay = RandomUtils.nextInt(0, RANGE_OF_DELAY) + MIN_DELAY_TIME;<a name="line.1829"></a>
@@ -2165,1616 +2165,1599 @@
 <span class="sourceLineNo">2157</span>  }<a name="line.2157"></a>
 <span class="sourceLineNo">2158</span><a name="line.2158"></a>
 <span class="sourceLineNo">2159</span>  @Override<a name="line.2159"></a>
-<span class="sourceLineNo">2160</span>  public void postOpenDeployTasks(final Region r) throws KeeperException, IOException {<a name="line.2160"></a>
-<span class="sourceLineNo">2161</span>    postOpenDeployTasks(new PostOpenDeployContext(r, -1));<a name="line.2161"></a>
-<span class="sourceLineNo">2162</span>  }<a name="line.2162"></a>
-<span class="sourceLineNo">2163</span><a name="line.2163"></a>
-<span class="sourceLineNo">2164</span>  @Override<a name="line.2164"></a>
-<span class="sourceLineNo">2165</span>  public void postOpenDeployTasks(final PostOpenDeployContext context)<a name="line.2165"></a>
-<span class="sourceLineNo">2166</span>      throws KeeperException, IOException {<a name="line.2166"></a>
-<span class="sourceLineNo">2167</span>    HRegion r = (HRegion) context.getRegion();<a name="line.2167"></a>
-<span class="sourceLineNo">2168</span>    long masterSystemTime = context.getMasterSystemTime();<a name="line.2168"></a>
-<span class="sourceLineNo">2169</span>    rpcServices.checkOpen();<a name="line.2169"></a>
-<span class="sourceLineNo">2170</span>    LOG.info("Post open deploy tasks for " + r.getRegionInfo().getRegionNameAsString());<a name="line.2170"></a>
-<span class="sourceLineNo">2171</span>    // Do checks to see if we need to compact (references or too many files)<a name="line.2171"></a>
-<span class="sourceLineNo">2172</span>    for (HStore s : r.stores.values()) {<a name="line.2172"></a>
-<span class="sourceLineNo">2173</span>      if (s.hasReferences() || s.needsCompaction()) {<a name="line.2173"></a>
-<span class="sourceLineNo">2174</span>        this.compactSplitThread.requestSystemCompaction(r, s, "Opening Region");<a name="line.2174"></a>
-<span class="sourceLineNo">2175</span>      }<a name="line.2175"></a>
-<span class="sourceLineNo">2176</span>    }<a name="line.2176"></a>
-<span class="sourceLineNo">2177</span>    long openSeqNum = r.getOpenSeqNum();<a name="line.2177"></a>
-<span class="sourceLineNo">2178</span>    if (openSeqNum == HConstants.NO_SEQNUM) {<a name="line.2178"></a>
-<span class="sourceLineNo">2179</span>      // If we opened a region, we should have read some sequence number from it.<a name="line.2179"></a>
-<span class="sourceLineNo">2180</span>      LOG.error("No sequence number found when opening " +<a name="line.2180"></a>
-<span class="sourceLineNo">2181</span>        r.getRegionInfo().getRegionNameAsString());<a name="line.2181"></a>
-<span class="sourceLineNo">2182</span>      openSeqNum = 0;<a name="line.2182"></a>
-<span class="sourceLineNo">2183</span>    }<a name="line.2183"></a>
-<span class="sourceLineNo">2184</span><a name="line.2184"></a>
-<span class="sourceLineNo">2185</span>    // Update flushed sequence id of a recovering region in ZK<a name="line.2185"></a>
-<span class="sourceLineNo">2186</span>    updateRecoveringRegionLastFlushedSequenceId(r);<a name="line.2186"></a>
-<span class="sourceLineNo">2187</span><a name="line.2187"></a>
-<span class="sourceLineNo">2188</span>    // Notify master<a name="line.2188"></a>
-<span class="sourceLineNo">2189</span>    if (!reportRegionStateTransition(new RegionStateTransitionContext(<a name="line.2189"></a>
-<span class="sourceLineNo">2190</span>        TransitionCode.OPENED, openSeqNum, masterSystemTime, r.getRegionInfo()))) {<a name="line.2190"></a>
-<span class="sourceLineNo">2191</span>      throw new IOException("Failed to report opened region to master: "<a name="line.2191"></a>
-<span class="sourceLineNo">2192</span>        + r.getRegionInfo().getRegionNameAsString());<a name="line.2192"></a>
-<span class="sourceLineNo">2193</span>    }<a name="line.2193"></a>
+<span class="sourceLineNo">2160</span>  public void postOpenDeployTasks(final PostOpenDeployContext context)<a name="line.2160"></a>
+<span class="sourceLineNo">2161</span>      throws KeeperException, IOException {<a name="line.2161"></a>
+<span class="sourceLineNo">2162</span>    HRegion r = (HRegion) context.getRegion();<a name="line.2162"></a>
+<span class="sourceLineNo">2163</span>    long masterSystemTime = context.getMasterSystemTime();<a name="line.2163"></a>
+<span class="sourceLineNo">2164</span>    rpcServices.checkOpen();<a name="line.2164"></a>
+<span class="sourceLineNo">2165</span>    LOG.info("Post open deploy tasks for " + r.getRegionInfo().getRegionNameAsString());<a name="line.2165"></a>
+<span class="sourceLineNo">2166</span>    // Do checks to see if we need to compact (references or too many files)<a name="line.2166"></a>
+<span class="sourceLineNo">2167</span>    for (HStore s : r.stores.values()) {<a name="line.2167"></a>
+<span class="sourceLineNo">2168</span>      if (s.hasReferences() || s.needsCompaction()) {<a name="line.2168"></a>
+<span class="sourceLineNo">2169</span>        this.compactSplitThread.requestSystemCompaction(r, s, "Opening Region");<a name="line.2169"></a>
+<span class="sourceLineNo">2170</span>      }<a name="line.2170"></a>
+<span class="sourceLineNo">2171</span>    }<a name="line.2171"></a>
+<span class="sourceLineNo">2172</span>    long openSeqNum = r.getOpenSeqNum();<a name="line.2172"></a>
+<span class="sourceLineNo">2173</span>    if (openSeqNum == HConstants.NO_SEQNUM) {<a name="line.2173"></a>
+<span class="sourceLineNo">2174</span>      // If we opened a region, we should have read some sequence number from it.<a name="line.2174"></a>
+<span class="sourceLineNo">2175</span>      LOG.error("No sequence number found when opening " +<a name="line.2175"></a>
+<span class="sourceLineNo">2176</span>        r.getRegionInfo().getRegionNameAsString());<a name="line.2176"></a>
+<span class="sourceLineNo">2177</span>      openSeqNum = 0;<a name="line.2177"></a>
+<span class="sourceLineNo">2178</span>    }<a name="line.2178"></a>
+<span class="sourceLineNo">2179</span><a name="line.2179"></a>
+<span class="sourceLineNo">2180</span>    // Update flushed sequence id of a recovering region in ZK<a name="line.2180"></a>
+<span class="sourceLineNo">2181</span>    updateRecoveringRegionLastFlushedSequenceId(r);<a name="line.2181"></a>
+<span class="sourceLineNo">2182</span><a name="line.2182"></a>
+<span class="sourceLineNo">2183</span>    // Notify master<a name="line.2183"></a>
+<span class="sourceLineNo">2184</span>    if (!reportRegionStateTransition(new RegionStateTransitionContext(<a name="line.2184"></a>
+<span class="sourceLineNo">2185</span>        TransitionCode.OPENED, openSeqNum, masterSystemTime, r.getRegionInfo()))) {<a name="line.2185"></a>
+<span class="sourceLineNo">2186</span>      throw new IOException("Failed to report opened region to master: "<a name="line.2186"></a>
+<span class="sourceLineNo">2187</span>        + r.getRegionInfo().getRegionNameAsString());<a name="line.2187"></a>
+<span class="sourceLineNo">2188</span>    }<a name="line.2188"></a>
+<span class="sourceLineNo">2189</span><a name="line.2189"></a>
+<span class="sourceLineNo">2190</span>    triggerFlushInPrimaryRegion((HRegion)r);<a name="line.2190"></a>
+<span class="sourceLineNo">2191</span><a name="line.2191"></a>
+<span class="sourceLineNo">2192</span>    LOG.debug("Finished post open deploy task for " + r.getRegionInfo().getRegionNameAsString());<a name="line.2192"></a>
+<span class="sourceLineNo">2193</span>  }<a name="line.2193"></a>
 <span class="sourceLineNo">2194</span><a name="line.2194"></a>
-<span class="sourceLineNo">2195</span>    triggerFlushInPrimaryRegion((HRegion)r);<a name="line.2195"></a>
-<span class="sourceLineNo">2196</span><a name="line.2196"></a>
-<span class="sourceLineNo">2197</span>    LOG.debug("Finished post open deploy task for " + r.getRegionInfo().getRegionNameAsString());<a name="line.2197"></a>
-<span class="sourceLineNo">2198</span>  }<a name="line.2198"></a>
-<span class="sourceLineNo">2199</span><a name="line.2199"></a>
-<span class="sourceLineNo">2200</span>  @Override<a name="line.2200"></a>
-<span class="sourceLineNo">2201</span>  public boolean reportRegionStateTransition(TransitionCode code, RegionInfo... hris) {<a name="line.2201"></a>
-<span class="sourceLineNo">2202</span>    return reportRegionStateTransition(code, HConstants.NO_SEQNUM, hris);<a name="line.2202"></a>
-<span class="sourceLineNo">2203</span>  }<a name="line.2203"></a>
-<span class="sourceLineNo">2204</span><a name="line.2204"></a>
-<span class="sourceLineNo">2205</span>  @Override<a name="line.2205"></a>
-<span class="sourceLineNo">2206</span>  public boolean reportRegionStateTransition(<a name="line.2206"></a>
-<span class="sourceLineNo">2207</span>      TransitionCode code, long openSeqNum, RegionInfo... hris) {<a name="line.2207"></a>
-<span class="sourceLineNo">2208</span>    return reportRegionStateTransition(<a name="line.2208"></a>
-<span class="sourceLineNo">2209</span>      new RegionStateTransitionContext(code, HConstants.NO_SEQNUM, -1, hris));<a name="line.2209"></a>
-<span class="sourceLineNo">2210</span>  }<a name="line.2210"></a>
-<span class="sourceLineNo">2211</span><a name="line.2211"></a>
-<span class="sourceLineNo">2212</span>  @Override<a name="line.2212"></a>
-<span class="sourceLineNo">2213</span>  public boolean reportRegionStateTransition(final RegionStateTransitionContext context) {<a name="line.2213"></a>
-<span class="sourceLineNo">2214</span>    TransitionCode code = context.getCode();<a name="line.2214"></a>
-<span class="sourceLineNo">2215</span>    long openSeqNum = context.getOpenSeqNum();<a name="line.2215"></a>
-<span class="sourceLineNo">2216</span>    long masterSystemTime = context.getMasterSystemTime();<a name="line.2216"></a>
-<span class="sourceLineNo">2217</span>    RegionInfo[] hris = context.getHris();<a name="line.2217"></a>
-<span class="sourceLineNo">2218</span><a name="line.2218"></a>
-<span class="sourceLineNo">2219</span>    if (TEST_SKIP_REPORTING_TRANSITION) {<a name="line.2219"></a>
-<span class="sourceLineNo">2220</span>      // This is for testing only in case there is no master<a name="line.2220"></a>
-<span class="sourceLineNo">2221</span>      // to handle the region transition report at all.<a name="line.2221"></a>
-<span class="sourceLineNo">2222</span>      if (code == TransitionCode.OPENED) {<a name="line.2222"></a>
-<span class="sourceLineNo">2223</span>        Preconditions.checkArgument(hris != null &amp;&amp; hris.length == 1);<a name="line.2223"></a>
-<span class="sourceLineNo">2224</span>        if (hris[0].isMetaRegion()) {<a name="line.2224"></a>
-<span class="sourceLineNo">2225</span>          try {<a name="line.2225"></a>
-<span class="sourceLineNo">2226</span>            MetaTableLocator.setMetaLocation(getZooKeeper(), serverName,<a name="line.2226"></a>
-<span class="sourceLineNo">2227</span>                hris[0].getReplicaId(),State.OPEN);<a name="line.2227"></a>
-<span class="sourceLineNo">2228</span>          } catch (KeeperException e) {<a name="line.2228"></a>
-<span class="sourceLineNo">2229</span>            LOG.info("Failed to update meta location", e);<a name="line.2229"></a>
-<span class="sourceLineNo">2230</span>            return false;<a name="line.2230"></a>
-<span class="sourceLineNo">2231</span>          }<a name="line.2231"></a>
-<span class="sourceLineNo">2232</span>        } else {<a name="line.2232"></a>
-<span class="sourceLineNo">2233</span>          try {<a name="line.2233"></a>
-<span class="sourceLineNo">2234</span>            MetaTableAccessor.updateRegionLocation(clusterConnection,<a name="line.2234"></a>
-<span class="sourceLineNo">2235</span>              hris[0], serverName, openSeqNum, masterSystemTime);<a name="line.2235"></a>
-<span class="sourceLineNo">2236</span>          } catch (IOException e) {<a name="line.2236"></a>
-<span class="sourceLineNo">2237</span>            LOG.info("Failed to update meta", e);<a name="line.2237"></a>
-<span class="sourceLineNo">2238</span>            return false;<a name="line.2238"></a>
-<span class="sourceLineNo">2239</span>          }<a name="line.2239"></a>
-<span class="sourceLineNo">2240</span>        }<a name="line.2240"></a>
-<span class="sourceLineNo">2241</span>      }<a name="line.2241"></a>
-<span class="sourceLineNo">2242</span>      return true;<a name="line.2242"></a>
-<span class="sourceLineNo">2243</span>    }<a name="line.2243"></a>
-<span class="sourceLineNo">2244</span><a name="line.2244"></a>
-<span class="sourceLineNo">2245</span>    ReportRegionStateTransitionRequest.Builder builder =<a name="line.2245"></a>
-<span class="sourceLineNo">2246</span>      ReportRegionStateTransitionRequest.newBuilder();<a name="line.2246"></a>
-<span class="sourceLineNo">2247</span>    builder.setServer(ProtobufUtil.toServerName(serverName));<a name="line.2247"></a>
-<span class="sourceLineNo">2248</span>    RegionStateTransition.Builder transition = builder.addTransitionBuilder();<a name="line.2248"></a>
-<span class="sourceLineNo">2249</span>    transition.setTransitionCode(code);<a name="line.2249"></a>
-<span class="sourceLineNo">2250</span>    if (code == TransitionCode.OPENED &amp;&amp; openSeqNum &gt;= 0) {<a name="line.2250"></a>
-<span class="sourceLineNo">2251</span>      transition.setOpenSeqNum(openSeqNum);<a name="line.2251"></a>
-<span class="sourceLineNo">2252</span>    }<a name="line.2252"></a>
-<span class="sourceLineNo">2253</span>    for (RegionInfo hri: hris) {<a name="line.2253"></a>
-<span class="sourceLineNo">2254</span>      transition.addRegionInfo(ProtobufUtil.toRegionInfo(hri));<a name="line.2254"></a>
-<span class="sourceLineNo">2255</span>    }<a name="line.2255"></a>
-<span class="sourceLineNo">2256</span>    ReportRegionStateTransitionRequest request = builder.build();<a name="line.2256"></a>
-<span class="sourceLineNo">2257</span>    int tries = 0;<a name="line.2257"></a>
-<span class="sourceLineNo">2258</span>    long pauseTime = INIT_PAUSE_TIME_MS;<a name="line.2258"></a>
-<span class="sourceLineNo">2259</span>    while (keepLooping()) {<a name="line.2259"></a>
-<span class="sourceLineNo">2260</span>      RegionServerStatusService.BlockingInterface rss = rssStub;<a name="line.2260"></a>
-<span class="sourceLineNo">2261</span>      try {<a name="line.2261"></a>
-<span class="sourceLineNo">2262</span>        if (rss == null) {<a name="line.2262"></a>
-<span class="sourceLineNo">2263</span>          createRegionServerStatusStub();<a name="line.2263"></a>
-<span class="sourceLineNo">2264</span>          continue;<a name="line.2264"></a>
-<span class="sourceLineNo">2265</span>        }<a name="line.2265"></a>
-<span class="sourceLineNo">2266</span>        ReportRegionStateTransitionResponse response =<a name="line.2266"></a>
-<span class="sourceLineNo">2267</span>          rss.reportRegionStateTransition(null, request);<a name="line.2267"></a>
-<span class="sourceLineNo">2268</span>        if (response.hasErrorMessage()) {<a name="line.2268"></a>
-<span class="sourceLineNo">2269</span>          LOG.info("TRANSITION FAILED " + request + ": " + response.getErrorMessage());<a name="line.2269"></a>
-<span class="sourceLineNo">2270</span>          // NOTE: Return mid-method!!!<a name="line.2270"></a>
-<span class="sourceLineNo">2271</span>          return false;<a name="line.2271"></a>
+<span class="sourceLineNo">2195</span>  @Override<a name="line.2195"></a>
+<span class="sourceLineNo">2196</span>  public boolean reportRegionStateTransition(final RegionStateTransitionContext context) {<a name="line.2196"></a>
+<span class="sourceLineNo">2197</span>    TransitionCode code = context.getCode();<a name="line.2197"></a>
+<span class="sourceLineNo">2198</span>    long openSeqNum = context.getOpenSeqNum();<a name="line.2198"></a>
+<span class="sourceLineNo">2199</span>    long masterSystemTime = context.getMasterSystemTime();<a name="line.2199"></a>
+<span class="sourceLineNo">2200</span>    RegionInfo[] hris = context.getHris();<a name="line.2200"></a>
+<span class="sourceLineNo">2201</span><a name="line.2201"></a>
+<span class="sourceLineNo">2202</span>    if (TEST_SKIP_REPORTING_TRANSITION) {<a name="line.2202"></a>
+<span class="sourceLineNo">2203</span>      // This is for testing only in case there is no master<a name="line.2203"></a>
+<span class="sourceLineNo">2204</span>      // to handle the region transition report at all.<a name="line.2204"></a>
+<span class="sourceLineNo">2205</span>      if (code == TransitionCode.OPENED) {<a name="line.2205"></a>
+<span class="sourceLineNo">2206</span>        Preconditions.checkArgument(hris != null &amp;&amp; hris.length == 1);<a name="line.2206"></a>
+<span class="sourceLineNo">2207</span>        if (hris[0].isMetaRegion()) {<a name="line.2207"></a>
+<span class="sourceLineNo">2208</span>          try {<a name="line.2208"></a>
+<span class="sourceLineNo">2209</span>            MetaTableLocator.setMetaLocation(getZooKeeper(), serverName,<a name="line.2209"></a>
+<span class="sourceLineNo">2210</span>                hris[0].getReplicaId(),State.OPEN);<a name="line.2210"></a>
+<span class="sourceLineNo">2211</span>          } catch (KeeperException e) {<a name="line.2211"></a>
+<span class="sourceLineNo">2212</span>            LOG.info("Failed to update meta location", e);<a name="line.2212"></a>
+<span class="sourceLineNo">2213</span>            return false;<a name="line.2213"></a>
+<span class="sourceLineNo">2214</span>          }<a name="line.2214"></a>
+<span class="sourceLineNo">2215</span>        } else {<a name="line.2215"></a>
+<span class="sourceLineNo">2216</span>          try {<a name="line.2216"></a>
+<span class="sourceLineNo">2217</span>            MetaTableAccessor.updateRegionLocation(clusterConnection,<a name="line.2217"></a>
+<span class="sourceLineNo">2218</span>              hris[0], serverName, openSeqNum, masterSystemTime);<a name="line.2218"></a>
+<span class="sourceLineNo">2219</span>          } catch (IOException e) {<a name="line.2219"></a>
+<span class="sourceLineNo">2220</span>            LOG.info("Failed to update meta", e);<a name="line.2220"></a>
+<span class="sourceLineNo">2221</span>            return false;<a name="line.2221"></a>
+<span class="sourceLineNo">2222</span>          }<a name="line.2222"></a>
+<span class="sourceLineNo">2223</span>        }<a name="line.2223"></a>
+<span class="sourceLineNo">2224</span>      }<a name="line.2224"></a>
+<span class="sourceLineNo">2225</span>      return true;<a name="line.2225"></a>
+<span class="sourceLineNo">2226</span>    }<a name="line.2226"></a>
+<span class="sourceLineNo">2227</span><a name="line.2227"></a>
+<span class="sourceLineNo">2228</span>    ReportRegionStateTransitionRequest.Builder builder =<a name="line.2228"></a>
+<span class="sourceLineNo">2229</span>      ReportRegionStateTransitionRequest.newBuilder();<a name="line.2229"></a>
+<span class="sourceLineNo">2230</span>    builder.setServer(ProtobufUtil.toServerName(serverName));<a name="line.2230"></a>
+<span class="sourceLineNo">2231</span>    RegionStateTransition.Builder transition = builder.addTransitionBuilder();<a name="line.2231"></a>
+<span class="sourceLineNo">2232</span>    transition.setTransitionCode(code);<a name="line.2232"></a>
+<span class="sourceLineNo">2233</span>    if (code == TransitionCode.OPENED &amp;&amp; openSeqNum &gt;= 0) {<a name="line.2233"></a>
+<span class="sourceLineNo">2234</span>      transition.setOpenSeqNum(openSeqNum);<a name="line.2234"></a>
+<span class="sourceLineNo">2235</span>    }<a name="line.2235"></a>
+<span class="sourceLineNo">2236</span>    for (RegionInfo hri: hris) {<a name="line.2236"></a>
+<span class="sourceLineNo">2237</span>      transition.addRegionInfo(ProtobufUtil.toRegionInfo(hri));<a name="line.2237"></a>
+<span class="sourceLineNo">2238</span>    }<a name="line.2238"></a>
+<span class="sourceLineNo">2239</span>    ReportRegionStateTransitionRequest request = builder.build();<a name="line.2239"></a>
+<span class="sourceLineNo">2240</span>    int tries = 0;<a name="line.2240"></a>
+<span class="sourceLineNo">2241</span>    long pauseTime = INIT_PAUSE_TIME_MS;<a name="line.2241"></a>
+<span class="sourceLineNo">2242</span>    while (keepLooping()) {<a name="line.2242"></a>
+<span class="sourceLineNo">2243</span>      RegionServerStatusService.BlockingInterface rss = rssStub;<a name="line.2243"></a>
+<span class="sourceLineNo">2244</span>      try {<a name="line.2244"></a>
+<span class="sourceLineNo">2245</span>        if (rss == null) {<a name="line.2245"></a>
+<span class="sourceLineNo">2246</span>          createRegionServerStatusStub();<a name="line.2246"></a>
+<span class="sourceLineNo">2247</span>          continue;<a name="line.2247"></a>
+<span class="sourceLineNo">2248</span>        }<a name="line.2248"></a>
+<span class="sourceLineNo">2249</span>        ReportRegionStateTransitionResponse response =<a name="line.2249"></a>
+<span class="sourceLineNo">2250</span>          rss.reportRegionStateTransition(null, request);<a name="line.2250"></a>
+<span class="sourceLineNo">2251</span>        if (response.hasErrorMessage()) {<a name="line.2251"></a>
+<span class="sourceLineNo">2252</span>          LOG.info("TRANSITION FAILED " + request + ": " + response.getErrorMessage());<a name="line.2252"></a>
+<span class="sourceLineNo">2253</span>          // NOTE: Return mid-method!!!<a name="line.2253"></a>
+<span class="sourceLineNo">2254</span>          return false;<a name="line.2254"></a>
+<span class="sourceLineNo">2255</span>        }<a name="line.2255"></a>
+<span class="sourceLineNo">2256</span>        // Log if we had to retry else don't log unless TRACE. We want to<a name="line.2256"></a>
+<span class="sourceLineNo">2257</span>        // know if were successful after an attempt showed in logs as failed.<a name="line.2257"></a>
+<span class="sourceLineNo">2258</span>        if (tries &gt; 0 || LOG.isTraceEnabled()) {<a name="line.2258"></a>
+<span class="sourceLineNo">2259</span>          LOG.info("TRANSITION REPORTED " + request);<a name="line.2259"></a>
+<span class="sourceLineNo">2260</span>        }<a name="line.2260"></a>
+<span class="sourceLineNo">2261</span>        // NOTE: Return mid-method!!!<a name="line.2261"></a>
+<span class="sourceLineNo">2262</span>        return true;<a name="line.2262"></a>
+<span class="sourceLineNo">2263</span>      } catch (ServiceException se) {<a name="line.2263"></a>
+<span class="sourceLineNo">2264</span>        IOException ioe = ProtobufUtil.getRemoteException(se);<a name="line.2264"></a>
+<span class="sourceLineNo">2265</span>        boolean pause = ioe instanceof ServerNotRunningYetException ||<a name="line.2265"></a>
+<span class="sourceLineNo">2266</span>            ioe instanceof PleaseHoldException;<a name="line.2266"></a>
+<span class="sourceLineNo">2267</span>        if (pause) {<a name="line.2267"></a>
+<span class="sourceLineNo">2268</span>          // Do backoff else we flood the Master with requests.<a name="line.2268"></a>
+<span class="sourceLineNo">2269</span>          pauseTime = ConnectionUtils.getPauseTime(INIT_PAUSE_TIME_MS, tries);<a name="line.2269"></a>
+<span class="sourceLineNo">2270</span>        } else {<a name="line.2270"></a>
+<span class="sourceLineNo">2271</span>          pauseTime = INIT_PAUSE_TIME_MS; // Reset.<a name="line.2271"></a>
 <span class="sourceLineNo">2272</span>        }<a name="line.2272"></a>
-<span class="sourceLineNo">2273</span>        // Log if we had to retry else don't log unless TRACE. We want to<a name="line.2273"></a>
-<span class="sourceLineNo">2274</span>        // know if were successful after an attempt showed in logs as failed.<a name="line.2274"></a>
-<span class="sourceLineNo">2275</span>        if (tries &gt; 0 || LOG.isTraceEnabled()) {<a name="line.2275"></a>
-<span class="sourceLineNo">2276</span>          LOG.info("TRANSITION REPORTED " + request);<a name="line.2276"></a>
-<span class="sourceLineNo">2277</span>        }<a name="line.2277"></a>
-<span class="sourceLineNo">2278</span>        // NOTE: Return mid-method!!!<a name="line.2278"></a>
-<span class="sourceLineNo">2279</span>        return true;<a name="line.2279"></a>
-<span class="sourceLineNo">2280</span>      } catch (ServiceException se) {<a name="line.2280"></a>
-<span class="sourceLineNo">2281</span>        IOException ioe = ProtobufUtil.getRemoteException(se);<a name="line.2281"></a>
-<span class="sourceLineNo">2282</span>        boolean pause = ioe instanceof ServerNotRunningYetException ||<a name="line.2282"></a>
-<span class="sourceLineNo">2283</span>            ioe instanceof PleaseHoldException;<a name="line.2283"></a>
-<span class="sourceLineNo">2284</span>        if (pause) {<a name="line.2284"></a>
-<span class="sourceLineNo">2285</span>          // Do backoff else we flood the Master with requests.<a name="line.2285"></a>
-<span class="sourceLineNo">2286</span>          pauseTime = ConnectionUtils.getPauseTime(INIT_PAUSE_TIME_MS, tries);<a name="line.2286"></a>
-<span class="sourceLineNo">2287</span>        } else {<a name="line.2287"></a>
-<span class="sourceLineNo">2288</span>          pauseTime = INIT_PAUSE_TIME_MS; // Reset.<a name="line.2288"></a>
-<span class="sourceLineNo">2289</span>        }<a name="line.2289"></a>
-<span class="sourceLineNo">2290</span>        LOG.info("Failed report transition " +<a name="line.2290"></a>
-<span class="sourceLineNo">2291</span>          TextFormat.shortDebugString(request) + "; retry (#" + tries + ")" +<a name="line.2291"></a>
-<span class="sourceLineNo">2292</span>            (pause?<a name="line.2292"></a>
-<span class="sourceLineNo">2293</span>                " after " + pauseTime + "ms delay (Master is coming online...).":<a name="line.2293"></a>
-<span class="sourceLineNo">2294</span>                " immediately."),<a name="line.2294"></a>
-<span class="sourceLineNo">2295</span>            ioe);<a name="line.2295"></a>
-<span class="sourceLineNo">2296</span>        if (pause) Threads.sleep(pauseTime);<a name="line.2296"></a>
-<span class="sourceLineNo">2297</span>        tries++;<a name="line.2297"></a>
-<span class="sourceLineNo">2298</span>        if (rssStub == rss) {<a name="line.2298"></a>
-<span class="sourceLineNo">2299</span>          rssStub = null;<a name="line.2299"></a>
-<span class="sourceLineNo">2300</span>        }<a name="line.2300"></a>
-<span class="sourceLineNo">2301</span>      }<a name="line.2301"></a>
-<span class="sourceLineNo">2302</span>    }<a name="line.2302"></a>
-<span class="sourceLineNo">2303</span>    LOG.info("TRANSITION NOT REPORTED " + request);<a name="line.2303"></a>
-<span class="sourceLineNo">2304</span>    return false;<a name="line.2304"></a>
-<span class="sourceLineNo">2305</span>  }<a name="line.2305"></a>
-<span class="sourceLineNo">2306</span><a name="line.2306"></a>
-<span class="sourceLineNo">2307</span>  /**<a name="line.2307"></a>
-<span class="sourceLineNo">2308</span>   * Trigger a flush in the primary region replica if this region is a secondary replica. Does not<a name="line.2308"></a>
-<span class="sourceLineNo">2309</span>   * block this thread. See RegionReplicaFlushHandler for details.<a name="line.2309"></a>
-<span class="sourceLineNo">2310</span>   */<a name="line.2310"></a>
-<span class="sourceLineNo">2311</span>  void triggerFlushInPrimaryRegion(final HRegion region) {<a name="line.2311"></a>
-<span class="sourceLineNo">2312</span>    if (ServerRegionReplicaUtil.isDefaultReplica(region.getRegionInfo())) {<a name="line.2312"></a>
-<span class="sourceLineNo">2313</span>      return;<a name="line.2313"></a>
-<span class="sourceLineNo">2314</span>    }<a name="line.2314"></a>
-<span class="sourceLineNo">2315</span>    if (!ServerRegionReplicaUtil.isRegionReplicaReplicationEnabled(region.conf) ||<a name="line.2315"></a>
-<span class="sourceLineNo">2316</span>        !ServerRegionReplicaUtil.isRegionReplicaWaitForPrimaryFlushEnabled(<a name="line.2316"></a>
-<span class="sourceLineNo">2317</span>          region.conf)) {<a name="line.2317"></a>
-<span class="sourceLineNo">2318</span>      region.setReadsEnabled(true);<a name="line.2318"></a>
-<span class="sourceLineNo">2319</span>      return;<a name="line.2319"></a>
-<span class="sourceLineNo">2320</span>    }<a name="line.2320"></a>
-<span class="sourceLineNo">2321</span><a name="line.2321"></a>
-<span class="sourceLineNo">2322</span>    region.setReadsEnabled(false); // disable reads before marking the region as opened.<a name="line.2322"></a>
-<span class="sourceLineNo">2323</span>    // RegionReplicaFlushHandler might reset this.<a name="line.2323"></a>
-<span class="sourceLineNo">2324</span><a name="line.2324"></a>
-<span class="sourceLineNo">2325</span>    // submit it to be handled by one of the handlers so that we do not block OpenRegionHandler<a name="line.2325"></a>
-<span class="sourceLineNo">2326</span>    this.service.submit(<a name="line.2326"></a>
-<span class="sourceLineNo">2327</span>      new RegionReplicaFlushHandler(this, clusterConnection,<a name="line.2327"></a>
-<span class="sourceLineNo">2328</span>        rpcRetryingCallerFactory, rpcControllerFactory, operationTimeout, region));<a name="line.2328"></a>
-<span class="sourceLineNo">2329</span>  }<a name="line.2329"></a>
-<span class="sourceLineNo">2330</span><a name="line.2330"></a>
-<span class="sourceLineNo">2331</span>  @Override<a name="line.2331"></a>
-<span class="sourceLineNo">2332</span>  public RpcServerInterface getRpcServer() {<a name="line.2332"></a>
-<span class="sourceLineNo">2333</span>    return rpcServices.rpcServer;<a name="line.2333"></a>
-<span class="sourceLineNo">2334</span>  }<a name="line.2334"></a>
-<span class="sourceLineNo">2335</span><a name="line.2335"></a>
-<span class="sourceLineNo">2336</span>  @VisibleForTesting<a name="line.2336"></a>
-<span class="sourceLineNo">2337</span>  public RSRpcServices getRSRpcServices() {<a name="line.2337"></a>
-<span class="sourceLineNo">2338</span>    return rpcServices;<a name="line.2338"></a>
-<span class="sourceLineNo">2339</span>  }<a name="line.2339"></a>
-<span class="sourceLineNo">2340</span><a name="line.2340"></a>
-<span class="sourceLineNo">2341</span>  /**<a name="line.2341"></a>
-<span class="sourceLineNo">2342</span>   * Cause the server to exit without closing the regions it is serving, the log<a name="line.2342"></a>
-<span class="sourceLineNo">2343</span>   * it is using and without notifying the master. Used unit testing and on<a name="line.2343"></a>
-<span class="sourceLineNo">2344</span>   * catastrophic events such as HDFS is yanked out from under hbase or we OOME.<a name="line.2344"></a>
-<span class="sourceLineNo">2345</span>   *<a name="line.2345"></a>
-<span class="sourceLineNo">2346</span>   * @param reason<a name="line.2346"></a>
-<span class="sourceLineNo">2347</span>   *          the reason we are aborting<a name="line.2347"></a>
-<span class="sourceLineNo">2348</span>   * @param cause<a name="line.2348"></a>
-<span class="sourceLineNo">2349</span>   *          the exception that caused the abort, or null<a name="line.2349"></a>
-<span class="sourceLineNo">2350</span>   */<a name="line.2350"></a>
-<span class="sourceLineNo">2351</span>  @Override<a name="line.2351"></a>
-<span class="sourceLineNo">2352</span>  public void abort(String reason, Throwable cause) {<a name="line.2352"></a>
-<span class="sourceLineNo">2353</span>    String msg = "***** ABORTING region server " + this + ": " + reason + " *****";<a name="line.2353"></a>
-<span class="sourceLineNo">2354</span>    if (cause != null) {<a name="line.2354"></a>
-<span class="sourceLineNo">2355</span>      LOG.fatal(msg, cause);<a name="line.2355"></a>
-<span class="sourceLineNo">2356</span>    } else {<a name="line.2356"></a>
-<span class="sourceLineNo">2357</span>      LOG.fatal(msg);<a name="line.2357"></a>
-<span class="sourceLineNo">2358</span>    }<a name="line.2358"></a>
-<span class="sourceLineNo">2359</span>    this.abortRequested = true;<a name="line.2359"></a>
-<span class="sourceLineNo">2360</span>    // HBASE-4014: show list of coprocessors that were loaded to help debug<a name="line.2360"></a>
-<span class="sourceLineNo">2361</span>    // regionserver crashes.Note that we're implicitly using<a name="line.2361"></a>
-<span class="sourceLineNo">2362</span>    // java.util.HashSet's toString() method to print the coprocessor names.<a name="line.2362"></a>
-<span class="sourceLineNo">2363</span>    LOG.fatal("RegionServer abort: loaded coprocessors are: " +<a name="line.2363"></a>
-<span class="sourceLineNo">2364</span>        CoprocessorHost.getLoadedCoprocessors());<a name="line.2364"></a>
-<span class="sourceLineNo">2365</span>    // Try and dump metrics if abort -- might give clue as to how fatal came about....<a name="line.2365"></a>
-<span class="sourceLineNo">2366</span>    try {<a name="line.2366"></a>
-<span class="sourceLineNo">2367</span>      LOG.info("Dump of metrics as JSON on abort: " + JSONBean.dumpRegionServerMetrics());<a name="line.2367"></a>
-<span class="sourceLineNo">2368</span>    } catch (MalformedObjectNameException | IOException e) {<a name="line.2368"></a>
-<span class="sourceLineNo">2369</span>      LOG.warn("Failed dumping metrics", e);<a name="line.2369"></a>
-<span class="sourceLineNo">2370</span>    }<a name="line.2370"></a>
-<span class="sourceLineNo">2371</span><a name="line.2371"></a>
-<span class="sourceLineNo">2372</span>    // Do our best to report our abort to the master, but this may not work<a name="line.2372"></a>
-<span class="sourceLineNo">2373</span>    try {<a name="line.2373"></a>
-<span class="sourceLineNo">2374</span>      if (cause != null) {<a name="line.2374"></a>
-<span class="sourceLineNo">2375</span>        msg += "\nCause:\n" + StringUtils.stringifyException(cause);<a name="line.2375"></a>
-<span class="sourceLineNo">2376</span>      }<a name="line.2376"></a>
-<span class="sourceLineNo">2377</span>      // Report to the master but only if we have already registered with the master.<a name="line.2377"></a>
-<span class="sourceLineNo">2378</span>      if (rssStub != null &amp;&amp; this.serverName != null) {<a name="line.2378"></a>
-<span class="sourceLineNo">2379</span>        ReportRSFatalErrorRequest.Builder builder =<a name="line.2379"></a>
-<span class="sourceLineNo">2380</span>          ReportRSFatalErrorRequest.newBuilder();<a name="line.2380"></a>
-<span class="sourceLineNo">2381</span>        ServerName sn =<a name="line.2381"></a>
-<span class="sourceLineNo">2382</span>          ServerName.parseVersionedServerName(this.serverName.getVersionedBytes());<a name="line.2382"></a>
-<span class="sourceLineNo">2383</span>        builder.setServer(ProtobufUtil.toServerName(sn));<a name="line.2383"></a>
-<span class="sourceLineNo">2384</span>        builder.setErrorMessage(msg);<a name="line.2384"></a>
-<span class="sourceLineNo">2385</span>        rssStub.reportRSFatalError(null, builder.build());<a name="line.2385"></a>
-<span class="sourceLineNo">2386</span>      }<a name="line.2386"></a>
-<span class="sourceLineNo">2387</span>    } catch (Throwable t) {<a name="line.2387"></a>
-<span class="sourceLineNo">2388</span>      LOG.warn("Unable to report fatal error to master", t);<a name="line.2388"></a>
-<span class="sourceLineNo">2389</span>    }<a name="line.2389"></a>
-<span class="sourceLineNo">2390</span>    // shutdown should be run as the internal user<a name="line.2390"></a>
-<span class="sourceLineNo">2391</span>    stop(reason, true, null);<a name="line.2391"></a>
-<span class="sourceLineNo">2392</span>  }<a name="line.2392"></a>
-<span class="sourceLineNo">2393</span><a name="line.2393"></a>
-<span class="sourceLineNo">2394</span>  /**<a name="line.2394"></a>
-<span class="sourceLineNo">2395</span>   * @see HRegionServer#abort(String, Throwable)<a name="line.2395"></a>
-<span class="sourceLineNo">2396</span>   */<a name="line.2396"></a>
-<span class="sourceLineNo">2397</span>  public void abort(String reason) {<a name="line.2397"></a>
-<span class="sourceLineNo">2398</span>    abort(reason, null);<a name="line.2398"></a>
-<span class="sourceLineNo">2399</span>  }<a name="line.2399"></a>
-<span class="sourceLineNo">2400</span><a name="line.2400"></a>
-<span class="sourceLineNo">2401</span>  @Override<a name="line.2401"></a>
-<span class="sourceLineNo">2402</span>  public boolean isAborted() {<a name="line.2402"></a>
-<span class="sourceLineNo">2403</span>    return this.abortRequested;<a name="line.2403"></a>
+<span class="sourceLineNo">2273</span>        LOG.info("Failed report transition " +<a name="line.2273"></a>
+<span class="sourceLineNo">2274</span>          TextFormat.shortDebugString(request) + "; retry (#" + tries + ")" +<a name="line.2274"></a>
+<span class="sourceLineNo">2275</span>            (pause?<a name="line.2275"></a>
+<span class="sourceLineNo">2276</span>                " after " + pauseTime + "ms delay (Master is coming online...).":<a name="line.2276"></a>
+<span class="sourceLineNo">2277</span>                " immediately."),<a name="line.2277"></a>
+<span class="sourceLineNo">2278</span>            ioe);<a name="line.2278"></a>
+<span class="sourceLineNo">2279</span>        if (pause) Threads.sleep(pauseTime);<a name="line.2279"></a>
+<span class="sourceLineNo">2280</span>        tries++;<a name="line.2280"></a>
+<span class="sourceLineNo">2281</span>        if (rssStub == rss) {<a name="line.2281"></a>
+<span class="sourceLineNo">2282</span>          rssStub = null;<a name="line.2282"></a>
+<span class="sourceLineNo">2283</span>        }<a name="line.2283"></a>
+<span class="sourceLineNo">2284</span>      }<a name="line.2284"></a>
+<span class="sourceLineNo">2285</span>    }<a name="line.2285"></a>
+<span class="sourceLineNo">2286</span>    LOG.info("TRANSITION NOT REPORTED " + request);<a name="line.2286"></a>
+<span class="sourceLineNo">2287</span>    return false;<a name="line.2287"></a>
+<span class="sourceLineNo">2288</span>  }<a name="line.2288"></a>
+<span class="sourceLineNo">2289</span><a name="line.2289"></a>
+<span class="sourceLineNo">2290</span>  /**<a name="line.2290"></a>
+<span class="sourceLineNo">2291</span>   * Trigger a flush in the primary region replica if this region is a secondary replica. Does not<a name="line.2291"></a>
+<span class="sourceLineNo">2292</span>   * block this thread. See RegionReplicaFlushHandler for details.<a name="line.2292"></a>
+<span class="sourceLineNo">2293</span>   */<a name="line.2293"></a>
+<span class="sourceLineNo">2294</span>  void triggerFlushInPrimaryRegion(final HRegion region) {<a name="line.2294"></a>
+<span class="sourceLineNo">2295</span>    if (ServerRegionReplicaUtil.isDefaultReplica(region.getRegionInfo())) {<a name="line.2295"></a>
+<span class="sourceLineNo">2296</span>      return;<a name="line.2296"></a>
+<span class="sourceLineNo">2297</span>    }<a name="line.2297"></a>
+<span class="sourceLineNo">2298</span>    if (!ServerRegionReplicaUtil.isRegionReplicaReplicationEnabled(region.conf) ||<a name="line.2298"></a>
+<span class="sourceLineNo">2299</span>        !ServerRegionReplicaUtil.isRegionReplicaWaitForPrimaryFlushEnabled(<a name="line.2299"></a>
+<span class="sourceLineNo">2300</span>          region.conf)) {<a name="line.2300"></a>
+<span class="sourceLineNo">2301</span>      region.setReadsEnabled(true);<a name="line.2301"></a>
+<span class="sourceLineNo">2302</span>      return;<a name="line.2302"></a>
+<span class="sourceLineNo">2303</span>    }<a name="line.2303"></a>
+<span class="sourceLineNo">2304</span><a name="line.2304"></a>
+<span class="sourceLineNo">2305</span>    region.setReadsEnabled(false); // disable reads before marking the region as opened.<a name="line.2305"></a>
+<span class="sourceLineNo">2306</span>    // RegionReplicaFlushHandler might reset this.<a name="line.2306"></a>
+<span class="sourceLineNo">2307</span><a name="line.2307"></a>
+<span class="sourceLineNo">2308</span>    // submit it to be handled by one of the handlers so that we do not block OpenRegionHandler<a name="line.2308"></a>
+<span class="sourceLineNo">2309</span>    this.service.submit(<a name="line.2309"></a>
+<span class="sourceLineNo">2310</span>      new RegionReplicaFlushHandler(this, clusterConnection,<a name="line.2310"></a>
+<span class="sourceLineNo">2311</span>        rpcRetryingCallerFactory, rpcControllerFactory, operationTimeout, region));<a name="line.2311"></a>
+<span class="sourceLineNo">2312</span>  }<a name="line.2312"></a>
+<span class="sourceLineNo">2313</span><a name="line.2313"></a>
+<span class="sourceLineNo">2314</span>  @Override<a name="line.2314"></a>
+<span class="sourceLineNo">2315</span>  public RpcServerInterface getRpcServer() {<a name="line.2315"></a>
+<span class="sourceLineNo">2316</span>    return rpcServices.rpcServer;<a name="line.2316"></a>
+<span class="sourceLineNo">2317</span>  }<a name="line.2317"></a>
+<span class="sourceLineNo">2318</span><a name="line.2318"></a>
+<span class="sourceLineNo">2319</span>  @VisibleForTesting<a name="line.2319"></a>
+<span class="sourceLineNo">2320</span>  public RSRpcServices getRSRpcServices() {<a name="line.2320"></a>
+<span class="sourceLineNo">2321</span>    return rpcServices;<a name="line.2321"></a>
+<span class="sourceLineNo">2322</span>  }<a name="line.2322"></a>
+<span class="sourceLineNo">2323</span><a name="line.2323"></a>
+<span class="sourceLineNo">2324</span>  /**<a name="line.2324"></a>
+<span class="sourceLineNo">2325</span>   * Cause the server to exit without closing the regions it is serving, the log<a name="line.2325"></a>
+<span class="sourceLineNo">2326</span>   * it is using and without notifying the master. Used unit testing and on<a name="line.2326"></a>
+<span class="sourceLineNo">2327</span>   * catastrophic events such as HDFS is yanked out from under hbase or we OOME.<a name="line.2327"></a>
+<span class="sourceLineNo">2328</span>   *<a name="line.2328"></a>
+<span class="sourceLineNo">2329</span>   * @param reason<a name="line.2329"></a>
+<span class="sourceLineNo">2330</span>   *          the reason we are aborting<a name="line.2330"></a>
+<span class="sourceLineNo">2331</span>   * @param cause<a name="line.2331"></a>
+<span class="sourceLineNo">2332</span>   *          the exception that caused the abort, or null<a name="line.2332"></a>
+<span class="sourceLineNo">2333</span>   */<a name="line.2333"></a>
+<span class="sourceLineNo">2334</span>  @Override<a name="line.2334"></a>
+<span class="sourceLineNo">2335</span>  public void abort(String reason, Throwable cause) {<a name="line.2335"></a>
+<span class="sourceLineNo">2336</span>    String msg = "***** ABORTING region server " + this + ": " + reason + " *****";<a name="line.2336"></a>
+<span class="sourceLineNo">2337</span>    if (cause != null) {<a name="line.2337"></a>
+<span class="sourceLineNo">2338</span>      LOG.fatal(msg, cause);<a name="line.2338"></a>
+<span class="sourceLineNo">2339</span>    } else {<a name="line.2339"></a>
+<span class="sourceLineNo">2340</span>      LOG.fatal(msg);<a name="line.2340"></a>
+<span class="sourceLineNo">2341</span>    }<a name="line.2341"></a>
+<span class="sourceLineNo">2342</span>    this.abortRequested = true;<a name="line.2342"></a>
+<span class="sourceLineNo">2343</span>    // HBASE-4014: show list of coprocessors that were loaded to help debug<a name="line.2343"></a>
+<span class="sourceLineNo">2344</span>    // regionserver crashes.Note that we're implicitly using<a name="line.2344"></a>
+<span class="sourceLineNo">2345</span>    // java.util.HashSet's toString() method to print the coprocessor names.<a name="line.2345"></a>
+<span class="sourceLineNo">2346</span>    LOG.fatal("RegionServer abort: loaded coprocessors are: " +<a name="line.2346"></a>
+<span class="sourceLineNo">2347</span>        CoprocessorHost.getLoadedCoprocessors());<a name="line.2347"></a>
+<span class="sourceLineNo">2348</span>    // Try and dump metrics if abort -- might give clue as to how fatal came about....<a name="line.2348"></a>
+<span class="sourceLineNo">2349</span>    try {<a name="line.2349"></a>
+<span class="sourceLineNo">2350</span>      LOG.info("Dump of metrics as JSON on abort: " + JSONBean.dumpRegionServerMetrics());<a name="line.2350"></a>
+<span class="sourceLineNo">2351</span>    } catch (MalformedObjectNameException | IOException e) {<a name="line.2351"></a>
+<span class="sourceLineNo">2352</span>      LOG.warn("Failed dumping metrics", e);<a name="line.2352"></a>
+<span class="sourceLineNo">2353</span>    }<a name="line.2353"></a>
+<span class="sourceLineNo">2354</span><a name="line.2354"></a>
+<span class="sourceLineNo">2355</span>    // Do our best to report our abort to the master, but this may not work<a name="line.2355"></a>
+<span class="sourceLineNo">2356</span>    try {<a name="line.2356"></a>
+<span class="sourceLineNo">2357</span>      if (cause != null) {<a name="line.2357"></a>
+<span class="sourceLineNo">2358</span>        msg += "\nCause:\n" + StringUtils.stringifyException(cause);<a name="line.2358"></a>
+<span class="sourceLineNo">2359</span>      }<a name="line.2359"></a>
+<span class="sourceLineNo">2360</span>      // Report to the master but only if we have already registered with the master.<a name="line.2360"></a>
+<span class="sourceLineNo">2361</span>      if (rssStub != null &amp;&amp; this.serverName != null) {<a name="line.2361"></a>
+<span class="sourceLineNo">2362</span>        ReportRSFatalErrorRequest.Builder builder =<a name="line.2362"></a>
+<span class="sourceLineNo">2363</span>          ReportRSFatalErrorRequest.newBuilder();<a name="line.2363"></a>
+<span class="sourceLineNo">2364</span>        ServerName sn =<a name="line.2364"></a>
+<span class="sourceLineNo">2365</span>          ServerName.parseVersionedServerName(this.serverName.getVersionedBytes());<a name="line.2365"></a>
+<span class="sourceLineNo">2366</span>        builder.setServer(ProtobufUtil.toServerName(sn));<a name="line.2366"></a>
+<span class="sourceLineNo">2367</span>        builder.setErrorMessage(msg);<a name="line.2367"></a>
+<span class="sourceLineNo">2368</span>        rssStub.reportRSFatalError(null, builder.build());<a name="line.2368"></a>
+<span class="sourceLineNo">2369</span>      }<a name="line.2369"></a>
+<span class="sourceLineNo">2370</span>    } catch (Throwable t) {<a name="line.2370"></a>
+<span class="sourceLineNo">2371</span>      LOG.warn("Unable to report fatal error to master", t);<a name="line.2371"></a>
+<span class="sourceLineNo">2372</span>    }<a name="line.2372"></a>
+<span class="sourceLineNo">2373</span>    // shutdown should be run as the internal user<a name="line.2373"></a>
+<span class="sourceLineNo">2374</span>    stop(reason, true, null);<a name="line.2374"></a>
+<span class="sourceLineNo">2375</span>  }<a name="line.2375"></a>
+<span class="sourceLineNo">2376</span><a name="line.2376"></a>
+<span class="sourceLineNo">2377</span>  /**<a name="line.2377"></a>
+<span class="sourceLineNo">2378</span>   * @see HRegionServer#abort(String, Throwable)<a name="line.2378"></a>
+<span class="sourceLineNo">2379</span>   */<a name="line.2379"></a>
+<span class="sourceLineNo">2380</span>  public void abort(String reason) {<a name="line.2380"></a>
+<span class="sourceLineNo">2381</span>    abort(reason, null);<a name="line.2381"></a>
+<span class="sourceLineNo">2382</span>  }<a name="line.2382"></a>
+<span class="sourceLineNo">2383</span><a name="line.2383"></a>
+<span class="sourceLineNo">2384</span>  @Override<a name="line.2384"></a>
+<span class="sourceLineNo">2385</span>  public boolean isAborted() {<a name="line.2385"></a>
+<span class="sourceLineNo">2386</span>    return this.abortRequested;<a name="line.2386"></a>
+<span class="sourceLineNo">2387</span>  }<a name="line.2387"></a>
+<span class="sourceLineNo">2388</span><a name="line.2388"></a>
+<span class="sourceLineNo">2389</span>  /*<a name="line.2389"></a>
+<span class="sourceLineNo">2390</span>   * Simulate a kill -9 of this server. Exits w/o closing regions or cleaninup<a name="line.2390"></a>
+<span class="sourceLineNo">2391</span>   * logs but it does close socket in case want to bring up server on old<a name="line.2391"></a>
+<span class="sourceLineNo">2392</span>   * hostname+port immediately.<a name="line.2392"></a>
+<span class="sourceLineNo">2393</span>   */<a name="line.2393"></a>
+<span class="sourceLineNo">2394</span>  @VisibleForTesting<a name="line.2394"></a>
+<span class="sourceLineNo">2395</span>  protected void kill() {<a name="line.2395"></a>
+<span class="sourceLineNo">2396</span>    this.killed = true;<a name="line.2396"></a>
+<span class="sourceLineNo">2397</span>    abort("Simulated kill");<a name="line.2397"></a>
+<span class="sourceLineNo">2398</span>  }<a name="line.2398"></a>
+<span class="sourceLineNo">2399</span><a name="line.2399"></a>
+<span class="sourceLineNo">2400</span>  /**<a name="line.2400"></a>
+<span class="sourceLineNo">2401</span>   * Called on stop/abort before closing the cluster connection and meta locator.<a name="line.2401"></a>
+<span class="sourceLineNo">2402</span>   */<a name="line.2402"></a>
+<span class="sourceLineNo">2403</span>  protected void sendShutdownInterrupt() {<a name="line.2403"></a>
 <span class="sourceLineNo">2404</span>  }<a name="line.2404"></a>
 <span class="sourceLineNo">2405</span><a name="line.2405"></a>
-<span class="sourceLineNo">2406</span>  /*<a name="line.2406"></a>
-<span class="sourceLineNo">2407</span>   * Simulate a kill -9 of this server. Exits w/o closing regions or cleaninup<a name="line.2407"></a>
-<span class="sourceLineNo">2408</span>   * logs but it does close socket in case want to bring up server on old<a name="line.2408"></a>
-<span class="sourceLineNo">2409</span>   * hostname+port immediately.<a name="line.2409"></a>
-<span class="sourceLineNo">2410</span>   */<a name="line.2410"></a>
-<span class="sourceLineNo">2411</span>  @VisibleForTesting<a name="line.2411"></a>
-<span class="sourceLineNo">2412</span>  protected void kill() {<a name="line.2412"></a>
-<span class="sourceLineNo">2413</span>    this.killed = true;<a name="line.2413"></a>
-<span class="sourceLineNo">2414</span>    abort("Simulated kill");<a name="line.2414"></a>
-<span class="sourceLineNo">2415</span>  }<a name="line.2415"></a>
-<span class="sourceLineNo">2416</span><a name="line.2416"></a>
-<span class="sourceLineNo">2417</span>  /**<a name="line.2417"></a>
-<span class="sourceLineNo">2418</span>   * Called on stop/abort before closing the cluster connection and meta locator.<a name="line.2418"></a>
-<span class="sourceLineNo">2419</span>   */<a name="line.2419"></a>
-<span class="sourceLineNo">2420</span>  protected void sendShutdownInterrupt() {<a name="line.2420"></a>
-<span class="sourceLineNo">2421</span>  }<a name="line.2421"></a>
-<span class="sourceLineNo">2422</span><a name="line.2422"></a>
-<span class="sourceLineNo">2423</span>  /**<a name="line.2423"></a>
-<span class="sourceLineNo">2424</span>   * Wait on all threads to finish. Presumption is that all closes and stops<a name="line.2424"></a>
-<span class="sourceLineNo">2425</span>   * have already been called.<a name="line.2425"></a>
-<span class="sourceLineNo">2426</span>   */<a name="line.2426"></a>
-<span class="sourceLineNo">2427</span>  protected void stopServiceThreads() {<a name="line.2427"></a>
-<span class="sourceLineNo">2428</span>    // clean up the scheduled chores<a name="line.2428"></a>
-<span class="sourceLineNo">2429</span>    if (this.choreService != null) choreService.shutdown();<a name="line.2429"></a>
-<span class="sourceLineNo">2430</span>    if (this.nonceManagerChore != null) nonceManagerChore.cancel(true);<a name="line.2430"></a>
-<span class="sourceLineNo">2431</span>    if (this.compactionChecker != null) compactionChecker.cancel(true);<a name="line.2431"></a>
-<span class="sourceLineNo">2432</span>    if (this.periodicFlusher != null) periodicFlusher.cancel(true);<a name="line.2432"></a>
-<span class="sourceLineNo">2433</span>    if (this.healthCheckChore != null) healthCheckChore.cancel(true);<a name="line.2433"></a>
-<span class="sourceLineNo">2434</span>    if (this.storefileRefresher != null) storefileRefresher.cancel(true);<a name="line.2434"></a>
-<span class="sourceLineNo">2435</span>    if (this.movedRegionsCleaner != null) movedRegionsCleaner.cancel(true);<a name="line.2435"></a>
-<span class="sourceLineNo">2436</span>    if (this.fsUtilizationChore != null) fsUtilizationChore.cancel(true);<a name="line.2436"></a>
-<span class="sourceLineNo">2437</span><a name="line.2437"></a>
-<span class="sourceLineNo">2438</span>    if (this.cacheFlusher != null) {<a name="line.2438"></a>
-<span class="sourceLineNo">2439</span>      this.cacheFlusher.join();<a name="line.2439"></a>
-<span class="sourceLineNo">2440</span>    }<a name="line.2440"></a>
-<span class="sourceLineNo">2441</span><a name="line.2441"></a>
-<span class="sourceLineNo">2442</span>    if (this.spanReceiverHost != null) {<a name="line.2442"></a>
-<span class="sourceLineNo">2443</span>      this.spanReceiverHost.closeReceivers();<a name="line.2443"></a>
-<span class="sourceLineNo">2444</span>    }<a name="line.2444"></a>
-<span class="sourceLineNo">2445</span>    if (this.walRoller != null) {<a name="line.2445"></a>
-<span class="sourceLineNo">2446</span>      this.walRoller.close();<a name="line.2446"></a>
-<span class="sourceLineNo">2447</span>    }<a name="line.2447"></a>
-<span class="sourceLineNo">2448</span>    if (this.compactSplitThread != null) {<a name="line.2448"></a>
-<span class="sourceLineNo">2449</span>      this.compactSplitThread.join();<a name="line.2449"></a>
-<span class="sourceLineNo">2450</span>    }<a name="line.2450"></a>
-<span class="sourceLineNo">2451</span>    if (this.service != null) this.service.shutdown();<a name="line.2451"></a>
-<span class="sourceLineNo">2452</span>    if (this.replicationSourceHandler != null &amp;&amp;<a name="line.2452"></a>
-<span class="sourceLineNo">2453</span>        this.replicationSourceHandler == this.replicationSinkHandler) {<a name="line.2453"></a>
-<span class="sourceLineNo">2454</span>      this.replicationSourceHandler.stopReplicationService();<a name="line.2454"></a>
-<span class="sourceLineNo">2455</span>    } else {<a name="line.2455"></a>
-<span class="sourceLineNo">2456</span>      if (this.replicationSourceHandler != null) {<a name="line.2456"></a>
-<span class="sourceLineNo">2457</span>        this.replicationSourceHandler.stopReplicationService();<a name="line.2457"></a>
-<span class="sourceLineNo">2458</span>      }<a name="line.2458"></a>
-<span class="sourceLineNo">2459</span>      if (this.replicationSinkHandler != null) {<a name="line.2459"></a>
-<span class="sourceLineNo">2460</span>        this.replicationSinkHandler.stopReplicationService();<a name="line.2460"></a>
-<span class="sourceLineNo">2461</span>      }<a name="line.2461"></a>
-<span class="sourceLineNo">2462</span>    }<a name="line.2462"></a>
+<span class="sourceLineNo">2406</span>  /**<a name="line.2406"></a>
+<span class="sourceLineNo">2407</span>   * Wait on all threads to finish. Presumption is that all closes and stops<a name="line.2407"></a>
+<span class="sourceLineNo">2408</span>   * have already been called.<a name="line.2408"></a>
+<span class="sourceLineNo">2409</span>   */<a name="line.2409"></a>
+<span class="sourceLineNo">2410</span>  protected void stopServiceThreads() {<a name="line.2410"></a>
+<span class="sourceLineNo">2411</span>    // clean up the scheduled chores<a name="line.2411"></a>
+<span class="sourceLineNo">2412</span>    if (this.choreService != null) choreService.shutdown();<a name="line.2412"></a>
+<span class="sourceLineNo">2413</span>    if (this.nonceManagerChore != null) nonceManagerChore.cancel(true);<a name="line.2413"></a>
+<span class="sourceLineNo">2414</span>    if (this.compactionChecker != null) compactionChecker.cancel(true);<a name="line.2414"></a>
+<span class="sourceLineNo">2415</span>    if (this.periodicFlusher != null) periodicFlusher.cancel(true);<a name="line.2415"></a>
+<span class="sourceLineNo">2416</span>    if (this.healthCheckChore != null) healthCheckChore.cancel(true);<a name="line.2416"></a>
+<span class="sourceLineNo">2417</span>    if (this.storefileRefresher != null) storefileRefresher.cancel(true);<a name="line.2417"></a>
+<span class="sourceLineNo">2418</span>    if (this.movedRegionsCleaner != null) movedRegionsCleaner.cancel(true);<a name="line.2418"></a>
+<span class="sourceLineNo">2419</span>    if (this.fsUtilizationChore != null) fsUtilizationChore.cancel(true);<a name="line.2419"></a>
+<span class="sourceLineNo">2420</span><a name="line.2420"></a>
+<span class="sourceLineNo">2421</span>    if (this.cacheFlusher != null) {<a name="line.2421"></a>
+<span class="sourceLineNo">2422</span>      this.cacheFlusher.join();<a name="line.2422"></a>
+<span class="sourceLineNo">2423</span>    }<a name="line.2423"></a>
+<span class="sourceLineNo">2424</span><a name="line.2424"></a>
+<span class="sourceLineNo">2425</span>    if (this.spanReceiverHost != null) {<a name="line.2425"></a>
+<span class="sourceLineNo">2426</span>      this.spanReceiverHost.closeReceivers();<a name="line.2426"></a>
+<span class="sourceLineNo">2427</span>    }<a name="line.2427"></a>
+<span class="sourceLineNo">2428</span>    if (this.walRoller != null) {<a name="line.2428"></a>
+<span class="sourceLineNo">2429</span>      this.walRoller.close();<a name="line.2429"></a>
+<span class="sourceLineNo">2430</span>    }<a name="line.2430"></a>
+<span class="sourceLineNo">2431</span>    if (this.compactSplitThread != null) {<a name="line.2431"></a>
+<span class="sourceLineNo">2432</span>      this.compactSplitThread.join();<a name="line.2432"></a>
+<span class="sourceLineNo">2433</span>    }<a name="line.2433"></a>
+<span class="sourceLineNo">2434</span>    if (this.service != null) this.service.shutdown();<a name="line.2434"></a>
+<span class="sourceLineNo">2435</span>    if (this.replicationSourceHandler != null &amp;&amp;<a name="line.2435"></a>
+<span class="sourceLineNo">2436</span>        this.replicationSourceHandler == this.replicationSinkHandler) {<a name="line.2436"></a>
+<span class="sourceLineNo">2437</span>      this.replicationSourceHandler.stopReplicationService();<a name="line.2437"></a>
+<span class="sourceLineNo">2438</span>    } else {<a name="line.2438"></a>
+<span class="sourceLineNo">2439</span>      if (this.replicationSourceHandler != null) {<a name="line.2439"></a>
+<span class="sourceLineNo">2440</span>        this.replicationSourceHandler.stopReplicationService();<a name="line.2440"></a>
+<span class="sourceLineNo">2441</span>      }<a name="line.2441"></a>
+<span class="sourceLineNo">2442</span>      if (this.replicationSinkHandler != null) {<a name="line.2442"></a>
+<span class="sourceLineNo">2443</span>        this.replicationSinkHandler.stopReplicationService();<a name="line.2443"></a>
+<span class="sourceLineNo">2444</span>      }<a name="line.2444"></a>
+<span class="sourceLineNo">2445</span>    }<a name="line.2445"></a>
+<span class="sourceLineNo">2446</span>  }<a name="line.2446"></a>
+<span class="sourceLineNo">2447</span><a name="line.2447"></a>
+<span class="sourceLineNo">2448</span>  /**<a name="line.2448"></a>
+<span class="sourceLineNo">2449</span>   * @return Return the object that implements the replication<a name="line.2449"></a>
+<span class="sourceLineNo">2450</span>   * source service.<a name="line.2450"></a>
+<span class="sourceLineNo">2451</span>   */<a name="line.2451"></a>
+<span class="sourceLineNo">2452</span>  @VisibleForTesting<a name="line.2452"></a>
+<span class="sourceLineNo">2453</span>  public ReplicationSourceService getReplicationSourceService() {<a name="line.2453"></a>
+<span class="sourceLineNo">2454</span>    return replicationSourceHandler;<a name="line.2454"></a>
+<span class="sourceLineNo">2455</span>  }<a name="line.2455"></a>
+<span class="sourceLineNo">2456</span><a name="line.2456"></a>
+<span class="sourceLineNo">2457</span>  /**<a name="line.2457"></a>
+<span class="sourceLineNo">2458</span>   * @return Return the object that implements the replication<a name="line.2458"></a>
+<span class="sourceLineNo">2459</span>   * sink service.<a name="line.2459"></a>
+<span class="sourceLineNo">2460</span>   */<a name="line.2460"></a>
+<span class="sourceLineNo">2461</span>  ReplicationSinkService getReplicationSinkService() {<a name="line.2461"></a>
+<span class="sourceLineNo">2462</span>    return replicationSinkHandler;<a name="line.2462"></a>
 <span class="sourceLineNo">2463</span>  }<a name="line.2463"></a>
 <span class="sourceLineNo">2464</span><a name="line.2464"></a>
 <span class="sourceLineNo">2465</span>  /**<a name="line.2465"></a>
-<span class="sourceLineNo">2466</span>   * @return Return the object that implements the replication<a name="line.2466"></a>
-<span class="sourceLineNo">2467</span>   * source service.<a name="line.2467"></a>
-<span class="sourceLineNo">2468</span>   */<a name="line.2468"></a>
-<span class="sourceLineNo">2469</span>  @VisibleForTesting<a name="line.2469"></a>
-<span class="sourceLineNo">2470</span>  public ReplicationSourceService getReplicationSourceService() {<a name="line.2470"></a>
-<span class="sourceLineNo">2471</span>    return replicationSourceHandler;<a name="line.2471"></a>
-<span class="sourceLineNo">2472</span>  }<a name="line.2472"></a>
-<span class="sourceLineNo">2473</span><a name="line.2473"></a>
-<span class="sourceLineNo">2474</span>  /**<a name="line.2474"></a>
-<span class="sourceLineNo">2475</span>   * @return Return the object that implements the replication<a name="line.2475"></a>
-<span class="sourceLineNo">2476</span>   * sink service.<a name="line.2476"></a>
-<span class="sourceLineNo">2477</span>   */<a name="line.2477"></a>
-<span class="sourceLineNo">2478</span>  ReplicationSinkService getReplicationSinkService() {<a name="line.2478"></a>
-<span class="sourceLineNo">2479</span>    return replicationSinkHandler;<a name="line.2479"></a>
-<span class="sourceLineNo">2480</span>  }<a name="line.2480"></a>
-<span class="sourceLineNo">2481</span><a name="line.2481"></a>
-<span class="sourceLineNo">2482</span>  /**<a name="line.2482"></a>
-<span class="sourceLineNo">2483</span>   * Get the current master from ZooKeeper and open the RPC connection to it.<a name="line.2483"></a>
-<span class="sourceLineNo">2484</span>   * To get a fresh connection, the current rssStub must be null.<a name="line.2484"></a>
-<span class="sourceLineNo">2485</span>   * Method will block until a master is available. You can break from this<a name="line.2485"></a>
-<span class="sourceLineNo">2486</span>   * block by requesting the server stop.<a name="line.2486"></a>
-<span class="sourceLineNo">2487</span>   *<a name="line.2487"></a>
-<span class="sourceLineNo">2488</span>   * @return master + port, or null if server has been stopped<a name="line.2488"></a>
-<span class="sourceLineNo">2489</span>   */<a name="line.2489"></a>
-<span class="sourceLineNo">2490</span>  @VisibleForTesting<a name="line.2490"></a>
-<span class="sourceLineNo">2491</span>  protected synchronized ServerName createRegionServerStatusStub() {<a name="line.2491"></a>
-<span class="sourceLineNo">2492</span>    // Create RS stub without refreshing the master node from ZK, use cached data<a name="line.2492"></a>
-<span class="sourceLineNo">2493</span>    return createRegionServerStatusStub(false);<a name="line.2493"></a>
-<span class="sourceLineNo">2494</span>  }<a name="line.2494"></a>
-<span class="sourceLineNo">2495</span><a name="line.2495"></a>
-<span class="sourceLineNo">2496</span>  /**<a name="line.2496"></a>
-<span class="sourceLineNo">2497</span>   * Get the current master from ZooKeeper and open the RPC connection to it. To get a fresh<a name="line.2497"></a>
-<span class="sourceLineNo">2498</span>   * connection, the current rssStub must be null. Method will block until a master is available.<a name="line.2498"></a>
-<span class="sourceLineNo">2499</span>   * You can break from this block by requesting the server stop.<a name="line.2499"></a>
-<span class="sourceLineNo">2500</span>   * @param refresh If true then master address will be read from ZK, otherwise use cached data<a name="line.2500"></a>
-<span class="sourceLineNo">2501</span>   * @return master + port, or null if server has been stopped<a name="line.2501"></a>
-<span class="sourceLineNo">2502</span>   */<a name="line.2502"></a>
-<span class="sourceLineNo">2503</span>  @VisibleForTesting<a name="line.2503"></a>
-<span class="sourceLineNo">2504</span>  protected synchronized ServerName createRegionServerStatusStub(boolean refresh) {<a name="line.2504"></a>
-<span class="sourceLineNo">2505</span>    if (rssStub != null) {<a name="line.2505"></a>
-<span class="sourceLineNo">2506</span>      return masterAddressTracker.getMasterAddress();<a name="line.2506"></a>
-<span class="sourceLineNo">2507</span>    }<a name="line.2507"></a>
-<span class="sourceLineNo">2508</span>    ServerName sn = null;<a name="line.2508"></a>
-<span class="sourceLineNo">2509</span>    long previousLogTime = 0;<a name="line.2509"></a>
-<span class="sourceLineNo">2510</span>    RegionServerStatusService.BlockingInterface intRssStub = null;<a name="line.2510"></a>
-<span class="sourceLineNo">2511</span>    LockService.BlockingInterface intLockStub = null;<a name="line.2511"></a>
-<span class="sourceLineNo">2512</span>    boolean interrupted = false;<a name="line.2512"></a>
-<span class="sourceLineNo">2513</span>    try {<a name="line.2513"></a>
-<span class="sourceLineNo">2514</span>      while (keepLooping()) {<a name="line.2514"></a>
-<span class="sourceLineNo">2515</span>        sn = this.masterAddressTracker.getMasterAddress(refresh);<a name="line.2515"></a>
-<span class="sourceLineNo">2516</span>        if (sn == null) {<a name="line.2516"></a>
-<span class="sourceLineNo">2517</span>          if (!keepLooping()) {<a name="line.2517"></a>
-<span class="sourceLineNo">2518</span>            // give up with no connection.<a name="line.2518"></a>
-<span class="sourceLineNo">2519</span>            LOG.debug("No master found and cluster is stopped; bailing out");<a name="line.2519"></a>
-<span class="sourceLineNo">2520</span>            return null;<a name="line.2520"></a>
-<span class="sourceLineNo">2521</span>          }<a name="line.2521"></a>
-<span class="sourceLineNo">2522</span>          if (System.currentTimeMillis() &gt; (previousLogTime + 1000)) {<a name="line.2522"></a>
-<span class="sourceLineNo">2523</span>            LOG.debug("No master found; retry");<a name="line.2523"></a>
-<span class="sourceLineNo">2524</span>            previousLogTime = System.currentTimeMillis();<a name="line.2524"></a>
-<span class="sourceLineNo">2525</span>          }<a name="line.2525"></a>
-<span class="sourceLineNo">2526</span>          refresh = true; // let's try pull it from ZK directly<a name="line.2526"></a>
-<span class="sourceLineNo">2527</span>          if (sleep(200)) {<a name="line.2527"></a>
-<span class="sourceLineNo">2528</span>            interrupted = true;<a name="line.2528"></a>
-<span class="sourceLineNo">2529</span>          }<a name="line.2529"></a>
-<span class="sourceLineNo">2530</span>          continue;<a name="line.2530"></a>
-<span class="sourceLineNo">2531</span>        }<a name="line.2531"></a>
-<span class="sourceLineNo">2532</span><a name="line.2532"></a>
-<span class="sourceLineNo">2533</span>        // If we are on the active master, use the shortcut<a name="line.2533"></a>
-<span class="sourceLineNo">2534</span>        if (this instanceof HMaster &amp;&amp; sn.equals(getServerName())) {<a name="line.2534"></a>
-<span class="sourceLineNo">2535</span>          intRssStub = ((HMaster)this).getMasterRpcServices();<a name="line.2535"></a>
-<span class="sourceLineNo">2536</span>          intLockStub = ((HMaster)this).getMasterRpcServices();<a name="line.2536"></a>
-<span class="sourceLineNo">2537</span>          break;<a name="line.2537"></a>
-<span class="sourceLineNo">2538</span>        }<a name="line.2538"></a>
-<span class="sourceLineNo">2539</span>        try {<a name="line.2539"></a>
-<span class="sourceLineNo">2540</span>          BlockingRpcChannel channel =<a name="line.2540"></a>
-<span class="sourceLineNo">2541</span>            this.rpcClient.createBlockingRpcChannel(sn, userProvider.getCurrent(),<a name="line.2541"></a>
-<span class="sourceLineNo">2542</span>              shortOperationTimeout);<a name="line.2542"></a>
-<span class="sourceLineNo">2543</span>          intRssStub = RegionServerStatusService.newBlockingStub(channel);<a name="line.2543"></a>
-<span class="sourceLineNo">2544</span>          intLockStub = LockService.newBlockingStub(channel);<a name="line.2544"></a>
-<span class="sourceLineNo">2545</span>          break;<a name="line.2545"></a>
-<span class="sourceLineNo">2546</span>        } catch (IOException e) {<a name="line.2546"></a>
-<span class="sourceLineNo">2547</span>          if (System.currentTimeMillis() &gt; (previousLogTime + 1000)) {<a name="line.2547"></a>
-<span class="sourceLineNo">2548</span>            e = e instanceof RemoteException ?<a name="line.2548"></a>
-<span class="sourceLineNo">2549</span>              ((RemoteException)e).unwrapRemoteException() : e;<a name="line.2549"></a>
-<span class="sourceLineNo">2550</span>            if (e instanceof ServerNotRunningYetException) {<a name="line.2550"></a>
-<span class="sourceLineNo">2551</span>              LOG.info("Master isn't available yet, retrying");<a name="line.2551"></a>
-<span class="sourceLineNo">2552</span>            } else {<a name="line.2552"></a>
-<span class="sourceLineNo">2553</span>              LOG.warn("Unable to connect to master. Retrying. Error was:", e);<a name="line.2553"></a>
-<span class="sourceLineNo">2554</span>            }<a name="line.2554"></a>
-<span class="sourceLineNo">2555</span>            previousLogTime = System.currentTimeMillis();<a name="line.2555"></a>
-<span class="sourceLineNo">2556</span>          }<a name="line.2556"></a>
-<span class="sourceLineNo">2557</span>          if (sleep(200)) {<a name="line.2557"></a>
-<span class="sourceLineNo">2558</span>            interrupted = true;<a name="line.2558"></a>
-<span class="sourceLineNo">2559</span>          }<a name="line.2559"></a>
-<span class="sourceLineNo">2560</span>        }<a name="line.2560"></a>
-<span class="sourceLineNo">2561</span>      }<a name="line.2561"></a>
-<span class="sourceLineNo">2562</span>    } finally {<a name="line.2562"></a>
-<span class="sourceLineNo">2563</span>      if (interrupted) {<a name="line.2563"></a>
-<span class="sourceLineNo">2564</span>        Thread.currentThread().interrupt();<a name="line.2564"></a>
-<span class="sourceLineNo">2565</span>      }<a name="line.2565"></a>
-<span class="sourceLineNo">2566</span>    }<a name="line.2566"></a>
-<span class="sourceLineNo">2567</span>    this.rssStub = intRssStub;<a name="line.2567"></a>
-<span class="sourceLineNo">2568</span>    this.lockStub = intLockStub;<a name="line.2568"></a>
-<span class="sourceLineNo">2569</span>    return sn;<a name="line.2569"></a>
-<span class="sourceLineNo">2570</span>  }<a name="line.2570"></a>
-<span class="sourceLineNo">2571</span><a name="line.2571"></a>
-<span class="sourceLineNo">2572</span>  /**<a name="line.2572"></a>
-<span class="sourceLineNo">2573</span>   * @return True if we should break loop because cluster is going down or<a name="line.2573"></a>
-<span class="sourceLineNo">2574</span>   * this server has been stopped or hdfs has gone bad.<a name="line.2574"></a>
-<span class="sourceLineNo">2575</span>   */<a name="line.2575"></a>
-<span class="sourceLineNo">2576</span>  private boolean keepLooping() {<a name="line.2576"></a>
-<span class="sourceLineNo">2577</span>    return !this.stopped &amp;&amp; isClusterUp();<a name="line.2577"></a>
-<span class="sourceLineNo">2578</span>  }<a name="line.2578"></a>
-<span class="sourceLineNo">2579</span><a name="line.2579"></a>
-<span class="sourceLineNo">2580</span>  /*<a name="line.2580"></a>
-<span class="sourceLineNo">2581</span>   * Let the master know we're here Run initialization using parameters passed<a name="line.2581"></a>
-<span class="sourceLineNo">2582</span>   * us by the master.<a name="line.2582"></a>
-<span class="sourceLineNo">2583</span>   * @return A Map of key/value configurations we got from the Master else<a name="line.2583"></a>
-<span class="sourceLineNo">2584</span>   * null if we failed to register.<a name="line.2584"></a>
-<span class="sourceLineNo">2585</span>   * @throws IOException<a name="line.2585"></a>
-<span class="sourceLineNo">2586</span>   */<a name="line.2586"></a>
-<span class="sourceLineNo">2587</span>  private RegionServerStartupResponse reportForDuty() throws IOException {<a name="line.2587"></a>
-<span class="sourceLineNo">2588</span>    ServerName masterServerName = createRegionServerStatusStub(true);<a name="line.2588"></a>
-<span class="sourceLineNo">2589</span>    if (masterServerName == null) return null;<a name="line.2589"></a>
-<span class="sourceLineNo">2590</span>    RegionServerStartupResponse result = null;<a name="line.2590"></a>
-<span class="sourceLineNo">2591</span>    try {<a name="line.2591"></a>
-<span class="sourceLineNo">2592</span>      rpcServices.requestCount.reset();<a name="line.2592"></a>
-<span class="sourceLineNo">2593</span>      rpcServices.rpcGetRequestCount.reset();<a name="line.2593"></a>
-<span class="sourceLineNo">2594</span>      rpcServices.rpcScanRequestCount.reset();<a name="line.2594"></a>
-<span class="sourceLineNo">2595</span>      rpcServices.rpcMultiRequestCount.reset();<a name="line.2595"></a>
-<span class="sourceLineNo">2596</span>      rpcServices.rpcMutateRequestCount.reset();<a name="line.2596"></a>
-<span class="sourceLineNo">2597</span>      LOG.info("reportForDuty to master=" + masterServerName + " with port="<a name="line.2597"></a>
-<span class="sourceLineNo">2598</span>        + rpcServices.isa.getPort() + ", startcode=" + this.startcode);<a name="line.2598"></a>
-<span class="sourceLineNo">2599</span>      long now = EnvironmentEdgeManager.currentTime();<a name="line.2599"></a>
-<span class="sourceLineNo">2600</span>      int port = rpcServices.isa.getPort();<a name="line.2600"></a>
-<span class="sourceLineNo">2601</span>      RegionServerStartupRequest.Builder request = RegionServerStartupRequest.newBuilder();<a name="line.2601"></a>
-<span class="sourceLineNo">2602</span>      if (shouldUseThisHostnameInstead()) {<a name="line.2602"></a>
-<span class="sourceLineNo">2603</span>        request.setUseThisHostnameInstead(useThisHostnameInstead);<a name="line.2603"></a>
-<span class="sourceLineNo">2604</span>      }<a name="line.2604"></a>
-<span class="sourceLineNo">2605</span>      request.setPort(port);<a name="line.2605"></a>
-<span class="sourceLineNo">2606</span>      request.setServerStartCode(this.startcode);<a name="line.2606"></a>
-<span class="sourceLineNo">2607</span>      request.setServerCurrentTime(now);<a name="line.2607"></a>
-<span class="sourceLineNo">2608</span>      result = this.rssStub.regionServerStartup(null, request.build());<a name="line.2608"></a>
-<span class="sourceLineNo">2609</span>    } catch (ServiceException se) {<a name="line.2609"></a>
-<span class="sourceLineNo">2610</span>      IOException ioe = ProtobufUtil.getRemoteException(se);<a name="line.2610"></a>
-<span class="sourceLineNo">2611</span>      if (ioe instanceof ClockOutOfSyncException) {<a name="line.2611"></a>
-<span class="sourceLineNo">2612</span>        LOG.fatal("Master rejected startup because clock is out of sync", ioe);<a name="line.2612"></a>
-<span class="sourceLineNo">2613</span>        // Re-throw IOE will cause RS to abort<a name="line.2613"></a>
-<span class="sourceLineNo">2614</span>        throw ioe;<a name="line.2614"></a>
-<span class="sourceLineNo">2615</span>      } else if (ioe instanceof ServerNotRunningYetException) {<a name="line.2615"></a>
-<span class="sourceLineNo">2616</span>        LOG.debug("Master is not running yet");<a name="line.2616"></a>
-<span class="sourceLineNo">2617</span>      } else {<a name="line.2617"></a>
-<span class="sourceLineNo">2618</span>        LOG.warn("error telling master we are up", se);<a name="line.2618"></a>
-<span class="sourceLineNo">2619</span>      }<a name="line.2619"></a>
-<span class="sourceLineNo">2620</span>      rssStub = null;<a name="line.2620"></a>
-<span class="sourceLineNo">2621</span>    }<a name="line.2621"></a>
-<span class="sourceLineNo">2622</span>    return result;<a name="line.2622"></a>
-<span class="sourceLineNo">2623</span>  }<a name="line.2623"></a>
-<span class="sourceLineNo">2624</span><a name="line.2624"></a>
-<span class="sourceLineNo">2625</span>  @Override<a name="line.2625"></a>
-<span class="sourceLineNo">2626</span>  public RegionStoreSequenceIds getLastSequenceId(byte[] encodedRegionName) {<a name="line.2626"></a>
-<span class="sourceLineNo">2627</span>    try {<a name="line.2627"></a>
-<span class="sourceLineNo">2628</span>      GetLastFlushedSequenceIdRequest req =<a name="line.2628"></a>
-<span class="sourceLineNo">2629</span>          RequestConverter.buildGetLastFlushedSequenceIdRequest(encodedRegionName);<a name="line.2629"></a>
-<span class="sourceLineNo">2630</span>      RegionServerStatusService.BlockingInterface rss = rssStub;<a name="line.2630"></a>
-<span class="sourceLineNo">2631</span>      if (rss == null) { // Try to connect one more time<a name="line.2631"></a>
-<span class="sourceLineNo">2632</span>        createRegionServerStatusStub();<a name="line.2632"></a>
-<span class="sourceLineNo">2633</span>        rss = rssStub;<a name="line.2633"></a>
-<span class="sourceLineNo">2634</span>        if (rss == null) {<a name="line.2634"></a>
-<span class="sourceLineNo">2635</span>          // Still no luck, we tried<a name="line.2635"></a>
-<span class="sourceLineNo">2636</span>          LOG.warn("Unable to connect to the master to check " + "the last flushed sequence id");<a name="line.2636"></a>
-<span class="sourceLineNo">2637</span>          return RegionStoreSequenceIds.newBuilder().setLastFlushedSequenceId(HConstants.NO_SEQNUM)<a name="line.2637"></a>
-<span class="sourceLineNo">2638</span>              .build();<a name="line.2638"></a>
-<span class="sourceLineNo">2639</span>        }<a name="line.2639"></a>
-<span class="sourceLineNo">2640</span>      }<a name="line.2640"></a>
-<span class="sourceLineNo">2641</span>      GetLastFlushedSequenceIdResponse resp = rss.getLastFlushedSequenceId(null, req);<a name="line.2641"></a>
-<span class="sourceLineNo">2642</span>      r

<TRUNCATED>

Mime
View raw message