hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [11/51] [partial] hbase-site git commit: Published site at 95a13b51ee052eb73882682e8f009bfa1e914866.
Date Tue, 22 Dec 2015 23:24:34 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/32d40534/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALSplitter.SinkWriter.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALSplitter.SinkWriter.html b/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALSplitter.SinkWriter.html
index f3aed1b..0597160 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALSplitter.SinkWriter.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALSplitter.SinkWriter.html
@@ -1513,810 +1513,816 @@
 <span class="sourceLineNo">1505</span>      if (maxSeqIdInStores == null || maxSeqIdInStores.isEmpty()) {<a name="line.1505"></a>
 <span class="sourceLineNo">1506</span>        return;<a name="line.1506"></a>
 <span class="sourceLineNo">1507</span>      }<a name="line.1507"></a>
-<span class="sourceLineNo">1508</span>      List&lt;Cell&gt; skippedCells = new ArrayList&lt;Cell&gt;();<a name="line.1508"></a>
-<span class="sourceLineNo">1509</span>      for (Cell cell : logEntry.getEdit().getCells()) {<a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>        if (!CellUtil.matchingFamily(cell, WALEdit.METAFAMILY)) {<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>          byte[] family = CellUtil.cloneFamily(cell);<a name="line.1511"></a>
-<span class="sourceLineNo">1512</span>          Long maxSeqId = maxSeqIdInStores.get(family);<a name="line.1512"></a>
-<span class="sourceLineNo">1513</span>          // Do not skip cell even if maxSeqId is null. Maybe we are in a rolling upgrade,<a name="line.1513"></a>
-<span class="sourceLineNo">1514</span>          // or the master was crashed before and we can not get the information.<a name="line.1514"></a>
-<span class="sourceLineNo">1515</span>          if (maxSeqId != null &amp;&amp; maxSeqId.longValue() &gt;= logEntry.getKey().getLogSeqNum()) {<a name="line.1515"></a>
-<span class="sourceLineNo">1516</span>            skippedCells.add(cell);<a name="line.1516"></a>
-<span class="sourceLineNo">1517</span>          }<a name="line.1517"></a>
-<span class="sourceLineNo">1518</span>        }<a name="line.1518"></a>
-<span class="sourceLineNo">1519</span>      }<a name="line.1519"></a>
-<span class="sourceLineNo">1520</span>      if (!skippedCells.isEmpty()) {<a name="line.1520"></a>
-<span class="sourceLineNo">1521</span>        logEntry.getEdit().getCells().removeAll(skippedCells);<a name="line.1521"></a>
-<span class="sourceLineNo">1522</span>      }<a name="line.1522"></a>
-<span class="sourceLineNo">1523</span>    }<a name="line.1523"></a>
+<span class="sourceLineNo">1508</span>      // Create the array list for the cells that aren't filtered.<a name="line.1508"></a>
+<span class="sourceLineNo">1509</span>      // We make the assumption that most cells will be kept.<a name="line.1509"></a>
+<span class="sourceLineNo">1510</span>      ArrayList&lt;Cell&gt; keptCells = new ArrayList&lt;Cell&gt;(logEntry.getEdit().getCells().size());<a name="line.1510"></a>
+<span class="sourceLineNo">1511</span>      for (Cell cell : logEntry.getEdit().getCells()) {<a name="line.1511"></a>
+<span class="sourceLineNo">1512</span>        if (CellUtil.matchingFamily(cell, WALEdit.METAFAMILY)) {<a name="line.1512"></a>
+<span class="sourceLineNo">1513</span>          keptCells.add(cell);<a name="line.1513"></a>
+<span class="sourceLineNo">1514</span>        } else {<a name="line.1514"></a>
+<span class="sourceLineNo">1515</span>          byte[] family = CellUtil.cloneFamily(cell);<a name="line.1515"></a>
+<span class="sourceLineNo">1516</span>          Long maxSeqId = maxSeqIdInStores.get(family);<a name="line.1516"></a>
+<span class="sourceLineNo">1517</span>          // Do not skip cell even if maxSeqId is null. Maybe we are in a rolling upgrade,<a name="line.1517"></a>
+<span class="sourceLineNo">1518</span>          // or the master was crashed before and we can not get the information.<a name="line.1518"></a>
+<span class="sourceLineNo">1519</span>          if (maxSeqId == null || maxSeqId.longValue() &lt; logEntry.getKey().getLogSeqNum()) {<a name="line.1519"></a>
+<span class="sourceLineNo">1520</span>            keptCells.add(cell);<a name="line.1520"></a>
+<span class="sourceLineNo">1521</span>          }<a name="line.1521"></a>
+<span class="sourceLineNo">1522</span>        }<a name="line.1522"></a>
+<span class="sourceLineNo">1523</span>      }<a name="line.1523"></a>
 <span class="sourceLineNo">1524</span><a name="line.1524"></a>
-<span class="sourceLineNo">1525</span>    @Override<a name="line.1525"></a>
-<span class="sourceLineNo">1526</span>    public void append(RegionEntryBuffer buffer) throws IOException {<a name="line.1526"></a>
-<span class="sourceLineNo">1527</span>      List&lt;Entry&gt; entries = buffer.entryBuffer;<a name="line.1527"></a>
-<span class="sourceLineNo">1528</span>      if (entries.isEmpty()) {<a name="line.1528"></a>
-<span class="sourceLineNo">1529</span>        LOG.warn("got an empty buffer, skipping");<a name="line.1529"></a>
-<span class="sourceLineNo">1530</span>        return;<a name="line.1530"></a>
-<span class="sourceLineNo">1531</span>      }<a name="line.1531"></a>
-<span class="sourceLineNo">1532</span><a name="line.1532"></a>
-<span class="sourceLineNo">1533</span>      WriterAndPath wap = null;<a name="line.1533"></a>
-<span class="sourceLineNo">1534</span><a name="line.1534"></a>
-<span class="sourceLineNo">1535</span>      long startTime = System.nanoTime();<a name="line.1535"></a>
-<span class="sourceLineNo">1536</span>      try {<a name="line.1536"></a>
-<span class="sourceLineNo">1537</span>        int editsCount = 0;<a name="line.1537"></a>
+<span class="sourceLineNo">1525</span>      // Anything in the keptCells array list is still live.<a name="line.1525"></a>
+<span class="sourceLineNo">1526</span>      // So rather than removing the cells from the array list<a name="line.1526"></a>
+<span class="sourceLineNo">1527</span>      // which would be an O(n^2) operation, we just replace the list<a name="line.1527"></a>
+<span class="sourceLineNo">1528</span>      logEntry.getEdit().setCells(keptCells);<a name="line.1528"></a>
+<span class="sourceLineNo">1529</span>    }<a name="line.1529"></a>
+<span class="sourceLineNo">1530</span><a name="line.1530"></a>
+<span class="sourceLineNo">1531</span>    @Override<a name="line.1531"></a>
+<span class="sourceLineNo">1532</span>    public void append(RegionEntryBuffer buffer) throws IOException {<a name="line.1532"></a>
+<span class="sourceLineNo">1533</span>      List&lt;Entry&gt; entries = buffer.entryBuffer;<a name="line.1533"></a>
+<span class="sourceLineNo">1534</span>      if (entries.isEmpty()) {<a name="line.1534"></a>
+<span class="sourceLineNo">1535</span>        LOG.warn("got an empty buffer, skipping");<a name="line.1535"></a>
+<span class="sourceLineNo">1536</span>        return;<a name="line.1536"></a>
+<span class="sourceLineNo">1537</span>      }<a name="line.1537"></a>
 <span class="sourceLineNo">1538</span><a name="line.1538"></a>
-<span class="sourceLineNo">1539</span>        for (Entry logEntry : entries) {<a name="line.1539"></a>
-<span class="sourceLineNo">1540</span>          if (wap == null) {<a name="line.1540"></a>
-<span class="sourceLineNo">1541</span>            wap = getWriterAndPath(logEntry);<a name="line.1541"></a>
-<span class="sourceLineNo">1542</span>            if (wap == null) {<a name="line.1542"></a>
-<span class="sourceLineNo">1543</span>              if (LOG.isDebugEnabled()) {<a name="line.1543"></a>
-<span class="sourceLineNo">1544</span>                LOG.debug("getWriterAndPath decided we don't need to write edits for " + logEntry);<a name="line.1544"></a>
-<span class="sourceLineNo">1545</span>              }<a name="line.1545"></a>
-<span class="sourceLineNo">1546</span>              return;<a name="line.1546"></a>
-<span class="sourceLineNo">1547</span>            }<a name="line.1547"></a>
-<span class="sourceLineNo">1548</span>          }<a name="line.1548"></a>
-<span class="sourceLineNo">1549</span>          filterCellByStore(logEntry);<a name="line.1549"></a>
-<span class="sourceLineNo">1550</span>          if (!logEntry.getEdit().isEmpty()) {<a name="line.1550"></a>
-<span class="sourceLineNo">1551</span>            wap.w.append(logEntry);<a name="line.1551"></a>
-<span class="sourceLineNo">1552</span>            this.updateRegionMaximumEditLogSeqNum(logEntry);<a name="line.1552"></a>
-<span class="sourceLineNo">1553</span>            editsCount++;<a name="line.1553"></a>
-<span class="sourceLineNo">1554</span>          } else {<a name="line.1554"></a>
-<span class="sourceLineNo">1555</span>            wap.incrementSkippedEdits(1);<a name="line.1555"></a>
-<span class="sourceLineNo">1556</span>          }<a name="line.1556"></a>
-<span class="sourceLineNo">1557</span>        }<a name="line.1557"></a>
-<span class="sourceLineNo">1558</span>        // Pass along summary statistics<a name="line.1558"></a>
-<span class="sourceLineNo">1559</span>        wap.incrementEdits(editsCount);<a name="line.1559"></a>
-<span class="sourceLineNo">1560</span>        wap.incrementNanoTime(System.nanoTime() - startTime);<a name="line.1560"></a>
-<span class="sourceLineNo">1561</span>      } catch (IOException e) {<a name="line.1561"></a>
-<span class="sourceLineNo">1562</span>          e = e instanceof RemoteException ?<a name="line.1562"></a>
-<span class="sourceLineNo">1563</span>                  ((RemoteException)e).unwrapRemoteException() : e;<a name="line.1563"></a>
-<span class="sourceLineNo">1564</span>        LOG.fatal(" Got while writing log entry to log", e);<a name="line.1564"></a>
-<span class="sourceLineNo">1565</span>        throw e;<a name="line.1565"></a>
-<span class="sourceLineNo">1566</span>      }<a name="line.1566"></a>
-<span class="sourceLineNo">1567</span>    }<a name="line.1567"></a>
-<span class="sourceLineNo">1568</span><a name="line.1568"></a>
-<span class="sourceLineNo">1569</span>    /**<a name="line.1569"></a>
-<span class="sourceLineNo">1570</span>     * @return a map from encoded region ID to the number of edits written out for that region.<a name="line.1570"></a>
-<span class="sourceLineNo">1571</span>     */<a name="line.1571"></a>
-<span class="sourceLineNo">1572</span>    @Override<a name="line.1572"></a>
-<span class="sourceLineNo">1573</span>    public Map&lt;byte[], Long&gt; getOutputCounts() {<a name="line.1573"></a>
-<span class="sourceLineNo">1574</span>      TreeMap&lt;byte[], Long&gt; ret = new TreeMap&lt;byte[], Long&gt;(Bytes.BYTES_COMPARATOR);<a name="line.1574"></a>
-<span class="sourceLineNo">1575</span>      synchronized (writers) {<a name="line.1575"></a>
-<span class="sourceLineNo">1576</span>        for (Map.Entry&lt;byte[], SinkWriter&gt; entry : writers.entrySet()) {<a name="line.1576"></a>
-<span class="sourceLineNo">1577</span>          ret.put(entry.getKey(), entry.getValue().editsWritten);<a name="line.1577"></a>
-<span class="sourceLineNo">1578</span>        }<a name="line.1578"></a>
-<span class="sourceLineNo">1579</span>      }<a name="line.1579"></a>
-<span class="sourceLineNo">1580</span>      return ret;<a name="line.1580"></a>
-<span class="sourceLineNo">1581</span>    }<a name="line.1581"></a>
-<span class="sourceLineNo">1582</span><a name="line.1582"></a>
-<span class="sourceLineNo">1583</span>    @Override<a name="line.1583"></a>
-<span class="sourceLineNo">1584</span>    public int getNumberOfRecoveredRegions() {<a name="line.1584"></a>
-<span class="sourceLineNo">1585</span>      return writers.size();<a name="line.1585"></a>
-<span class="sourceLineNo">1586</span>    }<a name="line.1586"></a>
-<span class="sourceLineNo">1587</span>  }<a name="line.1587"></a>
+<span class="sourceLineNo">1539</span>      WriterAndPath wap = null;<a name="line.1539"></a>
+<span class="sourceLineNo">1540</span><a name="line.1540"></a>
+<span class="sourceLineNo">1541</span>      long startTime = System.nanoTime();<a name="line.1541"></a>
+<span class="sourceLineNo">1542</span>      try {<a name="line.1542"></a>
+<span class="sourceLineNo">1543</span>        int editsCount = 0;<a name="line.1543"></a>
+<span class="sourceLineNo">1544</span><a name="line.1544"></a>
+<span class="sourceLineNo">1545</span>        for (Entry logEntry : entries) {<a name="line.1545"></a>
+<span class="sourceLineNo">1546</span>          if (wap == null) {<a name="line.1546"></a>
+<span class="sourceLineNo">1547</span>            wap = getWriterAndPath(logEntry);<a name="line.1547"></a>
+<span class="sourceLineNo">1548</span>            if (wap == null) {<a name="line.1548"></a>
+<span class="sourceLineNo">1549</span>              if (LOG.isDebugEnabled()) {<a name="line.1549"></a>
+<span class="sourceLineNo">1550</span>                LOG.debug("getWriterAndPath decided we don't need to write edits for " + logEntry);<a name="line.1550"></a>
+<span class="sourceLineNo">1551</span>              }<a name="line.1551"></a>
+<span class="sourceLineNo">1552</span>              return;<a name="line.1552"></a>
+<span class="sourceLineNo">1553</span>            }<a name="line.1553"></a>
+<span class="sourceLineNo">1554</span>          }<a name="line.1554"></a>
+<span class="sourceLineNo">1555</span>          filterCellByStore(logEntry);<a name="line.1555"></a>
+<span class="sourceLineNo">1556</span>          if (!logEntry.getEdit().isEmpty()) {<a name="line.1556"></a>
+<span class="sourceLineNo">1557</span>            wap.w.append(logEntry);<a name="line.1557"></a>
+<span class="sourceLineNo">1558</span>            this.updateRegionMaximumEditLogSeqNum(logEntry);<a name="line.1558"></a>
+<span class="sourceLineNo">1559</span>            editsCount++;<a name="line.1559"></a>
+<span class="sourceLineNo">1560</span>          } else {<a name="line.1560"></a>
+<span class="sourceLineNo">1561</span>            wap.incrementSkippedEdits(1);<a name="line.1561"></a>
+<span class="sourceLineNo">1562</span>          }<a name="line.1562"></a>
+<span class="sourceLineNo">1563</span>        }<a name="line.1563"></a>
+<span class="sourceLineNo">1564</span>        // Pass along summary statistics<a name="line.1564"></a>
+<span class="sourceLineNo">1565</span>        wap.incrementEdits(editsCount);<a name="line.1565"></a>
+<span class="sourceLineNo">1566</span>        wap.incrementNanoTime(System.nanoTime() - startTime);<a name="line.1566"></a>
+<span class="sourceLineNo">1567</span>      } catch (IOException e) {<a name="line.1567"></a>
+<span class="sourceLineNo">1568</span>          e = e instanceof RemoteException ?<a name="line.1568"></a>
+<span class="sourceLineNo">1569</span>                  ((RemoteException)e).unwrapRemoteException() : e;<a name="line.1569"></a>
+<span class="sourceLineNo">1570</span>        LOG.fatal(" Got while writing log entry to log", e);<a name="line.1570"></a>
+<span class="sourceLineNo">1571</span>        throw e;<a name="line.1571"></a>
+<span class="sourceLineNo">1572</span>      }<a name="line.1572"></a>
+<span class="sourceLineNo">1573</span>    }<a name="line.1573"></a>
+<span class="sourceLineNo">1574</span><a name="line.1574"></a>
+<span class="sourceLineNo">1575</span>    /**<a name="line.1575"></a>
+<span class="sourceLineNo">1576</span>     * @return a map from encoded region ID to the number of edits written out for that region.<a name="line.1576"></a>
+<span class="sourceLineNo">1577</span>     */<a name="line.1577"></a>
+<span class="sourceLineNo">1578</span>    @Override<a name="line.1578"></a>
+<span class="sourceLineNo">1579</span>    public Map&lt;byte[], Long&gt; getOutputCounts() {<a name="line.1579"></a>
+<span class="sourceLineNo">1580</span>      TreeMap&lt;byte[], Long&gt; ret = new TreeMap&lt;byte[], Long&gt;(Bytes.BYTES_COMPARATOR);<a name="line.1580"></a>
+<span class="sourceLineNo">1581</span>      synchronized (writers) {<a name="line.1581"></a>
+<span class="sourceLineNo">1582</span>        for (Map.Entry&lt;byte[], SinkWriter&gt; entry : writers.entrySet()) {<a name="line.1582"></a>
+<span class="sourceLineNo">1583</span>          ret.put(entry.getKey(), entry.getValue().editsWritten);<a name="line.1583"></a>
+<span class="sourceLineNo">1584</span>        }<a name="line.1584"></a>
+<span class="sourceLineNo">1585</span>      }<a name="line.1585"></a>
+<span class="sourceLineNo">1586</span>      return ret;<a name="line.1586"></a>
+<span class="sourceLineNo">1587</span>    }<a name="line.1587"></a>
 <span class="sourceLineNo">1588</span><a name="line.1588"></a>
-<span class="sourceLineNo">1589</span>  /**<a name="line.1589"></a>
-<span class="sourceLineNo">1590</span>   * Class wraps the actual writer which writes data out and related statistics<a name="line.1590"></a>
-<span class="sourceLineNo">1591</span>   */<a name="line.1591"></a>
-<span class="sourceLineNo">1592</span>  public abstract static class SinkWriter {<a name="line.1592"></a>
-<span class="sourceLineNo">1593</span>    /* Count of edits written to this path */<a name="line.1593"></a>
-<span class="sourceLineNo">1594</span>    long editsWritten = 0;<a name="line.1594"></a>
-<span class="sourceLineNo">1595</span>    /* Count of edits skipped to this path */<a name="line.1595"></a>
-<span class="sourceLineNo">1596</span>    long editsSkipped = 0;<a name="line.1596"></a>
-<span class="sourceLineNo">1597</span>    /* Number of nanos spent writing to this log */<a name="line.1597"></a>
-<span class="sourceLineNo">1598</span>    long nanosSpent = 0;<a name="line.1598"></a>
-<span class="sourceLineNo">1599</span><a name="line.1599"></a>
-<span class="sourceLineNo">1600</span>    void incrementEdits(int edits) {<a name="line.1600"></a>
-<span class="sourceLineNo">1601</span>      editsWritten += edits;<a name="line.1601"></a>
-<span class="sourceLineNo">1602</span>    }<a name="line.1602"></a>
-<span class="sourceLineNo">1603</span><a name="line.1603"></a>
-<span class="sourceLineNo">1604</span>    void incrementSkippedEdits(int skipped) {<a name="line.1604"></a>
-<span class="sourceLineNo">1605</span>      editsSkipped += skipped;<a name="line.1605"></a>
-<span class="sourceLineNo">1606</span>    }<a name="line.1606"></a>
-<span class="sourceLineNo">1607</span><a name="line.1607"></a>
-<span class="sourceLineNo">1608</span>    void incrementNanoTime(long nanos) {<a name="line.1608"></a>
-<span class="sourceLineNo">1609</span>      nanosSpent += nanos;<a name="line.1609"></a>
-<span class="sourceLineNo">1610</span>    }<a name="line.1610"></a>
-<span class="sourceLineNo">1611</span>  }<a name="line.1611"></a>
-<span class="sourceLineNo">1612</span><a name="line.1612"></a>
-<span class="sourceLineNo">1613</span>  /**<a name="line.1613"></a>
-<span class="sourceLineNo">1614</span>   * Private data structure that wraps a Writer and its Path, also collecting statistics about the<a name="line.1614"></a>
-<span class="sourceLineNo">1615</span>   * data written to this output.<a name="line.1615"></a>
-<span class="sourceLineNo">1616</span>   */<a name="line.1616"></a>
-<span class="sourceLineNo">1617</span>  private final static class WriterAndPath extends SinkWriter {<a name="line.1617"></a>
-<span class="sourceLineNo">1618</span>    final Path p;<a name="line.1618"></a>
-<span class="sourceLineNo">1619</span>    final Writer w;<a name="line.1619"></a>
-<span class="sourceLineNo">1620</span><a name="line.1620"></a>
-<span class="sourceLineNo">1621</span>    WriterAndPath(final Path p, final Writer w) {<a name="line.1621"></a>
-<span class="sourceLineNo">1622</span>      this.p = p;<a name="line.1622"></a>
-<span class="sourceLineNo">1623</span>      this.w = w;<a name="line.1623"></a>
-<span class="sourceLineNo">1624</span>    }<a name="line.1624"></a>
-<span class="sourceLineNo">1625</span>  }<a name="line.1625"></a>
+<span class="sourceLineNo">1589</span>    @Override<a name="line.1589"></a>
+<span class="sourceLineNo">1590</span>    public int getNumberOfRecoveredRegions() {<a name="line.1590"></a>
+<span class="sourceLineNo">1591</span>      return writers.size();<a name="line.1591"></a>
+<span class="sourceLineNo">1592</span>    }<a name="line.1592"></a>
+<span class="sourceLineNo">1593</span>  }<a name="line.1593"></a>
+<span class="sourceLineNo">1594</span><a name="line.1594"></a>
+<span class="sourceLineNo">1595</span>  /**<a name="line.1595"></a>
+<span class="sourceLineNo">1596</span>   * Class wraps the actual writer which writes data out and related statistics<a name="line.1596"></a>
+<span class="sourceLineNo">1597</span>   */<a name="line.1597"></a>
+<span class="sourceLineNo">1598</span>  public abstract static class SinkWriter {<a name="line.1598"></a>
+<span class="sourceLineNo">1599</span>    /* Count of edits written to this path */<a name="line.1599"></a>
+<span class="sourceLineNo">1600</span>    long editsWritten = 0;<a name="line.1600"></a>
+<span class="sourceLineNo">1601</span>    /* Count of edits skipped to this path */<a name="line.1601"></a>
+<span class="sourceLineNo">1602</span>    long editsSkipped = 0;<a name="line.1602"></a>
+<span class="sourceLineNo">1603</span>    /* Number of nanos spent writing to this log */<a name="line.1603"></a>
+<span class="sourceLineNo">1604</span>    long nanosSpent = 0;<a name="line.1604"></a>
+<span class="sourceLineNo">1605</span><a name="line.1605"></a>
+<span class="sourceLineNo">1606</span>    void incrementEdits(int edits) {<a name="line.1606"></a>
+<span class="sourceLineNo">1607</span>      editsWritten += edits;<a name="line.1607"></a>
+<span class="sourceLineNo">1608</span>    }<a name="line.1608"></a>
+<span class="sourceLineNo">1609</span><a name="line.1609"></a>
+<span class="sourceLineNo">1610</span>    void incrementSkippedEdits(int skipped) {<a name="line.1610"></a>
+<span class="sourceLineNo">1611</span>      editsSkipped += skipped;<a name="line.1611"></a>
+<span class="sourceLineNo">1612</span>    }<a name="line.1612"></a>
+<span class="sourceLineNo">1613</span><a name="line.1613"></a>
+<span class="sourceLineNo">1614</span>    void incrementNanoTime(long nanos) {<a name="line.1614"></a>
+<span class="sourceLineNo">1615</span>      nanosSpent += nanos;<a name="line.1615"></a>
+<span class="sourceLineNo">1616</span>    }<a name="line.1616"></a>
+<span class="sourceLineNo">1617</span>  }<a name="line.1617"></a>
+<span class="sourceLineNo">1618</span><a name="line.1618"></a>
+<span class="sourceLineNo">1619</span>  /**<a name="line.1619"></a>
+<span class="sourceLineNo">1620</span>   * Private data structure that wraps a Writer and its Path, also collecting statistics about the<a name="line.1620"></a>
+<span class="sourceLineNo">1621</span>   * data written to this output.<a name="line.1621"></a>
+<span class="sourceLineNo">1622</span>   */<a name="line.1622"></a>
+<span class="sourceLineNo">1623</span>  private final static class WriterAndPath extends SinkWriter {<a name="line.1623"></a>
+<span class="sourceLineNo">1624</span>    final Path p;<a name="line.1624"></a>
+<span class="sourceLineNo">1625</span>    final Writer w;<a name="line.1625"></a>
 <span class="sourceLineNo">1626</span><a name="line.1626"></a>
-<span class="sourceLineNo">1627</span>  /**<a name="line.1627"></a>
-<span class="sourceLineNo">1628</span>   * Class that manages to replay edits from WAL files directly to assigned fail over region servers<a name="line.1628"></a>
-<span class="sourceLineNo">1629</span>   */<a name="line.1629"></a>
-<span class="sourceLineNo">1630</span>  class LogReplayOutputSink extends OutputSink {<a name="line.1630"></a>
-<span class="sourceLineNo">1631</span>    private static final double BUFFER_THRESHOLD = 0.35;<a name="line.1631"></a>
-<span class="sourceLineNo">1632</span>    private static final String KEY_DELIMITER = "#";<a name="line.1632"></a>
-<span class="sourceLineNo">1633</span><a name="line.1633"></a>
-<span class="sourceLineNo">1634</span>    private long waitRegionOnlineTimeOut;<a name="line.1634"></a>
-<span class="sourceLineNo">1635</span>    private final Set&lt;String&gt; recoveredRegions = Collections.synchronizedSet(new HashSet&lt;String&gt;());<a name="line.1635"></a>
-<span class="sourceLineNo">1636</span>    private final Map&lt;String, RegionServerWriter&gt; writers =<a name="line.1636"></a>
-<span class="sourceLineNo">1637</span>        new ConcurrentHashMap&lt;String, RegionServerWriter&gt;();<a name="line.1637"></a>
-<span class="sourceLineNo">1638</span>    // online encoded region name -&gt; region location map<a name="line.1638"></a>
-<span class="sourceLineNo">1639</span>    private final Map&lt;String, HRegionLocation&gt; onlineRegions =<a name="line.1639"></a>
-<span class="sourceLineNo">1640</span>        new ConcurrentHashMap&lt;String, HRegionLocation&gt;();<a name="line.1640"></a>
-<span class="sourceLineNo">1641</span><a name="line.1641"></a>
-<span class="sourceLineNo">1642</span>    private Map&lt;TableName, HConnection&gt; tableNameToHConnectionMap = Collections<a name="line.1642"></a>
-<span class="sourceLineNo">1643</span>        .synchronizedMap(new TreeMap&lt;TableName, HConnection&gt;());<a name="line.1643"></a>
-<span class="sourceLineNo">1644</span>    /**<a name="line.1644"></a>
-<span class="sourceLineNo">1645</span>     * Map key -&gt; value layout<a name="line.1645"></a>
-<span class="sourceLineNo">1646</span>     * {@literal &lt;servername&gt;:&lt;table name&gt; -&gt; Queue&lt;Row&gt;}<a name="line.1646"></a>
-<span class="sourceLineNo">1647</span>     */<a name="line.1647"></a>
-<span class="sourceLineNo">1648</span>    private Map&lt;String, List&lt;Pair&lt;HRegionLocation, Entry&gt;&gt;&gt; serverToBufferQueueMap =<a name="line.1648"></a>
-<span class="sourceLineNo">1649</span>        new ConcurrentHashMap&lt;String, List&lt;Pair&lt;HRegionLocation, Entry&gt;&gt;&gt;();<a name="line.1649"></a>
-<span class="sourceLineNo">1650</span>    private List&lt;Throwable&gt; thrown = new ArrayList&lt;Throwable&gt;();<a name="line.1650"></a>
-<span class="sourceLineNo">1651</span><a name="line.1651"></a>
-<span class="sourceLineNo">1652</span>    // The following sink is used in distrubitedLogReplay mode for entries of regions in a disabling<a name="line.1652"></a>
-<span class="sourceLineNo">1653</span>    // table. It's a limitation of distributedLogReplay. Because log replay needs a region is<a name="line.1653"></a>
-<span class="sourceLineNo">1654</span>    // assigned and online before it can replay wal edits while regions of disabling/disabled table<a name="line.1654"></a>
-<span class="sourceLineNo">1655</span>    // won't be assigned by AM. We can retire this code after HBASE-8234.<a name="line.1655"></a>
-<span class="sourceLineNo">1656</span>    private LogRecoveredEditsOutputSink logRecoveredEditsOutputSink;<a name="line.1656"></a>
-<span class="sourceLineNo">1657</span>    private boolean hasEditsInDisablingOrDisabledTables = false;<a name="line.1657"></a>
-<span class="sourceLineNo">1658</span><a name="line.1658"></a>
-<span class="sourceLineNo">1659</span>    public LogReplayOutputSink(PipelineController controller, EntryBuffers entryBuffers,<a name="line.1659"></a>
-<span class="sourceLineNo">1660</span>        int numWriters) {<a name="line.1660"></a>
-<span class="sourceLineNo">1661</span>      super(controller, entryBuffers, numWriters);<a name="line.1661"></a>
-<span class="sourceLineNo">1662</span>      this.waitRegionOnlineTimeOut =<a name="line.1662"></a>
-<span class="sourceLineNo">1663</span>          conf.getInt(HConstants.HBASE_SPLITLOG_MANAGER_TIMEOUT,<a name="line.1663"></a>
-<span class="sourceLineNo">1664</span>            ZKSplitLogManagerCoordination.DEFAULT_TIMEOUT);<a name="line.1664"></a>
-<span class="sourceLineNo">1665</span>      this.logRecoveredEditsOutputSink = new LogRecoveredEditsOutputSink(controller,<a name="line.1665"></a>
-<span class="sourceLineNo">1666</span>        entryBuffers, numWriters);<a name="line.1666"></a>
-<span class="sourceLineNo">1667</span>      this.logRecoveredEditsOutputSink.setReporter(reporter);<a name="line.1667"></a>
-<span class="sourceLineNo">1668</span>    }<a name="line.1668"></a>
-<span class="sourceLineNo">1669</span><a name="line.1669"></a>
-<span class="sourceLineNo">1670</span>    @Override<a name="line.1670"></a>
-<span class="sourceLineNo">1671</span>    public void append(RegionEntryBuffer buffer) throws IOException {<a name="line.1671"></a>
-<span class="sourceLineNo">1672</span>      List&lt;Entry&gt; entries = buffer.entryBuffer;<a name="line.1672"></a>
-<span class="sourceLineNo">1673</span>      if (entries.isEmpty()) {<a name="line.1673"></a>
-<span class="sourceLineNo">1674</span>        LOG.warn("got an empty buffer, skipping");<a name="line.1674"></a>
-<span class="sourceLineNo">1675</span>        return;<a name="line.1675"></a>
-<span class="sourceLineNo">1676</span>      }<a name="line.1676"></a>
-<span class="sourceLineNo">1677</span><a name="line.1677"></a>
-<span class="sourceLineNo">1678</span>      // check if current region in a disabling or disabled table<a name="line.1678"></a>
-<span class="sourceLineNo">1679</span>      if (isTableDisabledOrDisabling(buffer.tableName)) {<a name="line.1679"></a>
-<span class="sourceLineNo">1680</span>        // need fall back to old way<a name="line.1680"></a>
-<span class="sourceLineNo">1681</span>        logRecoveredEditsOutputSink.append(buffer);<a name="line.1681"></a>
-<span class="sourceLineNo">1682</span>        hasEditsInDisablingOrDisabledTables = true;<a name="line.1682"></a>
-<span class="sourceLineNo">1683</span>        // store regions we have recovered so far<a name="line.1683"></a>
-<span class="sourceLineNo">1684</span>        addToRecoveredRegions(Bytes.toString(buffer.encodedRegionName));<a name="line.1684"></a>
-<span class="sourceLineNo">1685</span>        return;<a name="line.1685"></a>
-<span class="sourceLineNo">1686</span>      }<a name="line.1686"></a>
-<span class="sourceLineNo">1687</span><a name="line.1687"></a>
-<span class="sourceLineNo">1688</span>      // group entries by region servers<a name="line.1688"></a>
-<span class="sourceLineNo">1689</span>      groupEditsByServer(entries);<a name="line.1689"></a>
-<span class="sourceLineNo">1690</span><a name="line.1690"></a>
-<span class="sourceLineNo">1691</span>      // process workitems<a name="line.1691"></a>
-<span class="sourceLineNo">1692</span>      String maxLocKey = null;<a name="line.1692"></a>
-<span class="sourceLineNo">1693</span>      int maxSize = 0;<a name="line.1693"></a>
-<span class="sourceLineNo">1694</span>      List&lt;Pair&lt;HRegionLocation, Entry&gt;&gt; maxQueue = null;<a name="line.1694"></a>
-<span class="sourceLineNo">1695</span>      synchronized (this.serverToBufferQueueMap) {<a name="line.1695"></a>
-<span class="sourceLineNo">1696</span>        for (Map.Entry&lt;String, List&lt;Pair&lt;HRegionLocation, Entry&gt;&gt;&gt; entry :<a name="line.1696"></a>
-<span class="sourceLineNo">1697</span>            this.serverToBufferQueueMap.entrySet()) {<a name="line.1697"></a>
-<span class="sourceLineNo">1698</span>          List&lt;Pair&lt;HRegionLocation, Entry&gt;&gt; curQueue = entry.getValue();<a name="line.1698"></a>
-<span class="sourceLineNo">1699</span>          if (curQueue.size() &gt; maxSize) {<a name="line.1699"></a>
-<span class="sourceLineNo">1700</span>            maxSize = curQueue.size();<a name="line.1700"></a>
-<span class="sourceLineNo">1701</span>            maxQueue = curQueue;<a name="line.1701"></a>
-<span class="sourceLineNo">1702</span>            maxLocKey = entry.getKey();<a name="line.1702"></a>
-<span class="sourceLineNo">1703</span>          }<a name="line.1703"></a>
-<span class="sourceLineNo">1704</span>        }<a name="line.1704"></a>
-<span class="sourceLineNo">1705</span>        if (maxSize &lt; minBatchSize<a name="line.1705"></a>
-<span class="sourceLineNo">1706</span>            &amp;&amp; entryBuffers.totalBuffered &lt; BUFFER_THRESHOLD * entryBuffers.maxHeapUsage) {<a name="line.1706"></a>
-<span class="sourceLineNo">1707</span>          // buffer more to process<a name="line.1707"></a>
-<span class="sourceLineNo">1708</span>          return;<a name="line.1708"></a>
-<span class="sourceLineNo">1709</span>        } else if (maxSize &gt; 0) {<a name="line.1709"></a>
-<span class="sourceLineNo">1710</span>          this.serverToBufferQueueMap.remove(maxLocKey);<a name="line.1710"></a>
-<span class="sourceLineNo">1711</span>        }<a name="line.1711"></a>
-<span class="sourceLineNo">1712</span>      }<a name="line.1712"></a>
-<span class="sourceLineNo">1713</span><a name="line.1713"></a>
-<span class="sourceLineNo">1714</span>      if (maxSize &gt; 0) {<a name="line.1714"></a>
-<span class="sourceLineNo">1715</span>        processWorkItems(maxLocKey, maxQueue);<a name="line.1715"></a>
-<span class="sourceLineNo">1716</span>      }<a name="line.1716"></a>
-<span class="sourceLineNo">1717</span>    }<a name="line.1717"></a>
-<span class="sourceLineNo">1718</span><a name="line.1718"></a>
-<span class="sourceLineNo">1719</span>    private void addToRecoveredRegions(String encodedRegionName) {<a name="line.1719"></a>
-<span class="sourceLineNo">1720</span>      if (!recoveredRegions.contains(encodedRegionName)) {<a name="line.1720"></a>
-<span class="sourceLineNo">1721</span>        recoveredRegions.add(encodedRegionName);<a name="line.1721"></a>
+<span class="sourceLineNo">1627</span>    WriterAndPath(final Path p, final Writer w) {<a name="line.1627"></a>
+<span class="sourceLineNo">1628</span>      this.p = p;<a name="line.1628"></a>
+<span class="sourceLineNo">1629</span>      this.w = w;<a name="line.1629"></a>
+<span class="sourceLineNo">1630</span>    }<a name="line.1630"></a>
+<span class="sourceLineNo">1631</span>  }<a name="line.1631"></a>
+<span class="sourceLineNo">1632</span><a name="line.1632"></a>
+<span class="sourceLineNo">1633</span>  /**<a name="line.1633"></a>
+<span class="sourceLineNo">1634</span>   * Class that manages to replay edits from WAL files directly to assigned fail over region servers<a name="line.1634"></a>
+<span class="sourceLineNo">1635</span>   */<a name="line.1635"></a>
+<span class="sourceLineNo">1636</span>  class LogReplayOutputSink extends OutputSink {<a name="line.1636"></a>
+<span class="sourceLineNo">1637</span>    private static final double BUFFER_THRESHOLD = 0.35;<a name="line.1637"></a>
+<span class="sourceLineNo">1638</span>    private static final String KEY_DELIMITER = "#";<a name="line.1638"></a>
+<span class="sourceLineNo">1639</span><a name="line.1639"></a>
+<span class="sourceLineNo">1640</span>    private long waitRegionOnlineTimeOut;<a name="line.1640"></a>
+<span class="sourceLineNo">1641</span>    private final Set&lt;String&gt; recoveredRegions = Collections.synchronizedSet(new HashSet&lt;String&gt;());<a name="line.1641"></a>
+<span class="sourceLineNo">1642</span>    private final Map&lt;String, RegionServerWriter&gt; writers =<a name="line.1642"></a>
+<span class="sourceLineNo">1643</span>        new ConcurrentHashMap&lt;String, RegionServerWriter&gt;();<a name="line.1643"></a>
+<span class="sourceLineNo">1644</span>    // online encoded region name -&gt; region location map<a name="line.1644"></a>
+<span class="sourceLineNo">1645</span>    private final Map&lt;String, HRegionLocation&gt; onlineRegions =<a name="line.1645"></a>
+<span class="sourceLineNo">1646</span>        new ConcurrentHashMap&lt;String, HRegionLocation&gt;();<a name="line.1646"></a>
+<span class="sourceLineNo">1647</span><a name="line.1647"></a>
+<span class="sourceLineNo">1648</span>    private Map&lt;TableName, HConnection&gt; tableNameToHConnectionMap = Collections<a name="line.1648"></a>
+<span class="sourceLineNo">1649</span>        .synchronizedMap(new TreeMap&lt;TableName, HConnection&gt;());<a name="line.1649"></a>
+<span class="sourceLineNo">1650</span>    /**<a name="line.1650"></a>
+<span class="sourceLineNo">1651</span>     * Map key -&gt; value layout<a name="line.1651"></a>
+<span class="sourceLineNo">1652</span>     * {@literal &lt;servername&gt;:&lt;table name&gt; -&gt; Queue&lt;Row&gt;}<a name="line.1652"></a>
+<span class="sourceLineNo">1653</span>     */<a name="line.1653"></a>
+<span class="sourceLineNo">1654</span>    private Map&lt;String, List&lt;Pair&lt;HRegionLocation, Entry&gt;&gt;&gt; serverToBufferQueueMap =<a name="line.1654"></a>
+<span class="sourceLineNo">1655</span>        new ConcurrentHashMap&lt;String, List&lt;Pair&lt;HRegionLocation, Entry&gt;&gt;&gt;();<a name="line.1655"></a>
+<span class="sourceLineNo">1656</span>    private List&lt;Throwable&gt; thrown = new ArrayList&lt;Throwable&gt;();<a name="line.1656"></a>
+<span class="sourceLineNo">1657</span><a name="line.1657"></a>
+<span class="sourceLineNo">1658</span>    // The following sink is used in distrubitedLogReplay mode for entries of regions in a disabling<a name="line.1658"></a>
+<span class="sourceLineNo">1659</span>    // table. It's a limitation of distributedLogReplay. Because log replay needs a region is<a name="line.1659"></a>
+<span class="sourceLineNo">1660</span>    // assigned and online before it can replay wal edits while regions of disabling/disabled table<a name="line.1660"></a>
+<span class="sourceLineNo">1661</span>    // won't be assigned by AM. We can retire this code after HBASE-8234.<a name="line.1661"></a>
+<span class="sourceLineNo">1662</span>    private LogRecoveredEditsOutputSink logRecoveredEditsOutputSink;<a name="line.1662"></a>
+<span class="sourceLineNo">1663</span>    private boolean hasEditsInDisablingOrDisabledTables = false;<a name="line.1663"></a>
+<span class="sourceLineNo">1664</span><a name="line.1664"></a>
+<span class="sourceLineNo">1665</span>    public LogReplayOutputSink(PipelineController controller, EntryBuffers entryBuffers,<a name="line.1665"></a>
+<span class="sourceLineNo">1666</span>        int numWriters) {<a name="line.1666"></a>
+<span class="sourceLineNo">1667</span>      super(controller, entryBuffers, numWriters);<a name="line.1667"></a>
+<span class="sourceLineNo">1668</span>      this.waitRegionOnlineTimeOut =<a name="line.1668"></a>
+<span class="sourceLineNo">1669</span>          conf.getInt(HConstants.HBASE_SPLITLOG_MANAGER_TIMEOUT,<a name="line.1669"></a>
+<span class="sourceLineNo">1670</span>            ZKSplitLogManagerCoordination.DEFAULT_TIMEOUT);<a name="line.1670"></a>
+<span class="sourceLineNo">1671</span>      this.logRecoveredEditsOutputSink = new LogRecoveredEditsOutputSink(controller,<a name="line.1671"></a>
+<span class="sourceLineNo">1672</span>        entryBuffers, numWriters);<a name="line.1672"></a>
+<span class="sourceLineNo">1673</span>      this.logRecoveredEditsOutputSink.setReporter(reporter);<a name="line.1673"></a>
+<span class="sourceLineNo">1674</span>    }<a name="line.1674"></a>
+<span class="sourceLineNo">1675</span><a name="line.1675"></a>
+<span class="sourceLineNo">1676</span>    @Override<a name="line.1676"></a>
+<span class="sourceLineNo">1677</span>    public void append(RegionEntryBuffer buffer) throws IOException {<a name="line.1677"></a>
+<span class="sourceLineNo">1678</span>      List&lt;Entry&gt; entries = buffer.entryBuffer;<a name="line.1678"></a>
+<span class="sourceLineNo">1679</span>      if (entries.isEmpty()) {<a name="line.1679"></a>
+<span class="sourceLineNo">1680</span>        LOG.warn("got an empty buffer, skipping");<a name="line.1680"></a>
+<span class="sourceLineNo">1681</span>        return;<a name="line.1681"></a>
+<span class="sourceLineNo">1682</span>      }<a name="line.1682"></a>
+<span class="sourceLineNo">1683</span><a name="line.1683"></a>
+<span class="sourceLineNo">1684</span>      // check if current region in a disabling or disabled table<a name="line.1684"></a>
+<span class="sourceLineNo">1685</span>      if (isTableDisabledOrDisabling(buffer.tableName)) {<a name="line.1685"></a>
+<span class="sourceLineNo">1686</span>        // need fall back to old way<a name="line.1686"></a>
+<span class="sourceLineNo">1687</span>        logRecoveredEditsOutputSink.append(buffer);<a name="line.1687"></a>
+<span class="sourceLineNo">1688</span>        hasEditsInDisablingOrDisabledTables = true;<a name="line.1688"></a>
+<span class="sourceLineNo">1689</span>        // store regions we have recovered so far<a name="line.1689"></a>
+<span class="sourceLineNo">1690</span>        addToRecoveredRegions(Bytes.toString(buffer.encodedRegionName));<a name="line.1690"></a>
+<span class="sourceLineNo">1691</span>        return;<a name="line.1691"></a>
+<span class="sourceLineNo">1692</span>      }<a name="line.1692"></a>
+<span class="sourceLineNo">1693</span><a name="line.1693"></a>
+<span class="sourceLineNo">1694</span>      // group entries by region servers<a name="line.1694"></a>
+<span class="sourceLineNo">1695</span>      groupEditsByServer(entries);<a name="line.1695"></a>
+<span class="sourceLineNo">1696</span><a name="line.1696"></a>
+<span class="sourceLineNo">1697</span>      // process workitems<a name="line.1697"></a>
+<span class="sourceLineNo">1698</span>      String maxLocKey = null;<a name="line.1698"></a>
+<span class="sourceLineNo">1699</span>      int maxSize = 0;<a name="line.1699"></a>
+<span class="sourceLineNo">1700</span>      List&lt;Pair&lt;HRegionLocation, Entry&gt;&gt; maxQueue = null;<a name="line.1700"></a>
+<span class="sourceLineNo">1701</span>      synchronized (this.serverToBufferQueueMap) {<a name="line.1701"></a>
+<span class="sourceLineNo">1702</span>        for (Map.Entry&lt;String, List&lt;Pair&lt;HRegionLocation, Entry&gt;&gt;&gt; entry :<a name="line.1702"></a>
+<span class="sourceLineNo">1703</span>            this.serverToBufferQueueMap.entrySet()) {<a name="line.1703"></a>
+<span class="sourceLineNo">1704</span>          List&lt;Pair&lt;HRegionLocation, Entry&gt;&gt; curQueue = entry.getValue();<a name="line.1704"></a>
+<span class="sourceLineNo">1705</span>          if (curQueue.size() &gt; maxSize) {<a name="line.1705"></a>
+<span class="sourceLineNo">1706</span>            maxSize = curQueue.size();<a name="line.1706"></a>
+<span class="sourceLineNo">1707</span>            maxQueue = curQueue;<a name="line.1707"></a>
+<span class="sourceLineNo">1708</span>            maxLocKey = entry.getKey();<a name="line.1708"></a>
+<span class="sourceLineNo">1709</span>          }<a name="line.1709"></a>
+<span class="sourceLineNo">1710</span>        }<a name="line.1710"></a>
+<span class="sourceLineNo">1711</span>        if (maxSize &lt; minBatchSize<a name="line.1711"></a>
+<span class="sourceLineNo">1712</span>            &amp;&amp; entryBuffers.totalBuffered &lt; BUFFER_THRESHOLD * entryBuffers.maxHeapUsage) {<a name="line.1712"></a>
+<span class="sourceLineNo">1713</span>          // buffer more to process<a name="line.1713"></a>
+<span class="sourceLineNo">1714</span>          return;<a name="line.1714"></a>
+<span class="sourceLineNo">1715</span>        } else if (maxSize &gt; 0) {<a name="line.1715"></a>
+<span class="sourceLineNo">1716</span>          this.serverToBufferQueueMap.remove(maxLocKey);<a name="line.1716"></a>
+<span class="sourceLineNo">1717</span>        }<a name="line.1717"></a>
+<span class="sourceLineNo">1718</span>      }<a name="line.1718"></a>
+<span class="sourceLineNo">1719</span><a name="line.1719"></a>
+<span class="sourceLineNo">1720</span>      if (maxSize &gt; 0) {<a name="line.1720"></a>
+<span class="sourceLineNo">1721</span>        processWorkItems(maxLocKey, maxQueue);<a name="line.1721"></a>
 <span class="sourceLineNo">1722</span>      }<a name="line.1722"></a>
 <span class="sourceLineNo">1723</span>    }<a name="line.1723"></a>
 <span class="sourceLineNo">1724</span><a name="line.1724"></a>
-<span class="sourceLineNo">1725</span>    /**<a name="line.1725"></a>
-<span class="sourceLineNo">1726</span>     * Helper function to group WALEntries to individual region servers<a name="line.1726"></a>
-<span class="sourceLineNo">1727</span>     * @throws IOException<a name="line.1727"></a>
-<span class="sourceLineNo">1728</span>     */<a name="line.1728"></a>
-<span class="sourceLineNo">1729</span>    private void groupEditsByServer(List&lt;Entry&gt; entries) throws IOException {<a name="line.1729"></a>
-<span class="sourceLineNo">1730</span>      Set&lt;TableName&gt; nonExistentTables = null;<a name="line.1730"></a>
-<span class="sourceLineNo">1731</span>      Long cachedLastFlushedSequenceId = -1l;<a name="line.1731"></a>
-<span class="sourceLineNo">1732</span>      for (Entry entry : entries) {<a name="line.1732"></a>
-<span class="sourceLineNo">1733</span>        WALEdit edit = entry.getEdit();<a name="line.1733"></a>
-<span class="sourceLineNo">1734</span>        TableName table = entry.getKey().getTablename();<a name="line.1734"></a>
-<span class="sourceLineNo">1735</span>        // clear scopes which isn't needed for recovery<a name="line.1735"></a>
-<span class="sourceLineNo">1736</span>        entry.getKey().setScopes(null);<a name="line.1736"></a>
-<span class="sourceLineNo">1737</span>        String encodeRegionNameStr = Bytes.toString(entry.getKey().getEncodedRegionName());<a name="line.1737"></a>
-<span class="sourceLineNo">1738</span>        // skip edits of non-existent tables<a name="line.1738"></a>
-<span class="sourceLineNo">1739</span>        if (nonExistentTables != null &amp;&amp; nonExistentTables.contains(table)) {<a name="line.1739"></a>
-<span class="sourceLineNo">1740</span>          this.skippedEdits.incrementAndGet();<a name="line.1740"></a>
-<span class="sourceLineNo">1741</span>          continue;<a name="line.1741"></a>
-<span class="sourceLineNo">1742</span>        }<a name="line.1742"></a>
-<span class="sourceLineNo">1743</span><a name="line.1743"></a>
-<span class="sourceLineNo">1744</span>        Map&lt;byte[], Long&gt; maxStoreSequenceIds = null;<a name="line.1744"></a>
-<span class="sourceLineNo">1745</span>        boolean needSkip = false;<a name="line.1745"></a>
-<span class="sourceLineNo">1746</span>        HRegionLocation loc = null;<a name="line.1746"></a>
-<span class="sourceLineNo">1747</span>        String locKey = null;<a name="line.1747"></a>
-<span class="sourceLineNo">1748</span>        List&lt;Cell&gt; cells = edit.getCells();<a name="line.1748"></a>
-<span class="sourceLineNo">1749</span>        List&lt;Cell&gt; skippedCells = new ArrayList&lt;Cell&gt;();<a name="line.1749"></a>
-<span class="sourceLineNo">1750</span>        HConnection hconn = this.getConnectionByTableName(table);<a name="line.1750"></a>
-<span class="sourceLineNo">1751</span><a name="line.1751"></a>
-<span class="sourceLineNo">1752</span>        for (Cell cell : cells) {<a name="line.1752"></a>
-<span class="sourceLineNo">1753</span>          byte[] row = CellUtil.cloneRow(cell);<a name="line.1753"></a>
-<span class="sourceLineNo">1754</span>          byte[] family = CellUtil.cloneFamily(cell);<a name="line.1754"></a>
-<span class="sourceLineNo">1755</span>          boolean isCompactionEntry = false;<a name="line.1755"></a>
-<span class="sourceLineNo">1756</span>          if (CellUtil.matchingFamily(cell, WALEdit.METAFAMILY)) {<a name="line.1756"></a>
-<span class="sourceLineNo">1757</span>            CompactionDescriptor compaction = WALEdit.getCompaction(cell);<a name="line.1757"></a>
-<span class="sourceLineNo">1758</span>            if (compaction != null &amp;&amp; compaction.hasRegionName()) {<a name="line.1758"></a>
-<span class="sourceLineNo">1759</span>              try {<a name="line.1759"></a>
-<span class="sourceLineNo">1760</span>                byte[][] regionName = HRegionInfo.parseRegionName(compaction.getRegionName()<a name="line.1760"></a>
-<span class="sourceLineNo">1761</span>                  .toByteArray());<a name="line.1761"></a>
-<span class="sourceLineNo">1762</span>                row = regionName[1]; // startKey of the region<a name="line.1762"></a>
-<span class="sourceLineNo">1763</span>                family = compaction.getFamilyName().toByteArray();<a name="line.1763"></a>
-<span class="sourceLineNo">1764</span>                isCompactionEntry = true;<a name="line.1764"></a>
-<span class="sourceLineNo">1765</span>              } catch (Exception ex) {<a name="line.1765"></a>
-<span class="sourceLineNo">1766</span>                LOG.warn("Unexpected exception received, ignoring " + ex);<a name="line.1766"></a>
-<span class="sourceLineNo">1767</span>                skippedCells.add(cell);<a name="line.1767"></a>
-<span class="sourceLineNo">1768</span>                continue;<a name="line.1768"></a>
-<span class="sourceLineNo">1769</span>              }<a name="line.1769"></a>
-<span class="sourceLineNo">1770</span>            } else {<a name="line.1770"></a>
-<span class="sourceLineNo">1771</span>              skippedCells.add(cell);<a name="line.1771"></a>
-<span class="sourceLineNo">1772</span>              continue;<a name="line.1772"></a>
-<span class="sourceLineNo">1773</span>            }<a name="line.1773"></a>
-<span class="sourceLineNo">1774</span>          }<a name="line.1774"></a>
-<span class="sourceLineNo">1775</span><a name="line.1775"></a>
-<span class="sourceLineNo">1776</span>          try {<a name="line.1776"></a>
-<span class="sourceLineNo">1777</span>            loc =<a name="line.1777"></a>
-<span class="sourceLineNo">1778</span>                locateRegionAndRefreshLastFlushedSequenceId(hconn, table, row,<a name="line.1778"></a>
-<span class="sourceLineNo">1779</span>                  encodeRegionNameStr);<a name="line.1779"></a>
-<span class="sourceLineNo">1780</span>            // skip replaying the compaction if the region is gone<a name="line.1780"></a>
-<span class="sourceLineNo">1781</span>            if (isCompactionEntry &amp;&amp; !encodeRegionNameStr.equalsIgnoreCase(<a name="line.1781"></a>
-<span class="sourceLineNo">1782</span>              loc.getRegionInfo().getEncodedName())) {<a name="line.1782"></a>
-<span class="sourceLineNo">1783</span>              LOG.info("Not replaying a compaction marker for an older region: "<a name="line.1783"></a>
-<span class="sourceLineNo">1784</span>                  + encodeRegionNameStr);<a name="line.1784"></a>
-<span class="sourceLineNo">1785</span>              needSkip = true;<a name="line.1785"></a>
-<span class="sourceLineNo">1786</span>            }<a name="line.1786"></a>
-<span class="sourceLineNo">1787</span>          } catch (TableNotFoundException ex) {<a name="line.1787"></a>
-<span class="sourceLineNo">1788</span>            // table has been deleted so skip edits of the table<a name="line.1788"></a>
-<span class="sourceLineNo">1789</span>            LOG.info("Table " + table + " doesn't exist. Skip log replay for region "<a name="line.1789"></a>
-<span class="sourceLineNo">1790</span>                + encodeRegionNameStr);<a name="line.1790"></a>
-<span class="sourceLineNo">1791</span>            lastFlushedSequenceIds.put(encodeRegionNameStr, Long.MAX_VALUE);<a name="line.1791"></a>
-<span class="sourceLineNo">1792</span>            if (nonExistentTables == null) {<a name="line.1792"></a>
-<span class="sourceLineNo">1793</span>              nonExistentTables = new TreeSet&lt;TableName&gt;();<a name="line.1793"></a>
-<span class="sourceLineNo">1794</span>            }<a name="line.1794"></a>
-<span class="sourceLineNo">1795</span>            nonExistentTables.add(table);<a name="line.1795"></a>
-<span class="sourceLineNo">1796</span>            this.skippedEdits.incrementAndGet();<a name="line.1796"></a>
-<span class="sourceLineNo">1797</span>            needSkip = true;<a name="line.1797"></a>
-<span class="sourceLineNo">1798</span>            break;<a name="line.1798"></a>
-<span class="sourceLineNo">1799</span>          }<a name="line.1799"></a>
-<span class="sourceLineNo">1800</span><a name="line.1800"></a>
-<span class="sourceLineNo">1801</span>          cachedLastFlushedSequenceId =<a name="line.1801"></a>
-<span class="sourceLineNo">1802</span>              lastFlushedSequenceIds.get(loc.getRegionInfo().getEncodedName());<a name="line.1802"></a>
-<span class="sourceLineNo">1803</span>          if (cachedLastFlushedSequenceId != null<a name="line.1803"></a>
-<span class="sourceLineNo">1804</span>              &amp;&amp; cachedLastFlushedSequenceId &gt;= entry.getKey().getLogSeqNum()) {<a name="line.1804"></a>
-<span class="sourceLineNo">1805</span>            // skip the whole WAL entry<a name="line.1805"></a>
-<span class="sourceLineNo">1806</span>            this.skippedEdits.incrementAndGet();<a name="line.1806"></a>
-<span class="sourceLineNo">1807</span>            needSkip = true;<a name="line.1807"></a>
-<span class="sourceLineNo">1808</span>            break;<a name="line.1808"></a>
-<span class="sourceLineNo">1809</span>          } else {<a name="line.1809"></a>
-<span class="sourceLineNo">1810</span>            if (maxStoreSequenceIds == null) {<a name="line.1810"></a>
-<span class="sourceLineNo">1811</span>              maxStoreSequenceIds =<a name="line.1811"></a>
-<span class="sourceLineNo">1812</span>                  regionMaxSeqIdInStores.get(loc.getRegionInfo().getEncodedName());<a name="line.1812"></a>
-<span class="sourceLineNo">1813</span>            }<a name="line.1813"></a>
-<span class="sourceLineNo">1814</span>            if (maxStoreSequenceIds != null) {<a name="line.1814"></a>
-<span class="sourceLineNo">1815</span>              Long maxStoreSeqId = maxStoreSequenceIds.get(family);<a name="line.1815"></a>
-<span class="sourceLineNo">1816</span>              if (maxStoreSeqId == null || maxStoreSeqId &gt;= entry.getKey().getLogSeqNum()) {<a name="line.1816"></a>
-<span class="sourceLineNo">1817</span>                // skip current kv if column family doesn't exist anymore or already flushed<a name="line.1817"></a>
-<span class="sourceLineNo">1818</span>                skippedCells.add(cell);<a name="line.1818"></a>
-<span class="sourceLineNo">1819</span>                continue;<a name="line.1819"></a>
-<span class="sourceLineNo">1820</span>              }<a name="line.1820"></a>
-<span class="sourceLineNo">1821</span>            }<a name="line.1821"></a>
-<span class="sourceLineNo">1822</span>          }<a name="line.1822"></a>
-<span class="sourceLineNo">1823</span>        }<a name="line.1823"></a>
-<span class="sourceLineNo">1824</span><a name="line.1824"></a>
-<span class="sourceLineNo">1825</span>        // skip the edit<a name="line.1825"></a>
-<span class="sourceLineNo">1826</span>        if (loc == null || needSkip) continue;<a name="line.1826"></a>
-<span class="sourceLineNo">1827</span><a name="line.1827"></a>
-<span class="sourceLineNo">1828</span>        if (!skippedCells.isEmpty()) {<a name="line.1828"></a>
-<span class="sourceLineNo">1829</span>          cells.removeAll(skippedCells);<a name="line.1829"></a>
-<span class="sourceLineNo">1830</span>        }<a name="line.1830"></a>
-<span class="sourceLineNo">1831</span><a name="line.1831"></a>
-<span class="sourceLineNo">1832</span>        synchronized (serverToBufferQueueMap) {<a name="line.1832"></a>
-<span class="sourceLineNo">1833</span>          locKey = loc.getHostnamePort() + KEY_DELIMITER + table;<a name="line.1833"></a>
-<span class="sourceLineNo">1834</span>          List&lt;Pair&lt;HRegionLocation, Entry&gt;&gt; queue = serverToBufferQueueMap.get(locKey);<a name="line.1834"></a>
-<span class="sourceLineNo">1835</span>          if (queue == null) {<a name="line.1835"></a>
-<span class="sourceLineNo">1836</span>            queue =<a name="line.1836"></a>
-<span class="sourceLineNo">1837</span>                Collections.synchronizedList(new ArrayList&lt;Pair&lt;HRegionLocation, Entry&gt;&gt;());<a name="line.1837"></a>
-<span class="sourceLineNo">1838</span>            serverToBufferQueueMap.put(locKey, queue);<a name="line.1838"></a>
-<span class="sourceLineNo">1839</span>          }<a name="line.1839"></a>
-<span class="sourceLineNo">1840</span>          queue.add(new Pair&lt;HRegionLocation, Entry&gt;(loc, entry));<a name="line.1840"></a>
-<span class="sourceLineNo">1841</span>        }<a name="line.1841"></a>
-<span class="sourceLineNo">1842</span>        // store regions we have recovered so far<a name="line.1842"></a>
-<span class="sourceLineNo">1843</span>        addToRecoveredRegions(loc.getRegionInfo().getEncodedName());<a name="line.1843"></a>
-<span class="sourceLineNo">1844</span>      }<a name="line.1844"></a>
-<span class="sourceLineNo">1845</span>    }<a name="line.1845"></a>
-<span class="sourceLineNo">1846</span><a name="line.1846"></a>
-<span class="sourceLineNo">1847</span>    /**<a name="line.1847"></a>
-<span class="sourceLineNo">1848</span>     * Locate destination region based on table name &amp; row. This function also makes sure the<a name="line.1848"></a>
-<span class="sourceLineNo">1849</span>     * destination region is online for replay.<a name="line.1849"></a>
-<span class="sourceLineNo">1850</span>     * @throws IOException<a name="line.1850"></a>
-<span class="sourceLineNo">1851</span>     */<a name="line.1851"></a>
-<span class="sourceLineNo">1852</span>    private HRegionLocation locateRegionAndRefreshLastFlushedSequenceId(HConnection hconn,<a name="line.1852"></a>
-<span class="sourceLineNo">1853</span>        TableName table, byte[] row, String originalEncodedRegionName) throws IOException {<a name="line.1853"></a>
-<span class="sourceLineNo">1854</span>      // fetch location from cache<a name="line.1854"></a>
-<span class="sourceLineNo">1855</span>      HRegionLocation loc = onlineRegions.get(originalEncodedRegionName);<a name="line.1855"></a>
-<span class="sourceLineNo">1856</span>      if(loc != null) return loc;<a name="line.1856"></a>
-<span class="sourceLineNo">1857</span>      // fetch location from hbase:meta directly without using cache to avoid hit old dead server<a name="line.1857"></a>
-<span class="sourceLineNo">1858</span>      loc = hconn.getRegionLocation(table, row, true);<a name="line.1858"></a>
-<span class="sourceLineNo">1859</span>      if (loc == null) {<a name="line.1859"></a>
-<span class="sourceLineNo">1860</span>        throw new IOException("Can't locate location for row:" + Bytes.toString(row)<a name="line.1860"></a>
-<span class="sourceLineNo">1861</span>            + " of table:" + table);<a name="line.1861"></a>
-<span class="sourceLineNo">1862</span>      }<a name="line.1862"></a>
-<span class="sourceLineNo">1863</span>      // check if current row moves to a different region due to region merge/split<a name="line.1863"></a>
-<span class="sourceLineNo">1864</span>      if (!originalEncodedRegionName.equalsIgnoreCase(loc.getRegionInfo().getEncodedName())) {<a name="line.1864"></a>
-<span class="sourceLineNo">1865</span>        // originalEncodedRegionName should have already flushed<a name="line.1865"></a>
-<span class="sourceLineNo">1866</span>        lastFlushedSequenceIds.put(originalEncodedRegionName, Long.MAX_VALUE);<a name="line.1866"></a>
-<span class="sourceLineNo">1867</span>        HRegionLocation tmpLoc = onlineRegions.get(loc.getRegionInfo().getEncodedName());<a name="line.1867"></a>
-<span class="sourceLineNo">1868</span>        if (tmpLoc != null) return tmpLoc;<a name="line.1868"></a>
-<span class="sourceLineNo">1869</span>      }<a name="line.1869"></a>
-<span class="sourceLineNo">1870</span><a name="line.1870"></a>
-<span class="sourceLineNo">1871</span>      Long lastFlushedSequenceId = -1l;<a name="line.1871"></a>
-<span class="sourceLineNo">1872</span>      AtomicBoolean isRecovering = new AtomicBoolean(true);<a name="line.1872"></a>
-<span class="sourceLineNo">1873</span>      loc = waitUntilRegionOnline(loc, row, this.waitRegionOnlineTimeOut, isRecovering);<a name="line.1873"></a>
-<span class="sourceLineNo">1874</span>      if (!isRecovering.get()) {<a name="line.1874"></a>
-<span class="sourceLineNo">1875</span>        // region isn't in recovering at all because WAL file may contain a region that has<a name="line.1875"></a>
-<span class="sourceLineNo">1876</span>        // been moved to somewhere before hosting RS fails<a name="line.1876"></a>
-<span class="sourceLineNo">1877</span>        lastFlushedSequenceIds.put(loc.getRegionInfo().getEncodedName(), Long.MAX_VALUE);<a name="line.1877"></a>
-<span class="sourceLineNo">1878</span>        LOG.info("logReplay skip region: " + loc.getRegionInfo().getEncodedName()<a name="line.1878"></a>
-<span class="sourceLineNo">1879</span>            + " because it's not in recovering.");<a name="line.1879"></a>
-<span class="sourceLineNo">1880</span>      } else {<a name="line.1880"></a>
-<span class="sourceLineNo">1881</span>        Long cachedLastFlushedSequenceId =<a name="line.1881"></a>
-<span class="sourceLineNo">1882</span>            lastFlushedSequenceIds.get(loc.getRegionInfo().getEncodedName());<a name="line.1882"></a>
-<span class="sourceLineNo">1883</span><a name="line.1883"></a>
-<span class="sourceLineNo">1884</span>        // retrieve last flushed sequence Id from ZK. Because region postOpenDeployTasks will<a name="line.1884"></a>
-<span class="sourceLineNo">1885</span>        // update the value for the region<a name="line.1885"></a>
-<span class="sourceLineNo">1886</span>        RegionStoreSequenceIds ids =<a name="line.1886"></a>
-<span class="sourceLineNo">1887</span>            csm.getSplitLogWorkerCoordination().getRegionFlushedSequenceId(failedServerName,<a name="line.1887"></a>
-<span class="sourceLineNo">1888</span>              loc.getRegionInfo().getEncodedName());<a name="line.1888"></a>
-<span class="sourceLineNo">1889</span>        if (ids != null) {<a name="line.1889"></a>
-<span class="sourceLineNo">1890</span>          lastFlushedSequenceId = ids.getLastFlushedSequenceId();<a name="line.1890"></a>
-<span class="sourceLineNo">1891</span>          Map&lt;byte[], Long&gt; storeIds = new TreeMap&lt;byte[], Long&gt;(Bytes.BYTES_COMPARATOR);<a name="line.1891"></a>
-<span class="sourceLineNo">1892</span>          List&lt;StoreSequenceId&gt; maxSeqIdInStores = ids.getStoreSequenceIdList();<a name="line.1892"></a>
-<span class="sourceLineNo">1893</span>          for (StoreSequenceId id : maxSeqIdInStores) {<a name="line.1893"></a>
-<span class="sourceLineNo">1894</span>            storeIds.put(id.getFamilyName().toByteArray(), id.getSequenceId());<a name="line.1894"></a>
-<span class="sourceLineNo">1895</span>          }<a name="line.1895"></a>
-<span class="sourceLineNo">1896</span>          regionMaxSeqIdInStores.put(loc.getRegionInfo().getEncodedName(), storeIds);<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>        if (cachedLastFlushedSequenceId == null<a name="line.1899"></a>
-<span class="sourceLineNo">1900</span>            || lastFlushedSequenceId &gt; cachedLastFlushedSequenceId) {<a name="line.1900"></a>
-<span class="sourceLineNo">1901</span>          lastFlushedSequenceIds.put(loc.getRegionInfo().getEncodedName(), lastFlushedSequenceId);<a name="line.1901"></a>
-<span class="sourceLineNo">1902</span>        }<a name="line.1902"></a>
-<span class="sourceLineNo">1903</span>      }<a name="line.1903"></a>
+<span class="sourceLineNo">1725</span>    private void addToRecoveredRegions(String encodedRegionName) {<a name="line.1725"></a>
+<span class="sourceLineNo">1726</span>      if (!recoveredRegions.contains(encodedRegionName)) {<a name="line.1726"></a>
+<span class="sourceLineNo">1727</span>        recoveredRegions.add(encodedRegionName);<a name="line.1727"></a>
+<span class="sourceLineNo">1728</span>      }<a name="line.1728"></a>
+<span class="sourceLineNo">1729</span>    }<a name="line.1729"></a>
+<span class="sourceLineNo">1730</span><a name="line.1730"></a>
+<span class="sourceLineNo">1731</span>    /**<a name="line.1731"></a>
+<span class="sourceLineNo">1732</span>     * Helper function to group WALEntries to individual region servers<a name="line.1732"></a>
+<span class="sourceLineNo">1733</span>     * @throws IOException<a name="line.1733"></a>
+<span class="sourceLineNo">1734</span>     */<a name="line.1734"></a>
+<span class="sourceLineNo">1735</span>    private void groupEditsByServer(List&lt;Entry&gt; entries) throws IOException {<a name="line.1735"></a>
+<span class="sourceLineNo">1736</span>      Set&lt;TableName&gt; nonExistentTables = null;<a name="line.1736"></a>
+<span class="sourceLineNo">1737</span>      Long cachedLastFlushedSequenceId = -1l;<a name="line.1737"></a>
+<span class="sourceLineNo">1738</span>      for (Entry entry : entries) {<a name="line.1738"></a>
+<span class="sourceLineNo">1739</span>        WALEdit edit = entry.getEdit();<a name="line.1739"></a>
+<span class="sourceLineNo">1740</span>        TableName table = entry.getKey().getTablename();<a name="line.1740"></a>
+<span class="sourceLineNo">1741</span>        // clear scopes which isn't needed for recovery<a name="line.1741"></a>
+<span class="sourceLineNo">1742</span>        entry.getKey().setScopes(null);<a name="line.1742"></a>
+<span class="sourceLineNo">1743</span>        String encodeRegionNameStr = Bytes.toString(entry.getKey().getEncodedRegionName());<a name="line.1743"></a>
+<span class="sourceLineNo">1744</span>        // skip edits of non-existent tables<a name="line.1744"></a>
+<span class="sourceLineNo">1745</span>        if (nonExistentTables != null &amp;&amp; nonExistentTables.contains(table)) {<a name="line.1745"></a>
+<span class="sourceLineNo">1746</span>          this.skippedEdits.incrementAndGet();<a name="line.1746"></a>
+<span class="sourceLineNo">1747</span>          continue;<a name="line.1747"></a>
+<span class="sourceLineNo">1748</span>        }<a name="line.1748"></a>
+<span class="sourceLineNo">1749</span><a name="line.1749"></a>
+<span class="sourceLineNo">1750</span>        Map&lt;byte[], Long&gt; maxStoreSequenceIds = null;<a name="line.1750"></a>
+<span class="sourceLineNo">1751</span>        boolean needSkip = false;<a name="line.1751"></a>
+<span class="sourceLineNo">1752</span>        HRegionLocation loc = null;<a name="line.1752"></a>
+<span class="sourceLineNo">1753</span>        String locKey = null;<a name="line.1753"></a>
+<span class="sourceLineNo">1754</span>        List&lt;Cell&gt; cells = edit.getCells();<a name="line.1754"></a>
+<span class="sourceLineNo">1755</span>        List&lt;Cell&gt; skippedCells = new ArrayList&lt;Cell&gt;();<a name="line.1755"></a>
+<span class="sourceLineNo">1756</span>        HConnection hconn = this.getConnectionByTableName(table);<a name="line.1756"></a>
+<span class="sourceLineNo">1757</span><a name="line.1757"></a>
+<span class="sourceLineNo">1758</span>        for (Cell cell : cells) {<a name="line.1758"></a>
+<span class="sourceLineNo">1759</span>          byte[] row = CellUtil.cloneRow(cell);<a name="line.1759"></a>
+<span class="sourceLineNo">1760</span>          byte[] family = CellUtil.cloneFamily(cell);<a name="line.1760"></a>
+<span class="sourceLineNo">1761</span>          boolean isCompactionEntry = false;<a name="line.1761"></a>
+<span class="sourceLineNo">1762</span>          if (CellUtil.matchingFamily(cell, WALEdit.METAFAMILY)) {<a name="line.1762"></a>
+<span class="sourceLineNo">1763</span>            CompactionDescriptor compaction = WALEdit.getCompaction(cell);<a name="line.1763"></a>
+<span class="sourceLineNo">1764</span>            if (compaction != null &amp;&amp; compaction.hasRegionName()) {<a name="line.1764"></a>
+<span class="sourceLineNo">1765</span>              try {<a name="line.1765"></a>
+<span class="sourceLineNo">1766</span>                byte[][] regionName = HRegionInfo.parseRegionName(compaction.getRegionName()<a name="line.1766"></a>
+<span class="sourceLineNo">1767</span>                  .toByteArray());<a name="line.1767"></a>
+<span class="sourceLineNo">1768</span>                row = regionName[1]; // startKey of the region<a name="line.1768"></a>
+<span class="sourceLineNo">1769</span>                family = compaction.getFamilyName().toByteArray();<a name="line.1769"></a>
+<span class="sourceLineNo">1770</span>                isCompactionEntry = true;<a name="line.1770"></a>
+<span class="sourceLineNo">1771</span>              } catch (Exception ex) {<a name="line.1771"></a>
+<span class="sourceLineNo">1772</span>                LOG.warn("Unexpected exception received, ignoring " + ex);<a name="line.1772"></a>
+<span class="sourceLineNo">1773</span>                skippedCells.add(cell);<a name="line.1773"></a>
+<span class="sourceLineNo">1774</span>                continue;<a name="line.1774"></a>
+<span class="sourceLineNo">1775</span>              }<a name="line.1775"></a>
+<span class="sourceLineNo">1776</span>            } else {<a name="line.1776"></a>
+<span class="sourceLineNo">1777</span>              skippedCells.add(cell);<a name="line.1777"></a>
+<span class="sourceLineNo">1778</span>              continue;<a name="line.1778"></a>
+<span class="sourceLineNo">1779</span>            }<a name="line.1779"></a>
+<span class="sourceLineNo">1780</span>          }<a name="line.1780"></a>
+<span class="sourceLineNo">1781</span><a name="line.1781"></a>
+<span class="sourceLineNo">1782</span>          try {<a name="line.1782"></a>
+<span class="sourceLineNo">1783</span>            loc =<a name="line.1783"></a>
+<span class="sourceLineNo">1784</span>                locateRegionAndRefreshLastFlushedSequenceId(hconn, table, row,<a name="line.1784"></a>
+<span class="sourceLineNo">1785</span>                  encodeRegionNameStr);<a name="line.1785"></a>
+<span class="sourceLineNo">1786</span>            // skip replaying the compaction if the region is gone<a name="line.1786"></a>
+<span class="sourceLineNo">1787</span>            if (isCompactionEntry &amp;&amp; !encodeRegionNameStr.equalsIgnoreCase(<a name="line.1787"></a>
+<span class="sourceLineNo">1788</span>              loc.getRegionInfo().getEncodedName())) {<a name="line.1788"></a>
+<span class="sourceLineNo">1789</span>              LOG.info("Not replaying a compaction marker for an older region: "<a name="line.1789"></a>
+<span class="sourceLineNo">1790</span>                  + encodeRegionNameStr);<a name="line.1790"></a>
+<span class="sourceLineNo">1791</span>              needSkip = true;<a name="line.1791"></a>
+<span class="sourceLineNo">1792</span>            }<a name="line.1792"></a>
+<span class="sourceLineNo">1793</span>          } catch (TableNotFoundException ex) {<a name="line.1793"></a>
+<span class="sourceLineNo">1794</span>            // table has been deleted so skip edits of the table<a name="line.1794"></a>
+<span class="sourceLineNo">1795</span>            LOG.info("Table " + table + " doesn't exist. Skip log replay for region "<a name="line.1795"></a>
+<span class="sourceLineNo">1796</span>                + encodeRegionNameStr);<a name="line.1796"></a>
+<span class="sourceLineNo">1797</span>            lastFlushedSequenceIds.put(encodeRegionNameStr, Long.MAX_VALUE);<a name="line.1797"></a>
+<span class="sourceLineNo">1798</span>            if (nonExistentTables == null) {<a name="line.1798"></a>
+<span class="sourceLineNo">1799</span>              nonExistentTables = new TreeSet&lt;TableName&gt;();<a name="line.1799"></a>
+<span class="sourceLineNo">1800</span>            }<a name="line.1800"></a>
+<span class="sourceLineNo">1801</span>            nonExistentTables.add(table);<a name="line.1801"></a>
+<span class="sourceLineNo">1802</span>            this.skippedEdits.incrementAndGet();<a name="line.1802"></a>
+<span class="sourceLineNo">1803</span>            needSkip = true;<a name="line.1803"></a>
+<span class="sourceLineNo">1804</span>            break;<a name="line.1804"></a>
+<span class="sourceLineNo">1805</span>          }<a name="line.1805"></a>
+<span class="sourceLineNo">1806</span><a name="line.1806"></a>
+<span class="sourceLineNo">1807</span>          cachedLastFlushedSequenceId =<a name="line.1807"></a>
+<span class="sourceLineNo">1808</span>              lastFlushedSequenceIds.get(loc.getRegionInfo().getEncodedName());<a name="line.1808"></a>
+<span class="sourceLineNo">1809</span>          if (cachedLastFlushedSequenceId != null<a name="line.1809"></a>
+<span class="sourceLineNo">1810</span>              &amp;&amp; cachedLastFlushedSequenceId &gt;= entry.getKey().getLogSeqNum()) {<a name="line.1810"></a>
+<span class="sourceLineNo">1811</span>            // skip the whole WAL entry<a name="line.1811"></a>
+<span class="sourceLineNo">1812</span>            this.skippedEdits.incrementAndGet();<a name="line.1812"></a>
+<span class="sourceLineNo">1813</span>            needSkip = true;<a name="line.1813"></a>
+<span class="sourceLineNo">1814</span>            break;<a name="line.1814"></a>
+<span class="sourceLineNo">1815</span>          } else {<a name="line.1815"></a>
+<span class="sourceLineNo">1816</span>            if (maxStoreSequenceIds == null) {<a name="line.1816"></a>
+<span class="sourceLineNo">1817</span>              maxStoreSequenceIds =<a name="line.1817"></a>
+<span class="sourceLineNo">1818</span>                  regionMaxSeqIdInStores.get(loc.getRegionInfo().getEncodedName());<a name="line.1818"></a>
+<span class="sourceLineNo">1819</span>            }<a name="line.1819"></a>
+<span class="sourceLineNo">1820</span>            if (maxStoreSequenceIds != null) {<a name="line.1820"></a>
+<span class="sourceLineNo">1821</span>              Long maxStoreSeqId = maxStoreSequenceIds.get(family);<a name="line.1821"></a>
+<span class="sourceLineNo">1822</span>              if (maxStoreSeqId == null || maxStoreSeqId &gt;= entry.getKey().getLogSeqNum()) {<a name="line.1822"></a>
+<span class="sourceLineNo">1823</span>                // skip current kv if column family doesn't exist anymore or already flushed<a name="line.1823"></a>
+<span class="sourceLineNo">1824</span>                skippedCells.add(cell);<a name="line.1824"></a>
+<span class="sourceLineNo">1825</span>                continue;<a name="line.1825"></a>
+<span class="sourceLineNo">1826</span>              }<a name="line.1826"></a>
+<span class="sourceLineNo">1827</span>            }<a name="line.1827"></a>
+<span class="sourceLineNo">1828</span>          }<a name="line.1828"></a>
+<span class="sourceLineNo">1829</span>        }<a name="line.1829"></a>
+<span class="sourceLineNo">1830</span><a name="line.1830"></a>
+<span class="sourceLineNo">1831</span>        // skip the edit<a name="line.1831"></a>
+<span class="sourceLineNo">1832</span>        if (loc == null || needSkip) continue;<a name="line.1832"></a>
+<span class="sourceLineNo">1833</span><a name="line.1833"></a>
+<span class="sourceLineNo">1834</span>        if (!skippedCells.isEmpty()) {<a name="line.1834"></a>
+<span class="sourceLineNo">1835</span>          cells.removeAll(skippedCells);<a name="line.1835"></a>
+<span class="sourceLineNo">1836</span>        }<a name="line.1836"></a>
+<span class="sourceLineNo">1837</span><a name="line.1837"></a>
+<span class="sourceLineNo">1838</span>        synchronized (serverToBufferQueueMap) {<a name="line.1838"></a>
+<span class="sourceLineNo">1839</span>          locKey = loc.getHostnamePort() + KEY_DELIMITER + table;<a name="line.1839"></a>
+<span class="sourceLineNo">1840</span>          List&lt;Pair&lt;HRegionLocation, Entry&gt;&gt; queue = serverToBufferQueueMap.get(locKey);<a name="line.1840"></a>
+<span class="sourceLineNo">1841</span>          if (queue == null) {<a name="line.1841"></a>
+<span class="sourceLineNo">1842</span>            queue =<a name="line.1842"></a>
+<span class="sourceLineNo">1843</span>                Collections.synchronizedList(new ArrayList&lt;Pair&lt;HRegionLocation, Entry&gt;&gt;());<a name="line.1843"></a>
+<span class="sourceLineNo">1844</span>            serverToBufferQueueMap.put(locKey, queue);<a name="line.1844"></a>
+<span class="sourceLineNo">1845</span>          }<a name="line.1845"></a>
+<span class="sourceLineNo">1846</span>          queue.add(new Pair&lt;HRegionLocation, Entry&gt;(loc, entry));<a name="line.1846"></a>
+<span class="sourceLineNo">1847</span>        }<a name="line.1847"></a>
+<span class="sourceLineNo">1848</span>        // store regions we have recovered so far<a name="line.1848"></a>
+<span class="sourceLineNo">1849</span>        addToRecoveredRegions(loc.getRegionInfo().getEncodedName());<a name="line.1849"></a>
+<span class="sourceLineNo">1850</span>      }<a name="line.1850"></a>
+<span class="sourceLineNo">1851</span>    }<a name="line.1851"></a>
+<span class="sourceLineNo">1852</span><a name="line.1852"></a>
+<span class="sourceLineNo">1853</span>    /**<a name="line.1853"></a>
+<span class="sourceLineNo">1854</span>     * Locate destination region based on table name &amp; row. This function also makes sure the<a name="line.1854"></a>
+<span class="sourceLineNo">1855</span>     * destination region is online for replay.<a name="line.1855"></a>
+<span class="sourceLineNo">1856</span>     * @throws IOException<a name="line.1856"></a>
+<span class="sourceLineNo">1857</span>     */<a name="line.1857"></a>
+<span class="sourceLineNo">1858</span>    private HRegionLocation locateRegionAndRefreshLastFlushedSequenceId(HConnection hconn,<a name="line.1858"></a>
+<span class="sourceLineNo">1859</span>        TableName table, byte[] row, String originalEncodedRegionName) throws IOException {<a name="line.1859"></a>
+<span class="sourceLineNo">1860</span>      // fetch location from cache<a name="line.1860"></a>
+<span class="sourceLineNo">1861</span>      HRegionLocation loc = onlineRegions.get(originalEncodedRegionName);<a name="line.1861"></a>
+<span class="sourceLineNo">1862</span>      if(loc != null) return loc;<a name="line.1862"></a>
+<span class="sourceLineNo">1863</span>      // fetch location from hbase:meta directly without using cache to avoid hit old dead server<a name="line.1863"></a>
+<span class="sourceLineNo">1864</span>      loc = hconn.getRegionLocation(table, row, true);<a name="line.1864"></a>
+<span class="sourceLineNo">1865</span>      if (loc == null) {<a name="line.1865"></a>
+<span class="sourceLineNo">1866</span>        throw new IOException("Can't locate location for row:" + Bytes.toString(row)<a name="line.1866"></a>
+<span class="sourceLineNo">1867</span>            + " of table:" + table);<a name="line.1867"></a>
+<span class="sourceLineNo">1868</span>      }<a name="line.1868"></a>
+<span class="sourceLineNo">1869</span>      // check if current row moves to a different region due to region merge/split<a name="line.1869"></a>
+<span class="sourceLineNo">1870</span>      if (!originalEncodedRegionName.equalsIgnoreCase(loc.getRegionInfo().getEncodedName())) {<a name="line.1870"></a>
+<span class="sourceLineNo">1871</span>        // originalEncodedRegionName should have already flushed<a name="line.1871"></a>
+<span class="sourceLineNo">1872</span>        lastFlushedSequenceIds.put(originalEncodedRegionName, Long.MAX_VALUE);<a name="line.1872"></a>
+<span class="sourceLineNo">1873</span>        HRegionLocation tmpLoc = onlineRegions.get(loc.getRegionInfo().getEncodedName());<a name="line.1873"></a>
+<span class="sourceLineNo">1874</span>        if (tmpLoc != null) return tmpLoc;<a name="line.1874"></a>
+<span class="sourceLineNo">1875</span>      }<a name="line.1875"></a>
+<span class="sourceLineNo">1876</span><a name="line.1876"></a>
+<span class="sourceLineNo">1877</span>      Long lastFlushedSequenceId = -1l;<a name="line.1877"></a>
+<span class="sourceLineNo">1878</span>      AtomicBoolean isRecovering = new AtomicBoolean(true);<a name="line.1878"></a>
+<span class="sourceLineNo">1879</span>      loc = waitUntilRegionOnline(loc, row, this.waitRegionOnlineTimeOut, isRecovering);<a name="line.1879"></a>
+<span class="sourceLineNo">1880</span>      if (!isRecovering.get()) {<a name="line.1880"></a>
+<span class="sourceLineNo">1881</span>        // region isn't in recovering at all because WAL file may contain a region that has<a name="line.1881"></a>
+<span class="sourceLineNo">1882</span>        // been moved to somewhere before hosting RS fails<a name="line.1882"></a>
+<span class="sourceLineNo">1883</span>        lastFlushedSequenceIds.put(loc.getRegionInfo().getEncodedName(), Long.MAX_VALUE);<a name="line.1883"></a>
+<span class="sourceLineNo">1884</span>        LOG.info("logReplay skip region: " + loc.getRegionInfo().getEncodedName()<a name="line.1884"></a>
+<span class="sourceLineNo">1885</span>            + " because it's not in recovering.");<a name="line.1885"></a>
+<span class="sourceLineNo">1886</span>      } else {<a name="line.1886"></a>
+<span class="sourceLineNo">1887</span>        Long cachedLastFlushedSequenceId =<a name="line.1887"></a>
+<span class="sourceLineNo">1888</span>            lastFlushedSequenceIds.get(loc.getRegionInfo().getEncodedName());<a name="line.1888"></a>
+<span class="sourceLineNo">1889</span><a name="line.1889"></a>
+<span class="sourceLineNo">1890</span>        // retrieve last flushed sequence Id from ZK. Because region postOpenDeployTasks will<a name="line.1890"></a>
+<span class="sourceLineNo">1891</span>        // update the value for the region<a name="line.1891"></a>
+<span class="sourceLineNo">1892</span>        RegionStoreSequenceIds ids =<a name="line.1892"></a>
+<span class="sourceLineNo">1893</span>            csm.getSplitLogWorkerCoordination().getRegionFlushedSequenceId(failedServerName,<a name="line.1893"></a>
+<span class="sourceLineNo">1894</span>              loc.getRegionInfo().getEncodedName());<a name="line.1894"></a>
+<span class="sourceLineNo">1895</span>        if (ids != null) {<a name="line.1895"></a>
+<span class="sourceLineNo">1896</span>          lastFlushedSequenceId = ids.getLastFlushedSequenceId();<a name="line.1896"></a>
+<span class="sourceLineNo">1897</span>          Map&lt;byte[], Long&gt; storeIds = new TreeMap&lt;byte[], Long&gt;(Bytes.BYTES_COMPARATOR);<a name="line.1897"></a>
+<span class="sourceLineNo">1898</span>          List&lt;StoreSequenceId&gt; maxSeqIdInStores = ids.getStoreSequenceIdList();<a name="line.1898"></a>
+<span class="sourceLineNo">1899</span>          for (StoreSequenceId id : maxSeqIdInStores) {<a name="line.1899"></a>
+<span class="sourceLineNo">1900</span>            storeIds.put(id.getFamilyName().toByteArray(), id.getSequenceId());<a name="line.1900"></a>
+<span class="sourceLineNo">1901</span>          }<a name="line.1901"></a>
+<span class="sourceLineNo">1902</span>          regionMaxSeqIdInStores.put(loc.getRegionInfo().getEncodedName(), storeIds);<a name="line.1902"></a>
+<span class="sourceLineNo">1903</span>        }<a name="line.1903"></a>
 <span class="sourceLineNo">1904</span><a name="line.1904"></a>
-<span class="sourceLineNo">1905</span>      onlineRegions.put(loc.getRegionInfo().getEncodedName(), loc);<a name="line.1905"></a>
-<span class="sourceLineNo">1906</span>      return loc;<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>    private void processWorkItems(String key, List&lt;Pair&lt;HRegionLocation, Entry&gt;&gt; actions)<a name="line.1909"></a>
-<span class="sourceLineNo">1910</span>        throws IOException {<a name="line.1910"></a>
-<span class="sourceLineNo">1911</span>      RegionServerWriter rsw = null;<a name="line.1911"></a>
-<span class="sourceLineNo">1912</span><a name="line.1912"></a>
-<span class="sourceLineNo">1913</span>      long startTime = System.nanoTime();<a name="line.1913"></a>
-<span class="sourceLineNo">1914</span>      try {<a name="line.1914"></a>
-<span class="sourceLineNo">1915</span>        rsw = getRegionServerWriter(key);<a name="line.1915"></a>
-<span class="sourceLineNo">1916</span>        rsw.sink.replayEntries(actions);<a name="line.1916"></a>
-<span class="sourceLineNo">1917</span><a name="line.1917"></a>
-<span class="sourceLineNo">1918</span>        // Pass along summary statistics<a name="line.1918"></a>
-<span class="sourceLineNo">1919</span>        rsw.incrementEdits(actions.size());<a name="line.1919"></a>
-<span class="sourceLineNo">1920</span>        rsw.incrementNanoTime(System.nanoTime() - startTime);<a name="line.1920"></a>
-<span class="sourceLineNo">1921</span>      } catch (IOException e) {<a name="line.1921"></a>
-<span class="sourceLineNo">1922</span>        e = e instanceof RemoteException ? ((RemoteException) e).unwrapRemoteException() : e;<a name="line.1922"></a>
-<span class="sourceLineNo">1923</span>        LOG.fatal(" Got while writing log entry to log", e);<a name="line.1923"></a>
-<span class="sourceLineNo">1924</span>        throw e;<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>     * Wait until region is online on the destination region server<a name="line.1929"></a>
-<span class="sourceLineNo">1930</span>     * @param loc<a name="line.1930"></a>
-<span class="sourceLineNo">1931</span>     * @param row<a name="line.1931"></a>
-<span class="sourceLineNo">1932</span>     * @param timeout How long to wait<a name="line.1932"></a>
-<span class="sourceLineNo">1933</span>     * @param isRecovering Recovering state of the region interested on destination region server.<a name="line.1933"></a>
-<span class="sourceLineNo">1934</span>     * @return True when region is online on the destination region server<a name="line.1934"></a>
-<span class="sourceLineNo">1935</span>     * @throws InterruptedException<a name="line.1935"></a>
-<span class="sourceLineNo">1936</span>     */<a name="line.1936"></a>
-<span class="sourceLineNo">1937</span>    private HRegionLocation waitUntilRegionOnline(HRegionLocation loc, byte[] row,<a name="line.1937"></a>
-<span class="sourceLineNo">1938</span>        final long timeout, AtomicBoolean isRecovering)<a name="line.1938"></a>
-<span class="sourceLineNo">1939</span>        throws IOException {<a name="line.1939"></a>
-<span class="sourceLineNo">1940</span>      final long endTime = EnvironmentEdgeManager.currentTime() + timeout;<a name="line.1940"></a>
-<span class="sourceLineNo">1941</span>      final long pause = conf.getLong(HConstants.HBASE_CLIENT_PAUSE,<a name="line.1941"></a>
-<span class="sourceLineNo">1942</span>        HConstants.DEFAULT_HBASE_CLIENT_PAUSE);<a name="line.1942"></a>
-<span class="sourceLineNo">1943</span>      boolean reloadLocation = false;<a name="line.1943"></a>
-<span class="sourceLineNo">1944</span>      TableName tableName = loc.getRegionInfo().getTable();<a name="line.1944"></a>
-<span class="sourceLineNo">1945</span>      int tries = 0;<a name="line.1945"></a>
-<span class="sourceLineNo">1946</span>      Throwable cause = null;<a name="line.1946"></a>
-<span class="sourceLineNo">1947</span>      while (endTime &gt; EnvironmentEdgeManager.currentTime()) {<a name="line.1947"></a>
-<span class="sourceLineNo">1948</span>        try {<a name="line.1948"></a>
-<span class="sourceLineNo">1949</span>          // Try and get regioninfo from the hosting server.<a name="line.1949"></a>
-<span class="sourceLineNo">1950</span>          HConnection hconn = getConnectionByTableName(tableName);<a name="line.1950"></a>
-<span class="sourceLineNo">1951</span>          if(reloadLocation) {<a name="line.1951"></a>
-<span class="sourceLineNo">1952</span>            loc = hconn.getRegionLocation(tableName, row, true);<a name="line.1952"></a>
-<span class="sourceLineNo">1953</span>          }<a name="line.1953"></a>
-<span class="sourceLineNo">1954</span>          BlockingInterface remoteSvr = hconn.getAdmin(loc.getServerName());<a name="line.1954"></a>
-<span class="sourceLineNo">1955</span>          HRegionInfo region = loc.getRegionInfo();<a name="line.1955"></a>
-<span class="sourceLineNo">1956</span>          try {<a name="line.1956"></a>
-<span class="sourceLineNo">1957</span>            GetRegionInfoRequest request =<a name="line.1957"></a>
-<span class="sourceLineNo">1958</span>                RequestConverter.buildGetRegionInfoRequest(region.getRegionName());<a name="line.1958"></a>
-<span class="sourceLineNo">1959</span>            GetRegionInfoResponse response = remoteSvr.getRegionInfo(null, request);<a name="line.1959"></a>
-<span class="sourceLineNo">1960</span>            if (HRegionInfo.convert(response.getRegionInfo()) != null) {<a name="line.1960"></a>
-<span class="sourceLineNo">1961</span>              isRecovering.set((response.hasIsRecovering()) ? response.getIsRecovering() : true);<a name="line.1961"></a>
-<span class="sourceLineNo">1962</span>              return loc;<a name="line.1962"></a>
-<span class="sourceLineNo">1963</span>            }<a name="line.1963"></a>
-<span class="sourceLineNo">1964</span>          } catch (ServiceException se) {<a name="line.1964"></a>
-<span class="sourceLineNo">1965</span>            throw ProtobufUtil.getRemoteException(se);<a name="line.1965"></a>
-<span class="sourceLineNo">1966</span>          }<a name="line.1966"></a>
-<span class="sour

<TRUNCATED>

Mime
View raw message