hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [04/51] [partial] hbase-site git commit: Published site at 82d554e3783372cc6b05489452c815b57c06f6cd.
Date Fri, 11 Aug 2017 15:06:05 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/346adc37/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BatchOperation.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BatchOperation.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BatchOperation.html
index a701ece..26ee60a 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BatchOperation.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BatchOperation.html
@@ -896,7376 +896,7383 @@
 <span class="sourceLineNo">888</span>    }<a name="line.888"></a>
 <span class="sourceLineNo">889</span><a name="line.889"></a>
 <span class="sourceLineNo">890</span>    // Write HRI to a file in case we need to recover hbase:meta<a name="line.890"></a>
-<span class="sourceLineNo">891</span>    status.setStatus("Writing region info on filesystem");<a name="line.891"></a>
-<span class="sourceLineNo">892</span>    fs.checkRegionInfoOnFilesystem();<a name="line.892"></a>
-<span class="sourceLineNo">893</span><a name="line.893"></a>
-<span class="sourceLineNo">894</span>    // Initialize all the HStores<a name="line.894"></a>
-<span class="sourceLineNo">895</span>    status.setStatus("Initializing all the Stores");<a name="line.895"></a>
-<span class="sourceLineNo">896</span>    long maxSeqId = initializeStores(reporter, status);<a name="line.896"></a>
-<span class="sourceLineNo">897</span>    this.mvcc.advanceTo(maxSeqId);<a name="line.897"></a>
-<span class="sourceLineNo">898</span>    if (ServerRegionReplicaUtil.shouldReplayRecoveredEdits(this)) {<a name="line.898"></a>
-<span class="sourceLineNo">899</span>      List&lt;Store&gt; stores = this.getStores();  // update the stores that we are replaying<a name="line.899"></a>
-<span class="sourceLineNo">900</span>      try {<a name="line.900"></a>
-<span class="sourceLineNo">901</span>        for (Store store : stores) {<a name="line.901"></a>
-<span class="sourceLineNo">902</span>          ((HStore) store).startReplayingFromWAL();<a name="line.902"></a>
-<span class="sourceLineNo">903</span>        }<a name="line.903"></a>
-<span class="sourceLineNo">904</span>        // Recover any edits if available.<a name="line.904"></a>
-<span class="sourceLineNo">905</span>        maxSeqId = Math.max(maxSeqId,<a name="line.905"></a>
-<span class="sourceLineNo">906</span>            replayRecoveredEditsIfAny(this.fs.getRegionDir(), maxSeqIdInStores, reporter, status));<a name="line.906"></a>
-<span class="sourceLineNo">907</span>        // Make sure mvcc is up to max.<a name="line.907"></a>
-<span class="sourceLineNo">908</span>        this.mvcc.advanceTo(maxSeqId);<a name="line.908"></a>
-<span class="sourceLineNo">909</span>      } finally {<a name="line.909"></a>
-<span class="sourceLineNo">910</span>        for (Store store : stores) {            // update the stores that we are done replaying<a name="line.910"></a>
-<span class="sourceLineNo">911</span>          ((HStore)store).stopReplayingFromWAL();<a name="line.911"></a>
-<span class="sourceLineNo">912</span>        }<a name="line.912"></a>
-<span class="sourceLineNo">913</span>      }<a name="line.913"></a>
-<span class="sourceLineNo">914</span><a name="line.914"></a>
-<span class="sourceLineNo">915</span>    }<a name="line.915"></a>
-<span class="sourceLineNo">916</span>    this.lastReplayedOpenRegionSeqId = maxSeqId;<a name="line.916"></a>
-<span class="sourceLineNo">917</span><a name="line.917"></a>
-<span class="sourceLineNo">918</span>    this.writestate.setReadOnly(ServerRegionReplicaUtil.isReadOnly(this));<a name="line.918"></a>
-<span class="sourceLineNo">919</span>    this.writestate.flushRequested = false;<a name="line.919"></a>
-<span class="sourceLineNo">920</span>    this.writestate.compacting.set(0);<a name="line.920"></a>
+<span class="sourceLineNo">891</span>    // Only the primary replica should write .regioninfo<a name="line.891"></a>
+<span class="sourceLineNo">892</span>    if (this.getRegionInfo().getReplicaId() == HRegionInfo.DEFAULT_REPLICA_ID) {<a name="line.892"></a>
+<span class="sourceLineNo">893</span>      status.setStatus("Writing region info on filesystem");<a name="line.893"></a>
+<span class="sourceLineNo">894</span>      fs.checkRegionInfoOnFilesystem();<a name="line.894"></a>
+<span class="sourceLineNo">895</span>    } else {<a name="line.895"></a>
+<span class="sourceLineNo">896</span>      if (LOG.isDebugEnabled()) {<a name="line.896"></a>
+<span class="sourceLineNo">897</span>        LOG.debug("Skipping creation of .regioninfo file for " + this.getRegionInfo());<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><a name="line.900"></a>
+<span class="sourceLineNo">901</span>    // Initialize all the HStores<a name="line.901"></a>
+<span class="sourceLineNo">902</span>    status.setStatus("Initializing all the Stores");<a name="line.902"></a>
+<span class="sourceLineNo">903</span>    long maxSeqId = initializeStores(reporter, status);<a name="line.903"></a>
+<span class="sourceLineNo">904</span>    this.mvcc.advanceTo(maxSeqId);<a name="line.904"></a>
+<span class="sourceLineNo">905</span>    if (ServerRegionReplicaUtil.shouldReplayRecoveredEdits(this)) {<a name="line.905"></a>
+<span class="sourceLineNo">906</span>      List&lt;Store&gt; stores = this.getStores();  // update the stores that we are replaying<a name="line.906"></a>
+<span class="sourceLineNo">907</span>      try {<a name="line.907"></a>
+<span class="sourceLineNo">908</span>        for (Store store : stores) {<a name="line.908"></a>
+<span class="sourceLineNo">909</span>          ((HStore) store).startReplayingFromWAL();<a name="line.909"></a>
+<span class="sourceLineNo">910</span>        }<a name="line.910"></a>
+<span class="sourceLineNo">911</span>        // Recover any edits if available.<a name="line.911"></a>
+<span class="sourceLineNo">912</span>        maxSeqId = Math.max(maxSeqId,<a name="line.912"></a>
+<span class="sourceLineNo">913</span>            replayRecoveredEditsIfAny(this.fs.getRegionDir(), maxSeqIdInStores, reporter, status));<a name="line.913"></a>
+<span class="sourceLineNo">914</span>        // Make sure mvcc is up to max.<a name="line.914"></a>
+<span class="sourceLineNo">915</span>        this.mvcc.advanceTo(maxSeqId);<a name="line.915"></a>
+<span class="sourceLineNo">916</span>      } finally {<a name="line.916"></a>
+<span class="sourceLineNo">917</span>        for (Store store : stores) {            // update the stores that we are done replaying<a name="line.917"></a>
+<span class="sourceLineNo">918</span>          ((HStore)store).stopReplayingFromWAL();<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><a name="line.921"></a>
-<span class="sourceLineNo">922</span>    if (this.writestate.writesEnabled) {<a name="line.922"></a>
-<span class="sourceLineNo">923</span>      // Remove temporary data left over from old regions<a name="line.923"></a>
-<span class="sourceLineNo">924</span>      status.setStatus("Cleaning up temporary data from old regions");<a name="line.924"></a>
-<span class="sourceLineNo">925</span>      fs.cleanupTempDir();<a name="line.925"></a>
-<span class="sourceLineNo">926</span>    }<a name="line.926"></a>
-<span class="sourceLineNo">927</span><a name="line.927"></a>
-<span class="sourceLineNo">928</span>    if (this.writestate.writesEnabled) {<a name="line.928"></a>
-<span class="sourceLineNo">929</span>      status.setStatus("Cleaning up detritus from prior splits");<a name="line.929"></a>
-<span class="sourceLineNo">930</span>      // Get rid of any splits or merges that were lost in-progress.  Clean out<a name="line.930"></a>
-<span class="sourceLineNo">931</span>      // these directories here on open.  We may be opening a region that was<a name="line.931"></a>
-<span class="sourceLineNo">932</span>      // being split but we crashed in the middle of it all.<a name="line.932"></a>
-<span class="sourceLineNo">933</span>      fs.cleanupAnySplitDetritus();<a name="line.933"></a>
-<span class="sourceLineNo">934</span>      fs.cleanupMergesDir();<a name="line.934"></a>
-<span class="sourceLineNo">935</span>    }<a name="line.935"></a>
-<span class="sourceLineNo">936</span><a name="line.936"></a>
-<span class="sourceLineNo">937</span>    // Initialize split policy<a name="line.937"></a>
-<span class="sourceLineNo">938</span>    this.splitPolicy = RegionSplitPolicy.create(this, conf);<a name="line.938"></a>
-<span class="sourceLineNo">939</span><a name="line.939"></a>
-<span class="sourceLineNo">940</span>    // Initialize flush policy<a name="line.940"></a>
-<span class="sourceLineNo">941</span>    this.flushPolicy = FlushPolicyFactory.create(this, conf);<a name="line.941"></a>
-<span class="sourceLineNo">942</span><a name="line.942"></a>
-<span class="sourceLineNo">943</span>    long lastFlushTime = EnvironmentEdgeManager.currentTime();<a name="line.943"></a>
-<span class="sourceLineNo">944</span>    for (Store store: stores.values()) {<a name="line.944"></a>
-<span class="sourceLineNo">945</span>      this.lastStoreFlushTimeMap.put(store, lastFlushTime);<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>    // Use maximum of log sequenceid or that which was found in stores<a name="line.948"></a>
-<span class="sourceLineNo">949</span>    // (particularly if no recovered edits, seqid will be -1).<a name="line.949"></a>
-<span class="sourceLineNo">950</span>    long nextSeqid = maxSeqId;<a name="line.950"></a>
-<span class="sourceLineNo">951</span><a name="line.951"></a>
-<span class="sourceLineNo">952</span>    // In distributedLogReplay mode, we don't know the last change sequence number because region<a name="line.952"></a>
-<span class="sourceLineNo">953</span>    // is opened before recovery completes. So we add a safety bumper to avoid new sequence number<a name="line.953"></a>
-<span class="sourceLineNo">954</span>    // overlaps used sequence numbers<a name="line.954"></a>
-<span class="sourceLineNo">955</span>    if (this.writestate.writesEnabled) {<a name="line.955"></a>
-<span class="sourceLineNo">956</span>      nextSeqid = WALSplitter.writeRegionSequenceIdFile(this.fs.getFileSystem(), this.fs<a name="line.956"></a>
-<span class="sourceLineNo">957</span>          .getRegionDir(), nextSeqid, (this.recovering ? (this.flushPerChanges + 10000000) : 1));<a name="line.957"></a>
-<span class="sourceLineNo">958</span>    } else {<a name="line.958"></a>
-<span class="sourceLineNo">959</span>      nextSeqid++;<a name="line.959"></a>
-<span class="sourceLineNo">960</span>    }<a name="line.960"></a>
-<span class="sourceLineNo">961</span><a name="line.961"></a>
-<span class="sourceLineNo">962</span>    LOG.info("Onlined " + this.getRegionInfo().getShortNameToLog() +<a name="line.962"></a>
-<span class="sourceLineNo">963</span>      "; next sequenceid=" + nextSeqid);<a name="line.963"></a>
-<span class="sourceLineNo">964</span><a name="line.964"></a>
-<span class="sourceLineNo">965</span>    // A region can be reopened if failed a split; reset flags<a name="line.965"></a>
-<span class="sourceLineNo">966</span>    this.closing.set(false);<a name="line.966"></a>
-<span class="sourceLineNo">967</span>    this.closed.set(false);<a name="line.967"></a>
+<span class="sourceLineNo">922</span>    }<a name="line.922"></a>
+<span class="sourceLineNo">923</span>    this.lastReplayedOpenRegionSeqId = maxSeqId;<a name="line.923"></a>
+<span class="sourceLineNo">924</span><a name="line.924"></a>
+<span class="sourceLineNo">925</span>    this.writestate.setReadOnly(ServerRegionReplicaUtil.isReadOnly(this));<a name="line.925"></a>
+<span class="sourceLineNo">926</span>    this.writestate.flushRequested = false;<a name="line.926"></a>
+<span class="sourceLineNo">927</span>    this.writestate.compacting.set(0);<a name="line.927"></a>
+<span class="sourceLineNo">928</span><a name="line.928"></a>
+<span class="sourceLineNo">929</span>    if (this.writestate.writesEnabled) {<a name="line.929"></a>
+<span class="sourceLineNo">930</span>      // Remove temporary data left over from old regions<a name="line.930"></a>
+<span class="sourceLineNo">931</span>      status.setStatus("Cleaning up temporary data from old regions");<a name="line.931"></a>
+<span class="sourceLineNo">932</span>      fs.cleanupTempDir();<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>    if (this.writestate.writesEnabled) {<a name="line.935"></a>
+<span class="sourceLineNo">936</span>      status.setStatus("Cleaning up detritus from prior splits");<a name="line.936"></a>
+<span class="sourceLineNo">937</span>      // Get rid of any splits or merges that were lost in-progress.  Clean out<a name="line.937"></a>
+<span class="sourceLineNo">938</span>      // these directories here on open.  We may be opening a region that was<a name="line.938"></a>
+<span class="sourceLineNo">939</span>      // being split but we crashed in the middle of it all.<a name="line.939"></a>
+<span class="sourceLineNo">940</span>      fs.cleanupAnySplitDetritus();<a name="line.940"></a>
+<span class="sourceLineNo">941</span>      fs.cleanupMergesDir();<a name="line.941"></a>
+<span class="sourceLineNo">942</span>    }<a name="line.942"></a>
+<span class="sourceLineNo">943</span><a name="line.943"></a>
+<span class="sourceLineNo">944</span>    // Initialize split policy<a name="line.944"></a>
+<span class="sourceLineNo">945</span>    this.splitPolicy = RegionSplitPolicy.create(this, conf);<a name="line.945"></a>
+<span class="sourceLineNo">946</span><a name="line.946"></a>
+<span class="sourceLineNo">947</span>    // Initialize flush policy<a name="line.947"></a>
+<span class="sourceLineNo">948</span>    this.flushPolicy = FlushPolicyFactory.create(this, conf);<a name="line.948"></a>
+<span class="sourceLineNo">949</span><a name="line.949"></a>
+<span class="sourceLineNo">950</span>    long lastFlushTime = EnvironmentEdgeManager.currentTime();<a name="line.950"></a>
+<span class="sourceLineNo">951</span>    for (Store store: stores.values()) {<a name="line.951"></a>
+<span class="sourceLineNo">952</span>      this.lastStoreFlushTimeMap.put(store, lastFlushTime);<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>    // Use maximum of log sequenceid or that which was found in stores<a name="line.955"></a>
+<span class="sourceLineNo">956</span>    // (particularly if no recovered edits, seqid will be -1).<a name="line.956"></a>
+<span class="sourceLineNo">957</span>    long nextSeqid = maxSeqId;<a name="line.957"></a>
+<span class="sourceLineNo">958</span><a name="line.958"></a>
+<span class="sourceLineNo">959</span>    // In distributedLogReplay mode, we don't know the last change sequence number because region<a name="line.959"></a>
+<span class="sourceLineNo">960</span>    // is opened before recovery completes. So we add a safety bumper to avoid new sequence number<a name="line.960"></a>
+<span class="sourceLineNo">961</span>    // overlaps used sequence numbers<a name="line.961"></a>
+<span class="sourceLineNo">962</span>    if (this.writestate.writesEnabled) {<a name="line.962"></a>
+<span class="sourceLineNo">963</span>      nextSeqid = WALSplitter.writeRegionSequenceIdFile(this.fs.getFileSystem(), this.fs<a name="line.963"></a>
+<span class="sourceLineNo">964</span>          .getRegionDir(), nextSeqid, (this.recovering ? (this.flushPerChanges + 10000000) : 1));<a name="line.964"></a>
+<span class="sourceLineNo">965</span>    } else {<a name="line.965"></a>
+<span class="sourceLineNo">966</span>      nextSeqid++;<a name="line.966"></a>
+<span class="sourceLineNo">967</span>    }<a name="line.967"></a>
 <span class="sourceLineNo">968</span><a name="line.968"></a>
-<span class="sourceLineNo">969</span>    if (coprocessorHost != null) {<a name="line.969"></a>
-<span class="sourceLineNo">970</span>      status.setStatus("Running coprocessor post-open hooks");<a name="line.970"></a>
-<span class="sourceLineNo">971</span>      coprocessorHost.postOpen();<a name="line.971"></a>
-<span class="sourceLineNo">972</span>    }<a name="line.972"></a>
-<span class="sourceLineNo">973</span><a name="line.973"></a>
-<span class="sourceLineNo">974</span>    status.markComplete("Region opened successfully");<a name="line.974"></a>
-<span class="sourceLineNo">975</span>    return nextSeqid;<a name="line.975"></a>
-<span class="sourceLineNo">976</span>  }<a name="line.976"></a>
-<span class="sourceLineNo">977</span><a name="line.977"></a>
-<span class="sourceLineNo">978</span>  /**<a name="line.978"></a>
-<span class="sourceLineNo">979</span>   * Open all Stores.<a name="line.979"></a>
-<span class="sourceLineNo">980</span>   * @param reporter<a name="line.980"></a>
-<span class="sourceLineNo">981</span>   * @param status<a name="line.981"></a>
-<span class="sourceLineNo">982</span>   * @return Highest sequenceId found out in a Store.<a name="line.982"></a>
-<span class="sourceLineNo">983</span>   * @throws IOException<a name="line.983"></a>
-<span class="sourceLineNo">984</span>   */<a name="line.984"></a>
-<span class="sourceLineNo">985</span>  private long initializeStores(final CancelableProgressable reporter, MonitoredTask status)<a name="line.985"></a>
-<span class="sourceLineNo">986</span>  throws IOException {<a name="line.986"></a>
-<span class="sourceLineNo">987</span>    // Load in all the HStores.<a name="line.987"></a>
-<span class="sourceLineNo">988</span><a name="line.988"></a>
-<span class="sourceLineNo">989</span>    long maxSeqId = -1;<a name="line.989"></a>
-<span class="sourceLineNo">990</span>    // initialized to -1 so that we pick up MemstoreTS from column families<a name="line.990"></a>
-<span class="sourceLineNo">991</span>    long maxMemstoreTS = -1;<a name="line.991"></a>
-<span class="sourceLineNo">992</span><a name="line.992"></a>
-<span class="sourceLineNo">993</span>    if (htableDescriptor.getColumnFamilyCount() != 0) {<a name="line.993"></a>
-<span class="sourceLineNo">994</span>      // initialize the thread pool for opening stores in parallel.<a name="line.994"></a>
-<span class="sourceLineNo">995</span>      ThreadPoolExecutor storeOpenerThreadPool =<a name="line.995"></a>
-<span class="sourceLineNo">996</span>        getStoreOpenAndCloseThreadPool("StoreOpener-" + this.getRegionInfo().getShortNameToLog());<a name="line.996"></a>
-<span class="sourceLineNo">997</span>      CompletionService&lt;HStore&gt; completionService = new ExecutorCompletionService&lt;&gt;(storeOpenerThreadPool);<a name="line.997"></a>
-<span class="sourceLineNo">998</span><a name="line.998"></a>
-<span class="sourceLineNo">999</span>      // initialize each store in parallel<a name="line.999"></a>
-<span class="sourceLineNo">1000</span>      for (final ColumnFamilyDescriptor family : htableDescriptor.getColumnFamilies()) {<a name="line.1000"></a>
-<span class="sourceLineNo">1001</span>        status.setStatus("Instantiating store for column family " + family);<a name="line.1001"></a>
-<span class="sourceLineNo">1002</span>        completionService.submit(new Callable&lt;HStore&gt;() {<a name="line.1002"></a>
-<span class="sourceLineNo">1003</span>          @Override<a name="line.1003"></a>
-<span class="sourceLineNo">1004</span>          public HStore call() throws IOException {<a name="line.1004"></a>
-<span class="sourceLineNo">1005</span>            return instantiateHStore(family);<a name="line.1005"></a>
-<span class="sourceLineNo">1006</span>          }<a name="line.1006"></a>
-<span class="sourceLineNo">1007</span>        });<a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>      }<a name="line.1008"></a>
-<span class="sourceLineNo">1009</span>      boolean allStoresOpened = false;<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span>      boolean hasSloppyStores = false;<a name="line.1010"></a>
-<span class="sourceLineNo">1011</span>      try {<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>        for (int i = 0; i &lt; htableDescriptor.getColumnFamilyCount(); i++) {<a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>          Future&lt;HStore&gt; future = completionService.take();<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>          HStore store = future.get();<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span>          this.stores.put(store.getColumnFamilyDescriptor().getName(), store);<a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>          if (store.isSloppyMemstore()) {<a name="line.1016"></a>
-<span class="sourceLineNo">1017</span>            hasSloppyStores = true;<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>          long storeMaxSequenceId = store.getMaxSequenceId();<a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>          maxSeqIdInStores.put(store.getColumnFamilyName().getBytes(),<a name="line.1021"></a>
-<span class="sourceLineNo">1022</span>              storeMaxSequenceId);<a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>          if (maxSeqId == -1 || storeMaxSequenceId &gt; maxSeqId) {<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>            maxSeqId = storeMaxSequenceId;<a name="line.1024"></a>
+<span class="sourceLineNo">969</span>    LOG.info("Onlined " + this.getRegionInfo().getShortNameToLog() +<a name="line.969"></a>
+<span class="sourceLineNo">970</span>      "; next sequenceid=" + nextSeqid);<a name="line.970"></a>
+<span class="sourceLineNo">971</span><a name="line.971"></a>
+<span class="sourceLineNo">972</span>    // A region can be reopened if failed a split; reset flags<a name="line.972"></a>
+<span class="sourceLineNo">973</span>    this.closing.set(false);<a name="line.973"></a>
+<span class="sourceLineNo">974</span>    this.closed.set(false);<a name="line.974"></a>
+<span class="sourceLineNo">975</span><a name="line.975"></a>
+<span class="sourceLineNo">976</span>    if (coprocessorHost != null) {<a name="line.976"></a>
+<span class="sourceLineNo">977</span>      status.setStatus("Running coprocessor post-open hooks");<a name="line.977"></a>
+<span class="sourceLineNo">978</span>      coprocessorHost.postOpen();<a name="line.978"></a>
+<span class="sourceLineNo">979</span>    }<a name="line.979"></a>
+<span class="sourceLineNo">980</span><a name="line.980"></a>
+<span class="sourceLineNo">981</span>    status.markComplete("Region opened successfully");<a name="line.981"></a>
+<span class="sourceLineNo">982</span>    return nextSeqid;<a name="line.982"></a>
+<span class="sourceLineNo">983</span>  }<a name="line.983"></a>
+<span class="sourceLineNo">984</span><a name="line.984"></a>
+<span class="sourceLineNo">985</span>  /**<a name="line.985"></a>
+<span class="sourceLineNo">986</span>   * Open all Stores.<a name="line.986"></a>
+<span class="sourceLineNo">987</span>   * @param reporter<a name="line.987"></a>
+<span class="sourceLineNo">988</span>   * @param status<a name="line.988"></a>
+<span class="sourceLineNo">989</span>   * @return Highest sequenceId found out in a Store.<a name="line.989"></a>
+<span class="sourceLineNo">990</span>   * @throws IOException<a name="line.990"></a>
+<span class="sourceLineNo">991</span>   */<a name="line.991"></a>
+<span class="sourceLineNo">992</span>  private long initializeStores(final CancelableProgressable reporter, MonitoredTask status)<a name="line.992"></a>
+<span class="sourceLineNo">993</span>  throws IOException {<a name="line.993"></a>
+<span class="sourceLineNo">994</span>    // Load in all the HStores.<a name="line.994"></a>
+<span class="sourceLineNo">995</span><a name="line.995"></a>
+<span class="sourceLineNo">996</span>    long maxSeqId = -1;<a name="line.996"></a>
+<span class="sourceLineNo">997</span>    // initialized to -1 so that we pick up MemstoreTS from column families<a name="line.997"></a>
+<span class="sourceLineNo">998</span>    long maxMemstoreTS = -1;<a name="line.998"></a>
+<span class="sourceLineNo">999</span><a name="line.999"></a>
+<span class="sourceLineNo">1000</span>    if (htableDescriptor.getColumnFamilyCount() != 0) {<a name="line.1000"></a>
+<span class="sourceLineNo">1001</span>      // initialize the thread pool for opening stores in parallel.<a name="line.1001"></a>
+<span class="sourceLineNo">1002</span>      ThreadPoolExecutor storeOpenerThreadPool =<a name="line.1002"></a>
+<span class="sourceLineNo">1003</span>        getStoreOpenAndCloseThreadPool("StoreOpener-" + this.getRegionInfo().getShortNameToLog());<a name="line.1003"></a>
+<span class="sourceLineNo">1004</span>      CompletionService&lt;HStore&gt; completionService = new ExecutorCompletionService&lt;&gt;(storeOpenerThreadPool);<a name="line.1004"></a>
+<span class="sourceLineNo">1005</span><a name="line.1005"></a>
+<span class="sourceLineNo">1006</span>      // initialize each store in parallel<a name="line.1006"></a>
+<span class="sourceLineNo">1007</span>      for (final ColumnFamilyDescriptor family : htableDescriptor.getColumnFamilies()) {<a name="line.1007"></a>
+<span class="sourceLineNo">1008</span>        status.setStatus("Instantiating store for column family " + family);<a name="line.1008"></a>
+<span class="sourceLineNo">1009</span>        completionService.submit(new Callable&lt;HStore&gt;() {<a name="line.1009"></a>
+<span class="sourceLineNo">1010</span>          @Override<a name="line.1010"></a>
+<span class="sourceLineNo">1011</span>          public HStore call() throws IOException {<a name="line.1011"></a>
+<span class="sourceLineNo">1012</span>            return instantiateHStore(family);<a name="line.1012"></a>
+<span class="sourceLineNo">1013</span>          }<a name="line.1013"></a>
+<span class="sourceLineNo">1014</span>        });<a name="line.1014"></a>
+<span class="sourceLineNo">1015</span>      }<a name="line.1015"></a>
+<span class="sourceLineNo">1016</span>      boolean allStoresOpened = false;<a name="line.1016"></a>
+<span class="sourceLineNo">1017</span>      boolean hasSloppyStores = false;<a name="line.1017"></a>
+<span class="sourceLineNo">1018</span>      try {<a name="line.1018"></a>
+<span class="sourceLineNo">1019</span>        for (int i = 0; i &lt; htableDescriptor.getColumnFamilyCount(); i++) {<a name="line.1019"></a>
+<span class="sourceLineNo">1020</span>          Future&lt;HStore&gt; future = completionService.take();<a name="line.1020"></a>
+<span class="sourceLineNo">1021</span>          HStore store = future.get();<a name="line.1021"></a>
+<span class="sourceLineNo">1022</span>          this.stores.put(store.getColumnFamilyDescriptor().getName(), store);<a name="line.1022"></a>
+<span class="sourceLineNo">1023</span>          if (store.isSloppyMemstore()) {<a name="line.1023"></a>
+<span class="sourceLineNo">1024</span>            hasSloppyStores = true;<a name="line.1024"></a>
 <span class="sourceLineNo">1025</span>          }<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>          long maxStoreMemstoreTS = store.getMaxMemstoreTS();<a name="line.1026"></a>
-<span class="sourceLineNo">1027</span>          if (maxStoreMemstoreTS &gt; maxMemstoreTS) {<a name="line.1027"></a>
-<span class="sourceLineNo">1028</span>            maxMemstoreTS = maxStoreMemstoreTS;<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>        allStoresOpened = true;<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span>        if(hasSloppyStores) {<a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>          htableDescriptor = TableDescriptorBuilder.newBuilder(htableDescriptor)<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span>                  .setFlushPolicyClassName(FlushNonSloppyStoresFirstPolicy.class.getName())<a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>                  .build();<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span>          LOG.info("Setting FlushNonSloppyStoresFirstPolicy for the region=" + this);<a name="line.1036"></a>
+<span class="sourceLineNo">1026</span><a name="line.1026"></a>
+<span class="sourceLineNo">1027</span>          long storeMaxSequenceId = store.getMaxSequenceId();<a name="line.1027"></a>
+<span class="sourceLineNo">1028</span>          maxSeqIdInStores.put(store.getColumnFamilyName().getBytes(),<a name="line.1028"></a>
+<span class="sourceLineNo">1029</span>              storeMaxSequenceId);<a name="line.1029"></a>
+<span class="sourceLineNo">1030</span>          if (maxSeqId == -1 || storeMaxSequenceId &gt; maxSeqId) {<a name="line.1030"></a>
+<span class="sourceLineNo">1031</span>            maxSeqId = storeMaxSequenceId;<a name="line.1031"></a>
+<span class="sourceLineNo">1032</span>          }<a name="line.1032"></a>
+<span class="sourceLineNo">1033</span>          long maxStoreMemstoreTS = store.getMaxMemstoreTS();<a name="line.1033"></a>
+<span class="sourceLineNo">1034</span>          if (maxStoreMemstoreTS &gt; maxMemstoreTS) {<a name="line.1034"></a>
+<span class="sourceLineNo">1035</span>            maxMemstoreTS = maxStoreMemstoreTS;<a name="line.1035"></a>
+<span class="sourceLineNo">1036</span>          }<a name="line.1036"></a>
 <span class="sourceLineNo">1037</span>        }<a name="line.1037"></a>
-<span class="sourceLineNo">1038</span>      } catch (InterruptedException e) {<a name="line.1038"></a>
-<span class="sourceLineNo">1039</span>        throw (InterruptedIOException)new InterruptedIOException().initCause(e);<a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>      } catch (ExecutionException e) {<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span>        throw new IOException(e.getCause());<a name="line.1041"></a>
-<span class="sourceLineNo">1042</span>      } finally {<a name="line.1042"></a>
-<span class="sourceLineNo">1043</span>        storeOpenerThreadPool.shutdownNow();<a name="line.1043"></a>
-<span class="sourceLineNo">1044</span>        if (!allStoresOpened) {<a name="line.1044"></a>
-<span class="sourceLineNo">1045</span>          // something went wrong, close all opened stores<a name="line.1045"></a>
-<span class="sourceLineNo">1046</span>          LOG.error("Could not initialize all stores for the region=" + this);<a name="line.1046"></a>
-<span class="sourceLineNo">1047</span>          for (Store store : this.stores.values()) {<a name="line.1047"></a>
-<span class="sourceLineNo">1048</span>            try {<a name="line.1048"></a>
-<span class="sourceLineNo">1049</span>              store.close();<a name="line.1049"></a>
-<span class="sourceLineNo">1050</span>            } catch (IOException e) {<a name="line.1050"></a>
-<span class="sourceLineNo">1051</span>              LOG.warn(e.getMessage());<a name="line.1051"></a>
-<span class="sourceLineNo">1052</span>            }<a name="line.1052"></a>
-<span class="sourceLineNo">1053</span>          }<a name="line.1053"></a>
-<span class="sourceLineNo">1054</span>        }<a name="line.1054"></a>
-<span class="sourceLineNo">1055</span>      }<a name="line.1055"></a>
-<span class="sourceLineNo">1056</span>    }<a name="line.1056"></a>
-<span class="sourceLineNo">1057</span>    return Math.max(maxSeqId, maxMemstoreTS + 1);<a name="line.1057"></a>
-<span class="sourceLineNo">1058</span>  }<a name="line.1058"></a>
-<span class="sourceLineNo">1059</span><a name="line.1059"></a>
-<span class="sourceLineNo">1060</span>  private void initializeWarmup(final CancelableProgressable reporter) throws IOException {<a name="line.1060"></a>
-<span class="sourceLineNo">1061</span>    MonitoredTask status = TaskMonitor.get().createStatus("Initializing region " + this);<a name="line.1061"></a>
-<span class="sourceLineNo">1062</span>    // Initialize all the HStores<a name="line.1062"></a>
-<span class="sourceLineNo">1063</span>    status.setStatus("Warming up all the Stores");<a name="line.1063"></a>
-<span class="sourceLineNo">1064</span>    try {<a name="line.1064"></a>
-<span class="sourceLineNo">1065</span>      initializeStores(reporter, status);<a name="line.1065"></a>
-<span class="sourceLineNo">1066</span>    } finally {<a name="line.1066"></a>
-<span class="sourceLineNo">1067</span>      status.markComplete("Done warming up.");<a name="line.1067"></a>
-<span class="sourceLineNo">1068</span>    }<a name="line.1068"></a>
-<span class="sourceLineNo">1069</span>  }<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>   * @return Map of StoreFiles by column family<a name="line.1072"></a>
-<span class="sourceLineNo">1073</span>   */<a name="line.1073"></a>
-<span class="sourceLineNo">1074</span>  private NavigableMap&lt;byte[], List&lt;Path&gt;&gt; getStoreFiles() {<a name="line.1074"></a>
-<span class="sourceLineNo">1075</span>    NavigableMap&lt;byte[], List&lt;Path&gt;&gt; allStoreFiles = new TreeMap&lt;&gt;(Bytes.BYTES_COMPARATOR);<a name="line.1075"></a>
-<span class="sourceLineNo">1076</span>    for (Store store: getStores()) {<a name="line.1076"></a>
-<span class="sourceLineNo">1077</span>      Collection&lt;StoreFile&gt; storeFiles = store.getStorefiles();<a name="line.1077"></a>
-<span class="sourceLineNo">1078</span>      if (storeFiles == null) continue;<a name="line.1078"></a>
-<span class="sourceLineNo">1079</span>      List&lt;Path&gt; storeFileNames = new ArrayList&lt;&gt;();<a name="line.1079"></a>
-<span class="sourceLineNo">1080</span>      for (StoreFile storeFile: storeFiles) {<a name="line.1080"></a>
-<span class="sourceLineNo">1081</span>        storeFileNames.add(storeFile.getPath());<a name="line.1081"></a>
-<span class="sourceLineNo">1082</span>      }<a name="line.1082"></a>
-<span class="sourceLineNo">1083</span>      allStoreFiles.put(store.getColumnFamilyDescriptor().getName(), storeFileNames);<a name="line.1083"></a>
-<span class="sourceLineNo">1084</span>    }<a name="line.1084"></a>
-<span class="sourceLineNo">1085</span>    return allStoreFiles;<a name="line.1085"></a>
-<span class="sourceLineNo">1086</span>  }<a name="line.1086"></a>
-<span class="sourceLineNo">1087</span><a name="line.1087"></a>
-<span class="sourceLineNo">1088</span>  private void writeRegionOpenMarker(WAL wal, long openSeqId) throws IOException {<a name="line.1088"></a>
-<span class="sourceLineNo">1089</span>    Map&lt;byte[], List&lt;Path&gt;&gt; storeFiles = getStoreFiles();<a name="line.1089"></a>
-<span class="sourceLineNo">1090</span>    RegionEventDescriptor regionOpenDesc = ProtobufUtil.toRegionEventDescriptor(<a name="line.1090"></a>
-<span class="sourceLineNo">1091</span>      RegionEventDescriptor.EventType.REGION_OPEN, getRegionInfo(), openSeqId,<a name="line.1091"></a>
-<span class="sourceLineNo">1092</span>      getRegionServerServices().getServerName(), storeFiles);<a name="line.1092"></a>
-<span class="sourceLineNo">1093</span>    WALUtil.writeRegionEventMarker(wal, getReplicationScope(), getRegionInfo(), regionOpenDesc,<a name="line.1093"></a>
-<span class="sourceLineNo">1094</span>        mvcc);<a name="line.1094"></a>
-<span class="sourceLineNo">1095</span>  }<a name="line.1095"></a>
-<span class="sourceLineNo">1096</span><a name="line.1096"></a>
-<span class="sourceLineNo">1097</span>  private void writeRegionCloseMarker(WAL wal) throws IOException {<a name="line.1097"></a>
-<span class="sourceLineNo">1098</span>    Map&lt;byte[], List&lt;Path&gt;&gt; storeFiles = getStoreFiles();<a name="line.1098"></a>
-<span class="sourceLineNo">1099</span>    RegionEventDescriptor regionEventDesc = ProtobufUtil.toRegionEventDescriptor(<a name="line.1099"></a>
-<span class="sourceLineNo">1100</span>      RegionEventDescriptor.EventType.REGION_CLOSE, getRegionInfo(), mvcc.getReadPoint(),<a name="line.1100"></a>
-<span class="sourceLineNo">1101</span>      getRegionServerServices().getServerName(), storeFiles);<a name="line.1101"></a>
-<span class="sourceLineNo">1102</span>    WALUtil.writeRegionEventMarker(wal, getReplicationScope(), getRegionInfo(), regionEventDesc,<a name="line.1102"></a>
-<span class="sourceLineNo">1103</span>        mvcc);<a name="line.1103"></a>
-<span class="sourceLineNo">1104</span><a name="line.1104"></a>
-<span class="sourceLineNo">1105</span>    // Store SeqId in HDFS when a region closes<a name="line.1105"></a>
-<span class="sourceLineNo">1106</span>    // checking region folder exists is due to many tests which delete the table folder while a<a name="line.1106"></a>
-<span class="sourceLineNo">1107</span>    // table is still online<a name="line.1107"></a>
-<span class="sourceLineNo">1108</span>    if (this.fs.getFileSystem().exists(this.fs.getRegionDir())) {<a name="line.1108"></a>
-<span class="sourceLineNo">1109</span>      WALSplitter.writeRegionSequenceIdFile(this.fs.getFileSystem(), this.fs.getRegionDir(),<a name="line.1109"></a>
-<span class="sourceLineNo">1110</span>        mvcc.getReadPoint(), 0);<a name="line.1110"></a>
-<span class="sourceLineNo">1111</span>    }<a name="line.1111"></a>
-<span class="sourceLineNo">1112</span>  }<a name="line.1112"></a>
-<span class="sourceLineNo">1113</span><a name="line.1113"></a>
-<span class="sourceLineNo">1114</span>  /**<a name="line.1114"></a>
-<span class="sourceLineNo">1115</span>   * @return True if this region has references.<a name="line.1115"></a>
-<span class="sourceLineNo">1116</span>   */<a name="line.1116"></a>
-<span class="sourceLineNo">1117</span>  public boolean hasReferences() {<a name="line.1117"></a>
-<span class="sourceLineNo">1118</span>    for (Store store : this.stores.values()) {<a name="line.1118"></a>
-<span class="sourceLineNo">1119</span>      if (store.hasReferences()) return true;<a name="line.1119"></a>
-<span class="sourceLineNo">1120</span>    }<a name="line.1120"></a>
-<span class="sourceLineNo">1121</span>    return false;<a name="line.1121"></a>
-<span class="sourceLineNo">1122</span>  }<a name="line.1122"></a>
-<span class="sourceLineNo">1123</span><a name="line.1123"></a>
-<span class="sourceLineNo">1124</span>  public void blockUpdates() {<a name="line.1124"></a>
-<span class="sourceLineNo">1125</span>    this.updatesLock.writeLock().lock();<a name="line.1125"></a>
-<span class="sourceLineNo">1126</span>  }<a name="line.1126"></a>
-<span class="sourceLineNo">1127</span><a name="line.1127"></a>
-<span class="sourceLineNo">1128</span>  public void unblockUpdates() {<a name="line.1128"></a>
-<span class="sourceLineNo">1129</span>    this.updatesLock.writeLock().unlock();<a name="line.1129"></a>
-<span class="sourceLineNo">1130</span>  }<a name="line.1130"></a>
-<span class="sourceLineNo">1131</span><a name="line.1131"></a>
-<span class="sourceLineNo">1132</span>  @Override<a name="line.1132"></a>
-<span class="sourceLineNo">1133</span>  public HDFSBlocksDistribution getHDFSBlocksDistribution() {<a name="line.1133"></a>
-<span class="sourceLineNo">1134</span>    HDFSBlocksDistribution hdfsBlocksDistribution =<a name="line.1134"></a>
-<span class="sourceLineNo">1135</span>      new HDFSBlocksDistribution();<a name="line.1135"></a>
-<span class="sourceLineNo">1136</span>    synchronized (this.stores) {<a name="line.1136"></a>
-<span class="sourceLineNo">1137</span>      for (Store store : this.stores.values()) {<a name="line.1137"></a>
-<span class="sourceLineNo">1138</span>        Collection&lt;StoreFile&gt; storeFiles = store.getStorefiles();<a name="line.1138"></a>
-<span class="sourceLineNo">1139</span>        if (storeFiles == null) continue;<a name="line.1139"></a>
-<span class="sourceLineNo">1140</span>        for (StoreFile sf : storeFiles) {<a name="line.1140"></a>
-<span class="sourceLineNo">1141</span>          HDFSBlocksDistribution storeFileBlocksDistribution =<a name="line.1141"></a>
-<span class="sourceLineNo">1142</span>            sf.getHDFSBlockDistribution();<a name="line.1142"></a>
-<span class="sourceLineNo">1143</span>          hdfsBlocksDistribution.add(storeFileBlocksDistribution);<a name="line.1143"></a>
-<span class="sourceLineNo">1144</span>        }<a name="line.1144"></a>
-<span class="sourceLineNo">1145</span>      }<a name="line.1145"></a>
-<span class="sourceLineNo">1146</span>    }<a name="line.1146"></a>
-<span class="sourceLineNo">1147</span>    return hdfsBlocksDistribution;<a name="line.1147"></a>
-<span class="sourceLineNo">1148</span>  }<a name="line.1148"></a>
-<span class="sourceLineNo">1149</span><a name="line.1149"></a>
-<span class="sourceLineNo">1150</span>  /**<a name="line.1150"></a>
-<span class="sourceLineNo">1151</span>   * This is a helper function to compute HDFS block distribution on demand<a name="line.1151"></a>
-<span class="sourceLineNo">1152</span>   * @param conf configuration<a name="line.1152"></a>
-<span class="sourceLineNo">1153</span>   * @param tableDescriptor TableDescriptor of the table<a name="line.1153"></a>
-<span class="sourceLineNo">1154</span>   * @param regionInfo encoded name of the region<a name="line.1154"></a>
-<span class="sourceLineNo">1155</span>   * @return The HDFS blocks distribution for the given region.<a name="line.1155"></a>
-<span class="sourceLineNo">1156</span>   * @throws IOException<a name="line.1156"></a>
-<span class="sourceLineNo">1157</span>   */<a name="line.1157"></a>
-<span class="sourceLineNo">1158</span>  public static HDFSBlocksDistribution computeHDFSBlocksDistribution(final Configuration conf,<a name="line.1158"></a>
-<span class="sourceLineNo">1159</span>      final TableDescriptor tableDescriptor, final HRegionInfo regionInfo) throws IOException {<a name="line.1159"></a>
-<span class="sourceLineNo">1160</span>    Path tablePath = FSUtils.getTableDir(FSUtils.getRootDir(conf), tableDescriptor.getTableName());<a name="line.1160"></a>
-<span class="sourceLineNo">1161</span>    return computeHDFSBlocksDistribution(conf, tableDescriptor, regionInfo, tablePath);<a name="line.1161"></a>
-<span class="sourceLineNo">1162</span>  }<a name="line.1162"></a>
-<span class="sourceLineNo">1163</span><a name="line.1163"></a>
-<span class="sourceLineNo">1164</span>  /**<a name="line.1164"></a>
-<span class="sourceLineNo">1165</span>   * This is a helper function to compute HDFS block distribution on demand<a name="line.1165"></a>
-<span class="sourceLineNo">1166</span>   * @param conf configuration<a name="line.1166"></a>
-<span class="sourceLineNo">1167</span>   * @param tableDescriptor TableDescriptor of the table<a name="line.1167"></a>
-<span class="sourceLineNo">1168</span>   * @param regionInfo encoded name of the region<a name="line.1168"></a>
-<span class="sourceLineNo">1169</span>   * @param tablePath the table directory<a name="line.1169"></a>
-<span class="sourceLineNo">1170</span>   * @return The HDFS blocks distribution for the given region.<a name="line.1170"></a>
-<span class="sourceLineNo">1171</span>   * @throws IOException<a name="line.1171"></a>
-<span class="sourceLineNo">1172</span>   */<a name="line.1172"></a>
-<span class="sourceLineNo">1173</span>  public static HDFSBlocksDistribution computeHDFSBlocksDistribution(final Configuration conf,<a name="line.1173"></a>
-<span class="sourceLineNo">1174</span>      final TableDescriptor tableDescriptor, final HRegionInfo regionInfo,  Path tablePath)<a name="line.1174"></a>
-<span class="sourceLineNo">1175</span>      throws IOException {<a name="line.1175"></a>
-<span class="sourceLineNo">1176</span>    HDFSBlocksDistribution hdfsBlocksDistribution = new HDFSBlocksDistribution();<a name="line.1176"></a>
-<span class="sourceLineNo">1177</span>    FileSystem fs = tablePath.getFileSystem(conf);<a name="line.1177"></a>
-<span class="sourceLineNo">1178</span><a name="line.1178"></a>
-<span class="sourceLineNo">1179</span>    HRegionFileSystem regionFs = new HRegionFileSystem(conf, fs, tablePath, regionInfo);<a name="line.1179"></a>
-<span class="sourceLineNo">1180</span>    for (ColumnFamilyDescriptor family : tableDescriptor.getColumnFamilies()) {<a name="line.1180"></a>
-<span class="sourceLineNo">1181</span>      List&lt;LocatedFileStatus&gt; locatedFileStatusList = HRegionFileSystem<a name="line.1181"></a>
-<span class="sourceLineNo">1182</span>          .getStoreFilesLocatedStatus(regionFs, family.getNameAsString(), true);<a name="line.1182"></a>
-<span class="sourceLineNo">1183</span>      if (locatedFileStatusList == null) {<a name="line.1183"></a>
-<span class="sourceLineNo">1184</span>        continue;<a name="line.1184"></a>
-<span class="sourceLineNo">1185</span>      }<a name="line.1185"></a>
-<span class="sourceLineNo">1186</span><a name="line.1186"></a>
-<span class="sourceLineNo">1187</span>      for (LocatedFileStatus status : locatedFileStatusList) {<a name="line.1187"></a>
-<span class="sourceLineNo">1188</span>        Path p = status.getPath();<a name="line.1188"></a>
-<span class="sourceLineNo">1189</span>        if (StoreFileInfo.isReference(p) || HFileLink.isHFileLink(p)) {<a name="line.1189"></a>
-<span class="sourceLineNo">1190</span>          // Only construct StoreFileInfo object if its not a hfile, save obj<a name="line.1190"></a>
-<span class="sourceLineNo">1191</span>          // creation<a name="line.1191"></a>
-<span class="sourceLineNo">1192</span>          StoreFileInfo storeFileInfo = new StoreFileInfo(conf, fs, status);<a name="line.1192"></a>
-<span class="sourceLineNo">1193</span>          hdfsBlocksDistribution.add(storeFileInfo<a name="line.1193"></a>
-<span class="sourceLineNo">1194</span>              .computeHDFSBlocksDistribution(fs));<a name="line.1194"></a>
-<span class="sourceLineNo">1195</span>        } else if (StoreFileInfo.isHFile(p)) {<a name="line.1195"></a>
-<span class="sourceLineNo">1196</span>          // If its a HFile, then lets just add to the block distribution<a name="line.1196"></a>
-<span class="sourceLineNo">1197</span>          // lets not create more objects here, not even another HDFSBlocksDistribution<a name="line.1197"></a>
-<span class="sourceLineNo">1198</span>          FSUtils.addToHDFSBlocksDistribution(hdfsBlocksDistribution,<a name="line.1198"></a>
-<span class="sourceLineNo">1199</span>              status.getBlockLocations());<a name="line.1199"></a>
-<span class="sourceLineNo">1200</span>        } else {<a name="line.1200"></a>
-<span class="sourceLineNo">1201</span>          throw new IOException("path=" + p<a name="line.1201"></a>
-<span class="sourceLineNo">1202</span>              + " doesn't look like a valid StoreFile");<a name="line.1202"></a>
-<span class="sourceLineNo">1203</span>        }<a name="line.1203"></a>
-<span class="sourceLineNo">1204</span>      }<a name="line.1204"></a>
-<span class="sourceLineNo">1205</span>    }<a name="line.1205"></a>
-<span class="sourceLineNo">1206</span>    return hdfsBlocksDistribution;<a name="line.1206"></a>
-<span class="sourceLineNo">1207</span>  }<a name="line.1207"></a>
-<span class="sourceLineNo">1208</span><a name="line.1208"></a>
-<span class="sourceLineNo">1209</span>  /**<a name="line.1209"></a>
-<span class="sourceLineNo">1210</span>   * Increase the size of mem store in this region and the size of global mem<a name="line.1210"></a>
-<span class="sourceLineNo">1211</span>   * store<a name="line.1211"></a>
-<span class="sourceLineNo">1212</span>   * @return the size of memstore in this region<a name="line.1212"></a>
-<span class="sourceLineNo">1213</span>   */<a name="line.1213"></a>
-<span class="sourceLineNo">1214</span>  public long addAndGetMemstoreSize(MemstoreSize memstoreSize) {<a name="line.1214"></a>
-<span class="sourceLineNo">1215</span>    if (this.rsAccounting != null) {<a name="line.1215"></a>
-<span class="sourceLineNo">1216</span>      rsAccounting.incGlobalMemstoreSize(memstoreSize);<a name="line.1216"></a>
-<span class="sourceLineNo">1217</span>    }<a name="line.1217"></a>
-<span class="sourceLineNo">1218</span>    long size = this.memstoreDataSize.addAndGet(memstoreSize.getDataSize());<a name="line.1218"></a>
-<span class="sourceLineNo">1219</span>    checkNegativeMemstoreDataSize(size, memstoreSize.getDataSize());<a name="line.1219"></a>
-<span class="sourceLineNo">1220</span>    return size;<a name="line.1220"></a>
-<span class="sourceLineNo">1221</span>  }<a name="line.1221"></a>
-<span class="sourceLineNo">1222</span><a name="line.1222"></a>
-<span class="sourceLineNo">1223</span>  public void decrMemstoreSize(MemstoreSize memstoreSize) {<a name="line.1223"></a>
-<span class="sourceLineNo">1224</span>    if (this.rsAccounting != null) {<a name="line.1224"></a>
-<span class="sourceLineNo">1225</span>      rsAccounting.decGlobalMemstoreSize(memstoreSize);<a name="line.1225"></a>
-<span class="sourceLineNo">1226</span>    }<a name="line.1226"></a>
-<span class="sourceLineNo">1227</span>    long size = this.memstoreDataSize.addAndGet(-memstoreSize.getDataSize());<a name="line.1227"></a>
-<span class="sourceLineNo">1228</span>    checkNegativeMemstoreDataSize(size, -memstoreSize.getDataSize());<a name="line.1228"></a>
-<span class="sourceLineNo">1229</span>  }<a name="line.1229"></a>
-<span class="sourceLineNo">1230</span><a name="line.1230"></a>
-<span class="sourceLineNo">1231</span>  private void checkNegativeMemstoreDataSize(long memstoreDataSize, long delta) {<a name="line.1231"></a>
-<span class="sourceLineNo">1232</span>    // This is extremely bad if we make memstoreSize negative. Log as much info on the offending<a name="line.1232"></a>
-<span class="sourceLineNo">1233</span>    // caller as possible. (memStoreSize might be a negative value already -- freeing memory)<a name="line.1233"></a>
-<span class="sourceLineNo">1234</span>    if (memstoreDataSize &lt; 0) {<a name="line.1234"></a>
-<span class="sourceLineNo">1235</span>      LOG.error("Asked to modify this region's (" + this.toString()<a name="line.1235"></a>
-<span class="sourceLineNo">1236</span>          + ") memstoreSize to a negative value which is incorrect. Current memstoreSize="<a name="line.1236"></a>
-<span class="sourceLineNo">1237</span>          + (memstoreDataSize - delta) + ", delta=" + delta, new Exception());<a name="line.1237"></a>
-<span class="sourceLineNo">1238</span>    }<a name="line.1238"></a>
-<span class="sourceLineNo">1239</span>  }<a name="line.1239"></a>
-<span class="sourceLineNo">1240</span><a name="line.1240"></a>
-<span class="sourceLineNo">1241</span>  @Override<a name="line.1241"></a>
-<span class="sourceLineNo">1242</span>  public HRegionInfo getRegionInfo() {<a name="line.1242"></a>
-<span class="sourceLineNo">1243</span>    return this.fs.getRegionInfo();<a name="line.1243"></a>
-<span class="sourceLineNo">1244</span>  }<a name="line.1244"></a>
-<span class="sourceLineNo">1245</span><a name="line.1245"></a>
-<span class="sourceLineNo">1246</span>  /**<a name="line.1246"></a>
-<span class="sourceLineNo">1247</span>   * @return Instance of {@link RegionServerServices} used by this HRegion.<a name="line.1247"></a>
-<span class="sourceLineNo">1248</span>   * Can be null.<a name="line.1248"></a>
-<span class="sourceLineNo">1249</span>   */<a name="line.1249"></a>
-<span class="sourceLineNo">1250</span>  RegionServerServices getRegionServerServices() {<a name="line.1250"></a>
-<span class="sourceLineNo">1251</span>    return this.rsServices;<a name="line.1251"></a>
-<span class="sourceLineNo">1252</span>  }<a name="line.1252"></a>
-<span class="sourceLineNo">1253</span><a name="line.1253"></a>
-<span class="sourceLineNo">1254</span>  @Override<a name="line.1254"></a>
-<span class="sourceLineNo">1255</span>  public long getReadRequestsCount() {<a name="line.1255"></a>
-<span class="sourceLineNo">1256</span>    return readRequestsCount.sum();<a name="line.1256"></a>
-<span class="sourceLineNo">1257</span>  }<a name="line.1257"></a>
-<span class="sourceLineNo">1258</span><a name="line.1258"></a>
-<span class="sourceLineNo">1259</span>  @Override<a name="line.1259"></a>
-<span class="sourceLineNo">1260</span>  public void updateReadRequestsCount(long i) {<a name="line.1260"></a>
-<span class="sourceLineNo">1261</span>    readRequestsCount.add(i);<a name="line.1261"></a>
-<span class="sourceLineNo">1262</span>  }<a name="line.1262"></a>
-<span class="sourceLineNo">1263</span><a name="line.1263"></a>
-<span class="sourceLineNo">1264</span>  @Override<a name="line.1264"></a>
-<span class="sourceLineNo">1265</span>  public long getFilteredReadRequestsCount() {<a name="line.1265"></a>
-<span class="sourceLineNo">1266</span>    return filteredReadRequestsCount.sum();<a name="line.1266"></a>
-<span class="sourceLineNo">1267</span>  }<a name="line.1267"></a>
-<span class="sourceLineNo">1268</span><a name="line.1268"></a>
-<span class="sourceLineNo">1269</span>  @Override<a name="line.1269"></a>
-<span class="sourceLineNo">1270</span>  public long getWriteRequestsCount() {<a name="line.1270"></a>
-<span class="sourceLineNo">1271</span>    return writeRequestsCount.sum();<a name="line.1271"></a>
-<span class="sourceLineNo">1272</span>  }<a name="line.1272"></a>
-<span class="sourceLineNo">1273</span><a name="line.1273"></a>
-<span class="sourceLineNo">1274</span>  @Override<a name="line.1274"></a>
-<span class="sourceLineNo">1275</span>  public void updateWriteRequestsCount(long i) {<a name="line.1275"></a>
-<span class="sourceLineNo">1276</span>    writeRequestsCount.add(i);<a name="line.1276"></a>
-<span class="sourceLineNo">1277</span>  }<a name="line.1277"></a>
-<span class="sourceLineNo">1278</span><a name="line.1278"></a>
-<span class="sourceLineNo">1279</span>  @Override<a name="line.1279"></a>
-<span class="sourceLineNo">1280</span>  public long getMemstoreSize() {<a name="line.1280"></a>
-<span class="sourceLineNo">1281</span>    return memstoreDataSize.get();<a name="line.1281"></a>
-<span class="sourceLineNo">1282</span>  }<a name="line.1282"></a>
-<span class="sourceLineNo">1283</span><a name="line.1283"></a>
-<span class="sourceLineNo">1284</span>  @Override<a name="line.1284"></a>
-<span class="sourceLineNo">1285</span>  public RegionServicesForStores getRegionServicesForStores() {<a name="line.1285"></a>
-<span class="sourceLineNo">1286</span>    return regionServicesForStores;<a name="line.1286"></a>
-<span class="sourceLineNo">1287</span>  }<a name="line.1287"></a>
-<span class="sourceLineNo">1288</span><a name="line.1288"></a>
-<span class="sourceLineNo">1289</span>  @Override<a name="line.1289"></a>
-<span class="sourceLineNo">1290</span>  public long getNumMutationsWithoutWAL() {<a name="line.1290"></a>
-<span class="sourceLineNo">1291</span>    return numMutationsWithoutWAL.sum();<a name="line.1291"></a>
-<span class="sourceLineNo">1292</span>  }<a name="line.1292"></a>
-<span class="sourceLineNo">1293</span><a name="line.1293"></a>
-<span class="sourceLineNo">1294</span>  @Override<a name="line.1294"></a>
-<span class="sourceLineNo">1295</span>  public long getDataInMemoryWithoutWAL() {<a name="line.1295"></a>
-<span class="sourceLineNo">1296</span>    return dataInMemoryWithoutWAL.sum();<a name="line.1296"></a>
-<span class="sourceLineNo">1297</span>  }<a name="line.1297"></a>
-<span class="sourceLineNo">1298</span><a name="line.1298"></a>
-<span class="sourceLineNo">1299</span>  @Override<a name="line.1299"></a>
-<span class="sourceLineNo">1300</span>  public long getBlockedRequestsCount() {<a name="line.1300"></a>
-<span class="sourceLineNo">1301</span>    return blockedRequestsCount.sum();<a name="line.1301"></a>
-<span class="sourceLineNo">1302</span>  }<a name="line.1302"></a>
-<span class="sourceLineNo">1303</span><a name="line.1303"></a>
-<span class="sourceLineNo">1304</span>  @Override<a name="line.1304"></a>
-<span class="sourceLineNo">1305</span>  public long getCheckAndMutateChecksPassed() {<a name="line.1305"></a>
-<span class="sourceLineNo">1306</span>    return checkAndMutateChecksPassed.sum();<a name="line.1306"></a>
-<span class="sourceLineNo">1307</span>  }<a name="line.1307"></a>
-<span class="sourceLineNo">1308</span><a name="line.1308"></a>
-<span class="sourceLineNo">1309</span>  @Override<a name="line.1309"></a>
-<span class="sourceLineNo">1310</span>  public long getCheckAndMutateChecksFailed() {<a name="line.1310"></a>
-<span class="sourceLineNo">1311</span>    return checkAndMutateChecksFailed.sum();<a name="line.1311"></a>
-<span class="sourceLineNo">1312</span>  }<a name="line.1312"></a>
-<span class="sourceLineNo">1313</span><a name="line.1313"></a>
-<span class="sourceLineNo">1314</span>  @Override<a name="line.1314"></a>
-<span class="sourceLineNo">1315</span>  public MetricsRegion getMetrics() {<a name="line.1315"></a>
-<span class="sourceLineNo">1316</span>    return metricsRegion;<a name="line.1316"></a>
-<span class="sourceLineNo">1317</span>  }<a name="line.1317"></a>
-<span class="sourceLineNo">1318</span><a name="line.1318"></a>
-<span class="sourceLineNo">1319</span>  @Override<a name="line.1319"></a>
-<span class="sourceLineNo">1320</span>  public boolean isClosed() {<a name="line.1320"></a>
-<span class="sourceLineNo">1321</span>    return this.closed.get();<a name="line.1321"></a>
-<span class="sourceLineNo">1322</span>  }<a name="line.1322"></a>
-<span class="sourceLineNo">1323</span><a name="line.1323"></a>
-<span class="sourceLineNo">1324</span>  @Override<a name="line.1324"></a>
-<span class="sourceLineNo">1325</span>  public boolean isClosing() {<a name="line.1325"></a>
-<span class="sourceLineNo">1326</span>    return this.closing.get();<a name="line.1326"></a>
-<span class="sourceLineNo">1327</span>  }<a name="line.1327"></a>
-<span class="sourceLineNo">1328</span><a name="line.1328"></a>
-<span class="sourceLineNo">1329</span>  @Override<a name="line.1329"></a>
-<span class="sourceLineNo">1330</span>  public boolean isReadOnly() {<a name="line.1330"></a>
-<span class="sourceLineNo">1331</span>    return this.writestate.isReadOnly();<a name="line.1331"></a>
-<span class="sourceLineNo">1332</span>  }<a name="line.1332"></a>
-<span class="sourceLineNo">1333</span><a name="line.1333"></a>
-<span class="sourceLineNo">1334</span>  /**<a name="line.1334"></a>
-<span class="sourceLineNo">1335</span>   * Reset recovering state of current region<a name="line.1335"></a>
-<span class="sourceLineNo">1336</span>   */<a name="line.1336"></a>
-<span class="sourceLineNo">1337</span>  public void setRecovering(boolean newState) {<a name="line.1337"></a>
-<span class="sourceLineNo">1338</span>    boolean wasRecovering = this.recovering;<a name="line.1338"></a>
-<span class="sourceLineNo">1339</span>    // Before we flip the recovering switch (enabling reads) we should write the region open<a name="line.1339"></a>
-<span class="sourceLineNo">1340</span>    // event to WAL if needed<a name="line.1340"></a>
-<span class="sourceLineNo">1341</span>    if (wal != null &amp;&amp; getRegionServerServices() != null &amp;&amp; !writestate.readOnly<a name="line.1341"></a>
-<span class="sourceLineNo">1342</span>        &amp;&amp; wasRecovering &amp;&amp; !newState) {<a name="line.1342"></a>
-<span class="sourceLineNo">1343</span><a name="line.1343"></a>
-<span class="sourceLineNo">1344</span>      // force a flush only if region replication is set up for this region. Otherwise no need.<a name="line.1344"></a>
-<span class="sourceLineNo">1345</span>      boolean forceFlush = getTableDescriptor().getRegionReplication() &gt; 1;<a name="line.1345"></a>
-<span class="sourceLineNo">1346</span><a name="line.1346"></a>
-<span class="sourceLineNo">1347</span>      MonitoredTask status = TaskMonitor.get().createStatus("Recovering region " + this);<a name="line.1347"></a>
-<span class="sourceLineNo">1348</span><a name="line.1348"></a>
-<span class="sourceLineNo">1349</span>      try {<a name="line.1349"></a>
-<span class="sourceLineNo">1350</span>        // force a flush first<a name="line.1350"></a>
-<span class="sourceLineNo">1351</span>        if (forceFlush) {<a name="line.1351"></a>
-<span class="sourceLineNo">1352</span>          status.setStatus("Flushing region " + this + " because recovery is finished");<a name="line.1352"></a>
-<span class="sourceLineNo">1353</span>          internalFlushcache(status);<a name="line.1353"></a>
-<span class="sourceLineNo">1354</span>        }<a name="line.1354"></a>
+<span class="sourceLineNo">1038</span>        allStoresOpened = true;<a name="line.1038"></a>
+<span class="sourceLineNo">1039</span>        if(hasSloppyStores) {<a name="line.1039"></a>
+<span class="sourceLineNo">1040</span>          htableDescriptor = TableDescriptorBuilder.newBuilder(htableDescriptor)<a name="line.1040"></a>
+<span class="sourceLineNo">1041</span>                  .setFlushPolicyClassName(FlushNonSloppyStoresFirstPolicy.class.getName())<a name="line.1041"></a>
+<span class="sourceLineNo">1042</span>                  .build();<a name="line.1042"></a>
+<span class="sourceLineNo">1043</span>          LOG.info("Setting FlushNonSloppyStoresFirstPolicy for the region=" + this);<a name="line.1043"></a>
+<span class="sourceLineNo">1044</span>        }<a name="line.1044"></a>
+<span class="sourceLineNo">1045</span>      } catch (InterruptedException e) {<a name="line.1045"></a>
+<span class="sourceLineNo">1046</span>        throw (InterruptedIOException)new InterruptedIOException().initCause(e);<a name="line.1046"></a>
+<span class="sourceLineNo">1047</span>      } catch (ExecutionException e) {<a name="line.1047"></a>
+<span class="sourceLineNo">1048</span>        throw new IOException(e.getCause());<a name="line.1048"></a>
+<span class="sourceLineNo">1049</span>      } finally {<a name="line.1049"></a>
+<span class="sourceLineNo">1050</span>        storeOpenerThreadPool.shutdownNow();<a name="line.1050"></a>
+<span class="sourceLineNo">1051</span>        if (!allStoresOpened) {<a name="line.1051"></a>
+<span class="sourceLineNo">1052</span>          // something went wrong, close all opened stores<a name="line.1052"></a>
+<span class="sourceLineNo">1053</span>          LOG.error("Could not initialize all stores for the region=" + this);<a name="line.1053"></a>
+<span class="sourceLineNo">1054</span>          for (Store store : this.stores.values()) {<a name="line.1054"></a>
+<span class="sourceLineNo">1055</span>            try {<a name="line.1055"></a>
+<span class="sourceLineNo">1056</span>              store.close();<a name="line.1056"></a>
+<span class="sourceLineNo">1057</span>            } catch (IOException e) {<a name="line.1057"></a>
+<span class="sourceLineNo">1058</span>              LOG.warn(e.getMessage());<a name="line.1058"></a>
+<span class="sourceLineNo">1059</span>            }<a name="line.1059"></a>
+<span class="sourceLineNo">1060</span>          }<a name="line.1060"></a>
+<span class="sourceLineNo">1061</span>        }<a name="line.1061"></a>
+<span class="sourceLineNo">1062</span>      }<a name="line.1062"></a>
+<span class="sourceLineNo">1063</span>    }<a name="line.1063"></a>
+<span class="sourceLineNo">1064</span>    return Math.max(maxSeqId, maxMemstoreTS + 1);<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>  private void initializeWarmup(final CancelableProgressable reporter) throws IOException {<a name="line.1067"></a>
+<span class="sourceLineNo">1068</span>    MonitoredTask status = TaskMonitor.get().createStatus("Initializing region " + this);<a name="line.1068"></a>
+<span class="sourceLineNo">1069</span>    // Initialize all the HStores<a name="line.1069"></a>
+<span class="sourceLineNo">1070</span>    status.setStatus("Warming up all the Stores");<a name="line.1070"></a>
+<span class="sourceLineNo">1071</span>    try {<a name="line.1071"></a>
+<span class="sourceLineNo">1072</span>      initializeStores(reporter, status);<a name="line.1072"></a>
+<span class="sourceLineNo">1073</span>    } finally {<a name="line.1073"></a>
+<span class="sourceLineNo">1074</span>      status.markComplete("Done warming up.");<a name="line.1074"></a>
+<span class="sourceLineNo">1075</span>    }<a name="line.1075"></a>
+<span class="sourceLineNo">1076</span>  }<a name="line.1076"></a>
+<span class="sourceLineNo">1077</span><a name="line.1077"></a>
+<span class="sourceLineNo">1078</span>  /**<a name="line.1078"></a>
+<span class="sourceLineNo">1079</span>   * @return Map of StoreFiles by column family<a name="line.1079"></a>
+<span class="sourceLineNo">1080</span>   */<a name="line.1080"></a>
+<span class="sourceLineNo">1081</span>  private NavigableMap&lt;byte[], List&lt;Path&gt;&gt; getStoreFiles() {<a name="line.1081"></a>
+<span class="sourceLineNo">1082</span>    NavigableMap&lt;byte[], List&lt;Path&gt;&gt; allStoreFiles = new TreeMap&lt;&gt;(Bytes.BYTES_COMPARATOR);<a name="line.1082"></a>
+<span class="sourceLineNo">1083</span>    for (Store store: getStores()) {<a name="line.1083"></a>
+<span class="sourceLineNo">1084</span>      Collection&lt;StoreFile&gt; storeFiles = store.getStorefiles();<a name="line.1084"></a>
+<span class="sourceLineNo">1085</span>      if (storeFiles == null) continue;<a name="line.1085"></a>
+<span class="sourceLineNo">1086</span>      List&lt;Path&gt; storeFileNames = new ArrayList&lt;&gt;();<a name="line.1086"></a>
+<span class="sourceLineNo">1087</span>      for (StoreFile storeFile: storeFiles) {<a name="line.1087"></a>
+<span class="sourceLineNo">1088</span>        storeFileNames.add(storeFile.getPath());<a name="line.1088"></a>
+<span class="sourceLineNo">1089</span>      }<a name="line.1089"></a>
+<span class="sourceLineNo">1090</span>      allStoreFiles.put(store.getColumnFamilyDescriptor().getName(), storeFileNames);<a name="line.1090"></a>
+<span class="sourceLineNo">1091</span>    }<a name="line.1091"></a>
+<span class="sourceLineNo">1092</span>    return allStoreFiles;<a name="line.1092"></a>
+<span class="sourceLineNo">1093</span>  }<a name="line.1093"></a>
+<span class="sourceLineNo">1094</span><a name="line.1094"></a>
+<span class="sourceLineNo">1095</span>  private void writeRegionOpenMarker(WAL wal, long openSeqId) throws IOException {<a name="line.1095"></a>
+<span class="sourceLineNo">1096</span>    Map&lt;byte[], List&lt;Path&gt;&gt; storeFiles = getStoreFiles();<a name="line.1096"></a>
+<span class="sourceLineNo">1097</span>    RegionEventDescriptor regionOpenDesc = ProtobufUtil.toRegionEventDescriptor(<a name="line.1097"></a>
+<span class="sourceLineNo">1098</span>      RegionEventDescriptor.EventType.REGION_OPEN, getRegionInfo(), openSeqId,<a name="line.1098"></a>
+<span class="sourceLineNo">1099</span>      getRegionServerServices().getServerName(), storeFiles);<a name="line.1099"></a>
+<span class="sourceLineNo">1100</span>    WALUtil.writeRegionEventMarker(wal, getReplicationScope(), getRegionInfo(), regionOpenDesc,<a name="line.1100"></a>
+<span class="sourceLineNo">1101</span>        mvcc);<a name="line.1101"></a>
+<span class="sourceLineNo">1102</span>  }<a name="line.1102"></a>
+<span class="sourceLineNo">1103</span><a name="line.1103"></a>
+<span class="sourceLineNo">1104</span>  private void writeRegionCloseMarker(WAL wal) throws IOException {<a name="line.1104"></a>
+<span class="sourceLineNo">1105</span>    Map&lt;byte[], List&lt;Path&gt;&gt; storeFiles = getStoreFiles();<a name="line.1105"></a>
+<span class="sourceLineNo">1106</span>    RegionEventDescriptor regionEventDesc = ProtobufUtil.toRegionEventDescriptor(<a name="line.1106"></a>
+<span class="sourceLineNo">1107</span>      RegionEventDescriptor.EventType.REGION_CLOSE, getRegionInfo(), mvcc.getReadPoint(),<a name="line.1107"></a>
+<span class="sourceLineNo">1108</span>      getRegionServerServices().getServerName(), storeFiles);<a name="line.1108"></a>
+<span class="sourceLineNo">1109</span>    WALUtil.writeRegionEventMarker(wal, getReplicationScope(), getRegionInfo(), regionEventDesc,<a name="line.1109"></a>
+<span class="sourceLineNo">1110</span>        mvcc);<a name="line.1110"></a>
+<span class="sourceLineNo">1111</span><a name="line.1111"></a>
+<span class="sourceLineNo">1112</span>    // Store SeqId in HDFS when a region closes<a name="line.1112"></a>
+<span class="sourceLineNo">1113</span>    // checking region folder exists is due to many tests which delete the table folder while a<a name="line.1113"></a>
+<span class="sourceLineNo">1114</span>    // table is still online<a name="line.1114"></a>
+<span class="sourceLineNo">1115</span>    if (this.fs.getFileSystem().exists(this.fs.getRegionDir())) {<a name="line.1115"></a>
+<span class="sourceLineNo">1116</span>      WALSplitter.writeRegionSequenceIdFile(this.fs.getFileSystem(), this.fs.getRegionDir(),<a name="line.1116"></a>
+<span class="sourceLineNo">1117</span>        mvcc.getReadPoint(), 0);<a name="line.1117"></a>
+<span class="sourceLineNo">1118</span>    }<a name="line.1118"></a>
+<span class="sourceLineNo">1119</span>  }<a name="line.1119"></a>
+<span class="sourceLineNo">1120</span><a name="line.1120"></a>
+<span class="sourceLineNo">1121</span>  /**<a name="line.1121"></a>
+<span class="sourceLineNo">1122</span>   * @return True if this region has references.<a name="line.1122"></a>
+<span class="sourceLineNo">1123</span>   */<a name="line.1123"></a>
+<span class="sourceLineNo">1124</span>  public boolean hasReferences() {<a name="line.1124"></a>
+<span class="sourceLineNo">1125</span>    for (Store store : this.stores.values()) {<a name="line.1125"></a>
+<span class="sourceLineNo">1126</span>      if (store.hasReferences()) return true;<a name="line.1126"></a>
+<span class="sourceLineNo">1127</span>    }<a name="line.1127"></a>
+<span class="sourceLineNo">1128</span>    return false;<a name="line.1128"></a>
+<span class="sourceLineNo">1129</span>  }<a name="line.1129"></a>
+<span class="sourceLineNo">1130</span><a name="line.1130"></a>
+<span class="sourceLineNo">1131</span>  public void blockUpdates() {<a name="line.1131"></a>
+<span class="sourceLineNo">1132</span>    this.updatesLock.writeLock().lock();<a name="line.1132"></a>
+<span class="sourceLineNo">1133</span>  }<a name="line.1133"></a>
+<span class="sourceLineNo">1134</span><a name="line.1134"></a>
+<span class="sourceLineNo">1135</span>  public void unblockUpdates() {<a name="line.1135"></a>
+<span class="sourceLineNo">1136</span>    this.updatesLock.writeLock().unlock();<a name="line.1136"></a>
+<span class="sourceLineNo">1137</span>  }<a name="line.1137"></a>
+<span class="sourceLineNo">1138</span><a name="line.1138"></a>
+<span class="sourceLineNo">1139</span>  @Override<a name="line.1139"></a>
+<span class="sourceLineNo">1140</span>  public HDFSBlocksDistribution getHDFSBlocksDistribution() {<a name="line.1140"></a>
+<span class="sourceLineNo">1141</span>    HDFSBlocksDistribution hdfsBlocksDistribution =<a name="line.1141"></a>
+<span class="sourceLineNo">1142</span>      new HDFSBlocksDistribution();<a name="line.1142"></a>
+<span class="sourceLineNo">1143</span>    synchronized (this.stores) {<a name="line.1143"></a>
+<span class="sourceLineNo">1144</span>      for (Store store : this.stores.values()) {<a name="line.1144"></a>
+<span class="sourceLineNo">1145</span>        Collection&lt;StoreFile&gt; storeFiles = store.getStorefiles();<a name="line.1145"></a>
+<span class="sourceLineNo">1146</span>        if (storeFiles == null) continue;<a name="line.1146"></a>
+<span class="sourceLineNo">1147</span>        for (StoreFile sf : storeFiles) {<a name="line.1147"></a>
+<span class="sourceLineNo">1148</span>          HDFSBlocksDistribution storeFileBlocksDistribution =<a name="line.1148"></a>
+<span class="sourceLineNo">1149</span>            sf.getHDFSBlockDistribution();<a name="line.1149"></a>
+<span class="sourceLineNo">1150</span>          hdfsBlocksDistribution.add(storeFileBlocksDistribution);<a name="line.1150"></a>
+<span class="sourceLineNo">1151</span>        }<a name="line.1151"></a>
+<span class="sourceLineNo">1152</span>      }<a name="line.1152"></a>
+<span class="sourceLineNo">1153</span>    }<a name="line.1153"></a>
+<span class="sourceLineNo">1154</span>    return hdfsBlocksDistribution;<a name="line.1154"></a>
+<span class="sourceLineNo">1155</span>  }<a name="line.1155"></a>
+<span class="sourceLineNo">1156</span><a name="line.1156"></a>
+<span class="sourceLineNo">1157</span>  /**<a name="line.1157"></a>
+<span class="sourceLineNo">1158</span>   * This is a helper function to compute HDFS block distribution on demand<a name="line.1158"></a>
+<span class="sourceLineNo">1159</span>   * @param conf configuration<a name="line.1159"></a>
+<span class="sourceLineNo">1160</span>   * @param tableDescriptor TableDescriptor of the table<a name="line.1160"></a>
+<span class="sourceLineNo">1161</span>   * @param regionInfo encoded name of the region<a name="line.1161"></a>
+<span class="sourceLineNo">1162</span>   * @return The HDFS blocks distribution for the given region.<a name="line.1162"></a>
+<span class="sourceLineNo">1163</span>   * @throws IOException<a name="line.1163"></a>
+<span class="sourceLineNo">1164</span>   */<a name="line.1164"></a>
+<span class="sourceLineNo">1165</span>  public static HDFSBlocksDistribution computeHDFSBlocksDistribution(final Configuration conf,<a name="line.1165"></a>
+<span class="sourceLineNo">1166</span>      final TableDescriptor tableDescriptor, final HRegionInfo regionInfo) throws IOException {<a name="line.1166"></a>
+<span class="sourceLineNo">1167</span>    Path tablePath = FSUtils.getTableDir(FSUtils.getRootDir(conf), tableDescriptor.getTableName());<a name="line.1167"></a>
+<span class="sourceLineNo">1168</span>    return computeHDFSBlocksDistribution(conf, tableDescriptor, regionInfo, tablePath);<a name="line.1168"></a>
+<span class="sourceLineNo">1169</span>  }<a name="line.1169"></a>
+<span class="sourceLineNo">1170</span><a name="line.1170"></a>
+<span class="sourceLineNo">1171</span>  /**<a name="line.1171"></a>
+<span class="sourceLineNo">1172</span>   * This is a helper function to compute HDFS block distribution on demand<a name="line.1172"></a>
+<span class="sourceLineNo">1173</span>   * @param conf configuration<a name="line.1173"></a>
+<span class="sourceLineNo">1174</span>   * @param tableDescriptor TableDescriptor of the table<a name="line.1174"></a>
+<span class="sourceLineNo">1175</span>   * @param regionInfo encoded name of the region<a name="line.1175"></a>
+<span class="sourceLineNo">1176</span>   * @param tablePath the table directory<a name="line.1176"></a>
+<span class="sourceLineNo">1177</span>   * @return The HDFS blocks distribution for the given region.<a name="line.1177"></a>
+<span class="sourceLineNo">1178</span>   * @throws IOException<a name="line.1178"></a>
+<span class="sourceLineNo">1179</span>   */<a name="line.1179"></a>
+<span class="sourceLineNo">1180</span>  public static HDFSBlocksDistribution computeHDFSBlocksDistribution(final Configuration conf,<a name="line.1180"></a>
+<span class="sourceLineNo">1181</span>      final TableDescriptor tableDescriptor, final HRegionInfo regionInfo,  Path tablePath)<a name="line.1181"></a>
+<span class="sourceLineNo">1182</span>      throws IOException {<a name="line.1182"></a>
+<span class="sourceLineNo">1183</span>    HDFSBlocksDistribution hdfsBlocksDistribution = new HDFSBlocksDistribution();<a name="line.1183"></a>
+<span class="sourceLineNo">1184</span>    FileSystem fs = tablePath.getFileSystem(conf);<a name="line.1184"></a>
+<span class="sourceLineNo">1185</span><a name="line.1185"></a>
+<span class="sourceLineNo">1186</span>    HRegionFileSystem regionFs = new HRegionFileSystem(conf, fs, tablePath, regionInfo);<a name="line.1186"></a>
+<span class="sourceLineNo">1187</span>    for (ColumnFamilyDescriptor family : tableDescriptor.getColumnFamilies()) {<a name="line.1187"></a>
+<span class="sourceLineNo">1188</span>      List&lt;LocatedFileStatus&gt; locatedFileStatusList = HRegionFileSystem<a name="line.1188"></a>
+<span class="sourceLineNo">1189</span>          .getStoreFilesLocatedStatus(regionFs, family.getNameAsString(), true);<a name="line.1189"></a>
+<span class="sourceLineNo">1190</span>      if (locatedFileStatusList == null) {<a name="line.1190"></a>
+<span class="sourceLineNo">1191</span>        continue;<a name="line.1191"></a>
+<span class="sourceLineNo">1192</span>      }<a name="line.1192"></a>
+<span class="sourceLineNo">1193</span><a name="line.1193"></a>
+<span class="sourceLineNo">1194</span>      for (LocatedFileStatus status : locatedFileStatusList) {<a name="line.1194"></a>
+<span class="sourceLineNo">1195</span>        Path p = status.getPath();<a name="line.1195"></a>
+<span class="sourceLineNo">1196</span>        if (StoreFileInfo.isReference(p) || HFileLink.isHFileLink(p)) {<a name="line.1196"></a>
+<span class="sourceLineNo">1197</span>          // Only construct StoreFileInfo object if its not a hfile, save obj<a name="line.1197"></a>
+<span class="sourceLineNo">1198</span>          // creation<a name="line.1198"></a>
+<span class="sourceLineNo">1199</span>          StoreFileInfo storeFileInfo = new StoreFileInfo(conf, fs, status);<a name="line.1199"></a>
+<span class="sourceLineNo">1200</span>          hdfsBlocksDistribution.add(storeFileInfo<a name="line.1200"></a>
+<span class="sourceLineNo">1201</span>              .computeHDFSBlocksDistribution(fs));<a name="line.1201"></a>
+<span class="sourceLineNo">1202</span>        } else if (StoreFileInfo.isHFile(p)) {<a name="line.1202"></a>
+<span class="sourceLineNo">1203</span>          // If its a HFile, then lets just add to the block distribution<a name="line.1203"></a>
+<span class="sourceLineNo">1204</span>          // lets not create more objects here, not even another HDFSBlocksDistribution<a name="line.1204"></a>
+<span class="sourceLineNo">1205</span>          FSUtils.addToHDFSBlocksDistribution(hdfsBlocksDistribution,<a name="line.1205"></a>
+<span class="sourceLineNo">1206</span>              status.getBlockLocations());<a name="line.1206"></a>
+<span class="sourceLineNo">1207</span>        } else {<a name="line.1207"></a>
+<span class="sourceLineNo">1208</span>          throw new IOException("path=" + p<a name="line.1208"></a>
+<span class="sourceLineNo">1209</span>              + " doesn't look like a valid StoreFile");<a name="line.1209"></a>
+<span class="sourceLineNo">1210</span>        }<a name="line.1210"></a>
+<span class="sourceLineNo">1211</span>      }<a name="line.1211"></a>
+<span class="sourceLineNo">1212</span>    }<a name="line.1212"></a>
+<span class="sourceLineNo">1213</span>    return hdfsBlocksDistribution;<a name="line.1213"></a>
+<span class="sourceLineNo">1214</span>  }<a name="line.1214"></a>
+<span class="sourceLineNo">1215</span><a name="line.1215"></a>
+<span class="sourceLineNo">1216</span>  /**<a name="line.1216"></a>
+<span class="sourceLineNo">1217</span>   * Increase the size of mem store in this region and the size of global mem<a name="line.1217"></a>
+<span class="sourceLineNo">1218</span>   * store<a name="line.1218"></a>
+<span class="sourceLineNo">1219</span>   * @return the size of memstore in this region<a name="line.1219"></a>
+<span class="sourceLineNo">1220</span>   */<a name="line.1220"></a>
+<span class="sourceLineNo">1221</span>  public long addAndGetMemstoreSize(MemstoreSize memstoreSize) {<a name="line.1221"></a>
+<span class="sourceLineNo">1222</span>    if (this.rsAccounting != null) {<a name="line.1222"></a>
+<span class="sourceLineNo">1223</span>      rsAccounting.incGlobalMemstoreSize(memstoreSize);<a name="line.1223"></a>
+<span class="sourceLineNo">1224</span>    }<a name="line.1224"></a>
+<span class="sourceLineNo">1225</span>    long size = this.memstoreDataSize.addAndGet(memstoreSize.getDataSize());<a name="line.1225"></a>
+<span class="sourceLineNo">1226</span>    checkNegativeMemstoreDataSize(size, memstoreSize.getDataSize());<a name="line.1226"></a>
+<span class="sourceLineNo">1227</span>    return size;<a name="line.1227"></a>
+<span class="sourceLineNo">1228</span>  }<a name="line.1228"></a>
+<span class="sourceLineNo">1229</span><a name="line.1229"></a>
+<span class="sourceLineNo">1230</span>  public void decrMemstoreSize(MemstoreSize memstoreSize) {<a name="line.1230"></a>
+<span class="sourceLineNo">1231</span>    if (this.rsAccounting != null) {<a name="line.1231"></a>
+<span class="sourceLineNo">1232</span>      rsAccounting.decGlobalMemstoreSize(memstoreSize);<a name="line.1232"></a>
+<span class="sourceLineNo">1233</span>    }<a name="line.1233"></a>
+<span class="sourceLineNo">1234</span>    long size = this.memstoreDataSize.addAndGet(-memstoreSize.getDataSize());<a name="line.1234"></a>
+<span class="sourceLineNo">1235</span>    checkNegativeMemstoreDataSize(size, -memstoreSize.getDataSize());<a name="line.1235"></a>
+<span class="sourceLineNo">1236</span>  }<a name="line.1236"></a>
+<span class="sourceLineNo">1237</span><a name="line.1237"></a>
+<span class="sourceLineNo">1238</span>  private void checkNegativeMemstoreDataSize(long memstoreDataSize, long delta) {<a name="line.1238"></a>
+<span class="sourceLineNo">1239</span>    // This is extremely bad if we make memstoreSize negative. Log as much info on the offending<a name="line.1239"></a>
+<span class="sourceLineNo">1240</span>    // caller as possible. (memStoreSize might be a negative value already -- freeing memory)<a name="line.1240"></a>
+<span class="sourceLineNo">1241</span>    if (memstoreDataSize &lt; 0) {<a name="line.1241"></a>
+<span class="sourceLineNo">1242</span>      LOG.error("Asked to modify this region's (" + this.toString()<a name="line.1242"></a>
+<span class="sourceLineNo">1243</span>          + ") memstoreSize to a negative value which is incorrect. Current memstoreSize="<a name="line.1243"></a>
+<span class="sourceLineNo">1244</span>          + (memstoreDataSize - delta) + ", delta=" + delta, new Exception());<a name="line.1244"></a>
+<span class="sourceLineNo">1245</span>    }<a name="line.1245"></a>
+<span class="sourceLineNo">1246</span>  }<a name="line.1246"></a>
+<span class="sourceLineNo">1247</span><a name="line.1247"></a>
+<span class="sourceLineNo">1248</span>  @Override<a name="line.1248"></a>
+<span class="sourceLineNo">1249</span>  public HRegionInfo getRegionInfo() {<a name="line.1249"></a>
+<span class="sourceLineNo">1250</span>    return this.fs.getRegionInfo();<a name="line.1250"></a>
+<span class="sourceLineNo">1251</span>  }<a name="line.1251"></a>
+<span class="sourceLineNo">1252</span><a name="line.1252"></a>
+<span class="sourceLineNo">1253</span>  /**<a name="line.1253"></a>
+<span class="sourceLineNo">1254</span>   * @return Instance of {@link RegionServerServices} used by this HRegion.<a name="line.1254"></a>
+<span class="sourceLineNo">1255</span>   * Can be null.<a name="line.1255"></a>
+<span class="sourceLineNo">1256</span>   */<a name="line.1256"></a>
+<span class="sourceLineNo">1257</span>  RegionServerServices getRegionServerServices() {<a name="line.1257"></a>
+<span class="sourceLineNo">1258</span>    return this.rsServices;<a name="line.1258"></a>
+<span class="sourceLineNo">1259</span>  }<a name="line.1259"></a>
+<span class="sourceLineNo">1260</span><a name="line.1260"></a>
+<span class="sourceLineNo">1261</span>  @Override<a name="line.1261"></a>
+<span class="sourceLineNo">1262</span>  public long getReadRequestsCount() {<a name="line.1262"></a>
+<span class="sourceLineNo">1263</span>    return readRequestsCount.sum();<a name="line.1263"></a>
+<span class="sourceLineNo">1264</span>  }<a name="line.1264"></a>
+<span class="sourceLineNo">1265</span><a name="line.1265"></a>
+<span class="sourceLineNo">1266</span>  @Override<a name="line.1266"></a>
+<span class="sourceLineNo">1267</span>  public void updateReadRequestsCount(long i) {<a name="line.1267"></a>
+<span class="sourceLineNo">1268</span>    readRequestsCount.add(i);<a name="line.1268"></a>
+<span class="sourceLineNo">1269</span>  }<a name="line.1269"></a>
+<span class="sourceLineNo">1270</span><a name="line.1270"></a>
+<span class="sourceLineNo">1271</span>  @Override<a name="line.1271"></a>
+<span class="sourceLineNo">1272</span>  public long getFilteredReadRequestsCount() {<a name="line.1272"></a>
+<span class="sourceLineNo">1273</span>    return filteredReadRequestsCount.sum();<a name="line.1273"></a>
+<span class="sourceLineNo">1274</span>  }<a name="line.1274"></a>
+<span class="sourceLineNo">1275</span><a name="line.1275"></a>
+<span class="sourceLineNo">1276</span>  @Override<a name="line.1276"></a>
+<span class="sourceLineNo">1277</span>  public long getWriteRequestsCount() {<a name="line.1277"></a>
+<span class="sourceLineNo">1278</span>    return writeRequestsCount.sum();<a name="line.1278"></a>
+<span class="sourceLineNo">1279</span>  }<a name="line.1279"></a>
+<span class="sourceLineNo">1280</span><a name="line.1280"></a>
+<span class="sourceLineNo">1281</span>  @Override<a name="line.1281"></a>
+<span class="sourceLineNo">1282</span>  public void updateWriteRequestsCount(long i) {<a name="line.1282"></a>
+<span class="sourceLineNo">1283</span>    writeRequestsCount.add(i);<a name="line.1283"></a>
+<span class="sourceLineNo">1284</span>  }<a name="line.1284"></a>
+<span class="sourceLineNo">1285</span><a name="line.1285"></a>
+<span class="sourceLineNo">1286</span>  @Override<a name="line.1286"></a>
+<span class="sourceLineNo">1287</span>  public long getMemstoreSize() {<a name="line.1287"></a>
+<span class="sourceLineNo">1288</span>    return memstoreDataSize.get();<a name="line.1288"></a>
+<span class="sourceLineNo">1289</span>  }<a name="line.1289"></a>
+<span class="sourceLineNo">1290</span><a name="line.1290"></a>
+<span class="sourceLineNo">1291</span>  @Override<a name="line.1291"></a>
+<span class="sourceLineNo">1292</span>  public RegionServicesForStores getRegionServicesForStores() {<a name="line.1292"></a>
+<span class="sourceLineNo">1293</span>    return regionServicesForStores;<a name="line.1293"></a>
+<span class="sourceLineNo">1294</span>  }<a name="line.1294"></a>
+<span class="sourceLineNo">1295</span><a name="line.1295"></a>
+<span class="sourceLineNo">1296</span>  @Override<a name="line.1296"></a>
+<span class="sourceLineNo">1297</span>  public long getNumMutationsWithoutWAL() {<a name="line.1297"></a>
+<span class="sourceLineNo">1298</span>    return numMutationsWithoutWAL.sum();<a name="line.1298"></a>
+<span class="sourceLineNo">1299</span>  }<a name="line.1299"></a>
+<span class="sourceLineNo">1300</span><a name="line.1300"></a>
+<span class="sourceLineNo">1301</span>  @Override<a name="line.1301"></a>
+<span class="sourceLineNo">1302</span>  public long getDataInMemoryWithoutWAL() {<a name="line.1302"></a>
+<span class="sourceLineNo">1303</span>    return dataInMemoryWithoutWAL.sum();<a name="line.1303"></a>
+<span class="sourceLineNo">1304</span>  }<a name="line.1304"></a>
+<span class="sourceLineNo">1305</span><a name="line.1305"></a>
+<span class="sourceLineNo">1306</span>  @Override<a name="line.1306"></a>
+<span class="sourceLineNo">1307</span>  public long getBlockedRequestsCount() {<a name="line.1307"></a>
+<span class="sourceLineNo">1308</span>    return blockedRequestsCount.sum();<a name="line.1308"></a>
+<span class="sourceLineNo">1309</span>  }<a name="line.1309"></a>
+<span class="sourceLineNo">1310</span><a name="line.1310"></a>
+<span class="sourceLineNo">1311</span>  @Override<a name="line.1311"></a>
+<span class="sourceLineNo">1312</span>  public long getCheckAndMutateChecksPassed() {<a name="line.1312"></a>
+<span class="sourceLineNo">1313</span>    return checkAndMutateChecksPassed.sum();<a name="line.1313"></a>
+<span class="sourceLineNo">1314</span>  }<a name="line.1314"></a>
+<span class="sourceLineNo">1315</span><a name="line.1315"></a>
+<span class="sourceLineNo">1316</span>  @Override<a name="line.1316"></a>
+<span class="sourceLineNo">1317</span>  public long getCheckAndMutateChecksFailed() {<a name="line.1317"></a>
+<span class="sourceLineNo">1318</span>    return checkAndMutateChecksFailed.sum();<a name="line.1318"></a>
+<span class="sourceLineNo">1319</span>  }<a name="line.1319"></a>
+<span class="sourceLineNo">1320</span><a name="line.1320"></a>
+<span class="sourceLineNo">1321</span>  @Override<a name="line.1321"></a>
+<span class="sourceLineNo">1322</span>  public MetricsRegion getMetrics() {<a name="line.1322"></a>
+<span class="sourceLineNo">1323</span>    return metricsRegion;<a name="line.1323"></a>
+<span class="sourceLineNo">1324</s

<TRUNCATED>

Mime
View raw message