hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [07/51] [partial] hbase git commit: Published site at 7979ac46cce36f21033f8ed03c8d0dd5fddde005.
Date Tue, 01 Dec 2015 21:20:23 GMT
http://git-wip-us.apache.org/repos/asf/hbase/blob/c0e3c35a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.PeriodicMemstoreFlusher.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.PeriodicMemstoreFlusher.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.PeriodicMemstoreFlusher.html
index fdc4809..bb57874 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.PeriodicMemstoreFlusher.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.PeriodicMemstoreFlusher.html
@@ -1875,1491 +1875,1511 @@
 <span class="sourceLineNo">1867</span>  }<a name="line.1867"></a>
 <span class="sourceLineNo">1868</span><a name="line.1868"></a>
 <span class="sourceLineNo">1869</span>  @Override<a name="line.1869"></a>
-<span class="sourceLineNo">1870</span>  public ClusterConnection getConnection() {<a name="line.1870"></a>
-<span class="sourceLineNo">1871</span>    return this.clusterConnection;<a name="line.1871"></a>
-<span class="sourceLineNo">1872</span>  }<a name="line.1872"></a>
+<span class="sourceLineNo">1870</span>  public void releaseWAL(HRegionInfo regionInfo, WAL wal) throws IOException {<a name="line.1870"></a>
+<span class="sourceLineNo">1871</span>    if (regionInfo != null &amp;&amp; regionInfo.isMetaTable() &amp;&amp;<a name="line.1871"></a>
+<span class="sourceLineNo">1872</span>        regionInfo.getReplicaId() == HRegionInfo.DEFAULT_REPLICA_ID) {<a name="line.1872"></a>
 <span class="sourceLineNo">1873</span><a name="line.1873"></a>
-<span class="sourceLineNo">1874</span>  @Override<a name="line.1874"></a>
-<span class="sourceLineNo">1875</span>  public MetaTableLocator getMetaTableLocator() {<a name="line.1875"></a>
-<span class="sourceLineNo">1876</span>    return this.metaTableLocator;<a name="line.1876"></a>
-<span class="sourceLineNo">1877</span>  }<a name="line.1877"></a>
-<span class="sourceLineNo">1878</span><a name="line.1878"></a>
-<span class="sourceLineNo">1879</span>  @Override<a name="line.1879"></a>
-<span class="sourceLineNo">1880</span>  public void stop(final String msg) {<a name="line.1880"></a>
-<span class="sourceLineNo">1881</span>    if (!this.stopped) {<a name="line.1881"></a>
-<span class="sourceLineNo">1882</span>      try {<a name="line.1882"></a>
-<span class="sourceLineNo">1883</span>        if (this.rsHost != null) {<a name="line.1883"></a>
-<span class="sourceLineNo">1884</span>          this.rsHost.preStop(msg);<a name="line.1884"></a>
-<span class="sourceLineNo">1885</span>        }<a name="line.1885"></a>
-<span class="sourceLineNo">1886</span>        this.stopped = true;<a name="line.1886"></a>
-<span class="sourceLineNo">1887</span>        LOG.info("STOPPED: " + msg);<a name="line.1887"></a>
-<span class="sourceLineNo">1888</span>        // Wakes run() if it is sleeping<a name="line.1888"></a>
-<span class="sourceLineNo">1889</span>        sleeper.skipSleepCycle();<a name="line.1889"></a>
-<span class="sourceLineNo">1890</span>      } catch (IOException exp) {<a name="line.1890"></a>
-<span class="sourceLineNo">1891</span>        LOG.warn("The region server did not stop", exp);<a name="line.1891"></a>
-<span class="sourceLineNo">1892</span>      }<a name="line.1892"></a>
-<span class="sourceLineNo">1893</span>    }<a name="line.1893"></a>
-<span class="sourceLineNo">1894</span>  }<a name="line.1894"></a>
-<span class="sourceLineNo">1895</span><a name="line.1895"></a>
-<span class="sourceLineNo">1896</span>  public void waitForServerOnline(){<a name="line.1896"></a>
-<span class="sourceLineNo">1897</span>    while (!isStopped() &amp;&amp; !isOnline()) {<a name="line.1897"></a>
-<span class="sourceLineNo">1898</span>      synchronized (online) {<a name="line.1898"></a>
-<span class="sourceLineNo">1899</span>        try {<a name="line.1899"></a>
-<span class="sourceLineNo">1900</span>          online.wait(msgInterval);<a name="line.1900"></a>
-<span class="sourceLineNo">1901</span>        } catch (InterruptedException ie) {<a name="line.1901"></a>
-<span class="sourceLineNo">1902</span>          Thread.currentThread().interrupt();<a name="line.1902"></a>
-<span class="sourceLineNo">1903</span>          break;<a name="line.1903"></a>
-<span class="sourceLineNo">1904</span>        }<a name="line.1904"></a>
-<span class="sourceLineNo">1905</span>      }<a name="line.1905"></a>
-<span class="sourceLineNo">1906</span>    }<a name="line.1906"></a>
-<span class="sourceLineNo">1907</span>  }<a name="line.1907"></a>
-<span class="sourceLineNo">1908</span><a name="line.1908"></a>
-<span class="sourceLineNo">1909</span>  @Override<a name="line.1909"></a>
-<span class="sourceLineNo">1910</span>  public void postOpenDeployTasks(final Region r) throws KeeperException, IOException {<a name="line.1910"></a>
-<span class="sourceLineNo">1911</span>    postOpenDeployTasks(new PostOpenDeployContext(r, -1));<a name="line.1911"></a>
-<span class="sourceLineNo">1912</span>  }<a name="line.1912"></a>
-<span class="sourceLineNo">1913</span><a name="line.1913"></a>
-<span class="sourceLineNo">1914</span>  @Override<a name="line.1914"></a>
-<span class="sourceLineNo">1915</span>  public void postOpenDeployTasks(final PostOpenDeployContext context)<a name="line.1915"></a>
-<span class="sourceLineNo">1916</span>      throws KeeperException, IOException {<a name="line.1916"></a>
-<span class="sourceLineNo">1917</span>    Region r = context.getRegion();<a name="line.1917"></a>
-<span class="sourceLineNo">1918</span>    long masterSystemTime = context.getMasterSystemTime();<a name="line.1918"></a>
-<span class="sourceLineNo">1919</span>    Preconditions.checkArgument(r instanceof HRegion, "r must be an HRegion");<a name="line.1919"></a>
-<span class="sourceLineNo">1920</span>    rpcServices.checkOpen();<a name="line.1920"></a>
-<span class="sourceLineNo">1921</span>    LOG.info("Post open deploy tasks for " + r.getRegionInfo().getRegionNameAsString());<a name="line.1921"></a>
-<span class="sourceLineNo">1922</span>    // Do checks to see if we need to compact (references or too many files)<a name="line.1922"></a>
-<span class="sourceLineNo">1923</span>    for (Store s : r.getStores()) {<a name="line.1923"></a>
-<span class="sourceLineNo">1924</span>      if (s.hasReferences() || s.needsCompaction()) {<a name="line.1924"></a>
-<span class="sourceLineNo">1925</span>       this.compactSplitThread.requestSystemCompaction(r, s, "Opening Region");<a name="line.1925"></a>
-<span class="sourceLineNo">1926</span>      }<a name="line.1926"></a>
-<span class="sourceLineNo">1927</span>    }<a name="line.1927"></a>
-<span class="sourceLineNo">1928</span>    long openSeqNum = r.getOpenSeqNum();<a name="line.1928"></a>
-<span class="sourceLineNo">1929</span>    if (openSeqNum == HConstants.NO_SEQNUM) {<a name="line.1929"></a>
-<span class="sourceLineNo">1930</span>      // If we opened a region, we should have read some sequence number from it.<a name="line.1930"></a>
-<span class="sourceLineNo">1931</span>      LOG.error("No sequence number found when opening " +<a name="line.1931"></a>
-<span class="sourceLineNo">1932</span>        r.getRegionInfo().getRegionNameAsString());<a name="line.1932"></a>
-<span class="sourceLineNo">1933</span>      openSeqNum = 0;<a name="line.1933"></a>
-<span class="sourceLineNo">1934</span>    }<a name="line.1934"></a>
-<span class="sourceLineNo">1935</span><a name="line.1935"></a>
-<span class="sourceLineNo">1936</span>    // Update flushed sequence id of a recovering region in ZK<a name="line.1936"></a>
-<span class="sourceLineNo">1937</span>    updateRecoveringRegionLastFlushedSequenceId(r);<a name="line.1937"></a>
-<span class="sourceLineNo">1938</span><a name="line.1938"></a>
-<span class="sourceLineNo">1939</span>    // Notify master<a name="line.1939"></a>
-<span class="sourceLineNo">1940</span>    if (!reportRegionStateTransition(new RegionStateTransitionContext(<a name="line.1940"></a>
-<span class="sourceLineNo">1941</span>        TransitionCode.OPENED, openSeqNum, masterSystemTime, r.getRegionInfo()))) {<a name="line.1941"></a>
-<span class="sourceLineNo">1942</span>      throw new IOException("Failed to report opened region to master: "<a name="line.1942"></a>
-<span class="sourceLineNo">1943</span>        + r.getRegionInfo().getRegionNameAsString());<a name="line.1943"></a>
-<span class="sourceLineNo">1944</span>    }<a name="line.1944"></a>
-<span class="sourceLineNo">1945</span><a name="line.1945"></a>
-<span class="sourceLineNo">1946</span>    triggerFlushInPrimaryRegion((HRegion)r);<a name="line.1946"></a>
-<span class="sourceLineNo">1947</span><a name="line.1947"></a>
-<span class="sourceLineNo">1948</span>    LOG.debug("Finished post open deploy task for " + r.getRegionInfo().getRegionNameAsString());<a name="line.1948"></a>
-<span class="sourceLineNo">1949</span>  }<a name="line.1949"></a>
-<span class="sourceLineNo">1950</span><a name="line.1950"></a>
-<span class="sourceLineNo">1951</span>  @Override<a name="line.1951"></a>
-<span class="sourceLineNo">1952</span>  public boolean reportRegionStateTransition(TransitionCode code, HRegionInfo... hris) {<a name="line.1952"></a>
-<span class="sourceLineNo">1953</span>    return reportRegionStateTransition(code, HConstants.NO_SEQNUM, hris);<a name="line.1953"></a>
-<span class="sourceLineNo">1954</span>  }<a name="line.1954"></a>
+<span class="sourceLineNo">1874</span>      walFactory.closeMetaWAL(regionInfo.getEncodedNameAsBytes());<a name="line.1874"></a>
+<span class="sourceLineNo">1875</span><a name="line.1875"></a>
+<span class="sourceLineNo">1876</span>      LogRoller roller;<a name="line.1876"></a>
+<span class="sourceLineNo">1877</span>      if (regionInfo != null &amp;&amp; regionInfo.isMetaTable() &amp;&amp;<a name="line.1877"></a>
+<span class="sourceLineNo">1878</span>          regionInfo.getReplicaId() == HRegionInfo.DEFAULT_REPLICA_ID) {<a name="line.1878"></a>
+<span class="sourceLineNo">1879</span>        roller = metawalRoller.get();<a name="line.1879"></a>
+<span class="sourceLineNo">1880</span>        if (roller != null) {<a name="line.1880"></a>
+<span class="sourceLineNo">1881</span>          roller.removeWAL(wal); // only do this for meta WAL<a name="line.1881"></a>
+<span class="sourceLineNo">1882</span>        }<a name="line.1882"></a>
+<span class="sourceLineNo">1883</span><a name="line.1883"></a>
+<span class="sourceLineNo">1884</span>        // TODO: meta wal roller is left running. Should be fine.<a name="line.1884"></a>
+<span class="sourceLineNo">1885</span>      }<a name="line.1885"></a>
+<span class="sourceLineNo">1886</span>    }<a name="line.1886"></a>
+<span class="sourceLineNo">1887</span>  }<a name="line.1887"></a>
+<span class="sourceLineNo">1888</span><a name="line.1888"></a>
+<span class="sourceLineNo">1889</span>  @Override<a name="line.1889"></a>
+<span class="sourceLineNo">1890</span>  public ClusterConnection getConnection() {<a name="line.1890"></a>
+<span class="sourceLineNo">1891</span>    return this.clusterConnection;<a name="line.1891"></a>
+<span class="sourceLineNo">1892</span>  }<a name="line.1892"></a>
+<span class="sourceLineNo">1893</span><a name="line.1893"></a>
+<span class="sourceLineNo">1894</span>  @Override<a name="line.1894"></a>
+<span class="sourceLineNo">1895</span>  public MetaTableLocator getMetaTableLocator() {<a name="line.1895"></a>
+<span class="sourceLineNo">1896</span>    return this.metaTableLocator;<a name="line.1896"></a>
+<span class="sourceLineNo">1897</span>  }<a name="line.1897"></a>
+<span class="sourceLineNo">1898</span><a name="line.1898"></a>
+<span class="sourceLineNo">1899</span>  @Override<a name="line.1899"></a>
+<span class="sourceLineNo">1900</span>  public void stop(final String msg) {<a name="line.1900"></a>
+<span class="sourceLineNo">1901</span>    if (!this.stopped) {<a name="line.1901"></a>
+<span class="sourceLineNo">1902</span>      try {<a name="line.1902"></a>
+<span class="sourceLineNo">1903</span>        if (this.rsHost != null) {<a name="line.1903"></a>
+<span class="sourceLineNo">1904</span>          this.rsHost.preStop(msg);<a name="line.1904"></a>
+<span class="sourceLineNo">1905</span>        }<a name="line.1905"></a>
+<span class="sourceLineNo">1906</span>        this.stopped = true;<a name="line.1906"></a>
+<span class="sourceLineNo">1907</span>        LOG.info("STOPPED: " + msg);<a name="line.1907"></a>
+<span class="sourceLineNo">1908</span>        // Wakes run() if it is sleeping<a name="line.1908"></a>
+<span class="sourceLineNo">1909</span>        sleeper.skipSleepCycle();<a name="line.1909"></a>
+<span class="sourceLineNo">1910</span>      } catch (IOException exp) {<a name="line.1910"></a>
+<span class="sourceLineNo">1911</span>        LOG.warn("The region server did not stop", exp);<a name="line.1911"></a>
+<span class="sourceLineNo">1912</span>      }<a name="line.1912"></a>
+<span class="sourceLineNo">1913</span>    }<a name="line.1913"></a>
+<span class="sourceLineNo">1914</span>  }<a name="line.1914"></a>
+<span class="sourceLineNo">1915</span><a name="line.1915"></a>
+<span class="sourceLineNo">1916</span>  public void waitForServerOnline(){<a name="line.1916"></a>
+<span class="sourceLineNo">1917</span>    while (!isStopped() &amp;&amp; !isOnline()) {<a name="line.1917"></a>
+<span class="sourceLineNo">1918</span>      synchronized (online) {<a name="line.1918"></a>
+<span class="sourceLineNo">1919</span>        try {<a name="line.1919"></a>
+<span class="sourceLineNo">1920</span>          online.wait(msgInterval);<a name="line.1920"></a>
+<span class="sourceLineNo">1921</span>        } catch (InterruptedException ie) {<a name="line.1921"></a>
+<span class="sourceLineNo">1922</span>          Thread.currentThread().interrupt();<a name="line.1922"></a>
+<span class="sourceLineNo">1923</span>          break;<a name="line.1923"></a>
+<span class="sourceLineNo">1924</span>        }<a name="line.1924"></a>
+<span class="sourceLineNo">1925</span>      }<a name="line.1925"></a>
+<span class="sourceLineNo">1926</span>    }<a name="line.1926"></a>
+<span class="sourceLineNo">1927</span>  }<a name="line.1927"></a>
+<span class="sourceLineNo">1928</span><a name="line.1928"></a>
+<span class="sourceLineNo">1929</span>  @Override<a name="line.1929"></a>
+<span class="sourceLineNo">1930</span>  public void postOpenDeployTasks(final Region r) throws KeeperException, IOException {<a name="line.1930"></a>
+<span class="sourceLineNo">1931</span>    postOpenDeployTasks(new PostOpenDeployContext(r, -1));<a name="line.1931"></a>
+<span class="sourceLineNo">1932</span>  }<a name="line.1932"></a>
+<span class="sourceLineNo">1933</span><a name="line.1933"></a>
+<span class="sourceLineNo">1934</span>  @Override<a name="line.1934"></a>
+<span class="sourceLineNo">1935</span>  public void postOpenDeployTasks(final PostOpenDeployContext context)<a name="line.1935"></a>
+<span class="sourceLineNo">1936</span>      throws KeeperException, IOException {<a name="line.1936"></a>
+<span class="sourceLineNo">1937</span>    Region r = context.getRegion();<a name="line.1937"></a>
+<span class="sourceLineNo">1938</span>    long masterSystemTime = context.getMasterSystemTime();<a name="line.1938"></a>
+<span class="sourceLineNo">1939</span>    Preconditions.checkArgument(r instanceof HRegion, "r must be an HRegion");<a name="line.1939"></a>
+<span class="sourceLineNo">1940</span>    rpcServices.checkOpen();<a name="line.1940"></a>
+<span class="sourceLineNo">1941</span>    LOG.info("Post open deploy tasks for " + r.getRegionInfo().getRegionNameAsString());<a name="line.1941"></a>
+<span class="sourceLineNo">1942</span>    // Do checks to see if we need to compact (references or too many files)<a name="line.1942"></a>
+<span class="sourceLineNo">1943</span>    for (Store s : r.getStores()) {<a name="line.1943"></a>
+<span class="sourceLineNo">1944</span>      if (s.hasReferences() || s.needsCompaction()) {<a name="line.1944"></a>
+<span class="sourceLineNo">1945</span>       this.compactSplitThread.requestSystemCompaction(r, s, "Opening Region");<a name="line.1945"></a>
+<span class="sourceLineNo">1946</span>      }<a name="line.1946"></a>
+<span class="sourceLineNo">1947</span>    }<a name="line.1947"></a>
+<span class="sourceLineNo">1948</span>    long openSeqNum = r.getOpenSeqNum();<a name="line.1948"></a>
+<span class="sourceLineNo">1949</span>    if (openSeqNum == HConstants.NO_SEQNUM) {<a name="line.1949"></a>
+<span class="sourceLineNo">1950</span>      // If we opened a region, we should have read some sequence number from it.<a name="line.1950"></a>
+<span class="sourceLineNo">1951</span>      LOG.error("No sequence number found when opening " +<a name="line.1951"></a>
+<span class="sourceLineNo">1952</span>        r.getRegionInfo().getRegionNameAsString());<a name="line.1952"></a>
+<span class="sourceLineNo">1953</span>      openSeqNum = 0;<a name="line.1953"></a>
+<span class="sourceLineNo">1954</span>    }<a name="line.1954"></a>
 <span class="sourceLineNo">1955</span><a name="line.1955"></a>
-<span class="sourceLineNo">1956</span>  @Override<a name="line.1956"></a>
-<span class="sourceLineNo">1957</span>  public boolean reportRegionStateTransition(<a name="line.1957"></a>
-<span class="sourceLineNo">1958</span>      TransitionCode code, long openSeqNum, HRegionInfo... hris) {<a name="line.1958"></a>
-<span class="sourceLineNo">1959</span>    return reportRegionStateTransition(<a name="line.1959"></a>
-<span class="sourceLineNo">1960</span>      new RegionStateTransitionContext(code, HConstants.NO_SEQNUM, -1, hris));<a name="line.1960"></a>
-<span class="sourceLineNo">1961</span>  }<a name="line.1961"></a>
-<span class="sourceLineNo">1962</span><a name="line.1962"></a>
-<span class="sourceLineNo">1963</span>  @Override<a name="line.1963"></a>
-<span class="sourceLineNo">1964</span>  public boolean reportRegionStateTransition(final RegionStateTransitionContext context) {<a name="line.1964"></a>
-<span class="sourceLineNo">1965</span>    TransitionCode code = context.getCode();<a name="line.1965"></a>
-<span class="sourceLineNo">1966</span>    long openSeqNum = context.getOpenSeqNum();<a name="line.1966"></a>
-<span class="sourceLineNo">1967</span>    long masterSystemTime = context.getMasterSystemTime();<a name="line.1967"></a>
-<span class="sourceLineNo">1968</span>    HRegionInfo[] hris = context.getHris();<a name="line.1968"></a>
-<span class="sourceLineNo">1969</span><a name="line.1969"></a>
-<span class="sourceLineNo">1970</span>    if (TEST_SKIP_REPORTING_TRANSITION) {<a name="line.1970"></a>
-<span class="sourceLineNo">1971</span>      // This is for testing only in case there is no master<a name="line.1971"></a>
-<span class="sourceLineNo">1972</span>      // to handle the region transition report at all.<a name="line.1972"></a>
-<span class="sourceLineNo">1973</span>      if (code == TransitionCode.OPENED) {<a name="line.1973"></a>
-<span class="sourceLineNo">1974</span>        Preconditions.checkArgument(hris != null &amp;&amp; hris.length == 1);<a name="line.1974"></a>
-<span class="sourceLineNo">1975</span>        if (hris[0].isMetaRegion()) {<a name="line.1975"></a>
-<span class="sourceLineNo">1976</span>          try {<a name="line.1976"></a>
-<span class="sourceLineNo">1977</span>            MetaTableLocator.setMetaLocation(getZooKeeper(), serverName,<a name="line.1977"></a>
-<span class="sourceLineNo">1978</span>                hris[0].getReplicaId(),State.OPEN);<a name="line.1978"></a>
-<span class="sourceLineNo">1979</span>          } catch (KeeperException e) {<a name="line.1979"></a>
-<span class="sourceLineNo">1980</span>            LOG.info("Failed to update meta location", e);<a name="line.1980"></a>
-<span class="sourceLineNo">1981</span>            return false;<a name="line.1981"></a>
-<span class="sourceLineNo">1982</span>          }<a name="line.1982"></a>
-<span class="sourceLineNo">1983</span>        } else {<a name="line.1983"></a>
-<span class="sourceLineNo">1984</span>          try {<a name="line.1984"></a>
-<span class="sourceLineNo">1985</span>            MetaTableAccessor.updateRegionLocation(clusterConnection,<a name="line.1985"></a>
-<span class="sourceLineNo">1986</span>              hris[0], serverName, openSeqNum, masterSystemTime);<a name="line.1986"></a>
-<span class="sourceLineNo">1987</span>          } catch (IOException e) {<a name="line.1987"></a>
-<span class="sourceLineNo">1988</span>            LOG.info("Failed to update meta", e);<a name="line.1988"></a>
-<span class="sourceLineNo">1989</span>            return false;<a name="line.1989"></a>
-<span class="sourceLineNo">1990</span>          }<a name="line.1990"></a>
-<span class="sourceLineNo">1991</span>        }<a name="line.1991"></a>
-<span class="sourceLineNo">1992</span>      }<a name="line.1992"></a>
-<span class="sourceLineNo">1993</span>      return true;<a name="line.1993"></a>
-<span class="sourceLineNo">1994</span>    }<a name="line.1994"></a>
-<span class="sourceLineNo">1995</span><a name="line.1995"></a>
-<span class="sourceLineNo">1996</span>    ReportRegionStateTransitionRequest.Builder builder =<a name="line.1996"></a>
-<span class="sourceLineNo">1997</span>      ReportRegionStateTransitionRequest.newBuilder();<a name="line.1997"></a>
-<span class="sourceLineNo">1998</span>    builder.setServer(ProtobufUtil.toServerName(serverName));<a name="line.1998"></a>
-<span class="sourceLineNo">1999</span>    RegionStateTransition.Builder transition = builder.addTransitionBuilder();<a name="line.1999"></a>
-<span class="sourceLineNo">2000</span>    transition.setTransitionCode(code);<a name="line.2000"></a>
-<span class="sourceLineNo">2001</span>    if (code == TransitionCode.OPENED &amp;&amp; openSeqNum &gt;= 0) {<a name="line.2001"></a>
-<span class="sourceLineNo">2002</span>      transition.setOpenSeqNum(openSeqNum);<a name="line.2002"></a>
-<span class="sourceLineNo">2003</span>    }<a name="line.2003"></a>
-<span class="sourceLineNo">2004</span>    for (HRegionInfo hri: hris) {<a name="line.2004"></a>
-<span class="sourceLineNo">2005</span>      transition.addRegionInfo(HRegionInfo.convert(hri));<a name="line.2005"></a>
-<span class="sourceLineNo">2006</span>    }<a name="line.2006"></a>
-<span class="sourceLineNo">2007</span>    ReportRegionStateTransitionRequest request = builder.build();<a name="line.2007"></a>
-<span class="sourceLineNo">2008</span>    while (keepLooping()) {<a name="line.2008"></a>
-<span class="sourceLineNo">2009</span>      RegionServerStatusService.BlockingInterface rss = rssStub;<a name="line.2009"></a>
-<span class="sourceLineNo">2010</span>      try {<a name="line.2010"></a>
-<span class="sourceLineNo">2011</span>        if (rss == null) {<a name="line.2011"></a>
-<span class="sourceLineNo">2012</span>          createRegionServerStatusStub();<a name="line.2012"></a>
-<span class="sourceLineNo">2013</span>          continue;<a name="line.2013"></a>
-<span class="sourceLineNo">2014</span>        }<a name="line.2014"></a>
-<span class="sourceLineNo">2015</span>        ReportRegionStateTransitionResponse response =<a name="line.2015"></a>
-<span class="sourceLineNo">2016</span>          rss.reportRegionStateTransition(null, request);<a name="line.2016"></a>
-<span class="sourceLineNo">2017</span>        if (response.hasErrorMessage()) {<a name="line.2017"></a>
-<span class="sourceLineNo">2018</span>          LOG.info("Failed to transition " + hris[0]<a name="line.2018"></a>
-<span class="sourceLineNo">2019</span>            + " to " + code + ": " + response.getErrorMessage());<a name="line.2019"></a>
-<span class="sourceLineNo">2020</span>          return false;<a name="line.2020"></a>
-<span class="sourceLineNo">2021</span>        }<a name="line.2021"></a>
-<span class="sourceLineNo">2022</span>        return true;<a name="line.2022"></a>
-<span class="sourceLineNo">2023</span>      } catch (ServiceException se) {<a name="line.2023"></a>
-<span class="sourceLineNo">2024</span>        IOException ioe = ProtobufUtil.getRemoteException(se);<a name="line.2024"></a>
-<span class="sourceLineNo">2025</span>        LOG.info("Failed to report region transition, will retry", ioe);<a name="line.2025"></a>
-<span class="sourceLineNo">2026</span>        if (rssStub == rss) {<a name="line.2026"></a>
-<span class="sourceLineNo">2027</span>          rssStub = null;<a name="line.2027"></a>
-<span class="sourceLineNo">2028</span>        }<a name="line.2028"></a>
-<span class="sourceLineNo">2029</span>      }<a name="line.2029"></a>
-<span class="sourceLineNo">2030</span>    }<a name="line.2030"></a>
-<span class="sourceLineNo">2031</span>    return false;<a name="line.2031"></a>
-<span class="sourceLineNo">2032</span>  }<a name="line.2032"></a>
-<span class="sourceLineNo">2033</span><a name="line.2033"></a>
-<span class="sourceLineNo">2034</span>  /**<a name="line.2034"></a>
-<span class="sourceLineNo">2035</span>   * Trigger a flush in the primary region replica if this region is a secondary replica. Does not<a name="line.2035"></a>
-<span class="sourceLineNo">2036</span>   * block this thread. See RegionReplicaFlushHandler for details.<a name="line.2036"></a>
-<span class="sourceLineNo">2037</span>   */<a name="line.2037"></a>
-<span class="sourceLineNo">2038</span>  void triggerFlushInPrimaryRegion(final HRegion region) {<a name="line.2038"></a>
-<span class="sourceLineNo">2039</span>    if (ServerRegionReplicaUtil.isDefaultReplica(region.getRegionInfo())) {<a name="line.2039"></a>
-<span class="sourceLineNo">2040</span>      return;<a name="line.2040"></a>
-<span class="sourceLineNo">2041</span>    }<a name="line.2041"></a>
-<span class="sourceLineNo">2042</span>    if (!ServerRegionReplicaUtil.isRegionReplicaReplicationEnabled(region.conf) ||<a name="line.2042"></a>
-<span class="sourceLineNo">2043</span>        !ServerRegionReplicaUtil.isRegionReplicaWaitForPrimaryFlushEnabled(<a name="line.2043"></a>
-<span class="sourceLineNo">2044</span>          region.conf)) {<a name="line.2044"></a>
-<span class="sourceLineNo">2045</span>      region.setReadsEnabled(true);<a name="line.2045"></a>
-<span class="sourceLineNo">2046</span>      return;<a name="line.2046"></a>
-<span class="sourceLineNo">2047</span>    }<a name="line.2047"></a>
-<span class="sourceLineNo">2048</span><a name="line.2048"></a>
-<span class="sourceLineNo">2049</span>    region.setReadsEnabled(false); // disable reads before marking the region as opened.<a name="line.2049"></a>
-<span class="sourceLineNo">2050</span>    // RegionReplicaFlushHandler might reset this.<a name="line.2050"></a>
-<span class="sourceLineNo">2051</span><a name="line.2051"></a>
-<span class="sourceLineNo">2052</span>    // submit it to be handled by one of the handlers so that we do not block OpenRegionHandler<a name="line.2052"></a>
-<span class="sourceLineNo">2053</span>    this.service.submit(<a name="line.2053"></a>
-<span class="sourceLineNo">2054</span>      new RegionReplicaFlushHandler(this, clusterConnection,<a name="line.2054"></a>
-<span class="sourceLineNo">2055</span>        rpcRetryingCallerFactory, rpcControllerFactory, operationTimeout, region));<a name="line.2055"></a>
-<span class="sourceLineNo">2056</span>  }<a name="line.2056"></a>
-<span class="sourceLineNo">2057</span><a name="line.2057"></a>
-<span class="sourceLineNo">2058</span>  @Override<a name="line.2058"></a>
-<span class="sourceLineNo">2059</span>  public RpcServerInterface getRpcServer() {<a name="line.2059"></a>
-<span class="sourceLineNo">2060</span>    return rpcServices.rpcServer;<a name="line.2060"></a>
-<span class="sourceLineNo">2061</span>  }<a name="line.2061"></a>
-<span class="sourceLineNo">2062</span><a name="line.2062"></a>
-<span class="sourceLineNo">2063</span>  @VisibleForTesting<a name="line.2063"></a>
-<span class="sourceLineNo">2064</span>  public RSRpcServices getRSRpcServices() {<a name="line.2064"></a>
-<span class="sourceLineNo">2065</span>    return rpcServices;<a name="line.2065"></a>
-<span class="sourceLineNo">2066</span>  }<a name="line.2066"></a>
-<span class="sourceLineNo">2067</span><a name="line.2067"></a>
-<span class="sourceLineNo">2068</span>  /**<a name="line.2068"></a>
-<span class="sourceLineNo">2069</span>   * Cause the server to exit without closing the regions it is serving, the log<a name="line.2069"></a>
-<span class="sourceLineNo">2070</span>   * it is using and without notifying the master. Used unit testing and on<a name="line.2070"></a>
-<span class="sourceLineNo">2071</span>   * catastrophic events such as HDFS is yanked out from under hbase or we OOME.<a name="line.2071"></a>
-<span class="sourceLineNo">2072</span>   *<a name="line.2072"></a>
-<span class="sourceLineNo">2073</span>   * @param reason<a name="line.2073"></a>
-<span class="sourceLineNo">2074</span>   *          the reason we are aborting<a name="line.2074"></a>
-<span class="sourceLineNo">2075</span>   * @param cause<a name="line.2075"></a>
-<span class="sourceLineNo">2076</span>   *          the exception that caused the abort, or null<a name="line.2076"></a>
-<span class="sourceLineNo">2077</span>   */<a name="line.2077"></a>
+<span class="sourceLineNo">1956</span>    // Update flushed sequence id of a recovering region in ZK<a name="line.1956"></a>
+<span class="sourceLineNo">1957</span>    updateRecoveringRegionLastFlushedSequenceId(r);<a name="line.1957"></a>
+<span class="sourceLineNo">1958</span><a name="line.1958"></a>
+<span class="sourceLineNo">1959</span>    // Notify master<a name="line.1959"></a>
+<span class="sourceLineNo">1960</span>    if (!reportRegionStateTransition(new RegionStateTransitionContext(<a name="line.1960"></a>
+<span class="sourceLineNo">1961</span>        TransitionCode.OPENED, openSeqNum, masterSystemTime, r.getRegionInfo()))) {<a name="line.1961"></a>
+<span class="sourceLineNo">1962</span>      throw new IOException("Failed to report opened region to master: "<a name="line.1962"></a>
+<span class="sourceLineNo">1963</span>        + r.getRegionInfo().getRegionNameAsString());<a name="line.1963"></a>
+<span class="sourceLineNo">1964</span>    }<a name="line.1964"></a>
+<span class="sourceLineNo">1965</span><a name="line.1965"></a>
+<span class="sourceLineNo">1966</span>    triggerFlushInPrimaryRegion((HRegion)r);<a name="line.1966"></a>
+<span class="sourceLineNo">1967</span><a name="line.1967"></a>
+<span class="sourceLineNo">1968</span>    LOG.debug("Finished post open deploy task for " + r.getRegionInfo().getRegionNameAsString());<a name="line.1968"></a>
+<span class="sourceLineNo">1969</span>  }<a name="line.1969"></a>
+<span class="sourceLineNo">1970</span><a name="line.1970"></a>
+<span class="sourceLineNo">1971</span>  @Override<a name="line.1971"></a>
+<span class="sourceLineNo">1972</span>  public boolean reportRegionStateTransition(TransitionCode code, HRegionInfo... hris) {<a name="line.1972"></a>
+<span class="sourceLineNo">1973</span>    return reportRegionStateTransition(code, HConstants.NO_SEQNUM, hris);<a name="line.1973"></a>
+<span class="sourceLineNo">1974</span>  }<a name="line.1974"></a>
+<span class="sourceLineNo">1975</span><a name="line.1975"></a>
+<span class="sourceLineNo">1976</span>  @Override<a name="line.1976"></a>
+<span class="sourceLineNo">1977</span>  public boolean reportRegionStateTransition(<a name="line.1977"></a>
+<span class="sourceLineNo">1978</span>      TransitionCode code, long openSeqNum, HRegionInfo... hris) {<a name="line.1978"></a>
+<span class="sourceLineNo">1979</span>    return reportRegionStateTransition(<a name="line.1979"></a>
+<span class="sourceLineNo">1980</span>      new RegionStateTransitionContext(code, HConstants.NO_SEQNUM, -1, hris));<a name="line.1980"></a>
+<span class="sourceLineNo">1981</span>  }<a name="line.1981"></a>
+<span class="sourceLineNo">1982</span><a name="line.1982"></a>
+<span class="sourceLineNo">1983</span>  @Override<a name="line.1983"></a>
+<span class="sourceLineNo">1984</span>  public boolean reportRegionStateTransition(final RegionStateTransitionContext context) {<a name="line.1984"></a>
+<span class="sourceLineNo">1985</span>    TransitionCode code = context.getCode();<a name="line.1985"></a>
+<span class="sourceLineNo">1986</span>    long openSeqNum = context.getOpenSeqNum();<a name="line.1986"></a>
+<span class="sourceLineNo">1987</span>    long masterSystemTime = context.getMasterSystemTime();<a name="line.1987"></a>
+<span class="sourceLineNo">1988</span>    HRegionInfo[] hris = context.getHris();<a name="line.1988"></a>
+<span class="sourceLineNo">1989</span><a name="line.1989"></a>
+<span class="sourceLineNo">1990</span>    if (TEST_SKIP_REPORTING_TRANSITION) {<a name="line.1990"></a>
+<span class="sourceLineNo">1991</span>      // This is for testing only in case there is no master<a name="line.1991"></a>
+<span class="sourceLineNo">1992</span>      // to handle the region transition report at all.<a name="line.1992"></a>
+<span class="sourceLineNo">1993</span>      if (code == TransitionCode.OPENED) {<a name="line.1993"></a>
+<span class="sourceLineNo">1994</span>        Preconditions.checkArgument(hris != null &amp;&amp; hris.length == 1);<a name="line.1994"></a>
+<span class="sourceLineNo">1995</span>        if (hris[0].isMetaRegion()) {<a name="line.1995"></a>
+<span class="sourceLineNo">1996</span>          try {<a name="line.1996"></a>
+<span class="sourceLineNo">1997</span>            MetaTableLocator.setMetaLocation(getZooKeeper(), serverName,<a name="line.1997"></a>
+<span class="sourceLineNo">1998</span>                hris[0].getReplicaId(),State.OPEN);<a name="line.1998"></a>
+<span class="sourceLineNo">1999</span>          } catch (KeeperException e) {<a name="line.1999"></a>
+<span class="sourceLineNo">2000</span>            LOG.info("Failed to update meta location", e);<a name="line.2000"></a>
+<span class="sourceLineNo">2001</span>            return false;<a name="line.2001"></a>
+<span class="sourceLineNo">2002</span>          }<a name="line.2002"></a>
+<span class="sourceLineNo">2003</span>        } else {<a name="line.2003"></a>
+<span class="sourceLineNo">2004</span>          try {<a name="line.2004"></a>
+<span class="sourceLineNo">2005</span>            MetaTableAccessor.updateRegionLocation(clusterConnection,<a name="line.2005"></a>
+<span class="sourceLineNo">2006</span>              hris[0], serverName, openSeqNum, masterSystemTime);<a name="line.2006"></a>
+<span class="sourceLineNo">2007</span>          } catch (IOException e) {<a name="line.2007"></a>
+<span class="sourceLineNo">2008</span>            LOG.info("Failed to update meta", e);<a name="line.2008"></a>
+<span class="sourceLineNo">2009</span>            return false;<a name="line.2009"></a>
+<span class="sourceLineNo">2010</span>          }<a name="line.2010"></a>
+<span class="sourceLineNo">2011</span>        }<a name="line.2011"></a>
+<span class="sourceLineNo">2012</span>      }<a name="line.2012"></a>
+<span class="sourceLineNo">2013</span>      return true;<a name="line.2013"></a>
+<span class="sourceLineNo">2014</span>    }<a name="line.2014"></a>
+<span class="sourceLineNo">2015</span><a name="line.2015"></a>
+<span class="sourceLineNo">2016</span>    ReportRegionStateTransitionRequest.Builder builder =<a name="line.2016"></a>
+<span class="sourceLineNo">2017</span>      ReportRegionStateTransitionRequest.newBuilder();<a name="line.2017"></a>
+<span class="sourceLineNo">2018</span>    builder.setServer(ProtobufUtil.toServerName(serverName));<a name="line.2018"></a>
+<span class="sourceLineNo">2019</span>    RegionStateTransition.Builder transition = builder.addTransitionBuilder();<a name="line.2019"></a>
+<span class="sourceLineNo">2020</span>    transition.setTransitionCode(code);<a name="line.2020"></a>
+<span class="sourceLineNo">2021</span>    if (code == TransitionCode.OPENED &amp;&amp; openSeqNum &gt;= 0) {<a name="line.2021"></a>
+<span class="sourceLineNo">2022</span>      transition.setOpenSeqNum(openSeqNum);<a name="line.2022"></a>
+<span class="sourceLineNo">2023</span>    }<a name="line.2023"></a>
+<span class="sourceLineNo">2024</span>    for (HRegionInfo hri: hris) {<a name="line.2024"></a>
+<span class="sourceLineNo">2025</span>      transition.addRegionInfo(HRegionInfo.convert(hri));<a name="line.2025"></a>
+<span class="sourceLineNo">2026</span>    }<a name="line.2026"></a>
+<span class="sourceLineNo">2027</span>    ReportRegionStateTransitionRequest request = builder.build();<a name="line.2027"></a>
+<span class="sourceLineNo">2028</span>    while (keepLooping()) {<a name="line.2028"></a>
+<span class="sourceLineNo">2029</span>      RegionServerStatusService.BlockingInterface rss = rssStub;<a name="line.2029"></a>
+<span class="sourceLineNo">2030</span>      try {<a name="line.2030"></a>
+<span class="sourceLineNo">2031</span>        if (rss == null) {<a name="line.2031"></a>
+<span class="sourceLineNo">2032</span>          createRegionServerStatusStub();<a name="line.2032"></a>
+<span class="sourceLineNo">2033</span>          continue;<a name="line.2033"></a>
+<span class="sourceLineNo">2034</span>        }<a name="line.2034"></a>
+<span class="sourceLineNo">2035</span>        ReportRegionStateTransitionResponse response =<a name="line.2035"></a>
+<span class="sourceLineNo">2036</span>          rss.reportRegionStateTransition(null, request);<a name="line.2036"></a>
+<span class="sourceLineNo">2037</span>        if (response.hasErrorMessage()) {<a name="line.2037"></a>
+<span class="sourceLineNo">2038</span>          LOG.info("Failed to transition " + hris[0]<a name="line.2038"></a>
+<span class="sourceLineNo">2039</span>            + " to " + code + ": " + response.getErrorMessage());<a name="line.2039"></a>
+<span class="sourceLineNo">2040</span>          return false;<a name="line.2040"></a>
+<span class="sourceLineNo">2041</span>        }<a name="line.2041"></a>
+<span class="sourceLineNo">2042</span>        return true;<a name="line.2042"></a>
+<span class="sourceLineNo">2043</span>      } catch (ServiceException se) {<a name="line.2043"></a>
+<span class="sourceLineNo">2044</span>        IOException ioe = ProtobufUtil.getRemoteException(se);<a name="line.2044"></a>
+<span class="sourceLineNo">2045</span>        LOG.info("Failed to report region transition, will retry", ioe);<a name="line.2045"></a>
+<span class="sourceLineNo">2046</span>        if (rssStub == rss) {<a name="line.2046"></a>
+<span class="sourceLineNo">2047</span>          rssStub = null;<a name="line.2047"></a>
+<span class="sourceLineNo">2048</span>        }<a name="line.2048"></a>
+<span class="sourceLineNo">2049</span>      }<a name="line.2049"></a>
+<span class="sourceLineNo">2050</span>    }<a name="line.2050"></a>
+<span class="sourceLineNo">2051</span>    return false;<a name="line.2051"></a>
+<span class="sourceLineNo">2052</span>  }<a name="line.2052"></a>
+<span class="sourceLineNo">2053</span><a name="line.2053"></a>
+<span class="sourceLineNo">2054</span>  /**<a name="line.2054"></a>
+<span class="sourceLineNo">2055</span>   * Trigger a flush in the primary region replica if this region is a secondary replica. Does not<a name="line.2055"></a>
+<span class="sourceLineNo">2056</span>   * block this thread. See RegionReplicaFlushHandler for details.<a name="line.2056"></a>
+<span class="sourceLineNo">2057</span>   */<a name="line.2057"></a>
+<span class="sourceLineNo">2058</span>  void triggerFlushInPrimaryRegion(final HRegion region) {<a name="line.2058"></a>
+<span class="sourceLineNo">2059</span>    if (ServerRegionReplicaUtil.isDefaultReplica(region.getRegionInfo())) {<a name="line.2059"></a>
+<span class="sourceLineNo">2060</span>      return;<a name="line.2060"></a>
+<span class="sourceLineNo">2061</span>    }<a name="line.2061"></a>
+<span class="sourceLineNo">2062</span>    if (!ServerRegionReplicaUtil.isRegionReplicaReplicationEnabled(region.conf) ||<a name="line.2062"></a>
+<span class="sourceLineNo">2063</span>        !ServerRegionReplicaUtil.isRegionReplicaWaitForPrimaryFlushEnabled(<a name="line.2063"></a>
+<span class="sourceLineNo">2064</span>          region.conf)) {<a name="line.2064"></a>
+<span class="sourceLineNo">2065</span>      region.setReadsEnabled(true);<a name="line.2065"></a>
+<span class="sourceLineNo">2066</span>      return;<a name="line.2066"></a>
+<span class="sourceLineNo">2067</span>    }<a name="line.2067"></a>
+<span class="sourceLineNo">2068</span><a name="line.2068"></a>
+<span class="sourceLineNo">2069</span>    region.setReadsEnabled(false); // disable reads before marking the region as opened.<a name="line.2069"></a>
+<span class="sourceLineNo">2070</span>    // RegionReplicaFlushHandler might reset this.<a name="line.2070"></a>
+<span class="sourceLineNo">2071</span><a name="line.2071"></a>
+<span class="sourceLineNo">2072</span>    // submit it to be handled by one of the handlers so that we do not block OpenRegionHandler<a name="line.2072"></a>
+<span class="sourceLineNo">2073</span>    this.service.submit(<a name="line.2073"></a>
+<span class="sourceLineNo">2074</span>      new RegionReplicaFlushHandler(this, clusterConnection,<a name="line.2074"></a>
+<span class="sourceLineNo">2075</span>        rpcRetryingCallerFactory, rpcControllerFactory, operationTimeout, region));<a name="line.2075"></a>
+<span class="sourceLineNo">2076</span>  }<a name="line.2076"></a>
+<span class="sourceLineNo">2077</span><a name="line.2077"></a>
 <span class="sourceLineNo">2078</span>  @Override<a name="line.2078"></a>
-<span class="sourceLineNo">2079</span>  public void abort(String reason, Throwable cause) {<a name="line.2079"></a>
-<span class="sourceLineNo">2080</span>    String msg = "ABORTING region server " + this + ": " + reason;<a name="line.2080"></a>
-<span class="sourceLineNo">2081</span>    if (cause != null) {<a name="line.2081"></a>
-<span class="sourceLineNo">2082</span>      LOG.fatal(msg, cause);<a name="line.2082"></a>
-<span class="sourceLineNo">2083</span>    } else {<a name="line.2083"></a>
-<span class="sourceLineNo">2084</span>      LOG.fatal(msg);<a name="line.2084"></a>
-<span class="sourceLineNo">2085</span>    }<a name="line.2085"></a>
-<span class="sourceLineNo">2086</span>    this.abortRequested = true;<a name="line.2086"></a>
-<span class="sourceLineNo">2087</span>    // HBASE-4014: show list of coprocessors that were loaded to help debug<a name="line.2087"></a>
-<span class="sourceLineNo">2088</span>    // regionserver crashes.Note that we're implicitly using<a name="line.2088"></a>
-<span class="sourceLineNo">2089</span>    // java.util.HashSet's toString() method to print the coprocessor names.<a name="line.2089"></a>
-<span class="sourceLineNo">2090</span>    LOG.fatal("RegionServer abort: loaded coprocessors are: " +<a name="line.2090"></a>
-<span class="sourceLineNo">2091</span>        CoprocessorHost.getLoadedCoprocessors());<a name="line.2091"></a>
-<span class="sourceLineNo">2092</span>    // Try and dump metrics if abort -- might give clue as to how fatal came about....<a name="line.2092"></a>
-<span class="sourceLineNo">2093</span>    try {<a name="line.2093"></a>
-<span class="sourceLineNo">2094</span>      LOG.info("Dump of metrics as JSON on abort: " + JSONBean.dumpRegionServerMetrics());<a name="line.2094"></a>
-<span class="sourceLineNo">2095</span>    } catch (MalformedObjectNameException | IOException e) {<a name="line.2095"></a>
-<span class="sourceLineNo">2096</span>      LOG.warn("Failed dumping metrics", e);<a name="line.2096"></a>
-<span class="sourceLineNo">2097</span>    }<a name="line.2097"></a>
-<span class="sourceLineNo">2098</span><a name="line.2098"></a>
-<span class="sourceLineNo">2099</span>    // Do our best to report our abort to the master, but this may not work<a name="line.2099"></a>
-<span class="sourceLineNo">2100</span>    try {<a name="line.2100"></a>
-<span class="sourceLineNo">2101</span>      if (cause != null) {<a name="line.2101"></a>
-<span class="sourceLineNo">2102</span>        msg += "\nCause:\n" + StringUtils.stringifyException(cause);<a name="line.2102"></a>
-<span class="sourceLineNo">2103</span>      }<a name="line.2103"></a>
-<span class="sourceLineNo">2104</span>      // Report to the master but only if we have already registered with the master.<a name="line.2104"></a>
-<span class="sourceLineNo">2105</span>      if (rssStub != null &amp;&amp; this.serverName != null) {<a name="line.2105"></a>
-<span class="sourceLineNo">2106</span>        ReportRSFatalErrorRequest.Builder builder =<a name="line.2106"></a>
-<span class="sourceLineNo">2107</span>          ReportRSFatalErrorRequest.newBuilder();<a name="line.2107"></a>
-<span class="sourceLineNo">2108</span>        ServerName sn =<a name="line.2108"></a>
-<span class="sourceLineNo">2109</span>          ServerName.parseVersionedServerName(this.serverName.getVersionedBytes());<a name="line.2109"></a>
-<span class="sourceLineNo">2110</span>        builder.setServer(ProtobufUtil.toServerName(sn));<a name="line.2110"></a>
-<span class="sourceLineNo">2111</span>        builder.setErrorMessage(msg);<a name="line.2111"></a>
-<span class="sourceLineNo">2112</span>        rssStub.reportRSFatalError(null, builder.build());<a name="line.2112"></a>
-<span class="sourceLineNo">2113</span>      }<a name="line.2113"></a>
-<span class="sourceLineNo">2114</span>    } catch (Throwable t) {<a name="line.2114"></a>
-<span class="sourceLineNo">2115</span>      LOG.warn("Unable to report fatal error to master", t);<a name="line.2115"></a>
-<span class="sourceLineNo">2116</span>    }<a name="line.2116"></a>
-<span class="sourceLineNo">2117</span>    stop(reason);<a name="line.2117"></a>
-<span class="sourceLineNo">2118</span>  }<a name="line.2118"></a>
-<span class="sourceLineNo">2119</span><a name="line.2119"></a>
-<span class="sourceLineNo">2120</span>  /**<a name="line.2120"></a>
-<span class="sourceLineNo">2121</span>   * @see HRegionServer#abort(String, Throwable)<a name="line.2121"></a>
-<span class="sourceLineNo">2122</span>   */<a name="line.2122"></a>
-<span class="sourceLineNo">2123</span>  public void abort(String reason) {<a name="line.2123"></a>
-<span class="sourceLineNo">2124</span>    abort(reason, null);<a name="line.2124"></a>
-<span class="sourceLineNo">2125</span>  }<a name="line.2125"></a>
-<span class="sourceLineNo">2126</span><a name="line.2126"></a>
-<span class="sourceLineNo">2127</span>  @Override<a name="line.2127"></a>
-<span class="sourceLineNo">2128</span>  public boolean isAborted() {<a name="line.2128"></a>
-<span class="sourceLineNo">2129</span>    return this.abortRequested;<a name="line.2129"></a>
-<span class="sourceLineNo">2130</span>  }<a name="line.2130"></a>
-<span class="sourceLineNo">2131</span><a name="line.2131"></a>
-<span class="sourceLineNo">2132</span>  /*<a name="line.2132"></a>
-<span class="sourceLineNo">2133</span>   * Simulate a kill -9 of this server. Exits w/o closing regions or cleaninup<a name="line.2133"></a>
-<span class="sourceLineNo">2134</span>   * logs but it does close socket in case want to bring up server on old<a name="line.2134"></a>
-<span class="sourceLineNo">2135</span>   * hostname+port immediately.<a name="line.2135"></a>
-<span class="sourceLineNo">2136</span>   */<a name="line.2136"></a>
-<span class="sourceLineNo">2137</span>  protected void kill() {<a name="line.2137"></a>
-<span class="sourceLineNo">2138</span>    this.killed = true;<a name="line.2138"></a>
-<span class="sourceLineNo">2139</span>    abort("Simulated kill");<a name="line.2139"></a>
-<span class="sourceLineNo">2140</span>  }<a name="line.2140"></a>
-<span class="sourceLineNo">2141</span><a name="line.2141"></a>
-<span class="sourceLineNo">2142</span>  /**<a name="line.2142"></a>
-<span class="sourceLineNo">2143</span>   * Called on stop/abort before closing the cluster connection and meta locator.<a name="line.2143"></a>
-<span class="sourceLineNo">2144</span>   */<a name="line.2144"></a>
-<span class="sourceLineNo">2145</span>  protected void sendShutdownInterrupt() {<a name="line.2145"></a>
-<span class="sourceLineNo">2146</span>  }<a name="line.2146"></a>
-<span class="sourceLineNo">2147</span><a name="line.2147"></a>
-<span class="sourceLineNo">2148</span>  /**<a name="line.2148"></a>
-<span class="sourceLineNo">2149</span>   * Wait on all threads to finish. Presumption is that all closes and stops<a name="line.2149"></a>
-<span class="sourceLineNo">2150</span>   * have already been called.<a name="line.2150"></a>
-<span class="sourceLineNo">2151</span>   */<a name="line.2151"></a>
-<span class="sourceLineNo">2152</span>  protected void stopServiceThreads() {<a name="line.2152"></a>
-<span class="sourceLineNo">2153</span>    // clean up the scheduled chores<a name="line.2153"></a>
-<span class="sourceLineNo">2154</span>    if (this.choreService != null) choreService.shutdown();<a name="line.2154"></a>
-<span class="sourceLineNo">2155</span>    if (this.nonceManagerChore != null) nonceManagerChore.cancel(true);<a name="line.2155"></a>
-<span class="sourceLineNo">2156</span>    if (this.compactionChecker != null) compactionChecker.cancel(true);<a name="line.2156"></a>
-<span class="sourceLineNo">2157</span>    if (this.periodicFlusher != null) periodicFlusher.cancel(true);<a name="line.2157"></a>
-<span class="sourceLineNo">2158</span>    if (this.healthCheckChore != null) healthCheckChore.cancel(true);<a name="line.2158"></a>
-<span class="sourceLineNo">2159</span>    if (this.storefileRefresher != null) storefileRefresher.cancel(true);<a name="line.2159"></a>
-<span class="sourceLineNo">2160</span>    if (this.movedRegionsCleaner != null) movedRegionsCleaner.cancel(true);<a name="line.2160"></a>
+<span class="sourceLineNo">2079</span>  public RpcServerInterface getRpcServer() {<a name="line.2079"></a>
+<span class="sourceLineNo">2080</span>    return rpcServices.rpcServer;<a name="line.2080"></a>
+<span class="sourceLineNo">2081</span>  }<a name="line.2081"></a>
+<span class="sourceLineNo">2082</span><a name="line.2082"></a>
+<span class="sourceLineNo">2083</span>  @VisibleForTesting<a name="line.2083"></a>
+<span class="sourceLineNo">2084</span>  public RSRpcServices getRSRpcServices() {<a name="line.2084"></a>
+<span class="sourceLineNo">2085</span>    return rpcServices;<a name="line.2085"></a>
+<span class="sourceLineNo">2086</span>  }<a name="line.2086"></a>
+<span class="sourceLineNo">2087</span><a name="line.2087"></a>
+<span class="sourceLineNo">2088</span>  /**<a name="line.2088"></a>
+<span class="sourceLineNo">2089</span>   * Cause the server to exit without closing the regions it is serving, the log<a name="line.2089"></a>
+<span class="sourceLineNo">2090</span>   * it is using and without notifying the master. Used unit testing and on<a name="line.2090"></a>
+<span class="sourceLineNo">2091</span>   * catastrophic events such as HDFS is yanked out from under hbase or we OOME.<a name="line.2091"></a>
+<span class="sourceLineNo">2092</span>   *<a name="line.2092"></a>
+<span class="sourceLineNo">2093</span>   * @param reason<a name="line.2093"></a>
+<span class="sourceLineNo">2094</span>   *          the reason we are aborting<a name="line.2094"></a>
+<span class="sourceLineNo">2095</span>   * @param cause<a name="line.2095"></a>
+<span class="sourceLineNo">2096</span>   *          the exception that caused the abort, or null<a name="line.2096"></a>
+<span class="sourceLineNo">2097</span>   */<a name="line.2097"></a>
+<span class="sourceLineNo">2098</span>  @Override<a name="line.2098"></a>
+<span class="sourceLineNo">2099</span>  public void abort(String reason, Throwable cause) {<a name="line.2099"></a>
+<span class="sourceLineNo">2100</span>    String msg = "ABORTING region server " + this + ": " + reason;<a name="line.2100"></a>
+<span class="sourceLineNo">2101</span>    if (cause != null) {<a name="line.2101"></a>
+<span class="sourceLineNo">2102</span>      LOG.fatal(msg, cause);<a name="line.2102"></a>
+<span class="sourceLineNo">2103</span>    } else {<a name="line.2103"></a>
+<span class="sourceLineNo">2104</span>      LOG.fatal(msg);<a name="line.2104"></a>
+<span class="sourceLineNo">2105</span>    }<a name="line.2105"></a>
+<span class="sourceLineNo">2106</span>    this.abortRequested = true;<a name="line.2106"></a>
+<span class="sourceLineNo">2107</span>    // HBASE-4014: show list of coprocessors that were loaded to help debug<a name="line.2107"></a>
+<span class="sourceLineNo">2108</span>    // regionserver crashes.Note that we're implicitly using<a name="line.2108"></a>
+<span class="sourceLineNo">2109</span>    // java.util.HashSet's toString() method to print the coprocessor names.<a name="line.2109"></a>
+<span class="sourceLineNo">2110</span>    LOG.fatal("RegionServer abort: loaded coprocessors are: " +<a name="line.2110"></a>
+<span class="sourceLineNo">2111</span>        CoprocessorHost.getLoadedCoprocessors());<a name="line.2111"></a>
+<span class="sourceLineNo">2112</span>    // Try and dump metrics if abort -- might give clue as to how fatal came about....<a name="line.2112"></a>
+<span class="sourceLineNo">2113</span>    try {<a name="line.2113"></a>
+<span class="sourceLineNo">2114</span>      LOG.info("Dump of metrics as JSON on abort: " + JSONBean.dumpRegionServerMetrics());<a name="line.2114"></a>
+<span class="sourceLineNo">2115</span>    } catch (MalformedObjectNameException | IOException e) {<a name="line.2115"></a>
+<span class="sourceLineNo">2116</span>      LOG.warn("Failed dumping metrics", e);<a name="line.2116"></a>
+<span class="sourceLineNo">2117</span>    }<a name="line.2117"></a>
+<span class="sourceLineNo">2118</span><a name="line.2118"></a>
+<span class="sourceLineNo">2119</span>    // Do our best to report our abort to the master, but this may not work<a name="line.2119"></a>
+<span class="sourceLineNo">2120</span>    try {<a name="line.2120"></a>
+<span class="sourceLineNo">2121</span>      if (cause != null) {<a name="line.2121"></a>
+<span class="sourceLineNo">2122</span>        msg += "\nCause:\n" + StringUtils.stringifyException(cause);<a name="line.2122"></a>
+<span class="sourceLineNo">2123</span>      }<a name="line.2123"></a>
+<span class="sourceLineNo">2124</span>      // Report to the master but only if we have already registered with the master.<a name="line.2124"></a>
+<span class="sourceLineNo">2125</span>      if (rssStub != null &amp;&amp; this.serverName != null) {<a name="line.2125"></a>
+<span class="sourceLineNo">2126</span>        ReportRSFatalErrorRequest.Builder builder =<a name="line.2126"></a>
+<span class="sourceLineNo">2127</span>          ReportRSFatalErrorRequest.newBuilder();<a name="line.2127"></a>
+<span class="sourceLineNo">2128</span>        ServerName sn =<a name="line.2128"></a>
+<span class="sourceLineNo">2129</span>          ServerName.parseVersionedServerName(this.serverName.getVersionedBytes());<a name="line.2129"></a>
+<span class="sourceLineNo">2130</span>        builder.setServer(ProtobufUtil.toServerName(sn));<a name="line.2130"></a>
+<span class="sourceLineNo">2131</span>        builder.setErrorMessage(msg);<a name="line.2131"></a>
+<span class="sourceLineNo">2132</span>        rssStub.reportRSFatalError(null, builder.build());<a name="line.2132"></a>
+<span class="sourceLineNo">2133</span>      }<a name="line.2133"></a>
+<span class="sourceLineNo">2134</span>    } catch (Throwable t) {<a name="line.2134"></a>
+<span class="sourceLineNo">2135</span>      LOG.warn("Unable to report fatal error to master", t);<a name="line.2135"></a>
+<span class="sourceLineNo">2136</span>    }<a name="line.2136"></a>
+<span class="sourceLineNo">2137</span>    stop(reason);<a name="line.2137"></a>
+<span class="sourceLineNo">2138</span>  }<a name="line.2138"></a>
+<span class="sourceLineNo">2139</span><a name="line.2139"></a>
+<span class="sourceLineNo">2140</span>  /**<a name="line.2140"></a>
+<span class="sourceLineNo">2141</span>   * @see HRegionServer#abort(String, Throwable)<a name="line.2141"></a>
+<span class="sourceLineNo">2142</span>   */<a name="line.2142"></a>
+<span class="sourceLineNo">2143</span>  public void abort(String reason) {<a name="line.2143"></a>
+<span class="sourceLineNo">2144</span>    abort(reason, null);<a name="line.2144"></a>
+<span class="sourceLineNo">2145</span>  }<a name="line.2145"></a>
+<span class="sourceLineNo">2146</span><a name="line.2146"></a>
+<span class="sourceLineNo">2147</span>  @Override<a name="line.2147"></a>
+<span class="sourceLineNo">2148</span>  public boolean isAborted() {<a name="line.2148"></a>
+<span class="sourceLineNo">2149</span>    return this.abortRequested;<a name="line.2149"></a>
+<span class="sourceLineNo">2150</span>  }<a name="line.2150"></a>
+<span class="sourceLineNo">2151</span><a name="line.2151"></a>
+<span class="sourceLineNo">2152</span>  /*<a name="line.2152"></a>
+<span class="sourceLineNo">2153</span>   * Simulate a kill -9 of this server. Exits w/o closing regions or cleaninup<a name="line.2153"></a>
+<span class="sourceLineNo">2154</span>   * logs but it does close socket in case want to bring up server on old<a name="line.2154"></a>
+<span class="sourceLineNo">2155</span>   * hostname+port immediately.<a name="line.2155"></a>
+<span class="sourceLineNo">2156</span>   */<a name="line.2156"></a>
+<span class="sourceLineNo">2157</span>  protected void kill() {<a name="line.2157"></a>
+<span class="sourceLineNo">2158</span>    this.killed = true;<a name="line.2158"></a>
+<span class="sourceLineNo">2159</span>    abort("Simulated kill");<a name="line.2159"></a>
+<span class="sourceLineNo">2160</span>  }<a name="line.2160"></a>
 <span class="sourceLineNo">2161</span><a name="line.2161"></a>
-<span class="sourceLineNo">2162</span>    if (this.cacheFlusher != null) {<a name="line.2162"></a>
-<span class="sourceLineNo">2163</span>      this.cacheFlusher.join();<a name="line.2163"></a>
-<span class="sourceLineNo">2164</span>    }<a name="line.2164"></a>
-<span class="sourceLineNo">2165</span><a name="line.2165"></a>
-<span class="sourceLineNo">2166</span>    if (this.spanReceiverHost != null) {<a name="line.2166"></a>
-<span class="sourceLineNo">2167</span>      this.spanReceiverHost.closeReceivers();<a name="line.2167"></a>
-<span class="sourceLineNo">2168</span>    }<a name="line.2168"></a>
-<span class="sourceLineNo">2169</span>    if (this.walRoller != null) {<a name="line.2169"></a>
-<span class="sourceLineNo">2170</span>      Threads.shutdown(this.walRoller.getThread());<a name="line.2170"></a>
-<span class="sourceLineNo">2171</span>    }<a name="line.2171"></a>
-<span class="sourceLineNo">2172</span>    final LogRoller metawalRoller = this.metawalRoller.get();<a name="line.2172"></a>
-<span class="sourceLineNo">2173</span>    if (metawalRoller != null) {<a name="line.2173"></a>
-<span class="sourceLineNo">2174</span>      Threads.shutdown(metawalRoller.getThread());<a name="line.2174"></a>
-<span class="sourceLineNo">2175</span>    }<a name="line.2175"></a>
-<span class="sourceLineNo">2176</span>    if (this.compactSplitThread != null) {<a name="line.2176"></a>
-<span class="sourceLineNo">2177</span>      this.compactSplitThread.join();<a name="line.2177"></a>
-<span class="sourceLineNo">2178</span>    }<a name="line.2178"></a>
-<span class="sourceLineNo">2179</span>    if (this.service != null) this.service.shutdown();<a name="line.2179"></a>
-<span class="sourceLineNo">2180</span>    if (this.replicationSourceHandler != null &amp;&amp;<a name="line.2180"></a>
-<span class="sourceLineNo">2181</span>        this.replicationSourceHandler == this.replicationSinkHandler) {<a name="line.2181"></a>
-<span class="sourceLineNo">2182</span>      this.replicationSourceHandler.stopReplicationService();<a name="line.2182"></a>
-<span class="sourceLineNo">2183</span>    } else {<a name="line.2183"></a>
-<span class="sourceLineNo">2184</span>      if (this.replicationSourceHandler != null) {<a name="line.2184"></a>
-<span class="sourceLineNo">2185</span>        this.replicationSourceHandler.stopReplicationService();<a name="line.2185"></a>
-<span class="sourceLineNo">2186</span>      }<a name="line.2186"></a>
-<span class="sourceLineNo">2187</span>      if (this.replicationSinkHandler != null) {<a name="line.2187"></a>
-<span class="sourceLineNo">2188</span>        this.replicationSinkHandler.stopReplicationService();<a name="line.2188"></a>
-<span class="sourceLineNo">2189</span>      }<a name="line.2189"></a>
-<span class="sourceLineNo">2190</span>    }<a name="line.2190"></a>
-<span class="sourceLineNo">2191</span>  }<a name="line.2191"></a>
-<span class="sourceLineNo">2192</span><a name="line.2192"></a>
-<span class="sourceLineNo">2193</span>  /**<a name="line.2193"></a>
-<span class="sourceLineNo">2194</span>   * @return Return the object that implements the replication<a name="line.2194"></a>
-<span class="sourceLineNo">2195</span>   * source service.<a name="line.2195"></a>
-<span class="sourceLineNo">2196</span>   */<a name="line.2196"></a>
-<span class="sourceLineNo">2197</span>  ReplicationSourceService getReplicationSourceService() {<a name="line.2197"></a>
-<span class="sourceLineNo">2198</span>    return replicationSourceHandler;<a name="line.2198"></a>
-<span class="sourceLineNo">2199</span>  }<a name="line.2199"></a>
-<span class="sourceLineNo">2200</span><a name="line.2200"></a>
-<span class="sourceLineNo">2201</span>  /**<a name="line.2201"></a>
-<span class="sourceLineNo">2202</span>   * @return Return the object that implements the replication<a name="line.2202"></a>
-<span class="sourceLineNo">2203</span>   * sink service.<a name="line.2203"></a>
-<span class="sourceLineNo">2204</span>   */<a name="line.2204"></a>
-<span class="sourceLineNo">2205</span>  ReplicationSinkService getReplicationSinkService() {<a name="line.2205"></a>
-<span class="sourceLineNo">2206</span>    return replicationSinkHandler;<a name="line.2206"></a>
-<span class="sourceLineNo">2207</span>  }<a name="line.2207"></a>
-<span class="sourceLineNo">2208</span><a name="line.2208"></a>
-<span class="sourceLineNo">2209</span>  /**<a name="line.2209"></a>
-<span class="sourceLineNo">2210</span>   * Get the current master from ZooKeeper and open the RPC connection to it.<a name="line.2210"></a>
-<span class="sourceLineNo">2211</span>   * To get a fresh connection, the current rssStub must be null.<a name="line.2211"></a>
-<span class="sourceLineNo">2212</span>   * Method will block until a master is available. You can break from this<a name="line.2212"></a>
-<span class="sourceLineNo">2213</span>   * block by requesting the server stop.<a name="line.2213"></a>
-<span class="sourceLineNo">2214</span>   *<a name="line.2214"></a>
-<span class="sourceLineNo">2215</span>   * @return master + port, or null if server has been stopped<a name="line.2215"></a>
+<span class="sourceLineNo">2162</span>  /**<a name="line.2162"></a>
+<span class="sourceLineNo">2163</span>   * Called on stop/abort before closing the cluster connection and meta locator.<a name="line.2163"></a>
+<span class="sourceLineNo">2164</span>   */<a name="line.2164"></a>
+<span class="sourceLineNo">2165</span>  protected void sendShutdownInterrupt() {<a name="line.2165"></a>
+<span class="sourceLineNo">2166</span>  }<a name="line.2166"></a>
+<span class="sourceLineNo">2167</span><a name="line.2167"></a>
+<span class="sourceLineNo">2168</span>  /**<a name="line.2168"></a>
+<span class="sourceLineNo">2169</span>   * Wait on all threads to finish. Presumption is that all closes and stops<a name="line.2169"></a>
+<span class="sourceLineNo">2170</span>   * have already been called.<a name="line.2170"></a>
+<span class="sourceLineNo">2171</span>   */<a name="line.2171"></a>
+<span class="sourceLineNo">2172</span>  protected void stopServiceThreads() {<a name="line.2172"></a>
+<span class="sourceLineNo">2173</span>    // clean up the scheduled chores<a name="line.2173"></a>
+<span class="sourceLineNo">2174</span>    if (this.choreService != null) choreService.shutdown();<a name="line.2174"></a>
+<span class="sourceLineNo">2175</span>    if (this.nonceManagerChore != null) nonceManagerChore.cancel(true);<a name="line.2175"></a>
+<span class="sourceLineNo">2176</span>    if (this.compactionChecker != null) compactionChecker.cancel(true);<a name="line.2176"></a>
+<span class="sourceLineNo">2177</span>    if (this.periodicFlusher != null) periodicFlusher.cancel(true);<a name="line.2177"></a>
+<span class="sourceLineNo">2178</span>    if (this.healthCheckChore != null) healthCheckChore.cancel(true);<a name="line.2178"></a>
+<span class="sourceLineNo">2179</span>    if (this.storefileRefresher != null) storefileRefresher.cancel(true);<a name="line.2179"></a>
+<span class="sourceLineNo">2180</span>    if (this.movedRegionsCleaner != null) movedRegionsCleaner.cancel(true);<a name="line.2180"></a>
+<span class="sourceLineNo">2181</span><a name="line.2181"></a>
+<span class="sourceLineNo">2182</span>    if (this.cacheFlusher != null) {<a name="line.2182"></a>
+<span class="sourceLineNo">2183</span>      this.cacheFlusher.join();<a name="line.2183"></a>
+<span class="sourceLineNo">2184</span>    }<a name="line.2184"></a>
+<span class="sourceLineNo">2185</span><a name="line.2185"></a>
+<span class="sourceLineNo">2186</span>    if (this.spanReceiverHost != null) {<a name="line.2186"></a>
+<span class="sourceLineNo">2187</span>      this.spanReceiverHost.closeReceivers();<a name="line.2187"></a>
+<span class="sourceLineNo">2188</span>    }<a name="line.2188"></a>
+<span class="sourceLineNo">2189</span>    if (this.walRoller != null) {<a name="line.2189"></a>
+<span class="sourceLineNo">2190</span>      Threads.shutdown(this.walRoller.getThread());<a name="line.2190"></a>
+<span class="sourceLineNo">2191</span>    }<a name="line.2191"></a>
+<span class="sourceLineNo">2192</span>    final LogRoller metawalRoller = this.metawalRoller.get();<a name="line.2192"></a>
+<span class="sourceLineNo">2193</span>    if (metawalRoller != null) {<a name="line.2193"></a>
+<span class="sourceLineNo">2194</span>      Threads.shutdown(metawalRoller.getThread());<a name="line.2194"></a>
+<span class="sourceLineNo">2195</span>    }<a name="line.2195"></a>
+<span class="sourceLineNo">2196</span>    if (this.compactSplitThread != null) {<a name="line.2196"></a>
+<span class="sourceLineNo">2197</span>      this.compactSplitThread.join();<a name="line.2197"></a>
+<span class="sourceLineNo">2198</span>    }<a name="line.2198"></a>
+<span class="sourceLineNo">2199</span>    if (this.service != null) this.service.shutdown();<a name="line.2199"></a>
+<span class="sourceLineNo">2200</span>    if (this.replicationSourceHandler != null &amp;&amp;<a name="line.2200"></a>
+<span class="sourceLineNo">2201</span>        this.replicationSourceHandler == this.replicationSinkHandler) {<a name="line.2201"></a>
+<span class="sourceLineNo">2202</span>      this.replicationSourceHandler.stopReplicationService();<a name="line.2202"></a>
+<span class="sourceLineNo">2203</span>    } else {<a name="line.2203"></a>
+<span class="sourceLineNo">2204</span>      if (this.replicationSourceHandler != null) {<a name="line.2204"></a>
+<span class="sourceLineNo">2205</span>        this.replicationSourceHandler.stopReplicationService();<a name="line.2205"></a>
+<span class="sourceLineNo">2206</span>      }<a name="line.2206"></a>
+<span class="sourceLineNo">2207</span>      if (this.replicationSinkHandler != null) {<a name="line.2207"></a>
+<span class="sourceLineNo">2208</span>        this.replicationSinkHandler.stopReplicationService();<a name="line.2208"></a>
+<span class="sourceLineNo">2209</span>      }<a name="line.2209"></a>
+<span class="sourceLineNo">2210</span>    }<a name="line.2210"></a>
+<span class="sourceLineNo">2211</span>  }<a name="line.2211"></a>
+<span class="sourceLineNo">2212</span><a name="line.2212"></a>
+<span class="sourceLineNo">2213</span>  /**<a name="line.2213"></a>
+<span class="sourceLineNo">2214</span>   * @return Return the object that implements the replication<a name="line.2214"></a>
+<span class="sourceLineNo">2215</span>   * source service.<a name="line.2215"></a>
 <span class="sourceLineNo">2216</span>   */<a name="line.2216"></a>
-<span class="sourceLineNo">2217</span>  @VisibleForTesting<a name="line.2217"></a>
-<span class="sourceLineNo">2218</span>  protected synchronized ServerName createRegionServerStatusStub() {<a name="line.2218"></a>
-<span class="sourceLineNo">2219</span>    if (rssStub != null) {<a name="line.2219"></a>
-<span class="sourceLineNo">2220</span>      return masterAddressTracker.getMasterAddress();<a name="line.2220"></a>
-<span class="sourceLineNo">2221</span>    }<a name="line.2221"></a>
-<span class="sourceLineNo">2222</span>    ServerName sn = null;<a name="line.2222"></a>
-<span class="sourceLineNo">2223</span>    long previousLogTime = 0;<a name="line.2223"></a>
-<span class="sourceLineNo">2224</span>    boolean refresh = false; // for the first time, use cached data<a name="line.2224"></a>
-<span class="sourceLineNo">2225</span>    RegionServerStatusService.BlockingInterface intf = null;<a name="line.2225"></a>
-<span class="sourceLineNo">2226</span>    boolean interrupted = false;<a name="line.2226"></a>
-<span class="sourceLineNo">2227</span>    try {<a name="line.2227"></a>
-<span class="sourceLineNo">2228</span>      while (keepLooping()) {<a name="line.2228"></a>
-<span class="sourceLineNo">2229</span>        sn = this.masterAddressTracker.getMasterAddress(refresh);<a name="line.2229"></a>
-<span class="sourceLineNo">2230</span>        if (sn == null) {<a name="line.2230"></a>
-<span class="sourceLineNo">2231</span>          if (!keepLooping()) {<a name="line.2231"></a>
-<span class="sourceLineNo">2232</span>            // give up with no connection.<a name="line.2232"></a>
-<span class="sourceLineNo">2233</span>            LOG.debug("No master found and cluster is stopped; bailing out");<a name="line.2233"></a>
-<span class="sourceLineNo">2234</span>            return null;<a name="line.2234"></a>
-<span class="sourceLineNo">2235</span>          }<a name="line.2235"></a>
-<span class="sourceLineNo">2236</span>          if (System.currentTimeMillis() &gt; (previousLogTime + 1000)) {<a name="line.2236"></a>
-<span class="sourceLineNo">2237</span>            LOG.debug("No master found; retry");<a name="line.2237"></a>
-<span class="sourceLineNo">2238</span>            previousLogTime = System.currentTimeMillis();<a name="line.2238"></a>
-<span class="sourceLineNo">2239</span>          }<a name="line.2239"></a>
-<span class="sourceLineNo">2240</span>          refresh = true; // let's try pull it from ZK directly<a name="line.2240"></a>
-<span class="sourceLineNo">2241</span>          if (sleep(200)) {<a name="line.2241"></a>
-<span class="sourceLineNo">2242</span>            interrupted = true;<a name="line.2242"></a>
-<span class="sourceLineNo">2243</span>          }<a name="line.2243"></a>
-<span class="sourceLineNo">2244</span>          continue;<a name="line.2244"></a>
-<span class="sourceLineNo">2245</span>        }<a name="line.2245"></a>
-<span class="sourceLineNo">2246</span><a name="line.2246"></a>
-<span class="sourceLineNo">2247</span>        // If we are on the active master, use the shortcut<a name="line.2247"></a>
-<span class="sourceLineNo">2248</span>        if (this instanceof HMaster &amp;&amp; sn.equals(getServerName())) {<a name="line.2248"></a>
-<span class="sourceLineNo">2249</span>          intf = ((HMaster)this).getMasterRpcServices();<a name="line.2249"></a>
-<span class="sourceLineNo">2250</span>          break;<a name="line.2250"></a>
-<span class="sourceLineNo">2251</span>        }<a name="line.2251"></a>
-<span class="sourceLineNo">2252</span>        try {<a name="line.2252"></a>
-<span class="sourceLineNo">2253</span>          BlockingRpcChannel channel =<a name="line.2253"></a>
-<span class="sourceLineNo">2254</span>            this.rpcClient.createBlockingRpcChannel(sn, userProvider.getCurrent(),<a name="line.2254"></a>
-<span class="sourceLineNo">2255</span>              shortOperationTimeout);<a name="line.2255"></a>
-<span class="sourceLineNo">2256</span>          intf = RegionServerStatusService.newBlockingStub(channel);<a name="line.2256"></a>
-<span class="sourceLineNo">2257</span>          break;<a name="line.2257"></a>
-<span class="sourceLineNo">2258</span>        } catch (IOException e) {<a name="line.2258"></a>
-<span class="sourceLineNo">2259</span>          if (System.currentTimeMillis() &gt; (previousLogTime + 1000)) {<a name="line.2259"></a>
-<span class="sourceLineNo">2260</span>            e = e instanceof RemoteException ?<a name="line.2260"></a>
-<span class="sourceLineNo">2261</span>              ((RemoteException)e).unwrapRemoteException() : e;<a name="line.2261"></a>
-<span class="sourceLineNo">2262</span>            if (e instanceof ServerNotRunningYetException) {<a name="line.2262"></a>
-<span class="sourceLineNo">2263</span>              LOG.info("Master isn't available yet, retrying");<a name="line.2263"></a>
-<span class="sourceLineNo">2264</span>            } else {<a name="line.2264"></a>
-<span class="sourceLineNo">2265</span>              LOG.warn("Unable to connect to master. Retrying. Error was:", e);<a name="line.2265"></a>
-<span class="sourceLineNo">2266</span>            }<a name="line.2266"></a>
-<span class="sourceLineNo">2267</span>            previousLogTime = System.currentTimeMillis();<a name="line.2267"></a>
-<span class="sourceLineNo">2268</span>          }<a name="line.2268"></a>
-<span class="sourceLineNo">2269</span>          if (sleep(200)) {<a name="line.2269"></a>
-<span class="sourceLineNo">2270</span>            interrupted = true;<a name="line.2270"></a>
-<span class="sourceLineNo">2271</span>          }<a name="line.2271"></a>
-<span class="sourceLineNo">2272</span>        }<a name="line.2272"></a>
-<span class="sourceLineNo">2273</span>      }<a name="line.2273"></a>
-<span class="sourceLineNo">2274</span>    } finally {<a name="line.2274"></a>
-<span class="sourceLineNo">2275</span>      if (interrupted) {<a name="line.2275"></a>
-<span class="sourceLineNo">2276</span>        Thread.currentThread().interrupt();<a name="line.2276"></a>
-<span class="sourceLineNo">2277</span>      }<a name="line.2277"></a>
-<span class="sourceLineNo">2278</span>    }<a name="line.2278"></a>
-<span class="sourceLineNo">2279</span>    rssStub = intf;<a name="line.2279"></a>
-<span class="sourceLineNo">2280</span>    return sn;<a name="line.2280"></a>
-<span class="sourceLineNo">2281</span>  }<a name="line.2281"></a>
-<span class="sourceLineNo">2282</span><a name="line.2282"></a>
-<span class="sourceLineNo">2283</span>  /**<a name="line.2283"></a>
-<span class="sourceLineNo">2284</span>   * @return True if we should break loop because cluster is going down or<a name="line.2284"></a>
-<span class="sourceLineNo">2285</span>   * this server has been stopped or hdfs has gone bad.<a name="line.2285"></a>
-<span class="sourceLineNo">2286</span>   */<a name="line.2286"></a>
-<span class="sourceLineNo">2287</span>  private boolean keepLooping() {<a name="line.2287"></a>
-<span class="sourceLineNo">2288</span>    return !this.stopped &amp;&amp; isClusterUp();<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>  /*<a name="line.2291"></a>
-<span class="sourceLineNo">2292</span>   * Let the master know we're here Run initialization using parameters passed<a name="line.2292"></a>
-<span class="sourceLineNo">2293</span>   * us by the master.<a name="line.2293"></a>
-<span class="sourceLineNo">2294</span>   * @return A Map of key/value configurations we got from the Master else<a name="line.2294"></a>
-<span class="sourceLineNo">2295</span>   * null if we failed to register.<a name="line.2295"></a>
-<span class="sourceLineNo">2296</span>   * @throws IOException<a name="line.2296"></a>
-<span class="sourceLineNo">2297</span>   */<a name="line.2297"></a>
-<span class="sourceLineNo">2298</span>  private RegionServerStartupResponse reportForDuty() throws IOException {<a name="line.2298"></a>
-<span class="sourceLineNo">2299</span>    ServerName masterServerName = createRegionServerStatusStub();<a name="line.2299"></a>
-<span class="sourceLineNo">2300</span>    if (masterServerName == null) return null;<a name="line.2300"></a>
-<span class="sourceLineNo">2301</span>    RegionServerStartupResponse result = null;<a name="line.2301"></a>
-<span class="sourceLineNo">2302</span>    try {<a name="line.2302"></a>
-<span class="sourceLineNo">2303</span>      rpcServices.requestCount.set(0);<a name="line.2303"></a>
-<span class="sourceLineNo">2304</span>      LOG.info("reportForDuty to master=" + masterServerName + " with port="<a name="line.2304"></a>
-<span class="sourceLineNo">2305</span>        + rpcServices.isa.getPort() + ", startcode=" + this.startcode);<a name="line.2305"></a>
-<span class="sourceLineNo">2306</span>      long now = EnvironmentEdgeManager.currentTime();<a name="line.2306"></a>
-<span class="sourceLineNo">2307</span>      int port = rpcServices.isa.getPort();<a name="line.2307"></a>
-<span class="sourceLineNo">2308</span>      RegionServerStartupRequest.Builder request = RegionServerStartupRequest.newBuilder();<a name="line.2308"></a>
-<span class="sourceLineNo">2309</span>      if (shouldUseThisHostnameInstead()) {<a name="line.2309"></a>
-<span class="sourceLineNo">2310</span>        request.setUseThisHostnameInstead(useThisHostnameInstead);<a name="line.2310"></a>
-<span class="sourceLineNo">2311</span>      }<a name="line.2311"></a>
-<span class="sourceLineNo">2312</span>      request.setPort(port);<a name="line.2312"></a>
-<span class="sourceLineNo">2313</span>      request.setServerStartCode(this.startcode);<a name="line.2313"></a>
-<span class="sourceLineNo">2314</span>      request.setServerCurrentTime(now);<a name="line.2314"></a>
-<span class="sourceLineNo">2315</span>      result = this.rssStub.regionServerStartup(null, request.build());<a name="line.2315"></a>
-<span class="sourceLineNo">2316</span>    } catch (ServiceException se) {<a name="line.2316"></a>
-<span class="sourceLineNo">2317</span>      IOException ioe = ProtobufUtil.getRemoteException(se);<a name="line.2317"></a>
-<span class="sourceLineNo">2318</span>      if (ioe instanceof ClockOutOfSyncException) {<a name="line.2318"></a>
-<span class="sourceLineNo">2319</span>        LOG.fatal("Master rejected startup because clock is out of sync", ioe);<a name="line.2319"></a>
-<span class="sourceLineNo">2320</span>        // Re-throw IOE will cause RS to abort<a name="line.2320"></a>
-<span class="sourceLineNo">2321</span>        throw ioe;<a name="line.2321"></a>
-<span class="sourceLineNo">2322</span>      } else if (ioe instanceof ServerNotRunningYetException) {<a name="line.2322"></a>
-<span class="sourceLineNo">2323</span>        LOG.debug("Master is not running yet");<a name="line.2323"></a>
-<span class="sourceLineNo">2324</span>      } else {<a name="line.2324"></a>
-<span class="sourceLineNo">2325</span>        LOG.warn("error telling master we are up", se);<a name="line.2325"></a>
-<span class="sourceLineNo">2326</span>      }<a name="line.2326"></a>
-<span class="sourceLineNo">2327</span>      rssStub = null;<a name="line.2327"></a>
-<span class="sourceLineNo">2328</span>    }<a name="line.2328"></a>
-<span class="sourceLineNo">2329</span>    return result;<a name="line.2329"></a>
-<span class="sourceLineNo">2330</span>  }<a name="line.2330"></a>
-<span class="sourceLineNo">2331</span><a name="line.2331"></a>
-<span class="sourceLineNo">2332</span>  @Override<a name="line.2332"></a>
-<span class="sourceLineNo">2333</span>  public RegionStoreSequenceIds getLastSequenceId(byte[] encodedRegionName) {<a name="line.2333"></a>
-<span class="sourceLineNo">2334</span>    try {<a name="line.2334"></a>
-<span class="sourceLineNo">2335</span>      GetLastFlushedSequenceIdRequest req =<a name="line.2335"></a>
-<span class="sourceLineNo">2336</span>          RequestConverter.buildGetLastFlushedSequenceIdRequest(encodedRegionName);<a name="line.2336"></a>
-<span class="sourceLineNo">2337</span>      RegionServerStatusService.BlockingInterface rss = rssStub;<a name="line.2337"></a>
-<span class="sourceLineNo">2338</span>      if (rss == null) { // Try to connect one more time<a name="line.2338"></a>
-<span class="sourceLineNo">2339</span>        createRegionServerStatusStub();<a name="line.2339"></a>
-<span class="sourceLineNo">2340</span>        rss = rssStub;<a name="line.2340"></a>
-<span class="sourceLineNo">2341</span>        if (rss == null) {<a name="line.2341"></a>
-<span class="sourceLineNo">2342</span>          // Still no luck, we tried<a name="line.2342"></a>
-<span class="sourceLineNo">2343</span>          LOG.warn("Unable to connect to the master to check " + "the last flushed sequence id");<a name="line.2343"></a>
-<span class="sourceLineNo">2344</span>          return RegionStoreSequenceIds.newBuilder().setLastFlushedSequenceId(HConstants.NO_SEQNUM)<a name="line.2344"></a>
-<span class="sourceLineNo">2345</span>              .build();<a name="line.2345"></a>
-<span class="sourceLineNo">2346</span>        }<a name="line.2346"></a>
-<span class="sourceLineNo">2347</span>      }<a name="line.2347"></a>
-<span class="sourceLineNo">2348</span>      GetLastFlushedSequenceIdResponse resp = rss.getLastFlushedSequenceId(null, req);<a name="line.2348"></a>
-<span class="sourceLineNo">2349</span>      return RegionStoreSequenceIds.newBuilder()<a name="line.2349"></a>
-<span class="sourceLineNo">2350</span>          .setLastFlushedSequenceId(resp.getLastFlushedSequenceId())<a name="line.2350"></a>
-<span class="sourceLineNo">2351</span>          .addAllStoreSequenceId(resp.getStoreLastFlushedSequenceIdList()).build();<a name="line.2351"></a>
-<span class="sourceLineNo">2352</span>    } catch (ServiceException e) {<a name="line.2352"></a>
-<span class="sourceLineNo">2353</span>      LOG.warn("Unable to connect to the master to check the last flushed sequence id", e);<a name="line.2353"></a>
-<span class="sourceLineNo">2354</span>      return RegionStoreSequenceIds.newBuilder().setLastFlushedSequenceId(HConstants.NO_SEQNUM)<a name="line.2354"></a>
-<span class="sourceLineNo">2355</span>          .build();<a name="line.2355"></a>
-<span class="sourceLineNo">2356</span>    }<a name="line.2356"></a>
-<span class="sourceLineNo">2357</span>  }<a name="line.2357"></a>
-<span class="sourceLineNo">2358</span><a name="line.2358"></a>
-<span class="sourceLineNo">2359</span>  /**<a name="line.2359"></a>
-<span class="sourceLineNo">2360</span>   * Closes all regions.  Called on our way out.<a name="line.2360"></a>
-<span class="sourceLineNo">2361</span>   * Assumes that its not possible for new regions to be added to onlineRegions<a name="line.2361"></a>
-<span class="sourceLineNo">2362</span>   * while this method runs.<a name="line.2362"></a>
-<span class="sourceLineNo">2363</span>   */<a name="line.2363"></a>
-<span class="sourceLineNo">2364</span>  protected void closeAllRegions(final boolean abort) {<a name="line.2364"></a>
-<span class="sourceLineNo">2365</span>    closeUserRegions(abort);<a name="line.2365"></a>
-<span class="sourceLineNo">2366</span>    closeMetaTableRegions(abort);<a name="line.2366"></a>
-<span class="sourceLineNo">2367</span>  }<a name="line.2367"></a>
-<span class="sourceLineNo">2368</span><a name="line.2368"></a>
-<span class="sourceLineNo">2369</span>  /**<a name="line.2369"></a>
-<span class="sourceLineNo">2370</span>   * Close meta region if we carry it<a name="line.2370"></a>
-<span class="sourceLineNo">2371</span>   * @param abort Whether we're running an abort.<a name="line.2371"></a>
-<span class="sourceLineNo">2372</span>   */<a name="line.2372"></a>
-<span class="sourceLineNo">2373</span>  void closeMetaTableRegions(final boolean abort) {<a name="line.2373"></a>
-<span class="sourceLineNo">2374</span>    Region meta = null;<a name="line.2374"></a>
-<span class="sourceLineNo">2375</span>    this.lock.writeLock().lock();<a name="line.2375"></a>
-<span class="sourceLineNo">2376</span>    try {<a name="line.2376"></a>
-<span class="sourceLineNo">2377</span>      for (Map.Entry&lt;String, Region&gt; e: onlineRegions.entrySet()) {<a name="line.2377"></a>
-<span class="sourceLineNo">2378</span>        HRegionInfo hri = e.getValue().getRegionInfo();<a name="line.2378"></a>
-<span class="sourceLineNo">2379</span>        if (hri.isMetaRegion()) {<a name="line.2379"></a>
-<span class="sourceLineNo">2380</span>          meta = e.getValue();<a name="line.2380"></a>
-<span class="sourceLineNo">2381</span>        }<a name="line.2381"></a>
-<span class="sourceLineNo">2382</span>        if (meta != null) break;<a name="line.2382"></a>
-<span class="sourceLineNo">2383</span>      }<a name="line.2383"></a>
-<span class="sourceLineNo">2384</span>    } finally {<a name="line.2384"></a>
-<span class="sourceLineNo">2385</span>      this.lock.writeLock().unlock();<a name="line.2385"></a>
-<span class="sourceLineNo">2386</span>    }<a name="line.2386"></a>
-<span class="sourceLineNo">2387</span>    if (meta != null) closeRegionIgnoreErrors(meta.getRegionInfo(), abort);<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>  /**<a name="line.2390"></a>
-<span class="sourceLineNo">2391</span>   * Schedule closes on all user regions.<a name="line.2391"></a>
-<span class="sourceLineNo">2392</span>   * Should be safe calling multiple times because it wont' close regions<a name="line.2392"></a>
-<span class="sourceLineNo">2393</span>   * that are already closed or that are closing.<a name="line.2393"></a>
-<span class="sourceLineNo">2394</span>   * @param abort Whether we're running an abort.<a name="line.2394"></a>
-<span class="sourceLineNo">2395</span>   */<a name="line.2395"></a>
-<span class="sourceLineNo">2396</span>  void closeUserRegions(final boolean abort) {<a name="line.2396"></a>
-<span class="sourceLineNo">2397</span>    this.lock.writeLock().lock();<a name="line.2397"></a>
-<span class="sourceLineNo">2398</span>    try {<a name="line.2398"></a>
-<span class="sourceLineNo">2399</span>      for (Map.Entry&lt;String, Region&gt; e: this.onlineRegions.entrySet()) {<a name="line.2399"></a>
-<span class="sourceLineNo">2400</span>        Region r = e.getValue();<a name="line.2400"></a>
-<span class="sourceLineNo">2401</span>        if (!r.getRegionInfo().isMetaTable() &amp;&amp; r.isAvailable()) {<a name="line.2401"></a>
-<span class="sourceLineNo">2402</span>          // Don't update zk with this close transition; pass false.<a name="line.2402"></a>
-<span class="sourceLineNo">2403</span>          closeRegionIgnoreErrors(r.getRegionInfo(), abort);<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>    } finally {<a name="line.2406"></a>
-<span class="sourceLineNo">2407</span>      this.lock.writeLock().unlock();<a name="line.2407"></a>
-<span class="sourceLineNo">2408</span>    }<a name="line.2408"></a>
-<span class="sourceLineNo">2409</span>  }<a name="line.2409"></a>
-<span class="sourceLineNo">2410</span><a name="line.2410"></a>
-<span class="sourceLineNo">2411</span>  /** @return the info server */<a name="line.2411"></a>
-<span class="sourceLineNo">2412</span>  public InfoServer getInfoServer() {<a name="line.2412"></a>
-<span class="sourceLineNo">2413</span>    return infoServer;<a name="line.2413"></a>
-<span class="sourceLineNo">2414</span>  }<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>   * @return true if a stop has been requested.<a name="line.2417"></a>
-<span class="sourceLineNo">2418</span>   */<a name="line.2418"></a>
-<span class="sourceLineNo">2419</span>  @Override<a name="line.2419"></a>
-<span class="sourceLineNo">2420</span>  public boolean isStopped() {<a name="line.2420"></a>
-<span class="sourceLineNo">2421</span>    return this.stopped;<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>  @Override<a name="line.2424"></a>
-<span class="sourceLineNo">2425</span>  public boolean isStopping() {<a name="line.2425"></a>
-<span class="sourceLineNo">2426</span>    return this.stopping;<a name="line.2426"></a>
-<span class="sourceLineNo">2427</span>  }<a name="line.2427"></a>
-<span class="sourceLineNo">2428</span><a name="line.2428"></a>
-<span class="sourceLineNo">2429</span>  @Override<a name="line.2429"></a>
-<span class="sourceLineNo">2430</span>  public Map&lt;String, Region&gt; getRecoveringRegions() {<a name="line.2430"></a>
-<span class="sourceLineN

<TRUNCATED>

Mime
View raw message