hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [12/31] hbase-site git commit: Published site at 3e7f724837e35f41153bc3059e8ac507583a9200.
Date Wed, 04 Jul 2018 14:51:16 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/624dc6ea/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.WalProps.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.WalProps.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.WalProps.html
index 552067a..a72f1af 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.WalProps.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.WalProps.html
@@ -371,784 +371,785 @@
 <span class="sourceLineNo">363</span>    }<a name="line.363"></a>
 <span class="sourceLineNo">364</span>    // Now that it exists, set the storage policy for the entire directory of wal files related to<a name="line.364"></a>
 <span class="sourceLineNo">365</span>    // this FSHLog instance<a name="line.365"></a>
-<span class="sourceLineNo">366</span>    CommonFSUtils.setStoragePolicy(fs, conf, this.walDir, HConstants.WAL_STORAGE_POLICY,<a name="line.366"></a>
-<span class="sourceLineNo">367</span>      HConstants.DEFAULT_WAL_STORAGE_POLICY);<a name="line.367"></a>
-<span class="sourceLineNo">368</span>    this.walFileSuffix = (suffix == null) ? "" : URLEncoder.encode(suffix, "UTF8");<a name="line.368"></a>
-<span class="sourceLineNo">369</span>    this.prefixPathStr = new Path(walDir, walFilePrefix + WAL_FILE_NAME_DELIMITER).toString();<a name="line.369"></a>
-<span class="sourceLineNo">370</span><a name="line.370"></a>
-<span class="sourceLineNo">371</span>    this.ourFiles = new PathFilter() {<a name="line.371"></a>
-<span class="sourceLineNo">372</span>      @Override<a name="line.372"></a>
-<span class="sourceLineNo">373</span>      public boolean accept(final Path fileName) {<a name="line.373"></a>
-<span class="sourceLineNo">374</span>        // The path should start with dir/&lt;prefix&gt; and end with our suffix<a name="line.374"></a>
-<span class="sourceLineNo">375</span>        final String fileNameString = fileName.toString();<a name="line.375"></a>
-<span class="sourceLineNo">376</span>        if (!fileNameString.startsWith(prefixPathStr)) {<a name="line.376"></a>
-<span class="sourceLineNo">377</span>          return false;<a name="line.377"></a>
-<span class="sourceLineNo">378</span>        }<a name="line.378"></a>
-<span class="sourceLineNo">379</span>        if (walFileSuffix.isEmpty()) {<a name="line.379"></a>
-<span class="sourceLineNo">380</span>          // in the case of the null suffix, we need to ensure the filename ends with a timestamp.<a name="line.380"></a>
-<span class="sourceLineNo">381</span>          return org.apache.commons.lang3.StringUtils<a name="line.381"></a>
-<span class="sourceLineNo">382</span>              .isNumeric(fileNameString.substring(prefixPathStr.length()));<a name="line.382"></a>
-<span class="sourceLineNo">383</span>        } else if (!fileNameString.endsWith(walFileSuffix)) {<a name="line.383"></a>
-<span class="sourceLineNo">384</span>          return false;<a name="line.384"></a>
-<span class="sourceLineNo">385</span>        }<a name="line.385"></a>
-<span class="sourceLineNo">386</span>        return true;<a name="line.386"></a>
-<span class="sourceLineNo">387</span>      }<a name="line.387"></a>
-<span class="sourceLineNo">388</span>    };<a name="line.388"></a>
-<span class="sourceLineNo">389</span><a name="line.389"></a>
-<span class="sourceLineNo">390</span>    if (failIfWALExists) {<a name="line.390"></a>
-<span class="sourceLineNo">391</span>      final FileStatus[] walFiles = CommonFSUtils.listStatus(fs, walDir, ourFiles);<a name="line.391"></a>
-<span class="sourceLineNo">392</span>      if (null != walFiles &amp;&amp; 0 != walFiles.length) {<a name="line.392"></a>
-<span class="sourceLineNo">393</span>        throw new IOException("Target WAL already exists within directory " + walDir);<a name="line.393"></a>
-<span class="sourceLineNo">394</span>      }<a name="line.394"></a>
-<span class="sourceLineNo">395</span>    }<a name="line.395"></a>
-<span class="sourceLineNo">396</span><a name="line.396"></a>
-<span class="sourceLineNo">397</span>    // Register listeners. TODO: Should this exist anymore? We have CPs?<a name="line.397"></a>
-<span class="sourceLineNo">398</span>    if (listeners != null) {<a name="line.398"></a>
-<span class="sourceLineNo">399</span>      for (WALActionsListener i : listeners) {<a name="line.399"></a>
-<span class="sourceLineNo">400</span>        registerWALActionsListener(i);<a name="line.400"></a>
-<span class="sourceLineNo">401</span>      }<a name="line.401"></a>
-<span class="sourceLineNo">402</span>    }<a name="line.402"></a>
-<span class="sourceLineNo">403</span>    this.coprocessorHost = new WALCoprocessorHost(this, conf);<a name="line.403"></a>
-<span class="sourceLineNo">404</span><a name="line.404"></a>
-<span class="sourceLineNo">405</span>    // Schedule a WAL roll when the WAL is 50% of the HDFS block size. Scheduling at 50% of block<a name="line.405"></a>
-<span class="sourceLineNo">406</span>    // size should make it so WAL rolls before we get to the end-of-block (Block transitions cost<a name="line.406"></a>
-<span class="sourceLineNo">407</span>    // some latency). In hbase-1 we did this differently. We scheduled a roll when we hit 95% of<a name="line.407"></a>
-<span class="sourceLineNo">408</span>    // the block size but experience from the field has it that this was not enough time for the<a name="line.408"></a>
-<span class="sourceLineNo">409</span>    // roll to happen before end-of-block. So the new accounting makes WALs of about the same<a name="line.409"></a>
-<span class="sourceLineNo">410</span>    // size as those made in hbase-1 (to prevent surprise), we now have default block size as<a name="line.410"></a>
-<span class="sourceLineNo">411</span>    // 2 times the DFS default: i.e. 2 * DFS default block size rolling at 50% full will generally<a name="line.411"></a>
-<span class="sourceLineNo">412</span>    // make similar size logs to 1 * DFS default block size rolling at 95% full. See HBASE-19148.<a name="line.412"></a>
-<span class="sourceLineNo">413</span>    this.blocksize = WALUtil.getWALBlockSize(this.conf, this.fs, this.walDir);<a name="line.413"></a>
-<span class="sourceLineNo">414</span>    float multiplier = conf.getFloat("hbase.regionserver.logroll.multiplier", 0.5f);<a name="line.414"></a>
-<span class="sourceLineNo">415</span>    this.logrollsize = (long)(this.blocksize * multiplier);<a name="line.415"></a>
-<span class="sourceLineNo">416</span><a name="line.416"></a>
-<span class="sourceLineNo">417</span>    boolean maxLogsDefined = conf.get("hbase.regionserver.maxlogs") != null;<a name="line.417"></a>
-<span class="sourceLineNo">418</span>    if (maxLogsDefined) {<a name="line.418"></a>
-<span class="sourceLineNo">419</span>      LOG.warn("'hbase.regionserver.maxlogs' was deprecated.");<a name="line.419"></a>
-<span class="sourceLineNo">420</span>    }<a name="line.420"></a>
-<span class="sourceLineNo">421</span>    this.maxLogs = conf.getInt("hbase.regionserver.maxlogs",<a name="line.421"></a>
-<span class="sourceLineNo">422</span>      Math.max(32, calculateMaxLogFiles(conf, logrollsize)));<a name="line.422"></a>
-<span class="sourceLineNo">423</span><a name="line.423"></a>
-<span class="sourceLineNo">424</span>    LOG.info("WAL configuration: blocksize=" + StringUtils.byteDesc(blocksize) + ", rollsize=" +<a name="line.424"></a>
-<span class="sourceLineNo">425</span>      StringUtils.byteDesc(this.logrollsize) + ", prefix=" + this.walFilePrefix + ", suffix=" +<a name="line.425"></a>
-<span class="sourceLineNo">426</span>      walFileSuffix + ", logDir=" + this.walDir + ", archiveDir=" + this.walArchiveDir);<a name="line.426"></a>
-<span class="sourceLineNo">427</span>    this.slowSyncNs = TimeUnit.MILLISECONDS<a name="line.427"></a>
-<span class="sourceLineNo">428</span>        .toNanos(conf.getInt("hbase.regionserver.hlog.slowsync.ms", DEFAULT_SLOW_SYNC_TIME_MS));<a name="line.428"></a>
-<span class="sourceLineNo">429</span>    this.walSyncTimeoutNs = TimeUnit.MILLISECONDS<a name="line.429"></a>
-<span class="sourceLineNo">430</span>        .toNanos(conf.getLong("hbase.regionserver.hlog.sync.timeout", DEFAULT_WAL_SYNC_TIMEOUT_MS));<a name="line.430"></a>
-<span class="sourceLineNo">431</span>    int maxHandlersCount = conf.getInt(HConstants.REGION_SERVER_HANDLER_COUNT, 200);<a name="line.431"></a>
-<span class="sourceLineNo">432</span>    // Presize our map of SyncFutures by handler objects.<a name="line.432"></a>
-<span class="sourceLineNo">433</span>    this.syncFuturesByHandler = new ConcurrentHashMap&lt;&gt;(maxHandlersCount);<a name="line.433"></a>
-<span class="sourceLineNo">434</span>    this.implClassName = getClass().getSimpleName();<a name="line.434"></a>
-<span class="sourceLineNo">435</span>  }<a name="line.435"></a>
-<span class="sourceLineNo">436</span><a name="line.436"></a>
-<span class="sourceLineNo">437</span>  /**<a name="line.437"></a>
-<span class="sourceLineNo">438</span>   * Used to initialize the WAL. Usually just call rollWriter to create the first log writer.<a name="line.438"></a>
-<span class="sourceLineNo">439</span>   */<a name="line.439"></a>
-<span class="sourceLineNo">440</span>  public void init() throws IOException {<a name="line.440"></a>
-<span class="sourceLineNo">441</span>    rollWriter();<a name="line.441"></a>
-<span class="sourceLineNo">442</span>  }<a name="line.442"></a>
-<span class="sourceLineNo">443</span><a name="line.443"></a>
-<span class="sourceLineNo">444</span>  @Override<a name="line.444"></a>
-<span class="sourceLineNo">445</span>  public void registerWALActionsListener(WALActionsListener listener) {<a name="line.445"></a>
-<span class="sourceLineNo">446</span>    this.listeners.add(listener);<a name="line.446"></a>
-<span class="sourceLineNo">447</span>  }<a name="line.447"></a>
-<span class="sourceLineNo">448</span><a name="line.448"></a>
-<span class="sourceLineNo">449</span>  @Override<a name="line.449"></a>
-<span class="sourceLineNo">450</span>  public boolean unregisterWALActionsListener(WALActionsListener listener) {<a name="line.450"></a>
-<span class="sourceLineNo">451</span>    return this.listeners.remove(listener);<a name="line.451"></a>
-<span class="sourceLineNo">452</span>  }<a name="line.452"></a>
-<span class="sourceLineNo">453</span><a name="line.453"></a>
-<span class="sourceLineNo">454</span>  @Override<a name="line.454"></a>
-<span class="sourceLineNo">455</span>  public WALCoprocessorHost getCoprocessorHost() {<a name="line.455"></a>
-<span class="sourceLineNo">456</span>    return coprocessorHost;<a name="line.456"></a>
-<span class="sourceLineNo">457</span>  }<a name="line.457"></a>
-<span class="sourceLineNo">458</span><a name="line.458"></a>
-<span class="sourceLineNo">459</span>  @Override<a name="line.459"></a>
-<span class="sourceLineNo">460</span>  public Long startCacheFlush(byte[] encodedRegionName, Set&lt;byte[]&gt; families) {<a name="line.460"></a>
-<span class="sourceLineNo">461</span>    return this.sequenceIdAccounting.startCacheFlush(encodedRegionName, families);<a name="line.461"></a>
-<span class="sourceLineNo">462</span>  }<a name="line.462"></a>
-<span class="sourceLineNo">463</span><a name="line.463"></a>
-<span class="sourceLineNo">464</span>  @Override<a name="line.464"></a>
-<span class="sourceLineNo">465</span>  public Long startCacheFlush(byte[] encodedRegionName, Map&lt;byte[], Long&gt; familyToSeq) {<a name="line.465"></a>
-<span class="sourceLineNo">466</span>    return this.sequenceIdAccounting.startCacheFlush(encodedRegionName, familyToSeq);<a name="line.466"></a>
-<span class="sourceLineNo">467</span>  }<a name="line.467"></a>
-<span class="sourceLineNo">468</span><a name="line.468"></a>
-<span class="sourceLineNo">469</span>  @Override<a name="line.469"></a>
-<span class="sourceLineNo">470</span>  public void completeCacheFlush(byte[] encodedRegionName) {<a name="line.470"></a>
-<span class="sourceLineNo">471</span>    this.sequenceIdAccounting.completeCacheFlush(encodedRegionName);<a name="line.471"></a>
-<span class="sourceLineNo">472</span>  }<a name="line.472"></a>
-<span class="sourceLineNo">473</span><a name="line.473"></a>
-<span class="sourceLineNo">474</span>  @Override<a name="line.474"></a>
-<span class="sourceLineNo">475</span>  public void abortCacheFlush(byte[] encodedRegionName) {<a name="line.475"></a>
-<span class="sourceLineNo">476</span>    this.sequenceIdAccounting.abortCacheFlush(encodedRegionName);<a name="line.476"></a>
-<span class="sourceLineNo">477</span>  }<a name="line.477"></a>
-<span class="sourceLineNo">478</span><a name="line.478"></a>
-<span class="sourceLineNo">479</span>  @Override<a name="line.479"></a>
-<span class="sourceLineNo">480</span>  public long getEarliestMemStoreSeqNum(byte[] encodedRegionName) {<a name="line.480"></a>
-<span class="sourceLineNo">481</span>    // Used by tests. Deprecated as too subtle for general usage.<a name="line.481"></a>
-<span class="sourceLineNo">482</span>    return this.sequenceIdAccounting.getLowestSequenceId(encodedRegionName);<a name="line.482"></a>
-<span class="sourceLineNo">483</span>  }<a name="line.483"></a>
-<span class="sourceLineNo">484</span><a name="line.484"></a>
-<span class="sourceLineNo">485</span>  @Override<a name="line.485"></a>
-<span class="sourceLineNo">486</span>  public long getEarliestMemStoreSeqNum(byte[] encodedRegionName, byte[] familyName) {<a name="line.486"></a>
-<span class="sourceLineNo">487</span>    // This method is used by tests and for figuring if we should flush or not because our<a name="line.487"></a>
-<span class="sourceLineNo">488</span>    // sequenceids are too old. It is also used reporting the master our oldest sequenceid for use<a name="line.488"></a>
-<span class="sourceLineNo">489</span>    // figuring what edits can be skipped during log recovery. getEarliestMemStoreSequenceId<a name="line.489"></a>
-<span class="sourceLineNo">490</span>    // from this.sequenceIdAccounting is looking first in flushingOldestStoreSequenceIds, the<a name="line.490"></a>
-<span class="sourceLineNo">491</span>    // currently flushing sequence ids, and if anything found there, it is returning these. This is<a name="line.491"></a>
-<span class="sourceLineNo">492</span>    // the right thing to do for the reporting oldest sequenceids to master; we won't skip edits if<a name="line.492"></a>
-<span class="sourceLineNo">493</span>    // we crash during the flush. For figuring what to flush, we might get requeued if our sequence<a name="line.493"></a>
-<span class="sourceLineNo">494</span>    // id is old even though we are currently flushing. This may mean we do too much flushing.<a name="line.494"></a>
-<span class="sourceLineNo">495</span>    return this.sequenceIdAccounting.getLowestSequenceId(encodedRegionName, familyName);<a name="line.495"></a>
-<span class="sourceLineNo">496</span>  }<a name="line.496"></a>
-<span class="sourceLineNo">497</span><a name="line.497"></a>
-<span class="sourceLineNo">498</span>  @Override<a name="line.498"></a>
-<span class="sourceLineNo">499</span>  public byte[][] rollWriter() throws FailedLogCloseException, IOException {<a name="line.499"></a>
-<span class="sourceLineNo">500</span>    return rollWriter(false);<a name="line.500"></a>
-<span class="sourceLineNo">501</span>  }<a name="line.501"></a>
-<span class="sourceLineNo">502</span><a name="line.502"></a>
-<span class="sourceLineNo">503</span>  /**<a name="line.503"></a>
-<span class="sourceLineNo">504</span>   * This is a convenience method that computes a new filename with a given file-number.<a name="line.504"></a>
-<span class="sourceLineNo">505</span>   * @param filenum to use<a name="line.505"></a>
-<span class="sourceLineNo">506</span>   * @return Path<a name="line.506"></a>
-<span class="sourceLineNo">507</span>   */<a name="line.507"></a>
-<span class="sourceLineNo">508</span>  protected Path computeFilename(final long filenum) {<a name="line.508"></a>
-<span class="sourceLineNo">509</span>    if (filenum &lt; 0) {<a name="line.509"></a>
-<span class="sourceLineNo">510</span>      throw new RuntimeException("WAL file number can't be &lt; 0");<a name="line.510"></a>
-<span class="sourceLineNo">511</span>    }<a name="line.511"></a>
-<span class="sourceLineNo">512</span>    String child = walFilePrefix + WAL_FILE_NAME_DELIMITER + filenum + walFileSuffix;<a name="line.512"></a>
-<span class="sourceLineNo">513</span>    return new Path(walDir, child);<a name="line.513"></a>
-<span class="sourceLineNo">514</span>  }<a name="line.514"></a>
-<span class="sourceLineNo">515</span><a name="line.515"></a>
-<span class="sourceLineNo">516</span>  /**<a name="line.516"></a>
-<span class="sourceLineNo">517</span>   * This is a convenience method that computes a new filename with a given using the current WAL<a name="line.517"></a>
-<span class="sourceLineNo">518</span>   * file-number<a name="line.518"></a>
-<span class="sourceLineNo">519</span>   * @return Path<a name="line.519"></a>
-<span class="sourceLineNo">520</span>   */<a name="line.520"></a>
-<span class="sourceLineNo">521</span>  public Path getCurrentFileName() {<a name="line.521"></a>
-<span class="sourceLineNo">522</span>    return computeFilename(this.filenum.get());<a name="line.522"></a>
-<span class="sourceLineNo">523</span>  }<a name="line.523"></a>
-<span class="sourceLineNo">524</span><a name="line.524"></a>
-<span class="sourceLineNo">525</span>  /**<a name="line.525"></a>
-<span class="sourceLineNo">526</span>   * retrieve the next path to use for writing. Increments the internal filenum.<a name="line.526"></a>
-<span class="sourceLineNo">527</span>   */<a name="line.527"></a>
-<span class="sourceLineNo">528</span>  private Path getNewPath() throws IOException {<a name="line.528"></a>
-<span class="sourceLineNo">529</span>    this.filenum.set(System.currentTimeMillis());<a name="line.529"></a>
-<span class="sourceLineNo">530</span>    Path newPath = getCurrentFileName();<a name="line.530"></a>
-<span class="sourceLineNo">531</span>    while (fs.exists(newPath)) {<a name="line.531"></a>
-<span class="sourceLineNo">532</span>      this.filenum.incrementAndGet();<a name="line.532"></a>
-<span class="sourceLineNo">533</span>      newPath = getCurrentFileName();<a name="line.533"></a>
-<span class="sourceLineNo">534</span>    }<a name="line.534"></a>
-<span class="sourceLineNo">535</span>    return newPath;<a name="line.535"></a>
-<span class="sourceLineNo">536</span>  }<a name="line.536"></a>
-<span class="sourceLineNo">537</span><a name="line.537"></a>
-<span class="sourceLineNo">538</span>  @VisibleForTesting<a name="line.538"></a>
-<span class="sourceLineNo">539</span>  Path getOldPath() {<a name="line.539"></a>
-<span class="sourceLineNo">540</span>    long currentFilenum = this.filenum.get();<a name="line.540"></a>
-<span class="sourceLineNo">541</span>    Path oldPath = null;<a name="line.541"></a>
-<span class="sourceLineNo">542</span>    if (currentFilenum &gt; 0) {<a name="line.542"></a>
-<span class="sourceLineNo">543</span>      // ComputeFilename will take care of meta wal filename<a name="line.543"></a>
-<span class="sourceLineNo">544</span>      oldPath = computeFilename(currentFilenum);<a name="line.544"></a>
-<span class="sourceLineNo">545</span>    } // I presume if currentFilenum is &lt;= 0, this is first file and null for oldPath if fine?<a name="line.545"></a>
-<span class="sourceLineNo">546</span>    return oldPath;<a name="line.546"></a>
-<span class="sourceLineNo">547</span>  }<a name="line.547"></a>
-<span class="sourceLineNo">548</span><a name="line.548"></a>
-<span class="sourceLineNo">549</span>  /**<a name="line.549"></a>
-<span class="sourceLineNo">550</span>   * Tell listeners about pre log roll.<a name="line.550"></a>
-<span class="sourceLineNo">551</span>   */<a name="line.551"></a>
-<span class="sourceLineNo">552</span>  private void tellListenersAboutPreLogRoll(final Path oldPath, final Path newPath)<a name="line.552"></a>
-<span class="sourceLineNo">553</span>      throws IOException {<a name="line.553"></a>
-<span class="sourceLineNo">554</span>    coprocessorHost.preWALRoll(oldPath, newPath);<a name="line.554"></a>
-<span class="sourceLineNo">555</span><a name="line.555"></a>
-<span class="sourceLineNo">556</span>    if (!this.listeners.isEmpty()) {<a name="line.556"></a>
-<span class="sourceLineNo">557</span>      for (WALActionsListener i : this.listeners) {<a name="line.557"></a>
-<span class="sourceLineNo">558</span>        i.preLogRoll(oldPath, newPath);<a name="line.558"></a>
-<span class="sourceLineNo">559</span>      }<a name="line.559"></a>
-<span class="sourceLineNo">560</span>    }<a name="line.560"></a>
-<span class="sourceLineNo">561</span>  }<a name="line.561"></a>
-<span class="sourceLineNo">562</span><a name="line.562"></a>
-<span class="sourceLineNo">563</span>  /**<a name="line.563"></a>
-<span class="sourceLineNo">564</span>   * Tell listeners about post log roll.<a name="line.564"></a>
-<span class="sourceLineNo">565</span>   */<a name="line.565"></a>
-<span class="sourceLineNo">566</span>  private void tellListenersAboutPostLogRoll(final Path oldPath, final Path newPath)<a name="line.566"></a>
-<span class="sourceLineNo">567</span>      throws IOException {<a name="line.567"></a>
-<span class="sourceLineNo">568</span>    if (!this.listeners.isEmpty()) {<a name="line.568"></a>
-<span class="sourceLineNo">569</span>      for (WALActionsListener i : this.listeners) {<a name="line.569"></a>
-<span class="sourceLineNo">570</span>        i.postLogRoll(oldPath, newPath);<a name="line.570"></a>
-<span class="sourceLineNo">571</span>      }<a name="line.571"></a>
-<span class="sourceLineNo">572</span>    }<a name="line.572"></a>
-<span class="sourceLineNo">573</span><a name="line.573"></a>
-<span class="sourceLineNo">574</span>    coprocessorHost.postWALRoll(oldPath, newPath);<a name="line.574"></a>
-<span class="sourceLineNo">575</span>  }<a name="line.575"></a>
-<span class="sourceLineNo">576</span><a name="line.576"></a>
-<span class="sourceLineNo">577</span>  // public only until class moves to o.a.h.h.wal<a name="line.577"></a>
-<span class="sourceLineNo">578</span>  /** @return the number of rolled log files */<a name="line.578"></a>
-<span class="sourceLineNo">579</span>  public int getNumRolledLogFiles() {<a name="line.579"></a>
-<span class="sourceLineNo">580</span>    return walFile2Props.size();<a name="line.580"></a>
-<span class="sourceLineNo">581</span>  }<a name="line.581"></a>
-<span class="sourceLineNo">582</span><a name="line.582"></a>
-<span class="sourceLineNo">583</span>  // public only until class moves to o.a.h.h.wal<a name="line.583"></a>
-<span class="sourceLineNo">584</span>  /** @return the number of log files in use */<a name="line.584"></a>
-<span class="sourceLineNo">585</span>  public int getNumLogFiles() {<a name="line.585"></a>
-<span class="sourceLineNo">586</span>    // +1 for current use log<a name="line.586"></a>
-<span class="sourceLineNo">587</span>    return getNumRolledLogFiles() + 1;<a name="line.587"></a>
-<span class="sourceLineNo">588</span>  }<a name="line.588"></a>
-<span class="sourceLineNo">589</span><a name="line.589"></a>
-<span class="sourceLineNo">590</span>  /**<a name="line.590"></a>
-<span class="sourceLineNo">591</span>   * If the number of un-archived WAL files is greater than maximum allowed, check the first<a name="line.591"></a>
-<span class="sourceLineNo">592</span>   * (oldest) WAL file, and returns those regions which should be flushed so that it can be<a name="line.592"></a>
-<span class="sourceLineNo">593</span>   * archived.<a name="line.593"></a>
-<span class="sourceLineNo">594</span>   * @return regions (encodedRegionNames) to flush in order to archive oldest WAL file.<a name="line.594"></a>
-<span class="sourceLineNo">595</span>   */<a name="line.595"></a>
-<span class="sourceLineNo">596</span>  byte[][] findRegionsToForceFlush() throws IOException {<a name="line.596"></a>
-<span class="sourceLineNo">597</span>    byte[][] regions = null;<a name="line.597"></a>
-<span class="sourceLineNo">598</span>    int logCount = getNumRolledLogFiles();<a name="line.598"></a>
-<span class="sourceLineNo">599</span>    if (logCount &gt; this.maxLogs &amp;&amp; logCount &gt; 0) {<a name="line.599"></a>
-<span class="sourceLineNo">600</span>      Map.Entry&lt;Path, WalProps&gt; firstWALEntry = this.walFile2Props.firstEntry();<a name="line.600"></a>
-<span class="sourceLineNo">601</span>      regions =<a name="line.601"></a>
-<span class="sourceLineNo">602</span>        this.sequenceIdAccounting.findLower(firstWALEntry.getValue().encodedName2HighestSequenceId);<a name="line.602"></a>
-<span class="sourceLineNo">603</span>    }<a name="line.603"></a>
-<span class="sourceLineNo">604</span>    if (regions != null) {<a name="line.604"></a>
-<span class="sourceLineNo">605</span>      StringBuilder sb = new StringBuilder();<a name="line.605"></a>
-<span class="sourceLineNo">606</span>      for (int i = 0; i &lt; regions.length; i++) {<a name="line.606"></a>
-<span class="sourceLineNo">607</span>        if (i &gt; 0) {<a name="line.607"></a>
-<span class="sourceLineNo">608</span>          sb.append(", ");<a name="line.608"></a>
-<span class="sourceLineNo">609</span>        }<a name="line.609"></a>
-<span class="sourceLineNo">610</span>        sb.append(Bytes.toStringBinary(regions[i]));<a name="line.610"></a>
-<span class="sourceLineNo">611</span>      }<a name="line.611"></a>
-<span class="sourceLineNo">612</span>      LOG.info("Too many WALs; count=" + logCount + ", max=" + this.maxLogs +<a name="line.612"></a>
-<span class="sourceLineNo">613</span>        "; forcing flush of " + regions.length + " regions(s): " + sb.toString());<a name="line.613"></a>
-<span class="sourceLineNo">614</span>    }<a name="line.614"></a>
-<span class="sourceLineNo">615</span>    return regions;<a name="line.615"></a>
-<span class="sourceLineNo">616</span>  }<a name="line.616"></a>
-<span class="sourceLineNo">617</span><a name="line.617"></a>
-<span class="sourceLineNo">618</span>  /**<a name="line.618"></a>
-<span class="sourceLineNo">619</span>   * Archive old logs. A WAL is eligible for archiving if all its WALEdits have been flushed.<a name="line.619"></a>
-<span class="sourceLineNo">620</span>   */<a name="line.620"></a>
-<span class="sourceLineNo">621</span>  private void cleanOldLogs() throws IOException {<a name="line.621"></a>
-<span class="sourceLineNo">622</span>    List&lt;Pair&lt;Path, Long&gt;&gt; logsToArchive = null;<a name="line.622"></a>
-<span class="sourceLineNo">623</span>    // For each log file, look at its Map of regions to highest sequence id; if all sequence ids<a name="line.623"></a>
-<span class="sourceLineNo">624</span>    // are older than what is currently in memory, the WAL can be GC'd.<a name="line.624"></a>
-<span class="sourceLineNo">625</span>    for (Map.Entry&lt;Path, WalProps&gt; e : this.walFile2Props.entrySet()) {<a name="line.625"></a>
-<span class="sourceLineNo">626</span>      Path log = e.getKey();<a name="line.626"></a>
-<span class="sourceLineNo">627</span>      Map&lt;byte[], Long&gt; sequenceNums = e.getValue().encodedName2HighestSequenceId;<a name="line.627"></a>
-<span class="sourceLineNo">628</span>      if (this.sequenceIdAccounting.areAllLower(sequenceNums)) {<a name="line.628"></a>
-<span class="sourceLineNo">629</span>        if (logsToArchive == null) {<a name="line.629"></a>
-<span class="sourceLineNo">630</span>          logsToArchive = new ArrayList&lt;&gt;();<a name="line.630"></a>
-<span class="sourceLineNo">631</span>        }<a name="line.631"></a>
-<span class="sourceLineNo">632</span>        logsToArchive.add(Pair.newPair(log, e.getValue().logSize));<a name="line.632"></a>
-<span class="sourceLineNo">633</span>        if (LOG.isTraceEnabled()) {<a name="line.633"></a>
-<span class="sourceLineNo">634</span>          LOG.trace("WAL file ready for archiving " + log);<a name="line.634"></a>
-<span class="sourceLineNo">635</span>        }<a name="line.635"></a>
-<span class="sourceLineNo">636</span>      }<a name="line.636"></a>
-<span class="sourceLineNo">637</span>    }<a name="line.637"></a>
-<span class="sourceLineNo">638</span>    if (logsToArchive != null) {<a name="line.638"></a>
-<span class="sourceLineNo">639</span>      for (Pair&lt;Path, Long&gt; logAndSize : logsToArchive) {<a name="line.639"></a>
-<span class="sourceLineNo">640</span>        this.totalLogSize.addAndGet(-logAndSize.getSecond());<a name="line.640"></a>
-<span class="sourceLineNo">641</span>        archiveLogFile(logAndSize.getFirst());<a name="line.641"></a>
-<span class="sourceLineNo">642</span>        this.walFile2Props.remove(logAndSize.getFirst());<a name="line.642"></a>
-<span class="sourceLineNo">643</span>      }<a name="line.643"></a>
-<span class="sourceLineNo">644</span>    }<a name="line.644"></a>
-<span class="sourceLineNo">645</span>  }<a name="line.645"></a>
-<span class="sourceLineNo">646</span><a name="line.646"></a>
-<span class="sourceLineNo">647</span>  /*<a name="line.647"></a>
-<span class="sourceLineNo">648</span>   * only public so WALSplitter can use.<a name="line.648"></a>
-<span class="sourceLineNo">649</span>   * @return archived location of a WAL file with the given path p<a name="line.649"></a>
-<span class="sourceLineNo">650</span>   */<a name="line.650"></a>
-<span class="sourceLineNo">651</span>  public static Path getWALArchivePath(Path archiveDir, Path p) {<a name="line.651"></a>
-<span class="sourceLineNo">652</span>    return new Path(archiveDir, p.getName());<a name="line.652"></a>
-<span class="sourceLineNo">653</span>  }<a name="line.653"></a>
-<span class="sourceLineNo">654</span><a name="line.654"></a>
-<span class="sourceLineNo">655</span>  private void archiveLogFile(final Path p) throws IOException {<a name="line.655"></a>
-<span class="sourceLineNo">656</span>    Path newPath = getWALArchivePath(this.walArchiveDir, p);<a name="line.656"></a>
-<span class="sourceLineNo">657</span>    // Tell our listeners that a log is going to be archived.<a name="line.657"></a>
-<span class="sourceLineNo">658</span>    if (!this.listeners.isEmpty()) {<a name="line.658"></a>
-<span class="sourceLineNo">659</span>      for (WALActionsListener i : this.listeners) {<a name="line.659"></a>
-<span class="sourceLineNo">660</span>        i.preLogArchive(p, newPath);<a name="line.660"></a>
-<span class="sourceLineNo">661</span>      }<a name="line.661"></a>
-<span class="sourceLineNo">662</span>    }<a name="line.662"></a>
-<span class="sourceLineNo">663</span>    LOG.info("Archiving " + p + " to " + newPath);<a name="line.663"></a>
-<span class="sourceLineNo">664</span>    if (!CommonFSUtils.renameAndSetModifyTime(this.fs, p, newPath)) {<a name="line.664"></a>
-<span class="sourceLineNo">665</span>      throw new IOException("Unable to rename " + p + " to " + newPath);<a name="line.665"></a>
-<span class="sourceLineNo">666</span>    }<a name="line.666"></a>
-<span class="sourceLineNo">667</span>    // Tell our listeners that a log has been archived.<a name="line.667"></a>
-<span class="sourceLineNo">668</span>    if (!this.listeners.isEmpty()) {<a name="line.668"></a>
-<span class="sourceLineNo">669</span>      for (WALActionsListener i : this.listeners) {<a name="line.669"></a>
-<span class="sourceLineNo">670</span>        i.postLogArchive(p, newPath);<a name="line.670"></a>
-<span class="sourceLineNo">671</span>      }<a name="line.671"></a>
-<span class="sourceLineNo">672</span>    }<a name="line.672"></a>
-<span class="sourceLineNo">673</span>  }<a name="line.673"></a>
-<span class="sourceLineNo">674</span><a name="line.674"></a>
-<span class="sourceLineNo">675</span>  protected final void logRollAndSetupWalProps(Path oldPath, Path newPath, long oldFileLen) {<a name="line.675"></a>
-<span class="sourceLineNo">676</span>    int oldNumEntries = this.numEntries.getAndSet(0);<a name="line.676"></a>
-<span class="sourceLineNo">677</span>    String newPathString = newPath != null ? CommonFSUtils.getPath(newPath) : null;<a name="line.677"></a>
-<span class="sourceLineNo">678</span>    if (oldPath != null) {<a name="line.678"></a>
-<span class="sourceLineNo">679</span>      this.walFile2Props.put(oldPath,<a name="line.679"></a>
-<span class="sourceLineNo">680</span>        new WalProps(this.sequenceIdAccounting.resetHighest(), oldFileLen));<a name="line.680"></a>
-<span class="sourceLineNo">681</span>      this.totalLogSize.addAndGet(oldFileLen);<a name="line.681"></a>
-<span class="sourceLineNo">682</span>      LOG.info("Rolled WAL {} with entries={}, filesize={}; new WAL {}",<a name="line.682"></a>
-<span class="sourceLineNo">683</span>        CommonFSUtils.getPath(oldPath), oldNumEntries, StringUtils.byteDesc(oldFileLen),<a name="line.683"></a>
-<span class="sourceLineNo">684</span>        newPathString);<a name="line.684"></a>
-<span class="sourceLineNo">685</span>    } else {<a name="line.685"></a>
-<span class="sourceLineNo">686</span>      LOG.info("New WAL {}", newPathString);<a name="line.686"></a>
-<span class="sourceLineNo">687</span>    }<a name="line.687"></a>
-<span class="sourceLineNo">688</span>  }<a name="line.688"></a>
-<span class="sourceLineNo">689</span><a name="line.689"></a>
-<span class="sourceLineNo">690</span>  /**<a name="line.690"></a>
-<span class="sourceLineNo">691</span>   * &lt;p&gt;<a name="line.691"></a>
-<span class="sourceLineNo">692</span>   * Cleans up current writer closing it and then puts in place the passed in<a name="line.692"></a>
-<span class="sourceLineNo">693</span>   * &lt;code&gt;nextWriter&lt;/code&gt;.<a name="line.693"></a>
-<span class="sourceLineNo">694</span>   * &lt;/p&gt;<a name="line.694"></a>
-<span class="sourceLineNo">695</span>   * &lt;p&gt;<a name="line.695"></a>
-<span class="sourceLineNo">696</span>   * &lt;ul&gt;<a name="line.696"></a>
-<span class="sourceLineNo">697</span>   * &lt;li&gt;In the case of creating a new WAL, oldPath will be null.&lt;/li&gt;<a name="line.697"></a>
-<span class="sourceLineNo">698</span>   * &lt;li&gt;In the case of rolling over from one file to the next, none of the parameters will be null.<a name="line.698"></a>
-<span class="sourceLineNo">699</span>   * &lt;/li&gt;<a name="line.699"></a>
-<span class="sourceLineNo">700</span>   * &lt;li&gt;In the case of closing out this FSHLog with no further use newPath and nextWriter will be<a name="line.700"></a>
-<span class="sourceLineNo">701</span>   * null.&lt;/li&gt;<a name="line.701"></a>
-<span class="sourceLineNo">702</span>   * &lt;/ul&gt;<a name="line.702"></a>
-<span class="sourceLineNo">703</span>   * &lt;/p&gt;<a name="line.703"></a>
-<span class="sourceLineNo">704</span>   * @param oldPath may be null<a name="line.704"></a>
-<span class="sourceLineNo">705</span>   * @param newPath may be null<a name="line.705"></a>
-<span class="sourceLineNo">706</span>   * @param nextWriter may be null<a name="line.706"></a>
-<span class="sourceLineNo">707</span>   * @return the passed in &lt;code&gt;newPath&lt;/code&gt;<a name="line.707"></a>
-<span class="sourceLineNo">708</span>   * @throws IOException if there is a problem flushing or closing the underlying FS<a name="line.708"></a>
-<span class="sourceLineNo">709</span>   */<a name="line.709"></a>
-<span class="sourceLineNo">710</span>  @VisibleForTesting<a name="line.710"></a>
-<span class="sourceLineNo">711</span>  Path replaceWriter(Path oldPath, Path newPath, W nextWriter) throws IOException {<a name="line.711"></a>
-<span class="sourceLineNo">712</span>    try (TraceScope scope = TraceUtil.createTrace("FSHFile.replaceWriter")) {<a name="line.712"></a>
-<span class="sourceLineNo">713</span>      doReplaceWriter(oldPath, newPath, nextWriter);<a name="line.713"></a>
-<span class="sourceLineNo">714</span>      return newPath;<a name="line.714"></a>
-<span class="sourceLineNo">715</span>    }<a name="line.715"></a>
-<span class="sourceLineNo">716</span>  }<a name="line.716"></a>
-<span class="sourceLineNo">717</span><a name="line.717"></a>
-<span class="sourceLineNo">718</span>  protected final void blockOnSync(SyncFuture syncFuture) throws IOException {<a name="line.718"></a>
-<span class="sourceLineNo">719</span>    // Now we have published the ringbuffer, halt the current thread until we get an answer back.<a name="line.719"></a>
-<span class="sourceLineNo">720</span>    try {<a name="line.720"></a>
-<span class="sourceLineNo">721</span>      if (syncFuture != null) {<a name="line.721"></a>
-<span class="sourceLineNo">722</span>        if (closed) {<a name="line.722"></a>
-<span class="sourceLineNo">723</span>          throw new IOException("WAL has been closed");<a name="line.723"></a>
-<span class="sourceLineNo">724</span>        } else {<a name="line.724"></a>
-<span class="sourceLineNo">725</span>          syncFuture.get(walSyncTimeoutNs);<a name="line.725"></a>
-<span class="sourceLineNo">726</span>        }<a name="line.726"></a>
-<span class="sourceLineNo">727</span>      }<a name="line.727"></a>
-<span class="sourceLineNo">728</span>    } catch (TimeoutIOException tioe) {<a name="line.728"></a>
-<span class="sourceLineNo">729</span>      // SyncFuture reuse by thread, if TimeoutIOException happens, ringbuffer<a name="line.729"></a>
-<span class="sourceLineNo">730</span>      // still refer to it, so if this thread use it next time may get a wrong<a name="line.730"></a>
-<span class="sourceLineNo">731</span>      // result.<a name="line.731"></a>
-<span class="sourceLineNo">732</span>      this.syncFuturesByHandler.remove(Thread.currentThread());<a name="line.732"></a>
-<span class="sourceLineNo">733</span>      throw tioe;<a name="line.733"></a>
-<span class="sourceLineNo">734</span>    } catch (InterruptedException ie) {<a name="line.734"></a>
-<span class="sourceLineNo">735</span>      LOG.warn("Interrupted", ie);<a name="line.735"></a>
-<span class="sourceLineNo">736</span>      throw convertInterruptedExceptionToIOException(ie);<a name="line.736"></a>
-<span class="sourceLineNo">737</span>    } catch (ExecutionException e) {<a name="line.737"></a>
-<span class="sourceLineNo">738</span>      throw ensureIOException(e.getCause());<a name="line.738"></a>
-<span class="sourceLineNo">739</span>    }<a name="line.739"></a>
-<span class="sourceLineNo">740</span>  }<a name="line.740"></a>
-<span class="sourceLineNo">741</span><a name="line.741"></a>
-<span class="sourceLineNo">742</span>  private static IOException ensureIOException(final Throwable t) {<a name="line.742"></a>
-<span class="sourceLineNo">743</span>    return (t instanceof IOException) ? (IOException) t : new IOException(t);<a name="line.743"></a>
-<span class="sourceLineNo">744</span>  }<a name="line.744"></a>
-<span class="sourceLineNo">745</span><a name="line.745"></a>
-<span class="sourceLineNo">746</span>  private IOException convertInterruptedExceptionToIOException(final InterruptedException ie) {<a name="line.746"></a>
-<span class="sourceLineNo">747</span>    Thread.currentThread().interrupt();<a name="line.747"></a>
-<span class="sourceLineNo">748</span>    IOException ioe = new InterruptedIOException();<a name="line.748"></a>
-<span class="sourceLineNo">749</span>    ioe.initCause(ie);<a name="line.749"></a>
-<span class="sourceLineNo">750</span>    return ioe;<a name="line.750"></a>
-<span class="sourceLineNo">751</span>  }<a name="line.751"></a>
-<span class="sourceLineNo">752</span><a name="line.752"></a>
-<span class="sourceLineNo">753</span>  @Override<a name="line.753"></a>
-<span class="sourceLineNo">754</span>  public byte[][] rollWriter(boolean force) throws FailedLogCloseException, IOException {<a name="line.754"></a>
-<span class="sourceLineNo">755</span>    rollWriterLock.lock();<a name="line.755"></a>
-<span class="sourceLineNo">756</span>    try {<a name="line.756"></a>
-<span class="sourceLineNo">757</span>      if (this.closed) {<a name="line.757"></a>
-<span class="sourceLineNo">758</span>        throw new WALClosedException("WAL has been closed");<a name="line.758"></a>
-<span class="sourceLineNo">759</span>      }<a name="line.759"></a>
-<span class="sourceLineNo">760</span>      // Return if nothing to flush.<a name="line.760"></a>
-<span class="sourceLineNo">761</span>      if (!force &amp;&amp; this.writer != null &amp;&amp; this.numEntries.get() &lt;= 0) {<a name="line.761"></a>
-<span class="sourceLineNo">762</span>        return null;<a name="line.762"></a>
-<span class="sourceLineNo">763</span>      }<a name="line.763"></a>
-<span class="sourceLineNo">764</span>      byte[][] regionsToFlush = null;<a name="line.764"></a>
-<span class="sourceLineNo">765</span>      try (TraceScope scope = TraceUtil.createTrace("FSHLog.rollWriter")) {<a name="line.765"></a>
-<span class="sourceLineNo">766</span>        Path oldPath = getOldPath();<a name="line.766"></a>
-<span class="sourceLineNo">767</span>        Path newPath = getNewPath();<a name="line.767"></a>
-<span class="sourceLineNo">768</span>        // Any exception from here on is catastrophic, non-recoverable so we currently abort.<a name="line.768"></a>
-<span class="sourceLineNo">769</span>        W nextWriter = this.createWriterInstance(newPath);<a name="line.769"></a>
-<span class="sourceLineNo">770</span>        tellListenersAboutPreLogRoll(oldPath, newPath);<a name="line.770"></a>
-<span class="sourceLineNo">771</span>        // NewPath could be equal to oldPath if replaceWriter fails.<a name="line.771"></a>
-<span class="sourceLineNo">772</span>        newPath = replaceWriter(oldPath, newPath, nextWriter);<a name="line.772"></a>
-<span class="sourceLineNo">773</span>        tellListenersAboutPostLogRoll(oldPath, newPath);<a name="line.773"></a>
-<span class="sourceLineNo">774</span>        if (LOG.isDebugEnabled()) {<a name="line.774"></a>
-<span class="sourceLineNo">775</span>          LOG.debug("Create new " + implClassName + " writer with pipeline: " +<a name="line.775"></a>
-<span class="sourceLineNo">776</span>            Arrays.toString(getPipeline()));<a name="line.776"></a>
-<span class="sourceLineNo">777</span>        }<a name="line.777"></a>
-<span class="sourceLineNo">778</span>        // Can we delete any of the old log files?<a name="line.778"></a>
-<span class="sourceLineNo">779</span>        if (getNumRolledLogFiles() &gt; 0) {<a name="line.779"></a>
-<span class="sourceLineNo">780</span>          cleanOldLogs();<a name="line.780"></a>
-<span class="sourceLineNo">781</span>          regionsToFlush = findRegionsToForceFlush();<a name="line.781"></a>
-<span class="sourceLineNo">782</span>        }<a name="line.782"></a>
-<span class="sourceLineNo">783</span>      } catch (CommonFSUtils.StreamLacksCapabilityException exception) {<a name="line.783"></a>
-<span class="sourceLineNo">784</span>        // If the underlying FileSystem can't do what we ask, treat as IO failure so<a name="line.784"></a>
-<span class="sourceLineNo">785</span>        // we'll abort.<a name="line.785"></a>
-<span class="sourceLineNo">786</span>        throw new IOException(<a name="line.786"></a>
-<span class="sourceLineNo">787</span>            "Underlying FileSystem can't meet stream requirements. See RS log " + "for details.",<a name="line.787"></a>
-<span class="sourceLineNo">788</span>            exception);<a name="line.788"></a>
-<span class="sourceLineNo">789</span>      }<a name="line.789"></a>
-<span class="sourceLineNo">790</span>      return regionsToFlush;<a name="line.790"></a>
-<span class="sourceLineNo">791</span>    } finally {<a name="line.791"></a>
-<span class="sourceLineNo">792</span>      rollWriterLock.unlock();<a name="line.792"></a>
-<span class="sourceLineNo">793</span>    }<a name="line.793"></a>
-<span class="sourceLineNo">794</span>  }<a name="line.794"></a>
-<span class="sourceLineNo">795</span><a name="line.795"></a>
-<span class="sourceLineNo">796</span>  // public only until class moves to o.a.h.h.wal<a name="line.796"></a>
-<span class="sourceLineNo">797</span>  /** @return the size of log files in use */<a name="line.797"></a>
-<span class="sourceLineNo">798</span>  public long getLogFileSize() {<a name="line.798"></a>
-<span class="sourceLineNo">799</span>    return this.totalLogSize.get();<a name="line.799"></a>
-<span class="sourceLineNo">800</span>  }<a name="line.800"></a>
-<span class="sourceLineNo">801</span><a name="line.801"></a>
-<span class="sourceLineNo">802</span>  // public only until class moves to o.a.h.h.wal<a name="line.802"></a>
-<span class="sourceLineNo">803</span>  public void requestLogRoll() {<a name="line.803"></a>
-<span class="sourceLineNo">804</span>    requestLogRoll(false);<a name="line.804"></a>
-<span class="sourceLineNo">805</span>  }<a name="line.805"></a>
-<span class="sourceLineNo">806</span><a name="line.806"></a>
-<span class="sourceLineNo">807</span>  /**<a name="line.807"></a>
-<span class="sourceLineNo">808</span>   * Get the backing files associated with this WAL.<a name="line.808"></a>
-<span class="sourceLineNo">809</span>   * @return may be null if there are no files.<a name="line.809"></a>
-<span class="sourceLineNo">810</span>   */<a name="line.810"></a>
-<span class="sourceLineNo">811</span>  @VisibleForTesting<a name="line.811"></a>
-<span class="sourceLineNo">812</span>  FileStatus[] getFiles() throws IOException {<a name="line.812"></a>
-<span class="sourceLineNo">813</span>    return CommonFSUtils.listStatus(fs, walDir, ourFiles);<a name="line.813"></a>
-<span class="sourceLineNo">814</span>  }<a name="line.814"></a>
-<span class="sourceLineNo">815</span><a name="line.815"></a>
-<span class="sourceLineNo">816</span>  @Override<a name="line.816"></a>
-<span class="sourceLineNo">817</span>  public void shutdown() throws IOException {<a name="line.817"></a>
-<span class="sourceLineNo">818</span>    if (!shutdown.compareAndSet(false, true)) {<a name="line.818"></a>
-<span class="sourceLineNo">819</span>      return;<a name="line.819"></a>
-<span class="sourceLineNo">820</span>    }<a name="line.820"></a>
-<span class="sourceLineNo">821</span>    closed = true;<a name="line.821"></a>
-<span class="sourceLineNo">822</span>    // Tell our listeners that the log is closing<a name="line.822"></a>
-<span class="sourceLineNo">823</span>    if (!this.listeners.isEmpty()) {<a name="line.823"></a>
-<span class="sourceLineNo">824</span>      for (WALActionsListener i : this.listeners) {<a name="line.824"></a>
-<span class="sourceLineNo">825</span>        i.logCloseRequested();<a name="line.825"></a>
-<span class="sourceLineNo">826</span>      }<a name="line.826"></a>
-<span class="sourceLineNo">827</span>    }<a name="line.827"></a>
-<span class="sourceLineNo">828</span>    rollWriterLock.lock();<a name="line.828"></a>
-<span class="sourceLineNo">829</span>    try {<a name="line.829"></a>
-<span class="sourceLineNo">830</span>      doShutdown();<a name="line.830"></a>
-<span class="sourceLineNo">831</span>    } finally {<a name="line.831"></a>
-<span class="sourceLineNo">832</span>      rollWriterLock.unlock();<a name="line.832"></a>
-<span class="sourceLineNo">833</span>    }<a name="line.833"></a>
-<span class="sourceLineNo">834</span>  }<a name="line.834"></a>
-<span class="sourceLineNo">835</span><a name="line.835"></a>
-<span class="sourceLineNo">836</span>  @Override<a name="line.836"></a>
-<span class="sourceLineNo">837</span>  public void close() throws IOException {<a name="line.837"></a>
-<span class="sourceLineNo">838</span>    shutdown();<a name="line.838"></a>
-<span class="sourceLineNo">839</span>    final FileStatus[] files = getFiles();<a name="line.839"></a>
-<span class="sourceLineNo">840</span>    if (null != files &amp;&amp; 0 != files.length) {<a name="line.840"></a>
-<span class="sourceLineNo">841</span>      for (FileStatus file : files) {<a name="line.841"></a>
-<span class="sourceLineNo">842</span>        Path p = getWALArchivePath(this.walArchiveDir, file.getPath());<a name="line.842"></a>
-<span class="sourceLineNo">843</span>        // Tell our listeners that a log is going to be archived.<a name="line.843"></a>
-<span class="sourceLineNo">844</span>        if (!this.listeners.isEmpty()) {<a name="line.844"></a>
-<span class="sourceLineNo">845</span>          for (WALActionsListener i : this.listeners) {<a name="line.845"></a>
-<span class="sourceLineNo">846</span>            i.preLogArchive(file.getPath(), p);<a name="line.846"></a>
-<span class="sourceLineNo">847</span>          }<a name="line.847"></a>
-<span class="sourceLineNo">848</span>        }<a name="line.848"></a>
-<span class="sourceLineNo">849</span><a name="line.849"></a>
-<span class="sourceLineNo">850</span>        if (!CommonFSUtils.renameAndSetModifyTime(fs, file.getPath(), p)) {<a name="line.850"></a>
-<span class="sourceLineNo">851</span>          throw new IOException("Unable to rename " + file.getPath() + " to " + p);<a name="line.851"></a>
-<span class="sourceLineNo">852</span>        }<a name="line.852"></a>
-<span class="sourceLineNo">853</span>        // Tell our listeners that a log was archived.<a name="line.853"></a>
-<span class="sourceLineNo">854</span>        if (!this.listeners.isEmpty()) {<a name="line.854"></a>
-<span class="sourceLineNo">855</span>          for (WALActionsListener i : this.listeners) {<a name="line.855"></a>
-<span class="sourceLineNo">856</span>            i.postLogArchive(file.getPath(), p);<a name="line.856"></a>
-<span class="sourceLineNo">857</span>          }<a name="line.857"></a>
-<span class="sourceLineNo">858</span>        }<a name="line.858"></a>
-<span class="sourceLineNo">859</span>      }<a name="line.859"></a>
-<span class="sourceLineNo">860</span>      LOG.debug(<a name="line.860"></a>
-<span class="sourceLineNo">861</span>        "Moved " + files.length + " WAL file(s) to " + CommonFSUtils.getPath(this.walArchiveDir));<a name="line.861"></a>
-<span class="sourceLineNo">862</span>    }<a name="line.862"></a>
-<span class="sourceLineNo">863</span>    LOG.info("Closed WAL: " + toString());<a name="line.863"></a>
-<span class="sourceLineNo">864</span>  }<a name="line.864"></a>
-<span class="sourceLineNo">865</span><a name="line.865"></a>
-<span class="sourceLineNo">866</span>  /**<a name="line.866"></a>
-<span class="sourceLineNo">867</span>   * updates the sequence number of a specific store. depending on the flag: replaces current seq<a name="line.867"></a>
-<span class="sourceLineNo">868</span>   * number if the given seq id is bigger, or even if it is lower than existing one<a name="line.868"></a>
-<span class="sourceLineNo">869</span>   * @param encodedRegionName<a name="line.869"></a>
-<span class="sourceLineNo">870</span>   * @param familyName<a name="line.870"></a>
-<span class="sourceLineNo">871</span>   * @param sequenceid<a name="line.871"></a>
-<span class="sourceLineNo">872</span>   * @param onlyIfGreater<a name="line.872"></a>
-<span class="sourceLineNo">873</span>   */<a name="line.873"></a>
-<span class="sourceLineNo">874</span>  @Override<a name="line.874"></a>
-<span class="sourceLineNo">875</span>  public void updateStore(byte[] encodedRegionName, byte[] familyName, Long sequenceid,<a name="line.875"></a>
-<span class="sourceLineNo">876</span>      boolean onlyIfGreater) {<a name="line.876"></a>
-<span class="sourceLineNo">877</span>    sequenceIdAccounting.updateStore(encodedRegionName, familyName, sequenceid, onlyIfGreater);<a name="line.877"></a>
-<span class="sourceLineNo">878</span>  }<a name="line.878"></a>
-<span class="sourceLineNo">879</span><a name="line.879"></a>
-<span class="sourceLineNo">880</span>  protected final SyncFuture getSyncFuture(long sequence) {<a name="line.880"></a>
-<span class="sourceLineNo">881</span>    return CollectionUtils<a name="line.881"></a>
-<span class="sourceLineNo">882</span>        .computeIfAbsent(syncFuturesByHandler, Thread.currentThread(), SyncFuture::new)<a name="line.882"></a>
-<span class="sourceLineNo">883</span>        .reset(sequence);<a name="line.883"></a>
-<span class="sourceLineNo">884</span>  }<a name="line.884"></a>
-<span class="sourceLineNo">885</span><a name="line.885"></a>
-<span class="sourceLineNo">886</span>  protected final void requestLogRoll(boolean tooFewReplicas) {<a name="line.886"></a>
-<span class="sourceLineNo">887</span>    if (!this.listeners.isEmpty()) {<a name="line.887"></a>
-<span class="sourceLineNo">888</span>      for (WALActionsListener i : this.listeners) {<a name="line.888"></a>
-<span class="sourceLineNo">889</span>        i.logRollRequested(tooFewReplicas);<a name="line.889"></a>
-<span class="sourceLineNo">890</span>      }<a name="line.890"></a>
-<span class="sourceLineNo">891</span>    }<a name="line.891"></a>
-<span class="sourceLineNo">892</span>  }<a name="line.892"></a>
-<span class="sourceLineNo">893</span><a name="line.893"></a>
-<span class="sourceLineNo">894</span>  long getUnflushedEntriesCount() {<a name="line.894"></a>
-<span class="sourceLineNo">895</span>    long highestSynced = this.highestSyncedTxid.get();<a name="line.895"></a>
-<span class="sourceLineNo">896</span>    long highestUnsynced = this.highestUnsyncedTxid;<a name="line.896"></a>
-<span class="sourceLineNo">897</span>    return highestSynced &gt;= highestUnsynced ? 0 : highestUnsynced - highestSynced;<a name="line.897"></a>
-<span class="sourceLineNo">898</span>  }<a name="line.898"></a>
-<span class="sourceLineNo">899</span><a name="line.899"></a>
-<span class="sourceLineNo">900</span>  boolean isUnflushedEntries() {<a name="line.900"></a>
-<span class="sourceLineNo">901</span>    return getUnflushedEntriesCount() &gt; 0;<a name="line.901"></a>
-<span class="sourceLineNo">902</span>  }<a name="line.902"></a>
-<span class="sourceLineNo">903</span><a name="line.903"></a>
-<span class="sourceLineNo">904</span>  /**<a name="line.904"></a>
-<span class="sourceLineNo">905</span>   * Exposed for testing only. Use to tricks like halt the ring buffer appending.<a name="line.905"></a>
-<span class="sourceLineNo">906</span>   */<a name="line.906"></a>
-<span class="sourceLineNo">907</span>  @VisibleForTesting<a name="line.907"></a>
-<span class="sourceLineNo">908</span>  void atHeadOfRingBufferEventHandlerAppend() {<a name="line.908"></a>
-<span class="sourceLineNo">909</span>    // Noop<a name="line.909"></a>
-<span class="sourceLineNo">910</span>  }<a name="line.910"></a>
-<span class="sourceLineNo">911</span><a name="line.911"></a>
-<span class="sourceLineNo">912</span>  protected final boolean append(W writer, FSWALEntry entry) throws IOException {<a name="line.912"></a>
-<span class="sourceLineNo">913</span>    // TODO: WORK ON MAKING THIS APPEND FASTER. DOING WAY TOO MUCH WORK WITH CPs, PBing, etc.<a name="line.913"></a>
-<span class="sourceLineNo">914</span>    atHeadOfRingBufferEventHandlerAppend();<a name="line.914"></a>
-<span class="sourceLineNo">915</span>    long start = EnvironmentEdgeManager.currentTime();<a name="line.915"></a>
-<span class="sourceLineNo">916</span>    byte[] encodedRegionName = entry.getKey().getEncodedRegionName();<a name="line.916"></a>
-<span class="sourceLineNo">917</span>    long regionSequenceId = entry.getKey().getSequenceId();<a name="line.917"></a>
-<span class="sourceLineNo">918</span><a name="line.918"></a>
-<span class="sourceLineNo">919</span>    // Edits are empty, there is nothing to append. Maybe empty when we are looking for a<a name="line.919"></a>
-<span class="sourceLineNo">920</span>    // region sequence id only, a region edit/sequence id that is not associated with an actual<a name="line.920"></a>
-<span class="sourceLineNo">921</span>    // edit. It has to go through all the rigmarole to be sure we have the right ordering.<a name="line.921"></a>
-<span class="sourceLineNo">922</span>    if (entry.getEdit().isEmpty()) {<a name="line.922"></a>
-<span class="sourceLineNo">923</span>      return false;<a name="line.923"></a>
-<span class="sourceLineNo">924</span>    }<a name="line.924"></a>
-<span class="sourceLineNo">925</span><a name="line.925"></a>
-<span class="sourceLineNo">926</span>    // Coprocessor hook.<a name="line.926"></a>
-<span class="sourceLineNo">927</span>    coprocessorHost.preWALWrite(entry.getRegionInfo(), entry.getKey(), entry.getEdit());<a name="line.927"></a>
-<span class="sourceLineNo">928</span>    if (!listeners.isEmpty()) {<a name="line.928"></a>
-<span class="sourceLineNo">929</span>      for (WALActionsListener i : listeners) {<a name="line.929"></a>
-<span class="sourceLineNo">930</span>        i.visitLogEntryBeforeWrite(entry.getKey(), entry.getEdit());<a name="line.930"></a>
-<span class="sourceLineNo">931</span>      }<a name="line.931"></a>
-<span class="sourceLineNo">932</span>    }<a name="line.932"></a>
-<span class="sourceLineNo">933</span>    doAppend(writer, entry);<a name="line.933"></a>
-<span class="sourceLineNo">934</span>    assert highestUnsyncedTxid &lt; entry.getTxid();<a name="line.934"></a>
-<span class="sourceLineNo">935</span>    highestUnsyncedTxid = entry.getTxid();<a name="line.935"></a>
-<span class="sourceLineNo">936</span>    sequenceIdAccounting.update(encodedRegionName, entry.getFamilyNames(), regionSequenceId,<a name="line.936"></a>
-<span class="sourceLineNo">937</span>      entry.isInMemStore());<a name="line.937"></a>
-<span class="sourceLineNo">938</span>    coprocessorHost.postWALWrite(entry.getRegionInfo(), entry.getKey(), entry.getEdit());<a name="line.938"></a>
-<span class="sourceLineNo">939</span>    // Update metrics.<a name="line.939"></a>
-<span class="sourceLineNo">940</span>    postAppend(entry, EnvironmentEdgeManager.currentTime() - start);<a name="line.940"></a>
-<span class="sourceLineNo">941</span>    numEntries.incrementAndGet();<a name="line.941"></a>
-<span class="sourceLineNo">942</span>    return true;<a name="line.942"></a>
-<span class="sourceLineNo">943</span>  }<a name="line.943"></a>
-<span class="sourceLineNo">944</span><a name="line.944"></a>
-<span class="sourceLineNo">945</span>  private long postAppend(final Entry e, final long elapsedTime) throws IOException {<a name="line.945"></a>
-<span class="sourceLineNo">946</span>    long len = 0;<a name="line.946"></a>
-<span class="sourceLineNo">947</span>    if (!listeners.isEmpty()) {<a name="line.947"></a>
-<span class="sourceLineNo">948</span>      for (Cell cell : e.getEdit().getCells()) {<a name="line.948"></a>
-<span class="sourceLineNo">949</span>        len += PrivateCellUtil.estimatedSerializedSizeOf(cell);<a name="line.949"></a>
-<span class="sourceLineNo">950</span>      }<a name="line.950"></a>
-<span class="sourceLineNo">951</span>      for (WALActionsListener listener : listeners) {<a name="line.951"></a>
-<span class="sourceLineNo">952</span>        listener.postAppend(len, elapsedTime, e.getKey(), e.getEdit());<a name="line.952"></a>
-<span class="sourceLineNo">953</span>      }<a name="line.953"></a>
-<span class="sourceLineNo">954</span>    }<a name="line.954"></a>
-<span class="sourceLineNo">955</span>    return len;<a name="line.955"></a>
-<span class="sourceLineNo">956</span>  }<a name="line.956"></a>
-<span class="sourceLineNo">957</span><a name="line.957"></a>
-<span class="sourceLineNo">958</span>  protected final void postSync(final long timeInNanos, final int handlerSyncs) {<a name="line.958"></a>
-<span class="sourceLineNo">959</span>    if (timeInNanos &gt; this.slowSyncNs) {<a name="line.959"></a>
-<span class="sourceLineNo">960</span>      String msg = new StringBuilder().append("Slow sync cost: ").append(timeInNanos / 1000000)<a name="line.960"></a>
-<span class="sourceLineNo">961</span>          .append(" ms, current pipeline: ").append(Arrays.toString(getPipeline())).toString();<a name="line.961"></a>
-<span class="sourceLineNo">962</span>      TraceUtil.addTimelineAnnotation(msg);<a name="line.962"></a>
-<span class="sourceLineNo">963</span>      LOG.info(msg);<a name="line.963"></a>
-<span class="sourceLineNo">964</span>    }<a name="line.964"></a>
-<span class="sourceLineNo">965</span>    if (!listeners.isEmpty()) {<a name="line.965"></a>
-<span class="sourceLineNo">966</span>      for (WALActionsListener listener : listeners) {<a name="line.966"></a>
-<span class="sourceLineNo">967</span>        listener.postSync(timeInNanos, handlerSyncs);<a name="line.967"></a>
-<span class="sourceLineNo">968</span>      }<a name="line.968"></a>
-<span class="sourceLineNo">969</span>    }<a name="line.969"></a>
-<span class="sourceLineNo">970</span>  }<a name="line.970"></a>
-<span class="sourceLineNo">971</span><a name="line.971"></a>
-<span class="sourceLineNo">972</span>  protected final long stampSequenceIdAndPublishToRingBuffer(RegionInfo hri, WALKeyImpl key,<a name="line.972"></a>
-<span class="sourceLineNo">973</span>      WALEdit edits, boolean inMemstore, RingBuffer&lt;RingBufferTruck&gt; ringBuffer)<a name="line.973"></a>
-<span class="sourceLineNo">974</span>      throws IOException {<a name="line.974"></a>
-<span class="sourceLineNo">975</span>    if (this.closed) {<a name="line.975"></a>
-<span class="sourceLineNo">976</span>      throw new IOException(<a name="line.976"></a>
-<span class="sourceLineNo">977</span>          "Cannot append; log is closed, regionName = " + hri.getRegionNameAsString());<a name="line.977"></a>
-<span class="sourceLineNo">978</span>    }<a name="line.978"></a>
-<span class="sourceLineNo">979</span>    MutableLong txidHolder = new MutableLong();<a name="line.979"></a>
-<span class="sourceLineNo">980</span>    MultiVersionConcurrencyControl.WriteEntry we = key.getMvcc().begin(() -&gt; {<a name="line.980"></a>
-<span class="sourceLineNo">981</span>      txidHolder.setValue(ringBuffer.next());<a name="line.981"></a>
-<span class="sourceLineNo">982</span>    });<a name="line.982"></a>
-<span class="sourceLineNo">983</span>    long txid = txidHolder.longValue();<a name="line.983"></a>
-<span class="sourceLineNo">984</span>    try (TraceScope scope = TraceUtil.createTrace(implClassName + ".append")) {<a name="line.984"></a>
-<span class="sourceLineNo">985</span>      FSWALEntry entry = new FSWALEntry(txid, key, edits, hri, inMemstore);<a name="line.985"></a>
-<span class="sourceLineNo">986</span>      entry.stampRegionSequenceId(we);<a name="line.986"></a>
-<span class="sourceLineNo">987</span>      ringBuffer.get(txid).load(entry);<a name="line.987"></a>
-<span class="sourceLineNo">988</span>    } finally {<a name="line.988"></a>
-<span class="sourceLineNo">989</span>      ringBuffer.publish(txid);<a name="line.989"></a>
-<span class="sourceLineNo">990</span>    }<a name="line.990"></a>
-<span class="sourceLineNo">991</span>    return txid;<a name="line.991"></a>
-<span class="sourceLineNo">992</span>  }<a name="line.992"></a>
-<span class="sourceLineNo">993</span><a name="line.993"></a>
-<span class="sourceLineNo">994</span>  @Override<a name="line.994"></a>
-<span class="sourceLineNo">995</span>  public String toString() {<a name="line.995"></a>
-<span class="sourceLineNo">996</span>    return implClassName + " " + walFilePrefix + ":" + walFileSuffix + "(num " + filenum + ")";<a name="line.996"></a>
-<span class="sourceLineNo">997</span>  }<a name="line.997"></a>
-<span class="sourceLineNo">998</span><a name="line.998"></a>
-<span class="sourceLineNo">999</span>  /**<a name="line.999"></a>
-<span class="sourceLineNo">1000</span>   * if the given {@code path} is being written currently, then return its length.<a name="line.1000"></a>
-<span class="sourceLineNo">1001</span>   * &lt;p&gt;<a name="line.1001"></a>
-<span class="sourceLineNo">1002</span>   * This is used by replication to prevent replicating unacked log entries. See<a name="line.1002"></a>
-<span class="sourceLineNo">1003</span>   * https://issues.apache.org/jira/browse/HBASE-14004 for more details.<a name="line.1003"></a>
-<span class="sourceLineNo">1004</span>   */<a name="line.1004"></a>
-<span class="sourceLineNo">1005</span>  @Override<a name="line.1005"></a>
-<span class="sourceLineNo">1006</span>  public OptionalLong getLogFileSizeIfBeingWritten(Path path) {<a name="line.1006"></a>
-<span class="sourceLineNo">1007</span>    rollWriterLock.lock();<a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>    try {<a name="line.1008"></a>
-<span class="sourceLineNo">1009</span>      Path currentPath = getOldPath();<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span>      if (path.equals(currentPath)) {<a name="line.1010"></a>
-<span class="sourceLineNo">1011</span>        W writer = this.writer;<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>        return writer != null ? OptionalLong.of(writer.getLength()) : OptionalLong.empty();<a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>      } else {<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>        return OptionalLong.empty();<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span>      }<a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>    } finally {<a name="line.1016"></a>
-<span class="sourceLineNo">1017</span>      rollWriterLock.unlock();<a name="line.1017"></a>
-<span class="sourceLineNo">1018</span>    }<a name="line.1018"></a>
-<span class="sourceLineNo">1019</span>  }<a name="line.1019"></a>
-<span class="sourceLineNo">1020</span><a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>  /**<a name="line.1021"></a>
-<span class="sourceLineNo">1022</span>   * NOTE: This append, at a time that is usually after this call returns, starts an mvcc<a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>   * transaction by calling 'begin' wherein which we assign this update a sequenceid. At assignment<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>   * time, we stamp all the passed in Cells inside WALEdit with their sequenceId. You must<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span>   * 'complete' the transaction this mvcc transaction by calling<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>   * MultiVersionConcurrencyControl#complete(...) or a variant otherwise mvcc will get stuck. Do it<a name="line.1026"></a>
-<span class="sourceLineNo">1027</span>   * in the finally of a try/finally block within which this append lives and any subsequent<a name="line.1027"></a>
-<span class="sourceLineNo">1028</span>   * operations like sync or update of memstore, etc. Get the WriteEntry to pass mvcc out of the<a name="line.1028"></a>
-<span class="sourceLineNo">1029</span>   * passed in WALKey &lt;code&gt;walKey&lt;/code&gt; parameter. Be warned that the WriteEntry is not<a name="line.1029"></a>
-<span class="sourceLineNo">1030</span>   * immediately available on return from this method. It WILL be available subsequent to a sync of<a name="line.1030"></a>
-<span class="sourceLineNo">1031</span>   * this append; otherwise, you will just have to wait on the WriteEntry to get filled in.<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span>   */<a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>  @Override<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span>  public abstract long append(RegionInfo info, WALKeyImpl key, WALEdit edits, boolean inMemstore)<a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>      throws IOException;<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span><a name="line.1036"></a>
-<span class="sourceLineNo">1037</span>  protected abstract void doAppend(W writer, FSWALEntry entry) throws IOException;<a name="line.1037"></a>
-<span class="sourceLineNo">1038</span><a name="line.1038"></a>
-<span class="sourceLineNo">1039</span>  protected abstract W createWriterInstance(Path path)<a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>      throws IOException, CommonFSUtils.StreamLacksCapabilityException;<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span><a name="line.1041"></a>
-<span class="sourceLineNo">1042</span>  protected abstract void doReplaceWriter(Path oldPath, Path newPath, W nextWriter)<a name="line.1042"></a>
-<span class="sourceLineNo">1043</span>      throws IOException;<a name="line.1043"></a>
-<span class="sourceLineNo">1044</span><a name="line.1044"></a>
-<span class="sourceLineNo">1045</span>  protected abstract void doShutdown() throws IOException;<a name="line.1045"></a>
-<span class="sourceLineNo">1046</span><a name="line.1046"></a>
-<span class="sourceLineNo">1047</span>  protected abstract boolean doCheckLogLowReplication();<a name="line.1047"></a>
-<span class="sourceLineNo">1048</span><a name="line.1048"></a>
-<span class="sourceLineNo">1049</span>  public void checkLogLowReplication(long checkInterval) {<a name="line.1049"></a>
-<span class="sourceLineNo">1050</span>    long now = EnvironmentEdgeManager.currentTime();<a name="line.1050"></a>
-<span class="sourceLineNo">1051</span>    if (now - lastTimeCheckLowReplication &lt; checkInterval) {<a name="line.1051"></a>
-<span class="sourceLineNo">1052</span>      return;<a name="line.1052"></a>
-<span class="sourceLineNo">1053</span>    }<a name="line.1053"></a>
-<span class="sourceLineNo">1054</span>    // Will return immediately if we are in the middle of a WAL log roll currently.<a name="line.1054"></a>
-<span class="sourceLineNo">1055</span>    if (!rollWriterLock.tryLock()) {<a name="line.1055"></a>
-<span class="sourceLineNo">1056</span>      return;<a name="line.1056"></a>
-<span class="sourceLineNo">1057</span>    }<a name="line.1057"></a>
-<span class="sourceLineNo">1058</span>    try {<a name="line.1058"></a>
-<span class="sourceLineNo">1059</span>      lastTimeCheckLowReplication = now;<a name="line.1059"></a>
-<span class="sourceLineNo">1060</span>      if (doCheckLogLowReplication()) {<a name="line.1060"></a>
-<span class="sourceLineNo">1061</span>        requestLogRoll(true);<a name="line.1061"></a>
-<span class="sourceLineNo">1062</span>      }<a name="line.1062"></a>
-<span class="sourceLineNo">1063</span>    } finally {<a name="line.1063"></a>
-<span class="sourceLineNo">1064</span>      rollWriterLock.unlock();<a name="line.1064"></a>
-<span class="sourceLineNo">1065</span>    }<a name="line.1065"></a>
-<span class="sourceLineNo">1066</span>  }<a name="line.1066"></a>
-<span class="sourceLineNo">1067</span><a name="line.1067"></a>
-<span class="sourceLineNo">1068</span>  /**<a name="line.1068"></a>
-<span class="sourceLineNo">1069</span>   * This method gets the pipeline for the current WAL.<a name="line.1069"></a>
-<span class="sourceLineNo">1070</span>   */<a name="line.1070"></a>
-<span class="sourceLineNo">1071</span>  @VisibleForTesting<a name="line.1071"></a>
-<span class="sourceLineNo">1072</span>  abstract DatanodeInfo[] getPipeline();<a name="line.1072"></a>
-<span class="sourceLineNo">1073</span><a name="line.1073"></a>
-<span class="sourceLineNo">1074</span>  /**<a name="line.1074"></a>
-<span class="sourceLineNo">1075</span>   * This method gets the datanode replication count for the current WAL.<a name="line.1075"></a>
-<span class="sourceLineNo">1076</span>   */<a name="line.1076"></a>
-<span class="sourceLineNo">1077</span>  @VisibleForTesting<a name="line.1077"></a>
-<span class="sourceLineNo">1078</span>  abstract int getLogReplication();<a name="line.1078"></a>
-<span class="sourceLineNo">1079</span><a name="line.1079"></a>
-<span class="sourceLineNo">1080</span>  private static void split(final Configuration conf, final Path p) throws IOException {<a name="line.1080"></a>
-<span class="sourceLineNo">1081</span>    FileSystem fs = FSUtils.getWALFileSystem(conf);<a name="line.1081"></a>
-<span class="sourceLineNo">1082</span>    if (!fs.exists(p)) {<a name="line.1082"></a>
-<span class="sourceLineNo">1083</span>      throw new FileNotFoundException(p.toString());<a name="line.1083"></a>
-<span class="sourceLineNo">1084</span>    }<a name="line.1084"></a>
-<span class="sourceLineNo">1085</span>    if (!fs.getFileStatus(p).isDirectory()) {<a name="line.1085"></a>
-<span class="sourceLineNo">1086</span>      throw new IOException(p + " is not a directory");<a name="line.1086"></a>
-<span class="sourceLineNo">1087</span>    }<a name="line.1087"></a>
-<span class="sourceLineNo">1088</span><a name="line.1088"></a>
-<span class="sourceLineNo">1089</span>    final Path baseDir = FSUtils.getWALRootDir(conf);<a name="line.1089"></a>
-<span class="sourceLineNo">1090</span>    Path archiveDir = new Path(baseDir, HConstants.HREGION_OLDLOGDIR_NAME);<a name="line.1090"></a>
-<span class="sourceLineNo">1091</span>    if (conf.getBoolean(AbstractFSWALProvider.SEPARATE_OLDLOGDIR,<a name="line.1091"></a>
-<span class="sourceLineNo">1092</span>      AbstractFSWALProvider.DEFAULT_SEPARATE_OLDLOGDIR)) {<a name="line.1092"></a>
-<span class="sourceLineNo">1093</span>      archiveDir = new Path(archiveDir, p.getName());<a name="line.1093"></a>
-<span class="sourceLineNo">1094</span>    }<a name="line.1094"></a>
-<span class="sourceLineNo">1095</span>    WALSplitter.split(baseDir, p, archiveDir, fs, conf, WALFactory.getInstance(conf));<a name="line.1095"></a>
-<span class="sourceLineNo">1096</span>  }<a name="line.1096"></a>
-<span class="sourceLineNo">1097</span><a name="line.1097"></a>
-<span class="sourceLineNo">1098</span>  private static void usage() {<a name="line.1098"></a>
-<span class="sourceLineNo">1099</span>    System.err.println("Usage: AbstractFSWAL &lt;ARGS&gt;");<a name="line.1099"></a>
-<span class="sourceLineNo">1100</span>    System.err.println("Arguments:");<a name="line.1100"></a>
-<span class="sourceLineNo">1101</span>    System.err.println(" --dump  Dump textual representation of passed one or more files");<a name="line.1101"></a>
-<span class="sourceLineNo">1102</span>    System.err.println("         For example: " +<a name="line.1102"></a>
-<span class="sourceLineNo">1103</span>      "AbstractFSWAL --dump hdfs://example.com:9000/hbase/WALs/MACHINE/LOGFILE");<a name="line.1103"></a>
-<span class="sourceLineNo">1104</span>    System.err.println(" --split Split the passed directory of WAL logs");<a name="line.1104"></a>
-<span class="sourceLineNo">1105</span>    System.err.println(<a name="line.1105"></a>
-<span class="sourceLineNo">1106</span>      "         For example: AbstractFSWAL --split hdfs://example.com:9000/hbase/WALs/DIR");<a name="line.1106"></a>
-<span class="sourceLineNo">1107</span>  }<a name="line.1107"></a>
-<span class="sourceLineNo">1108</span><a name="line.1108"></a>
-<span class="sourceLineNo">1109</span>  /**<a name="line.1109"></a>
-<span class="sourceLineNo">1110</span>   * Pass one or more log file names and it will either dump out a text version on<a name="line.1110"></a>
-<span class="sourceLineNo">1111</span>   * &lt;code&gt;stdout&lt;/code&gt; or split the specified log files.<a name="line.1111"></a>
-<span class="sourceLineNo">1112</span>   */<a name="line.1112"></a>
-<span class="sourceLineNo">1113</span>  public static void main(String[] args) throws IOException {<a name="line.1113"></a>
-<span class="sourceLineNo">1114</span>    if (args.length &lt; 2) {<a name="line.1114"></a>
-<span class="sourceLineNo">1115</span>      usage();<a name="line.1115"></a>
-<span class="sourceLineNo">1116</span>      System.exit(-1);<a name="line.1116"></a>
-<span class="sourceLineNo">1117</span>    }<a name="line.1117"></a>
-<span class="sourceLineNo">1118</span>    // either dump using the WALPrettyPrinter or split, depending on args<a name="line.1118"></a>
-<span class="sourceLineNo">1119</span>    if (args[0].compareTo("--dump") == 0) {<a name="line.1119"></a>
-<span class="sourceLineNo">1120</span>      WALPrettyPrinter.run(Arrays.copyOfRange(args, 1, args.length));<a name="line.1120"></a>
-<span class="sourceLineNo">1121</span>    } else if (args[0].compareTo("--perf") == 0) {<a name="line.1121"></a>
-<span class="sourceLineNo">1122</span>      LOG.error(HBaseMarkers.FATAL, "Please use the WALPerformanceEvaluation tool instead. i.e.:");<a name="line.1122"></a>
-<span class="sourceLineNo">1123</span>      LOG.error(HBaseMarkers.FATAL,<a name="line.1123"></a>
-<span class="sourceLineNo">1124</span>        "\thbase org.apache.hadoop.hbase.wal.WALPerformanceEvaluation --iterations " + args[1]);<a name="line.1124"></a>
-<span class="sourceLineNo">1125</span>      System.exit(-1);<a name="line.1125"></a>
-<span class="sourceLineNo">1126</span>    } else if (args[0].compareTo("--split") == 0) {<a name="line.1126"></a>
-<span class="sourceLineNo">1127</span>      Configuration conf = HBaseConfiguration.create();<a name="line.1127"></a>
-<span class="sourceLineNo">1128</span>      for (int i = 1; i &lt; args.length; i++) {<a name="line.1128"></a>
-<span class="sourceLineNo">1129</span>        try {<a name="line.1129"></a>
-<span class="sourceLineNo">1130</span>          Path logPath = new Path(args[i]);<a name="line.1130"></a>
-<span class="sourceLineNo">1131</span>          FSUtils.setFsDefault(conf, logPath);<a name="line.1131"></a>
-<span class="sourceLineNo">1132</span>          split(conf, logPath);<a name="line.1132"></a>
-<span class="sourceLineNo">1133</span>        } catch (IOException t) {<a name="line.1133"></a>
-<span class="sourceLineNo">1134</span>          t.printStackTrace(System.err);<a name="line.1134"></a>
-<span class="sourceLineNo">1135</span>          System.exit(-1);<a name="line.1135"></a>
-<span class="sourceLineNo">1136</span>        }<a name="line.1136"></a>
-<span class="sourceLineNo">1137</span>      }<a name="line.1137"></a>
-<span class="sourceLineNo">1138</span>    } else {<a name="line.1138"></a>
-<span class="sourceLineNo">1139</span>      usage();<a name="line.1139"></a>
-<span class="sourceLineNo">1140</span>      System.exit(-1);<a name="line.1140"></a>
-<span class="sourceLineNo">1141</span>    }<a name="line.1141"></a>
-<span class="sourceLineNo">1142</span>  }<a name="line.1142"></a>
-<span class="sourceLineNo">1143</span>}<a name="line.1143"></a>
+<span class="sourceLineNo">366</span>    String storagePolicy =<a name="line.366"></a>
+<span class="sourceLineNo">367</span>        conf.get(HConstants.WAL_STORAGE_POLICY, HConstants.DEFAULT_WAL_STORAGE_POLICY);<a name="line.367"></a>
+<span class="sourceLineNo">368</span>    CommonFSUtils.setStoragePolicy(fs, this.walDir, storagePolicy);<a name="line.368"></a>
+<span class="sourceLineNo">369</span>    this.walFileSuffix = (suffix == null) ? "" : URLEncoder.encode(suffix, "UTF8");<a name="line.369"></a>
+<span class="sourceLineNo">370</span>    this.prefixPathStr = new Path(walDir, walFilePrefix + WAL_FILE_NAME_DELIMITER).toString();<a name="line.370"></a>
+<span class="sourceLineNo">371</span><a name="line.371"></a>
+<span class="sourceLineNo">372</span>    this.ourFiles = new PathFilter() {<a name="line.372"></a>
+<span class="sourceLineNo">373</span>      @Override<a name="line.373"></a>
+<span class="sourceLineNo">374</span>      public boolean accept(final Path fileName) {<a name="line.374"></a>
+<span class="sourceLineNo">375</span>        // The path should start with dir/&lt;prefix&gt; and end with our suffix<a name="line.375"></a>
+<span class="sourceLineNo">376</span>        final String fileNameString = fileName.toString();<a name="line.376"></a>
+<span class="sourceLineNo">377</span>        if (!fileNameString.startsWith(prefixPathStr)) {<a name="line.377"></a>
+<span class="sourceLineNo">378</span>          return false;<a name="line.378"></a>
+<span class="sourceLineNo">379</span>        }<a name="line.379"></a>
+<span class="sourceLineNo">380</span>        if (walFileSuffix.isEmpty()) {<a name="line.380"></a>
+<span class="sourceLineNo">381</span>          // in the case of the null suffix, we need to ensure the filename ends with a timestamp.<a name="line.381"></a>
+<span class="sourceLineNo">382</span>          return org.apache.commons.lang3.StringUtils<a name="line.382"></a>
+<span class="sourceLineNo">383</span>              .isNumeric(fileNameString.substring(prefixPathStr.length()));<a name="line.383"></a>
+<span class="sourceLineNo">384</span>        } else if (!fileNameString.endsWith(walFileSuffix)) {<a name="line.384"></a>
+<span class="sourceLineNo">385</span>          return false;<a name="line.385"></a>
+<span class="sourceLineNo">386</span>        }<a name="line.386"></a>
+<span class="sourceLineNo">387</span>        return true;<a name="line.387"></a>
+<span class="sourceLineNo">388</span>      }<a name="line.388"></a>
+<span class="sourceLineNo">389</span>    };<a name="line.389"></a>
+<span class="sourceLineNo">390</span><a name="line.390"></a>
+<span class="sourceLineNo">391</span>    if (failIfWALExists) {<a name="line.391"></a>
+<span class="sourceLineNo">392</span>      final FileStatus[] walFiles = CommonFSUtils.listStatus(fs, walDir, ourFiles);<a name="line.392"></a>
+<span class="sourceLineNo">393</span>      if (null != walFiles &amp;&amp; 0 != walFiles.length) {<a name="line.393"></a>
+<span class="sourceLineNo">394</span>        throw new IOException("Target WAL already exists within directory " + walDir);<a name="line.394"></a>
+<span class="sourceLineNo">395</span>      }<a name="line.395"></a>
+<span class="sourceLineNo">396</span>    }<a name="line.396"></a>
+<span class="sourceLineNo">397</span><a name="line.397"></a>
+<span class="sourceLineNo">398</span>    // Register listeners. TODO: Should this exist anymore? We have CPs?<a name="line.398"></a>
+<span class="sourceLineNo">399</span>    if (listeners != null) {<a name="line.399"></a>
+<span class="sourceLineNo">400</span>      for (WALActionsListener i : listeners) {<a name="line.400"></a>
+<span class="sourceLineNo">401</span>        registerWALActionsListener(i);<a name="line.401"></a>
+<span class="sourceLineNo">402</span>      }<a name="line.402"></a>
+<span class="sourceLineNo">403</span>    }<a name="line.403"></a>
+<span class="sourceLineNo">404</span>    this.coprocessorHost = new WALCoprocessorHost(this, conf);<a name="line.404"></a>
+<span class="sourceLineNo">405</span><a name="line.405"></a>
+<span class="sourceLineNo">406</span>    // Schedule a WAL roll when the WAL is 50% of the HDFS block size. Scheduling at 50% of block<a name="line.406"></a>
+<span class="sourceLineNo">407</span>    // size should make it so WAL rolls before we get to the end-of-block (Block transitions cost<a name="line.407"></a>
+<span class="sourceLineNo">408</span>    // some latency). In hbase-1 we did this differently. We scheduled a roll when we hit 95% of<a name="line.408"></a>
+<span class="sourceLineNo">409</span>    // the block size but experience from the field has it that this was not enough time for the<a name="line.409"></a>
+<span class="sourceLineNo">410</span>    // roll to happen before end-of-block. So the new accounting makes WALs of about the same<a name="line.410"></a>
+<span class="sourceLineNo">411</span>    // size as those made in hbase-1 (to prevent surprise), we now have default block size as<a name="line.411"></a>
+<span class="sourceLineNo">412</span>    // 2 times the DFS default: i.e. 2 * DFS default block size rolling at 50% full will generally<a name="line.412"></a>
+<span class="sourceLineNo">413</span>    // make similar size logs to 1 * DFS default block size rolling at 95% full. See HBASE-19148.<a name="line.413"></a>
+<span class="sourceLineNo">414</span>    this.blocksize = WALUtil.getWALBlockSize(this.conf, this.fs, this.walDir);<a name="line.414"></a>
+<span class="sourceLineNo">415</span>    float multiplier = conf.getFloat("hbase.regionserver.logroll.multiplier", 0.5f);<a name="line.415"></a>
+<span class="sourceLineNo">416</span>    this.logrollsize = (long)(this.blocksize * multiplier);<a name="line.416"></a>
+<span class="sourceLineNo">417</span><a name="line.417"></a>
+<span class="sourceLineNo">418</span>    boolean maxLogsDefined = conf.get("hbase.regionserver.maxlogs") != null;<a name="line.418"></a>
+<span class="sourceLineNo">419</span>    if (maxLogsDefined) {<a name="line.419"></a>
+<span class="sourceLineNo">420</span>      LOG.warn("'hbase.regionserver.maxlogs' was deprecated.");<a name="line.420"></a>
+<span class="sourceLineNo">421</span>    }<a name="line.421"></a>
+<span class="sourceLineNo">422</span>    this.maxLogs = conf.getInt("hbase.regionserver.maxlogs",<a name="line.422"></a>
+<span class="sourceLineNo">423</span>      Math.max(32, calculateMaxLogFiles(conf, logrollsize)));<a name="line.423"></a>
+<span class="sourceLineNo">424</span><a name="line.424"></a>
+<span class="sourceLineNo">425</span>    LOG.info("WAL configuration: blocksize=" + StringUtils.byteDesc(blocksize) + ", rollsize=" +<a name="line.425"></a>
+<span class="sourceLineNo">426</span>      StringUtils.byteDesc(this.logrollsize) + ", prefix=" + this.walFilePrefix + ", suffix=" +<a name="line.426"></a>
+<span class="sourceLineNo">427</span>      walFileSuffix + ", logDir=" + this.walDir + ", archiveDir=" + this.walArchiveDir);<a name="line.427"></a>
+<span class="sourceLineNo">428</span>    this.slowSyncNs = TimeUnit.MILLISECONDS<a name="line.428"></a>
+<span class="sourceLineNo">429</span>        .toNanos(conf.getInt("hbase.regionserver.hlog.slowsync.ms", DEFAULT_SLOW_SYNC_TIME_MS));<a name="line.429"></a>
+<span class="sourceLineNo">430</span>    this.walSyncTimeoutNs = TimeUnit.MILLISECONDS<a name="line.430"></a>
+<span class="sourceLineNo">431</span>        .toNanos(conf.getLong("hbase.regionserver.hlog.sync.timeout", DEFAULT_WAL_SYNC_TIMEOUT_MS));<a name="line.431"></a>
+<span class="sourceLineNo">432</span>    int maxHandlersCount = conf.getInt(HConstants.REGION_SERVER_HANDLER_COUNT, 200);<a name="line.432"></a>
+<span class="sourceLineNo">433</span>    // Presize our map of SyncFutures by handler objects.<a name="line.433"></a>
+<span class="sourceLineNo">434</span>    this.syncFuturesByHandler = new ConcurrentHashMap&lt;&gt;(maxHandlersCount);<a name="line.434"></a>
+<span class="sourceLineNo">435</span>    this.implClassName = getClass().getSimpleName();<a name="line.435"></a>
+<span class="sourceLineNo">436</span>  }<a name="line.436"></a>
+<span class="sourceLineNo">437</span><a name="line.437"></a>
+<span class="sourceLineNo">438</span>  /**<a name="line.438"></a>
+<span class="sourceLineNo">439</span>   * Used to initialize the WAL. Usually just call rollWriter to create the first log writer.<a name="line.439"></a>
+<span class="sourceLineNo">440</span>   */<a name="line.440"></a>
+<span class="sourceLineNo">441</span>  public void init() throws IOException {<a name="line.441"></a>
+<span class="sourceLineNo">442</span>    rollWriter();<a name="line.442"></a>
+<span class="sourceLineNo">443</span>  }<a name="line.443"></a>
+<span class="sourceLineNo">444</span><a name="line.444"></a>
+<span class="sourceLineNo">445</span>  @Override<a name="line.445"></a>
+<span class="sourceLineNo">446</span>  public void registerWALActionsListener(WALActionsListener listener) {<a name="line.446"></a>
+<span class="sourceLineNo">447</span>    this.listeners.add(listener);<a name="line.447"></a>
+<span class="sourceLineNo">448</span>  }<a name="line.448"></a>
+<span class="sourceLineNo">449</span><a name="line.449"></a>
+<span class="sourceLineNo">450</span>  @Override<a name="line.450"></a>
+<span class="sourceLineNo">451</span>  public boolean unregisterWALActionsListener(WALActionsListener listener) {<a name="line.451"></a>
+<span class="sourceLineNo">452</span>    return this.listeners.remove(listener);<a name="line.452"></a>
+<span class="sourceLineNo">453</span>  }<a name="line.453"></a>
+<span class="sourceLineNo">454</span><a name="line.454"></a>
+<span class="sourceLineNo">455</span>  @Override<a name="line.455"></a>
+<span class="sourceLineNo">456</span>  public WALCoprocessorHost getCoprocessorHost() {<a name="line.456"></a>
+<span class="sourceLineNo">457</span>    return coprocessorHost;<a name="line.457"></a>
+<span class="sourceLineNo">458</span>  }<a name="line.458"></a>
+<span class="sourceLineNo">459</span><a name="line.459"></a>
+<span class="sourceLineNo">460</span>  @Override<a name="line.460"></a>
+<span class="sourceLineNo">461</span>  public Long startCacheFlush(byte[] encodedRegionName, Set&lt;byte[]&gt; families) {<a name="line.461"></a>
+<span class="sourceLineNo">462</span>    return this.sequenceIdAccounting.startCacheFlush(encodedRegionName, families);<a name="line.462"></a>
+<span class="sourceLineNo">463</span>  }<a name="line.463"></a>
+<span class="sourceLineNo">464</span><a name="line.464"></a>
+<span class="sourceLineNo">465</span>  @Override<a name="line.465"></a>
+<span class="sourceLineNo">466</span>  public Long startCacheFlush(byte[] encodedRegionName, Map&lt;byte[], Long&gt; familyToSeq) {<a name="line.466"></a>
+<span class="sourceLineNo">467</span>    return this.sequenceIdAccounting.startCacheFlush(encodedRegionName, familyToSeq);<a name="line.467"></a>
+<span class="sourceLineNo">468</span>  }<a name="line.468"></a>
+<span class="sourceLineNo">469</span><a name="line.469"></a>
+<span class="sourceLineNo">470</span>  @Override<a name="line.470"></a>
+<span class="sourceLineNo">471</span>  public void completeCacheFlush(byte[] encodedRegionName) {<a name="line.471"></a>
+<span class="sou

<TRUNCATED>

Mime
View raw message