hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [23/51] [partial] hbase-site git commit: Published site at .
Date Sat, 30 Dec 2017 15:19:08 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/83bf6175/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HStore.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HStore.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HStore.html
index 985778f..854ba52 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HStore.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HStore.html
@@ -662,1932 +662,1924 @@
 <span class="sourceLineNo">654</span>    completeCompaction(toBeRemovedStoreFiles);<a name="line.654"></a>
 <span class="sourceLineNo">655</span>  }<a name="line.655"></a>
 <span class="sourceLineNo">656</span><a name="line.656"></a>
-<span class="sourceLineNo">657</span>  private HStoreFile createStoreFileAndReader(final Path p) throws IOException {<a name="line.657"></a>
-<span class="sourceLineNo">658</span>    StoreFileInfo info = new StoreFileInfo(conf, this.getFileSystem(), p);<a name="line.658"></a>
-<span class="sourceLineNo">659</span>    return createStoreFileAndReader(info);<a name="line.659"></a>
-<span class="sourceLineNo">660</span>  }<a name="line.660"></a>
-<span class="sourceLineNo">661</span><a name="line.661"></a>
-<span class="sourceLineNo">662</span>  private HStoreFile createStoreFileAndReader(StoreFileInfo info) throws IOException {<a name="line.662"></a>
-<span class="sourceLineNo">663</span>    info.setRegionCoprocessorHost(this.region.getCoprocessorHost());<a name="line.663"></a>
-<span class="sourceLineNo">664</span>    HStoreFile storeFile = new HStoreFile(this.getFileSystem(), info, this.conf, this.cacheConf,<a name="line.664"></a>
-<span class="sourceLineNo">665</span>        this.family.getBloomFilterType(), isPrimaryReplicaStore());<a name="line.665"></a>
-<span class="sourceLineNo">666</span>    storeFile.initReader();<a name="line.666"></a>
-<span class="sourceLineNo">667</span>    return storeFile;<a name="line.667"></a>
-<span class="sourceLineNo">668</span>  }<a name="line.668"></a>
-<span class="sourceLineNo">669</span><a name="line.669"></a>
-<span class="sourceLineNo">670</span>  /**<a name="line.670"></a>
-<span class="sourceLineNo">671</span>   * This message intends to inform the MemStore that next coming updates<a name="line.671"></a>
-<span class="sourceLineNo">672</span>   * are going to be part of the replaying edits from WAL<a name="line.672"></a>
-<span class="sourceLineNo">673</span>   */<a name="line.673"></a>
-<span class="sourceLineNo">674</span>  public void startReplayingFromWAL(){<a name="line.674"></a>
-<span class="sourceLineNo">675</span>    this.memstore.startReplayingFromWAL();<a name="line.675"></a>
-<span class="sourceLineNo">676</span>  }<a name="line.676"></a>
-<span class="sourceLineNo">677</span><a name="line.677"></a>
-<span class="sourceLineNo">678</span>  /**<a name="line.678"></a>
-<span class="sourceLineNo">679</span>   * This message intends to inform the MemStore that the replaying edits from WAL<a name="line.679"></a>
-<span class="sourceLineNo">680</span>   * are done<a name="line.680"></a>
-<span class="sourceLineNo">681</span>   */<a name="line.681"></a>
-<span class="sourceLineNo">682</span>  public void stopReplayingFromWAL(){<a name="line.682"></a>
-<span class="sourceLineNo">683</span>    this.memstore.stopReplayingFromWAL();<a name="line.683"></a>
-<span class="sourceLineNo">684</span>  }<a name="line.684"></a>
-<span class="sourceLineNo">685</span><a name="line.685"></a>
-<span class="sourceLineNo">686</span>  /**<a name="line.686"></a>
-<span class="sourceLineNo">687</span>   * Adds a value to the memstore<a name="line.687"></a>
-<span class="sourceLineNo">688</span>   */<a name="line.688"></a>
-<span class="sourceLineNo">689</span>  public void add(final Cell cell, MemStoreSizing memstoreSizing) {<a name="line.689"></a>
-<span class="sourceLineNo">690</span>    lock.readLock().lock();<a name="line.690"></a>
-<span class="sourceLineNo">691</span>    try {<a name="line.691"></a>
-<span class="sourceLineNo">692</span>       this.memstore.add(cell, memstoreSizing);<a name="line.692"></a>
-<span class="sourceLineNo">693</span>    } finally {<a name="line.693"></a>
-<span class="sourceLineNo">694</span>      lock.readLock().unlock();<a name="line.694"></a>
-<span class="sourceLineNo">695</span>    }<a name="line.695"></a>
-<span class="sourceLineNo">696</span>  }<a name="line.696"></a>
-<span class="sourceLineNo">697</span><a name="line.697"></a>
-<span class="sourceLineNo">698</span>  /**<a name="line.698"></a>
-<span class="sourceLineNo">699</span>   * Adds the specified value to the memstore<a name="line.699"></a>
-<span class="sourceLineNo">700</span>   */<a name="line.700"></a>
-<span class="sourceLineNo">701</span>  public void add(final Iterable&lt;Cell&gt; cells, MemStoreSizing memstoreSizing) {<a name="line.701"></a>
-<span class="sourceLineNo">702</span>    lock.readLock().lock();<a name="line.702"></a>
-<span class="sourceLineNo">703</span>    try {<a name="line.703"></a>
-<span class="sourceLineNo">704</span>      memstore.add(cells, memstoreSizing);<a name="line.704"></a>
-<span class="sourceLineNo">705</span>    } finally {<a name="line.705"></a>
-<span class="sourceLineNo">706</span>      lock.readLock().unlock();<a name="line.706"></a>
-<span class="sourceLineNo">707</span>    }<a name="line.707"></a>
-<span class="sourceLineNo">708</span>  }<a name="line.708"></a>
-<span class="sourceLineNo">709</span><a name="line.709"></a>
-<span class="sourceLineNo">710</span>  @Override<a name="line.710"></a>
-<span class="sourceLineNo">711</span>  public long timeOfOldestEdit() {<a name="line.711"></a>
-<span class="sourceLineNo">712</span>    return memstore.timeOfOldestEdit();<a name="line.712"></a>
-<span class="sourceLineNo">713</span>  }<a name="line.713"></a>
-<span class="sourceLineNo">714</span><a name="line.714"></a>
-<span class="sourceLineNo">715</span>  /**<a name="line.715"></a>
-<span class="sourceLineNo">716</span>   * @return All store files.<a name="line.716"></a>
-<span class="sourceLineNo">717</span>   */<a name="line.717"></a>
-<span class="sourceLineNo">718</span>  @Override<a name="line.718"></a>
-<span class="sourceLineNo">719</span>  public Collection&lt;HStoreFile&gt; getStorefiles() {<a name="line.719"></a>
-<span class="sourceLineNo">720</span>    return this.storeEngine.getStoreFileManager().getStorefiles();<a name="line.720"></a>
-<span class="sourceLineNo">721</span>  }<a name="line.721"></a>
-<span class="sourceLineNo">722</span><a name="line.722"></a>
-<span class="sourceLineNo">723</span>  @Override<a name="line.723"></a>
-<span class="sourceLineNo">724</span>  public Collection&lt;HStoreFile&gt; getCompactedFiles() {<a name="line.724"></a>
-<span class="sourceLineNo">725</span>    return this.storeEngine.getStoreFileManager().getCompactedfiles();<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>  /**<a name="line.728"></a>
-<span class="sourceLineNo">729</span>   * This throws a WrongRegionException if the HFile does not fit in this region, or an<a name="line.729"></a>
-<span class="sourceLineNo">730</span>   * InvalidHFileException if the HFile is not valid.<a name="line.730"></a>
-<span class="sourceLineNo">731</span>   */<a name="line.731"></a>
-<span class="sourceLineNo">732</span>  public void assertBulkLoadHFileOk(Path srcPath) throws IOException {<a name="line.732"></a>
-<span class="sourceLineNo">733</span>    HFile.Reader reader  = null;<a name="line.733"></a>
-<span class="sourceLineNo">734</span>    try {<a name="line.734"></a>
-<span class="sourceLineNo">735</span>      LOG.info("Validating hfile at " + srcPath + " for inclusion in "<a name="line.735"></a>
-<span class="sourceLineNo">736</span>          + "store " + this + " region " + this.getRegionInfo().getRegionNameAsString());<a name="line.736"></a>
-<span class="sourceLineNo">737</span>      reader = HFile.createReader(srcPath.getFileSystem(conf), srcPath, cacheConf,<a name="line.737"></a>
-<span class="sourceLineNo">738</span>        isPrimaryReplicaStore(), conf);<a name="line.738"></a>
-<span class="sourceLineNo">739</span>      reader.loadFileInfo();<a name="line.739"></a>
-<span class="sourceLineNo">740</span><a name="line.740"></a>
-<span class="sourceLineNo">741</span>      Optional&lt;byte[]&gt; firstKey = reader.getFirstRowKey();<a name="line.741"></a>
-<span class="sourceLineNo">742</span>      Preconditions.checkState(firstKey.isPresent(), "First key can not be null");<a name="line.742"></a>
-<span class="sourceLineNo">743</span>      Optional&lt;Cell&gt; lk = reader.getLastKey();<a name="line.743"></a>
-<span class="sourceLineNo">744</span>      Preconditions.checkState(lk.isPresent(), "Last key can not be null");<a name="line.744"></a>
-<span class="sourceLineNo">745</span>      byte[] lastKey =  CellUtil.cloneRow(lk.get());<a name="line.745"></a>
-<span class="sourceLineNo">746</span><a name="line.746"></a>
-<span class="sourceLineNo">747</span>      LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey.get()) +<a name="line.747"></a>
-<span class="sourceLineNo">748</span>          " last=" + Bytes.toStringBinary(lastKey));<a name="line.748"></a>
-<span class="sourceLineNo">749</span>      LOG.debug("Region bounds: first=" +<a name="line.749"></a>
-<span class="sourceLineNo">750</span>          Bytes.toStringBinary(getRegionInfo().getStartKey()) +<a name="line.750"></a>
-<span class="sourceLineNo">751</span>          " last=" + Bytes.toStringBinary(getRegionInfo().getEndKey()));<a name="line.751"></a>
-<span class="sourceLineNo">752</span><a name="line.752"></a>
-<span class="sourceLineNo">753</span>      if (!this.getRegionInfo().containsRange(firstKey.get(), lastKey)) {<a name="line.753"></a>
-<span class="sourceLineNo">754</span>        throw new WrongRegionException(<a name="line.754"></a>
-<span class="sourceLineNo">755</span>            "Bulk load file " + srcPath.toString() + " does not fit inside region "<a name="line.755"></a>
-<span class="sourceLineNo">756</span>            + this.getRegionInfo().getRegionNameAsString());<a name="line.756"></a>
-<span class="sourceLineNo">757</span>      }<a name="line.757"></a>
-<span class="sourceLineNo">758</span><a name="line.758"></a>
-<span class="sourceLineNo">759</span>      if(reader.length() &gt; conf.getLong(HConstants.HREGION_MAX_FILESIZE,<a name="line.759"></a>
-<span class="sourceLineNo">760</span>          HConstants.DEFAULT_MAX_FILE_SIZE)) {<a name="line.760"></a>
-<span class="sourceLineNo">761</span>        LOG.warn("Trying to bulk load hfile " + srcPath.toString() + " with size: " +<a name="line.761"></a>
-<span class="sourceLineNo">762</span>            reader.length() + " bytes can be problematic as it may lead to oversplitting.");<a name="line.762"></a>
-<span class="sourceLineNo">763</span>      }<a name="line.763"></a>
-<span class="sourceLineNo">764</span><a name="line.764"></a>
-<span class="sourceLineNo">765</span>      if (verifyBulkLoads) {<a name="line.765"></a>
-<span class="sourceLineNo">766</span>        long verificationStartTime = EnvironmentEdgeManager.currentTime();<a name="line.766"></a>
-<span class="sourceLineNo">767</span>        LOG.info("Full verification started for bulk load hfile: " + srcPath.toString());<a name="line.767"></a>
-<span class="sourceLineNo">768</span>        Cell prevCell = null;<a name="line.768"></a>
-<span class="sourceLineNo">769</span>        HFileScanner scanner = reader.getScanner(false, false, false);<a name="line.769"></a>
-<span class="sourceLineNo">770</span>        scanner.seekTo();<a name="line.770"></a>
-<span class="sourceLineNo">771</span>        do {<a name="line.771"></a>
-<span class="sourceLineNo">772</span>          Cell cell = scanner.getCell();<a name="line.772"></a>
-<span class="sourceLineNo">773</span>          if (prevCell != null) {<a name="line.773"></a>
-<span class="sourceLineNo">774</span>            if (comparator.compareRows(prevCell, cell) &gt; 0) {<a name="line.774"></a>
-<span class="sourceLineNo">775</span>              throw new InvalidHFileException("Previous row is greater than"<a name="line.775"></a>
-<span class="sourceLineNo">776</span>                  + " current row: path=" + srcPath + " previous="<a name="line.776"></a>
-<span class="sourceLineNo">777</span>                  + CellUtil.getCellKeyAsString(prevCell) + " current="<a name="line.777"></a>
-<span class="sourceLineNo">778</span>                  + CellUtil.getCellKeyAsString(cell));<a name="line.778"></a>
-<span class="sourceLineNo">779</span>            }<a name="line.779"></a>
-<span class="sourceLineNo">780</span>            if (CellComparator.getInstance().compareFamilies(prevCell, cell) != 0) {<a name="line.780"></a>
-<span class="sourceLineNo">781</span>              throw new InvalidHFileException("Previous key had different"<a name="line.781"></a>
-<span class="sourceLineNo">782</span>                  + " family compared to current key: path=" + srcPath<a name="line.782"></a>
-<span class="sourceLineNo">783</span>                  + " previous="<a name="line.783"></a>
-<span class="sourceLineNo">784</span>                  + Bytes.toStringBinary(prevCell.getFamilyArray(), prevCell.getFamilyOffset(),<a name="line.784"></a>
-<span class="sourceLineNo">785</span>                      prevCell.getFamilyLength())<a name="line.785"></a>
-<span class="sourceLineNo">786</span>                  + " current="<a name="line.786"></a>
-<span class="sourceLineNo">787</span>                  + Bytes.toStringBinary(cell.getFamilyArray(), cell.getFamilyOffset(),<a name="line.787"></a>
-<span class="sourceLineNo">788</span>                      cell.getFamilyLength()));<a name="line.788"></a>
-<span class="sourceLineNo">789</span>            }<a name="line.789"></a>
-<span class="sourceLineNo">790</span>          }<a name="line.790"></a>
-<span class="sourceLineNo">791</span>          prevCell = cell;<a name="line.791"></a>
-<span class="sourceLineNo">792</span>        } while (scanner.next());<a name="line.792"></a>
-<span class="sourceLineNo">793</span>      LOG.info("Full verification complete for bulk load hfile: " + srcPath.toString()<a name="line.793"></a>
-<span class="sourceLineNo">794</span>         + " took " + (EnvironmentEdgeManager.currentTime() - verificationStartTime)<a name="line.794"></a>
-<span class="sourceLineNo">795</span>         + " ms");<a name="line.795"></a>
-<span class="sourceLineNo">796</span>      }<a name="line.796"></a>
-<span class="sourceLineNo">797</span>    } finally {<a name="line.797"></a>
-<span class="sourceLineNo">798</span>      if (reader != null) reader.close();<a name="line.798"></a>
-<span class="sourceLineNo">799</span>    }<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>  /**<a name="line.802"></a>
-<span class="sourceLineNo">803</span>   * This method should only be called from Region. It is assumed that the ranges of values in the<a name="line.803"></a>
-<span class="sourceLineNo">804</span>   * HFile fit within the stores assigned region. (assertBulkLoadHFileOk checks this)<a name="line.804"></a>
-<span class="sourceLineNo">805</span>   *<a name="line.805"></a>
-<span class="sourceLineNo">806</span>   * @param srcPathStr<a name="line.806"></a>
-<span class="sourceLineNo">807</span>   * @param seqNum sequence Id associated with the HFile<a name="line.807"></a>
-<span class="sourceLineNo">808</span>   */<a name="line.808"></a>
-<span class="sourceLineNo">809</span>  public Pair&lt;Path, Path&gt; preBulkLoadHFile(String srcPathStr, long seqNum) throws IOException {<a name="line.809"></a>
-<span class="sourceLineNo">810</span>    Path srcPath = new Path(srcPathStr);<a name="line.810"></a>
-<span class="sourceLineNo">811</span>    return fs.bulkLoadStoreFile(getColumnFamilyName(), srcPath, seqNum);<a name="line.811"></a>
-<span class="sourceLineNo">812</span>  }<a name="line.812"></a>
-<span class="sourceLineNo">813</span><a name="line.813"></a>
-<span class="sourceLineNo">814</span>  public Path bulkLoadHFile(byte[] family, String srcPathStr, Path dstPath) throws IOException {<a name="line.814"></a>
-<span class="sourceLineNo">815</span>    Path srcPath = new Path(srcPathStr);<a name="line.815"></a>
-<span class="sourceLineNo">816</span>    try {<a name="line.816"></a>
-<span class="sourceLineNo">817</span>      fs.commitStoreFile(srcPath, dstPath);<a name="line.817"></a>
-<span class="sourceLineNo">818</span>    } finally {<a name="line.818"></a>
-<span class="sourceLineNo">819</span>      if (this.getCoprocessorHost() != null) {<a name="line.819"></a>
-<span class="sourceLineNo">820</span>        this.getCoprocessorHost().postCommitStoreFile(family, srcPath, dstPath);<a name="line.820"></a>
-<span class="sourceLineNo">821</span>      }<a name="line.821"></a>
-<span class="sourceLineNo">822</span>    }<a name="line.822"></a>
-<span class="sourceLineNo">823</span><a name="line.823"></a>
-<span class="sourceLineNo">824</span>    LOG.info("Loaded HFile " + srcPath + " into store '" + getColumnFamilyName() + "' as "<a name="line.824"></a>
-<span class="sourceLineNo">825</span>        + dstPath + " - updating store file list.");<a name="line.825"></a>
-<span class="sourceLineNo">826</span><a name="line.826"></a>
-<span class="sourceLineNo">827</span>    HStoreFile sf = createStoreFileAndReader(dstPath);<a name="line.827"></a>
-<span class="sourceLineNo">828</span>    bulkLoadHFile(sf);<a name="line.828"></a>
-<span class="sourceLineNo">829</span><a name="line.829"></a>
-<span class="sourceLineNo">830</span>    LOG.info("Successfully loaded store file " + srcPath + " into store " + this<a name="line.830"></a>
-<span class="sourceLineNo">831</span>        + " (new location: " + dstPath + ")");<a name="line.831"></a>
-<span class="sourceLineNo">832</span><a name="line.832"></a>
-<span class="sourceLineNo">833</span>    return dstPath;<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>  public void bulkLoadHFile(StoreFileInfo fileInfo) throws IOException {<a name="line.836"></a>
-<span class="sourceLineNo">837</span>    HStoreFile sf = createStoreFileAndReader(fileInfo);<a name="line.837"></a>
-<span class="sourceLineNo">838</span>    bulkLoadHFile(sf);<a name="line.838"></a>
-<span class="sourceLineNo">839</span>  }<a name="line.839"></a>
-<span class="sourceLineNo">840</span><a name="line.840"></a>
-<span class="sourceLineNo">841</span>  private void bulkLoadHFile(HStoreFile sf) throws IOException {<a name="line.841"></a>
-<span class="sourceLineNo">842</span>    StoreFileReader r = sf.getReader();<a name="line.842"></a>
-<span class="sourceLineNo">843</span>    this.storeSize += r.length();<a name="line.843"></a>
-<span class="sourceLineNo">844</span>    this.totalUncompressedBytes += r.getTotalUncompressedBytes();<a name="line.844"></a>
-<span class="sourceLineNo">845</span><a name="line.845"></a>
-<span class="sourceLineNo">846</span>    // Append the new storefile into the list<a name="line.846"></a>
-<span class="sourceLineNo">847</span>    this.lock.writeLock().lock();<a name="line.847"></a>
-<span class="sourceLineNo">848</span>    try {<a name="line.848"></a>
-<span class="sourceLineNo">849</span>      this.storeEngine.getStoreFileManager().insertNewFiles(Lists.newArrayList(sf));<a name="line.849"></a>
-<span class="sourceLineNo">850</span>    } finally {<a name="line.850"></a>
-<span class="sourceLineNo">851</span>      // We need the lock, as long as we are updating the storeFiles<a name="line.851"></a>
-<span class="sourceLineNo">852</span>      // or changing the memstore. Let us release it before calling<a name="line.852"></a>
-<span class="sourceLineNo">853</span>      // notifyChangeReadersObservers. See HBASE-4485 for a possible<a name="line.853"></a>
-<span class="sourceLineNo">854</span>      // deadlock scenario that could have happened if continue to hold<a name="line.854"></a>
-<span class="sourceLineNo">855</span>      // the lock.<a name="line.855"></a>
-<span class="sourceLineNo">856</span>      this.lock.writeLock().unlock();<a name="line.856"></a>
-<span class="sourceLineNo">857</span>    }<a name="line.857"></a>
-<span class="sourceLineNo">858</span>    LOG.info("Loaded HFile " + sf.getFileInfo() + " into store '" + getColumnFamilyName());<a name="line.858"></a>
-<span class="sourceLineNo">859</span>    if (LOG.isTraceEnabled()) {<a name="line.859"></a>
-<span class="sourceLineNo">860</span>      String traceMessage = "BULK LOAD time,size,store size,store files ["<a name="line.860"></a>
-<span class="sourceLineNo">861</span>          + EnvironmentEdgeManager.currentTime() + "," + r.length() + "," + storeSize<a name="line.861"></a>
-<span class="sourceLineNo">862</span>          + "," + storeEngine.getStoreFileManager().getStorefileCount() + "]";<a name="line.862"></a>
-<span class="sourceLineNo">863</span>      LOG.trace(traceMessage);<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>  /**<a name="line.867"></a>
-<span class="sourceLineNo">868</span>   * Close all the readers We don't need to worry about subsequent requests because the Region holds<a name="line.868"></a>
-<span class="sourceLineNo">869</span>   * a write lock that will prevent any more reads or writes.<a name="line.869"></a>
-<span class="sourceLineNo">870</span>   * @return the {@link StoreFile StoreFiles} that were previously being used.<a name="line.870"></a>
-<span class="sourceLineNo">871</span>   * @throws IOException on failure<a name="line.871"></a>
-<span class="sourceLineNo">872</span>   */<a name="line.872"></a>
-<span class="sourceLineNo">873</span>  public ImmutableCollection&lt;HStoreFile&gt; close() throws IOException {<a name="line.873"></a>
-<span class="sourceLineNo">874</span>    this.archiveLock.lock();<a name="line.874"></a>
-<span class="sourceLineNo">875</span>    this.lock.writeLock().lock();<a name="line.875"></a>
-<span class="sourceLineNo">876</span>    try {<a name="line.876"></a>
-<span class="sourceLineNo">877</span>      // Clear so metrics doesn't find them.<a name="line.877"></a>
-<span class="sourceLineNo">878</span>      ImmutableCollection&lt;HStoreFile&gt; result = storeEngine.getStoreFileManager().clearFiles();<a name="line.878"></a>
-<span class="sourceLineNo">879</span>      Collection&lt;HStoreFile&gt; compactedfiles =<a name="line.879"></a>
-<span class="sourceLineNo">880</span>          storeEngine.getStoreFileManager().clearCompactedFiles();<a name="line.880"></a>
-<span class="sourceLineNo">881</span>      // clear the compacted files<a name="line.881"></a>
-<span class="sourceLineNo">882</span>      if (compactedfiles != null &amp;&amp; !compactedfiles.isEmpty()) {<a name="line.882"></a>
-<span class="sourceLineNo">883</span>        removeCompactedfiles(compactedfiles);<a name="line.883"></a>
-<span class="sourceLineNo">884</span>      }<a name="line.884"></a>
-<span class="sourceLineNo">885</span>      if (!result.isEmpty()) {<a name="line.885"></a>
-<span class="sourceLineNo">886</span>        // initialize the thread pool for closing store files in parallel.<a name="line.886"></a>
-<span class="sourceLineNo">887</span>        ThreadPoolExecutor storeFileCloserThreadPool = this.region<a name="line.887"></a>
-<span class="sourceLineNo">888</span>            .getStoreFileOpenAndCloseThreadPool("StoreFileCloserThread-"<a name="line.888"></a>
-<span class="sourceLineNo">889</span>                + this.getColumnFamilyName());<a name="line.889"></a>
-<span class="sourceLineNo">890</span><a name="line.890"></a>
-<span class="sourceLineNo">891</span>        // close each store file in parallel<a name="line.891"></a>
-<span class="sourceLineNo">892</span>        CompletionService&lt;Void&gt; completionService =<a name="line.892"></a>
-<span class="sourceLineNo">893</span>          new ExecutorCompletionService&lt;&gt;(storeFileCloserThreadPool);<a name="line.893"></a>
-<span class="sourceLineNo">894</span>        for (HStoreFile f : result) {<a name="line.894"></a>
-<span class="sourceLineNo">895</span>          completionService.submit(new Callable&lt;Void&gt;() {<a name="line.895"></a>
-<span class="sourceLineNo">896</span>            @Override<a name="line.896"></a>
-<span class="sourceLineNo">897</span>            public Void call() throws IOException {<a name="line.897"></a>
-<span class="sourceLineNo">898</span>              boolean evictOnClose =<a name="line.898"></a>
-<span class="sourceLineNo">899</span>                  cacheConf != null? cacheConf.shouldEvictOnClose(): true;<a name="line.899"></a>
-<span class="sourceLineNo">900</span>              f.closeStoreFile(evictOnClose);<a name="line.900"></a>
-<span class="sourceLineNo">901</span>              return null;<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><a name="line.905"></a>
-<span class="sourceLineNo">906</span>        IOException ioe = null;<a name="line.906"></a>
-<span class="sourceLineNo">907</span>        try {<a name="line.907"></a>
-<span class="sourceLineNo">908</span>          for (int i = 0; i &lt; result.size(); i++) {<a name="line.908"></a>
-<span class="sourceLineNo">909</span>            try {<a name="line.909"></a>
-<span class="sourceLineNo">910</span>              Future&lt;Void&gt; future = completionService.take();<a name="line.910"></a>
-<span class="sourceLineNo">911</span>              future.get();<a name="line.911"></a>
-<span class="sourceLineNo">912</span>            } catch (InterruptedException e) {<a name="line.912"></a>
-<span class="sourceLineNo">913</span>              if (ioe == null) {<a name="line.913"></a>
-<span class="sourceLineNo">914</span>                ioe = new InterruptedIOException();<a name="line.914"></a>
-<span class="sourceLineNo">915</span>                ioe.initCause(e);<a name="line.915"></a>
-<span class="sourceLineNo">916</span>              }<a name="line.916"></a>
-<span class="sourceLineNo">917</span>            } catch (ExecutionException e) {<a name="line.917"></a>
-<span class="sourceLineNo">918</span>              if (ioe == null) ioe = new IOException(e.getCause());<a name="line.918"></a>
-<span class="sourceLineNo">919</span>            }<a name="line.919"></a>
-<span class="sourceLineNo">920</span>          }<a name="line.920"></a>
-<span class="sourceLineNo">921</span>        } finally {<a name="line.921"></a>
-<span class="sourceLineNo">922</span>          storeFileCloserThreadPool.shutdownNow();<a name="line.922"></a>
-<span class="sourceLineNo">923</span>        }<a name="line.923"></a>
-<span class="sourceLineNo">924</span>        if (ioe != null) throw ioe;<a name="line.924"></a>
-<span class="sourceLineNo">925</span>      }<a name="line.925"></a>
-<span class="sourceLineNo">926</span>      LOG.info("Closed " + this);<a name="line.926"></a>
-<span class="sourceLineNo">927</span>      return result;<a name="line.927"></a>
-<span class="sourceLineNo">928</span>    } finally {<a name="line.928"></a>
-<span class="sourceLineNo">929</span>      this.lock.writeLock().unlock();<a name="line.929"></a>
-<span class="sourceLineNo">930</span>      this.archiveLock.unlock();<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><a name="line.933"></a>
-<span class="sourceLineNo">934</span>  /**<a name="line.934"></a>
-<span class="sourceLineNo">935</span>   * Snapshot this stores memstore. Call before running<a name="line.935"></a>
-<span class="sourceLineNo">936</span>   * {@link #flushCache(long, MemStoreSnapshot, MonitoredTask, ThroughputController,<a name="line.936"></a>
-<span class="sourceLineNo">937</span>   * FlushLifeCycleTracker)}<a name="line.937"></a>
-<span class="sourceLineNo">938</span>   *  so it has some work to do.<a name="line.938"></a>
-<span class="sourceLineNo">939</span>   */<a name="line.939"></a>
-<span class="sourceLineNo">940</span>  void snapshot() {<a name="line.940"></a>
-<span class="sourceLineNo">941</span>    this.lock.writeLock().lock();<a name="line.941"></a>
-<span class="sourceLineNo">942</span>    try {<a name="line.942"></a>
-<span class="sourceLineNo">943</span>      this.memstore.snapshot();<a name="line.943"></a>
-<span class="sourceLineNo">944</span>    } finally {<a name="line.944"></a>
-<span class="sourceLineNo">945</span>      this.lock.writeLock().unlock();<a name="line.945"></a>
-<span class="sourceLineNo">946</span>    }<a name="line.946"></a>
-<span class="sourceLineNo">947</span>  }<a name="line.947"></a>
-<span class="sourceLineNo">948</span><a name="line.948"></a>
-<span class="sourceLineNo">949</span>  /**<a name="line.949"></a>
-<span class="sourceLineNo">950</span>   * Write out current snapshot. Presumes {@link #snapshot()} has been called previously.<a name="line.950"></a>
-<span class="sourceLineNo">951</span>   * @param logCacheFlushId flush sequence number<a name="line.951"></a>
-<span class="sourceLineNo">952</span>   * @param snapshot<a name="line.952"></a>
-<span class="sourceLineNo">953</span>   * @param status<a name="line.953"></a>
-<span class="sourceLineNo">954</span>   * @param throughputController<a name="line.954"></a>
-<span class="sourceLineNo">955</span>   * @return The path name of the tmp file to which the store was flushed<a name="line.955"></a>
-<span class="sourceLineNo">956</span>   * @throws IOException if exception occurs during process<a name="line.956"></a>
-<span class="sourceLineNo">957</span>   */<a name="line.957"></a>
-<span class="sourceLineNo">958</span>  protected List&lt;Path&gt; flushCache(final long logCacheFlushId, MemStoreSnapshot snapshot,<a name="line.958"></a>
-<span class="sourceLineNo">959</span>      MonitoredTask status, ThroughputController throughputController,<a name="line.959"></a>
-<span class="sourceLineNo">960</span>      FlushLifeCycleTracker tracker) throws IOException {<a name="line.960"></a>
-<span class="sourceLineNo">961</span>    // If an exception happens flushing, we let it out without clearing<a name="line.961"></a>
-<span class="sourceLineNo">962</span>    // the memstore snapshot.  The old snapshot will be returned when we say<a name="line.962"></a>
-<span class="sourceLineNo">963</span>    // 'snapshot', the next time flush comes around.<a name="line.963"></a>
-<span class="sourceLineNo">964</span>    // Retry after catching exception when flushing, otherwise server will abort<a name="line.964"></a>
-<span class="sourceLineNo">965</span>    // itself<a name="line.965"></a>
-<span class="sourceLineNo">966</span>    StoreFlusher flusher = storeEngine.getStoreFlusher();<a name="line.966"></a>
-<span class="sourceLineNo">967</span>    IOException lastException = null;<a name="line.967"></a>
-<span class="sourceLineNo">968</span>    for (int i = 0; i &lt; flushRetriesNumber; i++) {<a name="line.968"></a>
-<span class="sourceLineNo">969</span>      try {<a name="line.969"></a>
-<span class="sourceLineNo">970</span>        List&lt;Path&gt; pathNames =<a name="line.970"></a>
-<span class="sourceLineNo">971</span>            flusher.flushSnapshot(snapshot, logCacheFlushId, status, throughputController, tracker);<a name="line.971"></a>
-<span class="sourceLineNo">972</span>        Path lastPathName = null;<a name="line.972"></a>
-<span class="sourceLineNo">973</span>        try {<a name="line.973"></a>
-<span class="sourceLineNo">974</span>          for (Path pathName : pathNames) {<a name="line.974"></a>
-<span class="sourceLineNo">975</span>            lastPathName = pathName;<a name="line.975"></a>
-<span class="sourceLineNo">976</span>            validateStoreFile(pathName);<a name="line.976"></a>
-<span class="sourceLineNo">977</span>          }<a name="line.977"></a>
-<span class="sourceLineNo">978</span>          return pathNames;<a name="line.978"></a>
-<span class="sourceLineNo">979</span>        } catch (Exception e) {<a name="line.979"></a>
-<span class="sourceLineNo">980</span>          LOG.warn("Failed validating store file " + lastPathName + ", retrying num=" + i, e);<a name="line.980"></a>
-<span class="sourceLineNo">981</span>          if (e instanceof IOException) {<a name="line.981"></a>
-<span class="sourceLineNo">982</span>            lastException = (IOException) e;<a name="line.982"></a>
-<span class="sourceLineNo">983</span>          } else {<a name="line.983"></a>
-<span class="sourceLineNo">984</span>            lastException = new IOException(e);<a name="line.984"></a>
-<span class="sourceLineNo">985</span>          }<a name="line.985"></a>
-<span class="sourceLineNo">986</span>        }<a name="line.986"></a>
-<span class="sourceLineNo">987</span>      } catch (IOException e) {<a name="line.987"></a>
-<span class="sourceLineNo">988</span>        LOG.warn("Failed flushing store file, retrying num=" + i, e);<a name="line.988"></a>
-<span class="sourceLineNo">989</span>        lastException = e;<a name="line.989"></a>
-<span class="sourceLineNo">990</span>      }<a name="line.990"></a>
-<span class="sourceLineNo">991</span>      if (lastException != null &amp;&amp; i &lt; (flushRetriesNumber - 1)) {<a name="line.991"></a>
-<span class="sourceLineNo">992</span>        try {<a name="line.992"></a>
-<span class="sourceLineNo">993</span>          Thread.sleep(pauseTime);<a name="line.993"></a>
-<span class="sourceLineNo">994</span>        } catch (InterruptedException e) {<a name="line.994"></a>
-<span class="sourceLineNo">995</span>          IOException iie = new InterruptedIOException();<a name="line.995"></a>
-<span class="sourceLineNo">996</span>          iie.initCause(e);<a name="line.996"></a>
-<span class="sourceLineNo">997</span>          throw iie;<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>    }<a name="line.1000"></a>
-<span class="sourceLineNo">1001</span>    throw lastException;<a name="line.1001"></a>
-<span class="sourceLineNo">1002</span>  }<a name="line.1002"></a>
-<span class="sourceLineNo">1003</span><a name="line.1003"></a>
-<span class="sourceLineNo">1004</span>  /**<a name="line.1004"></a>
-<span class="sourceLineNo">1005</span>   * @param path The pathname of the tmp file into which the store was flushed<a name="line.1005"></a>
-<span class="sourceLineNo">1006</span>   * @param logCacheFlushId<a name="line.1006"></a>
-<span class="sourceLineNo">1007</span>   * @param status<a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>   * @return store file created.<a name="line.1008"></a>
-<span class="sourceLineNo">1009</span>   * @throws IOException<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span>   */<a name="line.1010"></a>
-<span class="sourceLineNo">1011</span>  private HStoreFile commitFile(Path path, long logCacheFlushId, MonitoredTask status)<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>      throws IOException {<a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>    // Write-out finished successfully, move into the right spot<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>    Path dstPath = fs.commitStoreFile(getColumnFamilyName(), path);<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span><a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>    status.setStatus("Flushing " + this + ": reopening flushed file");<a name="line.1016"></a>
-<span class="sourceLineNo">1017</span>    HStoreFile sf = createStoreFileAndReader(dstPath);<a name="line.1017"></a>
-<span class="sourceLineNo">1018</span><a name="line.1018"></a>
-<span class="sourceLineNo">1019</span>    StoreFileReader r = sf.getReader();<a name="line.1019"></a>
-<span class="sourceLineNo">1020</span>    this.storeSize += r.length();<a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>    this.totalUncompressedBytes += r.getTotalUncompressedBytes();<a name="line.1021"></a>
-<span class="sourceLineNo">1022</span><a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>    if (LOG.isInfoEnabled()) {<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>      LOG.info("Added " + sf + ", entries=" + r.getEntries() +<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span>        ", sequenceid=" + logCacheFlushId +<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>        ", filesize=" + TraditionalBinaryPrefix.long2String(r.length(), "", 1));<a name="line.1026"></a>
-<span class="sourceLineNo">1027</span>    }<a name="line.1027"></a>
-<span class="sourceLineNo">1028</span>    return sf;<a name="line.1028"></a>
-<span class="sourceLineNo">1029</span>  }<a name="line.1029"></a>
-<span class="sourceLineNo">1030</span><a name="line.1030"></a>
-<span class="sourceLineNo">1031</span>  /**<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span>   * @param maxKeyCount<a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>   * @param compression Compression algorithm to use<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span>   * @param isCompaction whether we are creating a new file in a compaction<a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>   * @param includeMVCCReadpoint - whether to include MVCC or not<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span>   * @param includesTag - includesTag or not<a name="line.1036"></a>
-<span class="sourceLineNo">1037</span>   * @return Writer for a new StoreFile in the tmp dir.<a name="line.1037"></a>
-<span class="sourceLineNo">1038</span>   */<a name="line.1038"></a>
-<span class="sourceLineNo">1039</span>  // TODO : allow the Writer factory to create Writers of ShipperListener type only in case of<a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>  // compaction<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span>  public StoreFileWriter createWriterInTmp(long maxKeyCount, Compression.Algorithm compression,<a name="line.1041"></a>
-<span class="sourceLineNo">1042</span>      boolean isCompaction, boolean includeMVCCReadpoint, boolean includesTag,<a name="line.1042"></a>
-<span class="sourceLineNo">1043</span>      boolean shouldDropBehind) throws IOException {<a name="line.1043"></a>
-<span class="sourceLineNo">1044</span>    final CacheConfig writerCacheConf;<a name="line.1044"></a>
-<span class="sourceLineNo">1045</span>    if (isCompaction) {<a name="line.1045"></a>
-<span class="sourceLineNo">1046</span>      // Don't cache data on write on compactions.<a name="line.1046"></a>
-<span class="sourceLineNo">1047</span>      writerCacheConf = new CacheConfig(cacheConf);<a name="line.1047"></a>
-<span class="sourceLineNo">1048</span>      writerCacheConf.setCacheDataOnWrite(false);<a name="line.1048"></a>
-<span class="sourceLineNo">1049</span>    } else {<a name="line.1049"></a>
-<span class="sourceLineNo">1050</span>      writerCacheConf = cacheConf;<a name="line.1050"></a>
-<span class="sourceLineNo">1051</span>    }<a name="line.1051"></a>
-<span class="sourceLineNo">1052</span>    InetSocketAddress[] favoredNodes = null;<a name="line.1052"></a>
-<span class="sourceLineNo">1053</span>    if (region.getRegionServerServices() != null) {<a name="line.1053"></a>
-<span class="sourceLineNo">1054</span>      favoredNodes = region.getRegionServerServices().getFavoredNodesForRegion(<a name="line.1054"></a>
-<span class="sourceLineNo">1055</span>          region.getRegionInfo().getEncodedName());<a name="line.1055"></a>
-<span class="sourceLineNo">1056</span>    }<a name="line.1056"></a>
-<span class="sourceLineNo">1057</span>    HFileContext hFileContext = createFileContext(compression, includeMVCCReadpoint, includesTag,<a name="line.1057"></a>
-<span class="sourceLineNo">1058</span>      cryptoContext);<a name="line.1058"></a>
-<span class="sourceLineNo">1059</span>    Path familyTempDir = new Path(fs.getTempDir(), family.getNameAsString());<a name="line.1059"></a>
-<span class="sourceLineNo">1060</span>    StoreFileWriter.Builder builder = new StoreFileWriter.Builder(conf, writerCacheConf,<a name="line.1060"></a>
-<span class="sourceLineNo">1061</span>        this.getFileSystem())<a name="line.1061"></a>
-<span class="sourceLineNo">1062</span>            .withOutputDir(familyTempDir)<a name="line.1062"></a>
-<span class="sourceLineNo">1063</span>            .withComparator(comparator)<a name="line.1063"></a>
-<span class="sourceLineNo">1064</span>            .withBloomType(family.getBloomFilterType())<a name="line.1064"></a>
-<span class="sourceLineNo">1065</span>            .withMaxKeyCount(maxKeyCount)<a name="line.1065"></a>
-<span class="sourceLineNo">1066</span>            .withFavoredNodes(favoredNodes)<a name="line.1066"></a>
-<span class="sourceLineNo">1067</span>            .withFileContext(hFileContext)<a name="line.1067"></a>
-<span class="sourceLineNo">1068</span>            .withShouldDropCacheBehind(shouldDropBehind);<a name="line.1068"></a>
-<span class="sourceLineNo">1069</span>    return builder.build();<a name="line.1069"></a>
-<span class="sourceLineNo">1070</span>  }<a name="line.1070"></a>
-<span class="sourceLineNo">1071</span><a name="line.1071"></a>
-<span class="sourceLineNo">1072</span>  private HFileContext createFileContext(Compression.Algorithm compression,<a name="line.1072"></a>
-<span class="sourceLineNo">1073</span>      boolean includeMVCCReadpoint, boolean includesTag, Encryption.Context cryptoContext) {<a name="line.1073"></a>
-<span class="sourceLineNo">1074</span>    if (compression == null) {<a name="line.1074"></a>
-<span class="sourceLineNo">1075</span>      compression = HFile.DEFAULT_COMPRESSION_ALGORITHM;<a name="line.1075"></a>
-<span class="sourceLineNo">1076</span>    }<a name="line.1076"></a>
-<span class="sourceLineNo">1077</span>    HFileContext hFileContext = new HFileContextBuilder()<a name="line.1077"></a>
-<span class="sourceLineNo">1078</span>                                .withIncludesMvcc(includeMVCCReadpoint)<a name="line.1078"></a>
-<span class="sourceLineNo">1079</span>                                .withIncludesTags(includesTag)<a name="line.1079"></a>
-<span class="sourceLineNo">1080</span>                                .withCompression(compression)<a name="line.1080"></a>
-<span class="sourceLineNo">1081</span>                                .withCompressTags(family.isCompressTags())<a name="line.1081"></a>
-<span class="sourceLineNo">1082</span>                                .withChecksumType(checksumType)<a name="line.1082"></a>
-<span class="sourceLineNo">1083</span>                                .withBytesPerCheckSum(bytesPerChecksum)<a name="line.1083"></a>
-<span class="sourceLineNo">1084</span>                                .withBlockSize(blocksize)<a name="line.1084"></a>
-<span class="sourceLineNo">1085</span>                                .withHBaseCheckSum(true)<a name="line.1085"></a>
-<span class="sourceLineNo">1086</span>                                .withDataBlockEncoding(family.getDataBlockEncoding())<a name="line.1086"></a>
-<span class="sourceLineNo">1087</span>                                .withEncryptionContext(cryptoContext)<a name="line.1087"></a>
-<span class="sourceLineNo">1088</span>                                .withCreateTime(EnvironmentEdgeManager.currentTime())<a name="line.1088"></a>
-<span class="sourceLineNo">1089</span>                                .build();<a name="line.1089"></a>
-<span class="sourceLineNo">1090</span>    return hFileContext;<a name="line.1090"></a>
-<span class="sourceLineNo">1091</span>  }<a name="line.1091"></a>
-<span class="sourceLineNo">1092</span><a name="line.1092"></a>
+<span class="sourceLineNo">657</span>  @VisibleForTesting<a name="line.657"></a>
+<span class="sourceLineNo">658</span>  protected HStoreFile createStoreFileAndReader(final Path p) throws IOException {<a name="line.658"></a>
+<span class="sourceLineNo">659</span>    StoreFileInfo info = new StoreFileInfo(conf, this.getFileSystem(), p);<a name="line.659"></a>
+<span class="sourceLineNo">660</span>    return createStoreFileAndReader(info);<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>  private HStoreFile createStoreFileAndReader(StoreFileInfo info) throws IOException {<a name="line.663"></a>
+<span class="sourceLineNo">664</span>    info.setRegionCoprocessorHost(this.region.getCoprocessorHost());<a name="line.664"></a>
+<span class="sourceLineNo">665</span>    HStoreFile storeFile = new HStoreFile(this.getFileSystem(), info, this.conf, this.cacheConf,<a name="line.665"></a>
+<span class="sourceLineNo">666</span>        this.family.getBloomFilterType(), isPrimaryReplicaStore());<a name="line.666"></a>
+<span class="sourceLineNo">667</span>    storeFile.initReader();<a name="line.667"></a>
+<span class="sourceLineNo">668</span>    return storeFile;<a name="line.668"></a>
+<span class="sourceLineNo">669</span>  }<a name="line.669"></a>
+<span class="sourceLineNo">670</span><a name="line.670"></a>
+<span class="sourceLineNo">671</span>  /**<a name="line.671"></a>
+<span class="sourceLineNo">672</span>   * This message intends to inform the MemStore that next coming updates<a name="line.672"></a>
+<span class="sourceLineNo">673</span>   * are going to be part of the replaying edits from WAL<a name="line.673"></a>
+<span class="sourceLineNo">674</span>   */<a name="line.674"></a>
+<span class="sourceLineNo">675</span>  public void startReplayingFromWAL(){<a name="line.675"></a>
+<span class="sourceLineNo">676</span>    this.memstore.startReplayingFromWAL();<a name="line.676"></a>
+<span class="sourceLineNo">677</span>  }<a name="line.677"></a>
+<span class="sourceLineNo">678</span><a name="line.678"></a>
+<span class="sourceLineNo">679</span>  /**<a name="line.679"></a>
+<span class="sourceLineNo">680</span>   * This message intends to inform the MemStore that the replaying edits from WAL<a name="line.680"></a>
+<span class="sourceLineNo">681</span>   * are done<a name="line.681"></a>
+<span class="sourceLineNo">682</span>   */<a name="line.682"></a>
+<span class="sourceLineNo">683</span>  public void stopReplayingFromWAL(){<a name="line.683"></a>
+<span class="sourceLineNo">684</span>    this.memstore.stopReplayingFromWAL();<a name="line.684"></a>
+<span class="sourceLineNo">685</span>  }<a name="line.685"></a>
+<span class="sourceLineNo">686</span><a name="line.686"></a>
+<span class="sourceLineNo">687</span>  /**<a name="line.687"></a>
+<span class="sourceLineNo">688</span>   * Adds a value to the memstore<a name="line.688"></a>
+<span class="sourceLineNo">689</span>   */<a name="line.689"></a>
+<span class="sourceLineNo">690</span>  public void add(final Cell cell, MemStoreSizing memstoreSizing) {<a name="line.690"></a>
+<span class="sourceLineNo">691</span>    lock.readLock().lock();<a name="line.691"></a>
+<span class="sourceLineNo">692</span>    try {<a name="line.692"></a>
+<span class="sourceLineNo">693</span>       this.memstore.add(cell, memstoreSizing);<a name="line.693"></a>
+<span class="sourceLineNo">694</span>    } finally {<a name="line.694"></a>
+<span class="sourceLineNo">695</span>      lock.readLock().unlock();<a name="line.695"></a>
+<span class="sourceLineNo">696</span>    }<a name="line.696"></a>
+<span class="sourceLineNo">697</span>  }<a name="line.697"></a>
+<span class="sourceLineNo">698</span><a name="line.698"></a>
+<span class="sourceLineNo">699</span>  /**<a name="line.699"></a>
+<span class="sourceLineNo">700</span>   * Adds the specified value to the memstore<a name="line.700"></a>
+<span class="sourceLineNo">701</span>   */<a name="line.701"></a>
+<span class="sourceLineNo">702</span>  public void add(final Iterable&lt;Cell&gt; cells, MemStoreSizing memstoreSizing) {<a name="line.702"></a>
+<span class="sourceLineNo">703</span>    lock.readLock().lock();<a name="line.703"></a>
+<span class="sourceLineNo">704</span>    try {<a name="line.704"></a>
+<span class="sourceLineNo">705</span>      memstore.add(cells, memstoreSizing);<a name="line.705"></a>
+<span class="sourceLineNo">706</span>    } finally {<a name="line.706"></a>
+<span class="sourceLineNo">707</span>      lock.readLock().unlock();<a name="line.707"></a>
+<span class="sourceLineNo">708</span>    }<a name="line.708"></a>
+<span class="sourceLineNo">709</span>  }<a name="line.709"></a>
+<span class="sourceLineNo">710</span><a name="line.710"></a>
+<span class="sourceLineNo">711</span>  @Override<a name="line.711"></a>
+<span class="sourceLineNo">712</span>  public long timeOfOldestEdit() {<a name="line.712"></a>
+<span class="sourceLineNo">713</span>    return memstore.timeOfOldestEdit();<a name="line.713"></a>
+<span class="sourceLineNo">714</span>  }<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>   * @return All store files.<a name="line.717"></a>
+<span class="sourceLineNo">718</span>   */<a name="line.718"></a>
+<span class="sourceLineNo">719</span>  @Override<a name="line.719"></a>
+<span class="sourceLineNo">720</span>  public Collection&lt;HStoreFile&gt; getStorefiles() {<a name="line.720"></a>
+<span class="sourceLineNo">721</span>    return this.storeEngine.getStoreFileManager().getStorefiles();<a name="line.721"></a>
+<span class="sourceLineNo">722</span>  }<a name="line.722"></a>
+<span class="sourceLineNo">723</span><a name="line.723"></a>
+<span class="sourceLineNo">724</span>  @Override<a name="line.724"></a>
+<span class="sourceLineNo">725</span>  public Collection&lt;HStoreFile&gt; getCompactedFiles() {<a name="line.725"></a>
+<span class="sourceLineNo">726</span>    return this.storeEngine.getStoreFileManager().getCompactedfiles();<a name="line.726"></a>
+<span class="sourceLineNo">727</span>  }<a name="line.727"></a>
+<span class="sourceLineNo">728</span><a name="line.728"></a>
+<span class="sourceLineNo">729</span>  /**<a name="line.729"></a>
+<span class="sourceLineNo">730</span>   * This throws a WrongRegionException if the HFile does not fit in this region, or an<a name="line.730"></a>
+<span class="sourceLineNo">731</span>   * InvalidHFileException if the HFile is not valid.<a name="line.731"></a>
+<span class="sourceLineNo">732</span>   */<a name="line.732"></a>
+<span class="sourceLineNo">733</span>  public void assertBulkLoadHFileOk(Path srcPath) throws IOException {<a name="line.733"></a>
+<span class="sourceLineNo">734</span>    HFile.Reader reader  = null;<a name="line.734"></a>
+<span class="sourceLineNo">735</span>    try {<a name="line.735"></a>
+<span class="sourceLineNo">736</span>      LOG.info("Validating hfile at " + srcPath + " for inclusion in "<a name="line.736"></a>
+<span class="sourceLineNo">737</span>          + "store " + this + " region " + this.getRegionInfo().getRegionNameAsString());<a name="line.737"></a>
+<span class="sourceLineNo">738</span>      reader = HFile.createReader(srcPath.getFileSystem(conf), srcPath, cacheConf,<a name="line.738"></a>
+<span class="sourceLineNo">739</span>        isPrimaryReplicaStore(), conf);<a name="line.739"></a>
+<span class="sourceLineNo">740</span>      reader.loadFileInfo();<a name="line.740"></a>
+<span class="sourceLineNo">741</span><a name="line.741"></a>
+<span class="sourceLineNo">742</span>      Optional&lt;byte[]&gt; firstKey = reader.getFirstRowKey();<a name="line.742"></a>
+<span class="sourceLineNo">743</span>      Preconditions.checkState(firstKey.isPresent(), "First key can not be null");<a name="line.743"></a>
+<span class="sourceLineNo">744</span>      Optional&lt;Cell&gt; lk = reader.getLastKey();<a name="line.744"></a>
+<span class="sourceLineNo">745</span>      Preconditions.checkState(lk.isPresent(), "Last key can not be null");<a name="line.745"></a>
+<span class="sourceLineNo">746</span>      byte[] lastKey =  CellUtil.cloneRow(lk.get());<a name="line.746"></a>
+<span class="sourceLineNo">747</span><a name="line.747"></a>
+<span class="sourceLineNo">748</span>      LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey.get()) +<a name="line.748"></a>
+<span class="sourceLineNo">749</span>          " last=" + Bytes.toStringBinary(lastKey));<a name="line.749"></a>
+<span class="sourceLineNo">750</span>      LOG.debug("Region bounds: first=" +<a name="line.750"></a>
+<span class="sourceLineNo">751</span>          Bytes.toStringBinary(getRegionInfo().getStartKey()) +<a name="line.751"></a>
+<span class="sourceLineNo">752</span>          " last=" + Bytes.toStringBinary(getRegionInfo().getEndKey()));<a name="line.752"></a>
+<span class="sourceLineNo">753</span><a name="line.753"></a>
+<span class="sourceLineNo">754</span>      if (!this.getRegionInfo().containsRange(firstKey.get(), lastKey)) {<a name="line.754"></a>
+<span class="sourceLineNo">755</span>        throw new WrongRegionException(<a name="line.755"></a>
+<span class="sourceLineNo">756</span>            "Bulk load file " + srcPath.toString() + " does not fit inside region "<a name="line.756"></a>
+<span class="sourceLineNo">757</span>            + this.getRegionInfo().getRegionNameAsString());<a name="line.757"></a>
+<span class="sourceLineNo">758</span>      }<a name="line.758"></a>
+<span class="sourceLineNo">759</span><a name="line.759"></a>
+<span class="sourceLineNo">760</span>      if(reader.length() &gt; conf.getLong(HConstants.HREGION_MAX_FILESIZE,<a name="line.760"></a>
+<span class="sourceLineNo">761</span>          HConstants.DEFAULT_MAX_FILE_SIZE)) {<a name="line.761"></a>
+<span class="sourceLineNo">762</span>        LOG.warn("Trying to bulk load hfile " + srcPath.toString() + " with size: " +<a name="line.762"></a>
+<span class="sourceLineNo">763</span>            reader.length() + " bytes can be problematic as it may lead to oversplitting.");<a name="line.763"></a>
+<span class="sourceLineNo">764</span>      }<a name="line.764"></a>
+<span class="sourceLineNo">765</span><a name="line.765"></a>
+<span class="sourceLineNo">766</span>      if (verifyBulkLoads) {<a name="line.766"></a>
+<span class="sourceLineNo">767</span>        long verificationStartTime = EnvironmentEdgeManager.currentTime();<a name="line.767"></a>
+<span class="sourceLineNo">768</span>        LOG.info("Full verification started for bulk load hfile: " + srcPath.toString());<a name="line.768"></a>
+<span class="sourceLineNo">769</span>        Cell prevCell = null;<a name="line.769"></a>
+<span class="sourceLineNo">770</span>        HFileScanner scanner = reader.getScanner(false, false, false);<a name="line.770"></a>
+<span class="sourceLineNo">771</span>        scanner.seekTo();<a name="line.771"></a>
+<span class="sourceLineNo">772</span>        do {<a name="line.772"></a>
+<span class="sourceLineNo">773</span>          Cell cell = scanner.getCell();<a name="line.773"></a>
+<span class="sourceLineNo">774</span>          if (prevCell != null) {<a name="line.774"></a>
+<span class="sourceLineNo">775</span>            if (comparator.compareRows(prevCell, cell) &gt; 0) {<a name="line.775"></a>
+<span class="sourceLineNo">776</span>              throw new InvalidHFileException("Previous row is greater than"<a name="line.776"></a>
+<span class="sourceLineNo">777</span>                  + " current row: path=" + srcPath + " previous="<a name="line.777"></a>
+<span class="sourceLineNo">778</span>                  + CellUtil.getCellKeyAsString(prevCell) + " current="<a name="line.778"></a>
+<span class="sourceLineNo">779</span>                  + CellUtil.getCellKeyAsString(cell));<a name="line.779"></a>
+<span class="sourceLineNo">780</span>            }<a name="line.780"></a>
+<span class="sourceLineNo">781</span>            if (CellComparator.getInstance().compareFamilies(prevCell, cell) != 0) {<a name="line.781"></a>
+<span class="sourceLineNo">782</span>              throw new InvalidHFileException("Previous key had different"<a name="line.782"></a>
+<span class="sourceLineNo">783</span>                  + " family compared to current key: path=" + srcPath<a name="line.783"></a>
+<span class="sourceLineNo">784</span>                  + " previous="<a name="line.784"></a>
+<span class="sourceLineNo">785</span>                  + Bytes.toStringBinary(prevCell.getFamilyArray(), prevCell.getFamilyOffset(),<a name="line.785"></a>
+<span class="sourceLineNo">786</span>                      prevCell.getFamilyLength())<a name="line.786"></a>
+<span class="sourceLineNo">787</span>                  + " current="<a name="line.787"></a>
+<span class="sourceLineNo">788</span>                  + Bytes.toStringBinary(cell.getFamilyArray(), cell.getFamilyOffset(),<a name="line.788"></a>
+<span class="sourceLineNo">789</span>                      cell.getFamilyLength()));<a name="line.789"></a>
+<span class="sourceLineNo">790</span>            }<a name="line.790"></a>
+<span class="sourceLineNo">791</span>          }<a name="line.791"></a>
+<span class="sourceLineNo">792</span>          prevCell = cell;<a name="line.792"></a>
+<span class="sourceLineNo">793</span>        } while (scanner.next());<a name="line.793"></a>
+<span class="sourceLineNo">794</span>      LOG.info("Full verification complete for bulk load hfile: " + srcPath.toString()<a name="line.794"></a>
+<span class="sourceLineNo">795</span>         + " took " + (EnvironmentEdgeManager.currentTime() - verificationStartTime)<a name="line.795"></a>
+<span class="sourceLineNo">796</span>         + " ms");<a name="line.796"></a>
+<span class="sourceLineNo">797</span>      }<a name="line.797"></a>
+<span class="sourceLineNo">798</span>    } finally {<a name="line.798"></a>
+<span class="sourceLineNo">799</span>      if (reader != null) reader.close();<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><a name="line.802"></a>
+<span class="sourceLineNo">803</span>  /**<a name="line.803"></a>
+<span class="sourceLineNo">804</span>   * This method should only be called from Region. It is assumed that the ranges of values in the<a name="line.804"></a>
+<span class="sourceLineNo">805</span>   * HFile fit within the stores assigned region. (assertBulkLoadHFileOk checks this)<a name="line.805"></a>
+<span class="sourceLineNo">806</span>   *<a name="line.806"></a>
+<span class="sourceLineNo">807</span>   * @param srcPathStr<a name="line.807"></a>
+<span class="sourceLineNo">808</span>   * @param seqNum sequence Id associated with the HFile<a name="line.808"></a>
+<span class="sourceLineNo">809</span>   */<a name="line.809"></a>
+<span class="sourceLineNo">810</span>  public Pair&lt;Path, Path&gt; preBulkLoadHFile(String srcPathStr, long seqNum) throws IOException {<a name="line.810"></a>
+<span class="sourceLineNo">811</span>    Path srcPath = new Path(srcPathStr);<a name="line.811"></a>
+<span class="sourceLineNo">812</span>    return fs.bulkLoadStoreFile(getColumnFamilyName(), srcPath, seqNum);<a name="line.812"></a>
+<span class="sourceLineNo">813</span>  }<a name="line.813"></a>
+<span class="sourceLineNo">814</span><a name="line.814"></a>
+<span class="sourceLineNo">815</span>  public Path bulkLoadHFile(byte[] family, String srcPathStr, Path dstPath) throws IOException {<a name="line.815"></a>
+<span class="sourceLineNo">816</span>    Path srcPath = new Path(srcPathStr);<a name="line.816"></a>
+<span class="sourceLineNo">817</span>    try {<a name="line.817"></a>
+<span class="sourceLineNo">818</span>      fs.commitStoreFile(srcPath, dstPath);<a name="line.818"></a>
+<span class="sourceLineNo">819</span>    } finally {<a name="line.819"></a>
+<span class="sourceLineNo">820</span>      if (this.getCoprocessorHost() != null) {<a name="line.820"></a>
+<span class="sourceLineNo">821</span>        this.getCoprocessorHost().postCommitStoreFile(family, srcPath, dstPath);<a name="line.821"></a>
+<span class="sourceLineNo">822</span>      }<a name="line.822"></a>
+<span class="sourceLineNo">823</span>    }<a name="line.823"></a>
+<span class="sourceLineNo">824</span><a name="line.824"></a>
+<span class="sourceLineNo">825</span>    LOG.info("Loaded HFile " + srcPath + " into store '" + getColumnFamilyName() + "' as "<a name="line.825"></a>
+<span class="sourceLineNo">826</span>        + dstPath + " - updating store file list.");<a name="line.826"></a>
+<span class="sourceLineNo">827</span><a name="line.827"></a>
+<span class="sourceLineNo">828</span>    HStoreFile sf = createStoreFileAndReader(dstPath);<a name="line.828"></a>
+<span class="sourceLineNo">829</span>    bulkLoadHFile(sf);<a name="line.829"></a>
+<span class="sourceLineNo">830</span><a name="line.830"></a>
+<span class="sourceLineNo">831</span>    LOG.info("Successfully loaded store file " + srcPath + " into store " + this<a name="line.831"></a>
+<span class="sourceLineNo">832</span>        + " (new location: " + dstPath + ")");<a name="line.832"></a>
+<span class="sourceLineNo">833</span><a name="line.833"></a>
+<span class="sourceLineNo">834</span>    return dstPath;<a name="line.834"></a>
+<span class="sourceLineNo">835</span>  }<a name="line.835"></a>
+<span class="sourceLineNo">836</span><a name="line.836"></a>
+<span class="sourceLineNo">837</span>  public void bulkLoadHFile(StoreFileInfo fileInfo) throws IOException {<a name="line.837"></a>
+<span class="sourceLineNo">838</span>    HStoreFile sf = createStoreFileAndReader(fileInfo);<a name="line.838"></a>
+<span class="sourceLineNo">839</span>    bulkLoadHFile(sf);<a name="line.839"></a>
+<span class="sourceLineNo">840</span>  }<a name="line.840"></a>
+<span class="sourceLineNo">841</span><a name="line.841"></a>
+<span class="sourceLineNo">842</span>  private void bulkLoadHFile(HStoreFile sf) throws IOException {<a name="line.842"></a>
+<span class="sourceLineNo">843</span>    StoreFileReader r = sf.getReader();<a name="line.843"></a>
+<span class="sourceLineNo">844</span>    this.storeSize += r.length();<a name="line.844"></a>
+<span class="sourceLineNo">845</span>    this.totalUncompressedBytes += r.getTotalUncompressedBytes();<a name="line.845"></a>
+<span class="sourceLineNo">846</span><a name="line.846"></a>
+<span class="sourceLineNo">847</span>    // Append the new storefile into the list<a name="line.847"></a>
+<span class="sourceLineNo">848</span>    this.lock.writeLock().lock();<a name="line.848"></a>
+<span class="sourceLineNo">849</span>    try {<a name="line.849"></a>
+<span class="sourceLineNo">850</span>      this.storeEngine.getStoreFileManager().insertNewFiles(Lists.newArrayList(sf));<a name="line.850"></a>
+<span class="sourceLineNo">851</span>    } finally {<a name="line.851"></a>
+<span class="sourceLineNo">852</span>      // We need the lock, as long as we are updating the storeFiles<a name="line.852"></a>
+<span class="sourceLineNo">853</span>      // or changing the memstore. Let us release it before calling<a name="line.853"></a>
+<span class="sourceLineNo">854</span>      // notifyChangeReadersObservers. See HBASE-4485 for a possible<a name="line.854"></a>
+<span class="sourceLineNo">855</span>      // deadlock scenario that could have happened if continue to hold<a name="line.855"></a>
+<span class="sourceLineNo">856</span>      // the lock.<a name="line.856"></a>
+<span class="sourceLineNo">857</span>      this.lock.writeLock().unlock();<a name="line.857"></a>
+<span class="sourceLineNo">858</span>    }<a name="line.858"></a>
+<span class="sourceLineNo">859</span>    LOG.info("Loaded HFile " + sf.getFileInfo() + " into store '" + getColumnFamilyName());<a name="line.859"></a>
+<span class="sourceLineNo">860</span>    if (LOG.isTraceEnabled()) {<a name="line.860"></a>
+<span class="sourceLineNo">861</span>      String traceMessage = "BULK LOAD time,size,store size,store files ["<a name="line.861"></a>
+<span class="sourceLineNo">862</span>          + EnvironmentEdgeManager.currentTime() + "," + r.length() + "," + storeSize<a name="line.862"></a>
+<span class="sourceLineNo">863</span>          + "," + storeEngine.getStoreFileManager().getStorefileCount() + "]";<a name="line.863"></a>
+<span class="sourceLineNo">864</span>      LOG.trace(traceMessage);<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><a name="line.867"></a>
+<span class="sourceLineNo">868</span>  /**<a name="line.868"></a>
+<span class="sourceLineNo">869</span>   * Close all the readers We don't need to worry about subsequent requests because the Region holds<a name="line.869"></a>
+<span class="sourceLineNo">870</span>   * a write lock that will prevent any more reads or writes.<a name="line.870"></a>
+<span class="sourceLineNo">871</span>   * @return the {@link StoreFile StoreFiles} that were previously being used.<a name="line.871"></a>
+<span class="sourceLineNo">872</span>   * @throws IOException on failure<a name="line.872"></a>
+<span class="sourceLineNo">873</span>   */<a name="line.873"></a>
+<span class="sourceLineNo">874</span>  public ImmutableCollection&lt;HStoreFile&gt; close() throws IOException {<a name="line.874"></a>
+<span class="sourceLineNo">875</span>    this.archiveLock.lock();<a name="line.875"></a>
+<span class="sourceLineNo">876</span>    this.lock.writeLock().lock();<a name="line.876"></a>
+<span class="sourceLineNo">877</span>    try {<a name="line.877"></a>
+<span class="sourceLineNo">878</span>      // Clear so metrics doesn't find them.<a name="line.878"></a>
+<span class="sourceLineNo">879</span>      ImmutableCollection&lt;HStoreFile&gt; result = storeEngine.getStoreFileManager().clearFiles();<a name="line.879"></a>
+<span class="sourceLineNo">880</span>      Collection&lt;HStoreFile&gt; compactedfiles =<a name="line.880"></a>
+<span class="sourceLineNo">881</span>          storeEngine.getStoreFileManager().clearCompactedFiles();<a name="line.881"></a>
+<span class="sourceLineNo">882</span>      // clear the compacted files<a name="line.882"></a>
+<span class="sourceLineNo">883</span>      if (compactedfiles != null &amp;&amp; !compactedfiles.isEmpty()) {<a name="line.883"></a>
+<span class="sourceLineNo">884</span>        removeCompactedfiles(compactedfiles);<a name="line.884"></a>
+<span class="sourceLineNo">885</span>      }<a name="line.885"></a>
+<span class="sourceLineNo">886</span>      if (!result.isEmpty()) {<a name="line.886"></a>
+<span class="sourceLineNo">887</span>        // initialize the thread pool for closing store files in parallel.<a name="line.887"></a>
+<span class="sourceLineNo">888</span>        ThreadPoolExecutor storeFileCloserThreadPool = this.region<a name="line.888"></a>
+<span class="sourceLineNo">889</span>            .getStoreFileOpenAndCloseThreadPool("StoreFileCloserThread-"<a name="line.889"></a>
+<span class="sourceLineNo">890</span>                + this.getColumnFamilyName());<a name="line.890"></a>
+<span class="sourceLineNo">891</span><a name="line.891"></a>
+<span class="sourceLineNo">892</span>        // close each store file in parallel<a name="line.892"></a>
+<span class="sourceLineNo">893</span>        CompletionService&lt;Void&gt; completionService =<a name="line.893"></a>
+<span class="sourceLineNo">894</span>          new ExecutorCompletionService&lt;&gt;(storeFileCloserThreadPool);<a name="line.894"></a>
+<span class="sourceLineNo">895</span>        for (HStoreFile f : result) {<a name="line.895"></a>
+<span class="sourceLineNo">896</span>          completionService.submit(new Callable&lt;Void&gt;() {<a name="line.896"></a>
+<span class="sourceLineNo">897</span>            @Override<a name="line.897"></a>
+<span class="sourceLineNo">898</span>            public Void call() throws IOException {<a name="line.898"></a>
+<span class="sourceLineNo">899</span>              boolean evictOnClose =<a name="line.899"></a>
+<span class="sourceLineNo">900</span>                  cacheConf != null? cacheConf.shouldEvictOnClose(): true;<a name="line.900"></a>
+<span class="sourceLineNo">901</span>              f.closeStoreFile(evictOnClose);<a name="line.901"></a>
+<span class="sourceLineNo">902</span>              return null;<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>        }<a name="line.905"></a>
+<span class="sourceLineNo">906</span><a name="line.906"></a>
+<span class="sourceLineNo">907</span>        IOException ioe = null;<a name="line.907"></a>
+<span class="sourceLineNo">908</span>        try {<a name="line.908"></a>
+<span class="sourceLineNo">909</span>          for (int i = 0; i &lt; result.size(); i++) {<a name="line.909"></a>
+<span class="sourceLineNo">910</span>            try {<a name="line.910"></a>
+<span class="sourceLineNo">911</span>              Future&lt;Void&gt; future = completionService.take();<a name="line.911"></a>
+<span class="sourceLineNo">912</span>              future.get();<a name="line.912"></a>
+<span class="sourceLineNo">913</span>            } catch (InterruptedException e) {<a name="line.913"></a>
+<span class="sourceLineNo">914</span>              if (ioe == null) {<a name="line.914"></a>
+<span class="sourceLineNo">915</span>                ioe = new InterruptedIOException();<a name="line.915"></a>
+<span class="sourceLineNo">916</span>                ioe.initCause(e);<a name="line.916"></a>
+<span class="sourceLineNo">917</span>              }<a name="line.917"></a>
+<span class="sourceLineNo">918</span>            } catch (ExecutionException e) {<a name="line.918"></a>
+<span class="sourceLineNo">919</span>              if (ioe == null) ioe = new IOException(e.getCause());<a name="line.919"></a>
+<span class="sourceLineNo">920</span>            }<a name="line.920"></a>
+<span class="sourceLineNo">921</span>          }<a name="line.921"></a>
+<span class="sourceLineNo">922</span>        } finally {<a name="line.922"></a>
+<span class="sourceLineNo">923</span>          storeFileCloserThreadPool.shutdownNow();<a name="line.923"></a>
+<span class="sourceLineNo">924</span>        }<a name="line.924"></a>
+<span class="sourceLineNo">925</span>        if (ioe != null) throw ioe;<a name="line.925"></a>
+<span class="sourceLineNo">926</span>      }<a name="line.926"></a>
+<span class="sourceLineNo">927</span>      LOG.info("Closed " + this);<a name="line.927"></a>
+<span class="sourceLineNo">928</span>      return result;<a name="line.928"></a>
+<span class="sourceLineNo">929</span>    } finally {<a name="line.929"></a>
+<span class="sourceLineNo">930</span>      this.lock.writeLock().unlock();<a name="line.930"></a>
+<span class="sourceLineNo">931</span>      this.archiveLock.unlock();<a name="line.931"></a>
+<span class="sourceLineNo">932</span>    }<a name="line.932"></a>
+<span class="sourceLineNo">933</span>  }<a name="line.933"></a>
+<span class="sourceLineNo">934</span><a name="line.934"></a>
+<span class="sourceLineNo">935</span>  /**<a name="line.935"></a>
+<span class="sourceLineNo">936</span>   * Snapshot this stores memstore. Call before running<a name="line.936"></a>
+<span class="sourceLineNo">937</span>   * {@link #flushCache(long, MemStoreSnapshot, MonitoredTask, ThroughputController,<a name="line.937"></a>
+<span class="sourceLineNo">938</span>   * FlushLifeCycleTracker)}<a name="line.938"></a>
+<span class="sourceLineNo">939</span>   *  so it has some work to do.<a name="line.939"></a>
+<span class="sourceLineNo">940</span>   */<a name="line.940"></a>
+<span class="sourceLineNo">941</span>  void snapshot() {<a name="line.941"></a>
+<span class="sourceLineNo">942</span>    this.lock.writeLock().lock();<a name="line.942"></a>
+<span class="sourceLineNo">943</span>    try {<a name="line.943"></a>
+<span class="sourceLineNo">944</span>      this.memstore.snapshot();<a name="line.944"></a>
+<span class="sourceLineNo">945</span>    } finally {<a name="line.945"></a>
+<span class="sourceLineNo">946</span>      this.lock.writeLock().unlock();<a name="line.946"></a>
+<span class="sourceLineNo">947</span>    }<a name="line.947"></a>
+<span class="sourceLineNo">948</span>  }<a name="line.948"></a>
+<span class="sourceLineNo">949</span><a name="line.949"></a>
+<span class="sourceLineNo">950</span>  /**<a name="line.950"></a>
+<span class="sourceLineNo">951</span>   * Write out current snapshot. Presumes {@link #snapshot()} has been called previously.<a name="line.951"></a>
+<span class="sourceLineNo">952</span>   * @param logCacheFlushId flush sequence number<a name="line.952"></a>
+<span class="sourceLineNo">953</span>   * @param snapshot<a name="line.953"></a>
+<span class="sourceLineNo">954</span>   * @param status<a name="line.954"></a>
+<span class="sourceLineNo">955</span>   * @param throughputController<a name="line.955"></a>
+<span class="sourceLineNo">956</span>   * @return The path name of the tmp file to which the store was flushed<a name="line.956"></a>
+<span class="sourceLineNo">957</span>   * @throws IOException if exception occurs during process<a name="line.957"></a>
+<span class="sourceLineNo">958</span>   */<a name="line.958"></a>
+<span class="sourceLineNo">959</span>  protected List&lt;Path&gt; flushCache(final long logCacheFlushId, MemStoreSnapshot snapshot,<a name="line.959"></a>
+<span class="sourceLineNo">960</span>      MonitoredTask status, ThroughputController throughputController,<a name="line.960"></a>
+<span class="sourceLineNo">961</span>      FlushLifeCycleTracker tracker) throws IOException {<a name="line.961"></a>
+<span class="sourceLineNo">962</span>    // If an exception happens flushing, we let it out without clearing<a name="line.962"></a>
+<span class="sourceLineNo">963</span>    // the memstore snapshot.  The old snapshot will be returned when we say<a name="line.963"></a>
+<span class="sourceLineNo">964</span>    // 'snapshot', the next time flush comes around.<a name="line.964"></a>
+<span class="sourceLineNo">965</span>    // Retry after catching exception when flushing, otherwise server will abort<a name="line.965"></a>
+<span class="sourceLineNo">966</span>    // itself<a name="line.966"></a>
+<span class="sourceLineNo">967</span>    StoreFlusher flusher = storeEngine.getStoreFlusher();<a name="line.967"></a>
+<span class="sourceLineNo">968</span>    IOException lastException = null;<a name="line.968"></a>
+<span class="sourceLineNo">969</span>    for (int i = 0; i &lt; flushRetriesNumber; i++) {<a name="line.969"></a>
+<span class="sourceLineNo">970</span>      try {<a name="line.970"></a>
+<span class="sourceLineNo">971</span>        List&lt;Path&gt; pathNames =<a name="line.971"></a>
+<span class="sourceLineNo">972</span>            flusher.flushSnapshot(snapshot, logCacheFlushId, status, throughputController, tracker);<a name="line.972"></a>
+<span class="sourceLineNo">973</span>        Path lastPathName = null;<a name="line.973"></a>
+<span class="sourceLineNo">974</span>        try {<a name="line.974"></a>
+<span class="sourceLineNo">975</span>          for (Path pathName : pathNames) {<a name="line.975"></a>
+<span class="sourceLineNo">976</span>            lastPathName = pathName;<a name="line.976"></a>
+<span class="sourceLineNo">977</span>            validateStoreFile(pathName);<a name="line.977"></a>
+<span class="sourceLineNo">978</span>          }<a name="line.978"></a>
+<span class="sourceLineNo">979</span>          return pathNames;<a name="line.979"></a>
+<span class="sourceLineNo">980</span>        } catch (Exception e) {<a name="line.980"></a>
+<span class="sourceLineNo">981</span>          LOG.warn("Failed validating store file " + lastPathName + ", retrying num=" + i, e);<a name="line.981"></a>
+<span class="sourceLineNo">982</span>          if (e instanceof IOException) {<a name="line.982"></a>
+<span class="sourceLineNo">983</span>            lastException = (IOException) e;<a name="line.983"></a>
+<span class="sourceLineNo">984</span>          } else {<a name="line.984"></a>
+<span class="sourceLineNo">985</span>            lastException = new IOException(e);<a name="line.985"></a>
+<span class="sourceLineNo">986</span>          }<a name="line.986"></a>
+<span class="sourceLineNo">987</span>        }<a name="line.987"></a>
+<span class="sourceLineNo">988</span>      } catch (IOException e) {<a name="line.988"></a>
+<span class="sourceLineNo">989</span>        LOG.warn("Failed flushing store file, retrying num=" + i, e);<a name="line.989"></a>
+<span class="sourceLineNo">990</span>        lastException = e;<a name="line.990"></a>
+<span class="sourceLineNo">991</span>      }<a name="line.991"></a>
+<span class="sourceLineNo">992</span>      if (lastException != null &amp;&amp; i &lt; (flushRetriesNumber - 1)) {<a name="line.992"></a>
+<span class="sourceLineNo">993</span>        try {<a name="line.993"></a>
+<span class="sourceLineNo">994</span>          Thread.sleep(pauseTime);<a name="line.994"></a>
+<span class="sourceLineNo">995</span>        } catch (InterruptedException e) {<a name="line.995"></a>
+<span class="sourceLineNo">996</span>          IOException iie = new InterruptedIOException();<a name="line.996"></a>
+<span class="sourceLineNo">997</span>          iie.initCause(e);<a name="line.997"></a>
+<span class="sourceLineNo">998</span>          throw iie;<a name="line.998"></a>
+<span class="sourceLineNo">999</span>        }<a name="line.999"></a>
+<span class="sourceLineNo">1000</span>      }<a name="line.1000"></a>
+<span class="sourceLineNo">1001</span>    }<a name="line.1001"></a>
+<span class="sourceLineNo">1002</span>    throw lastException;<a name="line.1002"></a>
+<span class="sourceLineNo">1003</span>  }<a name="line.1003"></a>
+<span class="sourceLineNo">1004</span><a name="line.1004"></a>
+<span class="sourceLineNo">1005</span>  /**<a name="line.1005"></a>
+<span class="sourceLineNo">1006</span>   * @param path The pathname of the tmp file into which the store was flushed<a name="line.1006"></a>
+<span class="sourceLineNo">1007</span>   * @param logCacheFlushId<a name="line.1007"></a>
+<span class="sourceLineNo">1008</span>   * @param status<a name="line.1008"></a>
+<span class="sourceLineNo">1009</span>   * @return store file created.<a name="line.1009"></a>
+<span class="sourceLineNo">1010</span>   * @throws IOException<a name="line.1010"></a>
+<span class="sourceLineNo">1011</span>   */<a name="line.1011"></a>
+<span class="sourceLineNo">1012</span>  private HStoreFile commitFile(Path path, long logCacheFlushId, MonitoredTask status)<a name="line.1012"></a>
+<span class="sourceLineNo">1013</span>      throws IOException {<a name="line.1013"></a>
+<span class="sourceLineNo">1014</span>    // Write-out finished successfully, move into the right spot<a name="line.1014"></a>
+<span class="sourceLineNo">1015</span>    Path dstPath = fs.commitStoreFile(getColumnFamilyName(), path);<a name="line.1015"></a>
+<span class="sourceLineNo">1016</span><a name="line.1016"></a>
+<span class="sourceLineNo">1017</span>    status.setStatus("Flushing " + this + ": reopening flushed file");<a name="line.1017"></a>
+<span class="sourceLineNo">1018</span>    HStoreFile sf = createStoreFileAndReader(dstPath);<a name="line.1018"></a>
+<span class="sourceLineNo">1019</span><a name="line.1019"></a>
+<span class="sourceLineNo">1020</span>    StoreFileReader r = sf.getReader();<a name="line.1020"></a>
+<span class="sourceLineNo">1021</span>    this.storeSize += r.length();<a name="line.1021"></a>
+<span class="sourceLineNo">1022</span>    this.totalUncompressedBytes += r.getTotalUncompressedBytes();<a name="line.1022"></a>
+<span class="sourceLineNo">1023</span><a name="line.1023"></a>
+<span class="sourceLineNo">1024</span>    if (LOG.isInfoEnabled()) {<a name="line.1024"></a>
+<span class="sourceLineNo">1025</span>      LOG.info("Added " + sf + ", entries=" + r.getEntries() +<a name="line.1025"></a>
+<span class="sourceLineNo">1026</span>        ", sequenceid=" + logCacheFlushId +<a name="line.1026"></a>
+<span class="sourceLineNo">1027</span>        ", filesize=" + TraditionalBinaryPrefix.long2String(r.length(), "", 1));<a name="line.1027"></a>
+<span class="sourceLineNo">1028</span>    }<a name="line.1028"></a>
+<span class="sourceLineNo">1029</span>    return sf;<a name="line.1029"></a>
+<span class="sourceLineNo">1030</span>  }<a name="line.1030"></a>
+<span class="sourceLineNo">1031</span><a name="line.1031"></a>
+<span class="sourceLineNo">1032</span>  /**<a name="line.1032"></a>
+<span class="sourceLineNo">1033</span>   * @param maxKeyCount<a name="line.1033"></a>
+<span class="sourceLineNo">1034</span>   * @param compression Compression algorithm to use<a name="line.1034"></a>
+<span class="sourceLineNo">1035</span>   * @param isCompaction whether we are creating a new file in a compaction<a name="line.1035"></a>
+<span class="sourceLineNo">1036</span>   * @param includeMVCCReadpoint - whether to include MVCC or not<a name="line.1036"></a>
+<span class="sourceLineNo">1037</span>   * @param includesTag - includesTag or not<a name="line.1037"></a>
+<span class="sourceLineNo">1038</span>   * @return Writer for a new StoreFile in the tmp dir.<a name="line.1038"></a>
+<span class="sourceLineNo">1039</span>   */<a name="line.1039"></a>
+<span class="sourceLineNo">1040</span>  // TODO : allow the Writer factory to create Writers of ShipperListener type only in case of<a name="line.1040"></a>
+<span class="sourceLineNo">1041</span>  // compaction<a name="line.1041"></a>
+<span class="sourceLineNo">1042</span>  public StoreFileWriter createWriterInTmp(long maxKeyCount, Compression.Algorithm compression,<a name="line.1042"></a>
+<span class="sourceLineNo">1043</span>      boolean isCompaction, boolean includeMVCCReadpoint, boolean includesTag,<a name="line.1043"></a>
+<span class="sourceLineNo">1044</span>      boolean shouldDropBehind) throws IOException {<a name="line.1044"></a>
+<span class="sourceLineNo">1045</span>    final CacheConfig writerCacheConf;<a name="line.1045"></a>
+<span class="sourceLineNo">1046</span>    if (isCompaction) {<a name="line.1046"></a>
+<span class="sourceLineNo">1047</span>      // Don't cache data on write on compactions.<a name="line.1047"></a>
+<span class="sourceLineNo">1048</span>      writerCacheConf = new CacheConfig(cacheConf);<a name="line.1048"></a>
+<span class="sourceLineNo">1049</span>      writerCacheConf.setCacheDataOnWrite(false);<a name="line.1049"></a>
+<span class="sourceLineNo">1050</span>    } else {<a name="line.1050"></a>
+<span class="sourceLineNo">1051</span>      writerCacheConf = cacheConf;<a name="line.1051"></a>
+<span class="sourceLineNo">1052</span>    }<a name="line.1052"></a>
+<span class="sourceLineNo">1053</span>    InetSocketAddress[] favoredNodes = null;<a name="line.1053"></a>
+<span class="sourceLineNo">1054</span>    if (region.getRegionServerServices() != null) {<a name="line.1054"></a>
+<span class="sourceLineNo">1055</span>      favoredNodes = region.getRegionServerServices().getFavoredNodesForRegion(<a name="line.1055"></a>
+<span class="sourceLineNo">1056</span>          region.getRegionInfo().getEncodedName());<a name="line.1056"></a>
+<span class="sourceLineNo">1057</span>    }<a name="line.1057"></a>
+<span class="sourceLineNo">1058</span>    HFileContext hFileContext = createFileContext(compression, includeMVCCReadpoint, includesTag,<a name="line.1058"></a>
+<span class="sourceLineNo">1059</span>      cryptoContext);<a name="line.1059"></a>
+<span class="sourceLineNo">1060</span>    Path familyTempDir = new Path(fs.getTempDir(), family.getNameAsString());<a name="line.1060"></a>
+<span class="sourceLineNo">1061</span>    StoreFileWriter.Builder builder = new StoreFileWriter.Builder(conf, writerCacheConf,<a name="line.1061"></a>
+<span class="sourceLineNo">1062</span>        this.getFileSystem())<a name="line.1062"></a>
+<span class="sourceLineNo">1063</span>            .withOutputDir(familyTempDir)<a name="line.1063"></a>
+<span class="sourceLineNo">1064</span>            .withComparator(comparator)<a name="line.1064"></a>
+<span class="sourceLineNo">1065</span>            .withBloomType(family.getBloomFilterType())<a name="line.1065"></a>
+<span class="sourceLineNo">1066</span>            .withMaxKeyCount(maxKeyCount)<a name="line.1066"></a>
+<span class="sourceLineNo">1067</span>            .withFavoredNodes(favoredNodes)<a name="line.1067"></a>
+<span class="sourceLineNo">1068</span>            .withFileContext(hFileContext)<a name="line.1068"></a>
+<span class="sourceLineNo">1069</span>            .withShouldDropCacheBehind(shouldDropBehind);<a name="line.1069"></a>
+<span class="sourceLineNo">1070</span>    return builder.build();<a name="line.1070"></a>
+<span class="sourceLineNo">1071</span>  }<a name="line.1071"></a>
+<span class="sourceLineNo">1072</span><a name="line.1072"></a>
+<span class="sourceLineNo">1073</span>  private HFileContext createFileContext(Compression.Algorithm compression,<a name="line.1073"></a>
+<span class="sourceLineNo">1074</span>      boolean includeMVCCReadpoint, boolean includesTag, Encryption.Context cryptoContext) {<a name="line.1074"></a>
+<span class="sourceLineNo">1075</span>    if (compression == null) {<a name="line.1075"></a>
+<span class="sourceLineNo">1076</span>      compression = HFile.DEFAULT_COMPRESSION_ALGORITHM;<a name="line.1076"></a>
+<span class="sourceLineNo">1077</span>    }<a name="line.1077"></a>
+<span class="sourceLineNo">1078</span>    HFileContext hFileContext = new HFileContextBuilder()<a name="line.1078"></a>
+<span class="sourceLineNo">1079</span>                                .withIncludesMvcc(includeMVCCReadpoint)<a name="line.1079"></a>
+<span class="sourceLineNo">1080</span>                                .withIncludesTags(includesTag)<a name="line.1080"></a>
+<span class="sourceLineNo">1081</span>                                .withCompression(compression)<a name="line.1081"></a>
+<span class="sourceLineNo">1082</span>                                .withCompressTags(family.isCompressTags())<a name="line.1082"></a>
+<span class="sourceLineNo">1083</span>                                .withChecksumType(checksumType)<a name="line.1083"></a>
+<span class="sourceLineNo">1084</span>                                .withBytesPerCheckSum(bytesPerChecksum)<a name="line.1084"></a>
+<span class="sourceLineNo">1085</span>                                .withBlockSize(blocksize)<a name="line.1085"></a>
+<span class="sourceLineNo">1086</span>                                .withHBaseCheckSum(true)<a name="line.1086"></a>
+<span class="sourceLineNo">1087</span>                                .withDataBlockEncoding(family.getDataBlockEncoding())<a name="line.1087"></a>
+<span class="sourceLineNo">1088</span>                                .withEncryptionContext(cryptoContext)<a name="line.1088"></a>
+<span class="sourceLineNo">1089</span>                                .withCreateTime(EnvironmentEdgeManager.currentTime())<a name="line.1089"></a>
+<span class="sourceLineNo">1090</span>                                .build();<a name="line.1090"></a>
+<span class="sourceLineNo">1091</span>    return hFileContext;<a name="line.1091"></a>
+<span class="sourceLineNo">1092</span>  }<a name="line.1092"></a>
 <span class="sourceLineNo">1093</span><a name="line.1093"></a>
-<span class="sourceLineNo">1094</span>  private long getTotalSize(Collection&lt;HStoreFile&gt; sfs) {<a name="line.1094"></a>
-<span class="sourceLineNo">1095</span>    return sfs.stream().mapToLong(sf -&gt; sf.getReader().length()).sum();<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>  /**<a name="line.1098"></a>
-<span class="sourceLineNo">1099</span>   * Change storeFiles adding into place the Reader produced by this new flush.<a name="line.1099"></a>
-<span class="sourceLineNo">1100</span>   * @param sfs Store files<a name="line.1100"></a>
-<span class="sourceLineNo">1101</span>   * @param snapshotId<a name="line.1101"></a>
-<span class="sourceLineNo">1102</span>   * @throws IOException<a name="line.1102"></a>
-<span class="sourceLineNo">1103</span>   * @return Whe

<TRUNCATED>

Mime
View raw message