hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [14/37] hbase-site git commit: Published site at 82d554e3783372cc6b05489452c815b57c06f6cd.
Date Thu, 25 May 2017 14:59:46 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/6cafca90/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.ObservedExceptionsInBatch.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.ObservedExceptionsInBatch.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.ObservedExceptionsInBatch.html
index fe28fe2..86378be 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.ObservedExceptionsInBatch.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.ObservedExceptionsInBatch.html
@@ -1765,6408 +1765,6439 @@
 <span class="sourceLineNo">1757</span>    }<a name="line.1757"></a>
 <span class="sourceLineNo">1758</span>  }<a name="line.1758"></a>
 <span class="sourceLineNo">1759</span><a name="line.1759"></a>
-<span class="sourceLineNo">1760</span>  protected ThreadPoolExecutor getStoreOpenAndCloseThreadPool(<a name="line.1760"></a>
-<span class="sourceLineNo">1761</span>      final String threadNamePrefix) {<a name="line.1761"></a>
-<span class="sourceLineNo">1762</span>    int numStores = Math.max(1, this.htableDescriptor.getFamilies().size());<a name="line.1762"></a>
-<span class="sourceLineNo">1763</span>    int maxThreads = Math.min(numStores,<a name="line.1763"></a>
-<span class="sourceLineNo">1764</span>        conf.getInt(HConstants.HSTORE_OPEN_AND_CLOSE_THREADS_MAX,<a name="line.1764"></a>
-<span class="sourceLineNo">1765</span>            HConstants.DEFAULT_HSTORE_OPEN_AND_CLOSE_THREADS_MAX));<a name="line.1765"></a>
-<span class="sourceLineNo">1766</span>    return getOpenAndCloseThreadPool(maxThreads, threadNamePrefix);<a name="line.1766"></a>
-<span class="sourceLineNo">1767</span>  }<a name="line.1767"></a>
-<span class="sourceLineNo">1768</span><a name="line.1768"></a>
-<span class="sourceLineNo">1769</span>  protected ThreadPoolExecutor getStoreFileOpenAndCloseThreadPool(<a name="line.1769"></a>
-<span class="sourceLineNo">1770</span>      final String threadNamePrefix) {<a name="line.1770"></a>
-<span class="sourceLineNo">1771</span>    int numStores = Math.max(1, this.htableDescriptor.getFamilies().size());<a name="line.1771"></a>
-<span class="sourceLineNo">1772</span>    int maxThreads = Math.max(1,<a name="line.1772"></a>
-<span class="sourceLineNo">1773</span>        conf.getInt(HConstants.HSTORE_OPEN_AND_CLOSE_THREADS_MAX,<a name="line.1773"></a>
-<span class="sourceLineNo">1774</span>            HConstants.DEFAULT_HSTORE_OPEN_AND_CLOSE_THREADS_MAX)<a name="line.1774"></a>
-<span class="sourceLineNo">1775</span>            / numStores);<a name="line.1775"></a>
-<span class="sourceLineNo">1776</span>    return getOpenAndCloseThreadPool(maxThreads, threadNamePrefix);<a name="line.1776"></a>
-<span class="sourceLineNo">1777</span>  }<a name="line.1777"></a>
-<span class="sourceLineNo">1778</span><a name="line.1778"></a>
-<span class="sourceLineNo">1779</span>  static ThreadPoolExecutor getOpenAndCloseThreadPool(int maxThreads,<a name="line.1779"></a>
-<span class="sourceLineNo">1780</span>      final String threadNamePrefix) {<a name="line.1780"></a>
-<span class="sourceLineNo">1781</span>    return Threads.getBoundedCachedThreadPool(maxThreads, 30L, TimeUnit.SECONDS,<a name="line.1781"></a>
-<span class="sourceLineNo">1782</span>      new ThreadFactory() {<a name="line.1782"></a>
-<span class="sourceLineNo">1783</span>        private int count = 1;<a name="line.1783"></a>
-<span class="sourceLineNo">1784</span><a name="line.1784"></a>
-<span class="sourceLineNo">1785</span>        @Override<a name="line.1785"></a>
-<span class="sourceLineNo">1786</span>        public Thread newThread(Runnable r) {<a name="line.1786"></a>
-<span class="sourceLineNo">1787</span>          return new Thread(r, threadNamePrefix + "-" + count++);<a name="line.1787"></a>
-<span class="sourceLineNo">1788</span>        }<a name="line.1788"></a>
-<span class="sourceLineNo">1789</span>      });<a name="line.1789"></a>
+<span class="sourceLineNo">1760</span>  @Override<a name="line.1760"></a>
+<span class="sourceLineNo">1761</span>  public void waitForFlushes() {<a name="line.1761"></a>
+<span class="sourceLineNo">1762</span>    synchronized (writestate) {<a name="line.1762"></a>
+<span class="sourceLineNo">1763</span>      if (this.writestate.readOnly) {<a name="line.1763"></a>
+<span class="sourceLineNo">1764</span>        // we should not wait for replayed flushed if we are read only (for example in case the<a name="line.1764"></a>
+<span class="sourceLineNo">1765</span>        // region is a secondary replica).<a name="line.1765"></a>
+<span class="sourceLineNo">1766</span>        return;<a name="line.1766"></a>
+<span class="sourceLineNo">1767</span>      }<a name="line.1767"></a>
+<span class="sourceLineNo">1768</span>      if (!writestate.flushing) return;<a name="line.1768"></a>
+<span class="sourceLineNo">1769</span>      long start = System.currentTimeMillis();<a name="line.1769"></a>
+<span class="sourceLineNo">1770</span>      boolean interrupted = false;<a name="line.1770"></a>
+<span class="sourceLineNo">1771</span>      try {<a name="line.1771"></a>
+<span class="sourceLineNo">1772</span>        while (writestate.flushing) {<a name="line.1772"></a>
+<span class="sourceLineNo">1773</span>          LOG.debug("waiting for cache flush to complete for region " + this);<a name="line.1773"></a>
+<span class="sourceLineNo">1774</span>          try {<a name="line.1774"></a>
+<span class="sourceLineNo">1775</span>            writestate.wait();<a name="line.1775"></a>
+<span class="sourceLineNo">1776</span>          } catch (InterruptedException iex) {<a name="line.1776"></a>
+<span class="sourceLineNo">1777</span>            // essentially ignore and propagate the interrupt back up<a name="line.1777"></a>
+<span class="sourceLineNo">1778</span>            LOG.warn("Interrupted while waiting");<a name="line.1778"></a>
+<span class="sourceLineNo">1779</span>            interrupted = true;<a name="line.1779"></a>
+<span class="sourceLineNo">1780</span>          }<a name="line.1780"></a>
+<span class="sourceLineNo">1781</span>        }<a name="line.1781"></a>
+<span class="sourceLineNo">1782</span>      } finally {<a name="line.1782"></a>
+<span class="sourceLineNo">1783</span>        if (interrupted) {<a name="line.1783"></a>
+<span class="sourceLineNo">1784</span>          Thread.currentThread().interrupt();<a name="line.1784"></a>
+<span class="sourceLineNo">1785</span>        }<a name="line.1785"></a>
+<span class="sourceLineNo">1786</span>      }<a name="line.1786"></a>
+<span class="sourceLineNo">1787</span>      long duration = System.currentTimeMillis() - start;<a name="line.1787"></a>
+<span class="sourceLineNo">1788</span>      LOG.debug("Waited " + duration + " ms for flush to complete");<a name="line.1788"></a>
+<span class="sourceLineNo">1789</span>    }<a name="line.1789"></a>
 <span class="sourceLineNo">1790</span>  }<a name="line.1790"></a>
-<span class="sourceLineNo">1791</span><a name="line.1791"></a>
-<span class="sourceLineNo">1792</span>   /**<a name="line.1792"></a>
-<span class="sourceLineNo">1793</span>    * @return True if its worth doing a flush before we put up the close flag.<a name="line.1793"></a>
-<span class="sourceLineNo">1794</span>    */<a name="line.1794"></a>
-<span class="sourceLineNo">1795</span>  private boolean worthPreFlushing() {<a name="line.1795"></a>
-<span class="sourceLineNo">1796</span>    return this.memstoreDataSize.get() &gt;<a name="line.1796"></a>
-<span class="sourceLineNo">1797</span>      this.conf.getLong("hbase.hregion.preclose.flush.size", 1024 * 1024 * 5);<a name="line.1797"></a>
+<span class="sourceLineNo">1791</span>  protected ThreadPoolExecutor getStoreOpenAndCloseThreadPool(<a name="line.1791"></a>
+<span class="sourceLineNo">1792</span>      final String threadNamePrefix) {<a name="line.1792"></a>
+<span class="sourceLineNo">1793</span>    int numStores = Math.max(1, this.htableDescriptor.getFamilies().size());<a name="line.1793"></a>
+<span class="sourceLineNo">1794</span>    int maxThreads = Math.min(numStores,<a name="line.1794"></a>
+<span class="sourceLineNo">1795</span>        conf.getInt(HConstants.HSTORE_OPEN_AND_CLOSE_THREADS_MAX,<a name="line.1795"></a>
+<span class="sourceLineNo">1796</span>            HConstants.DEFAULT_HSTORE_OPEN_AND_CLOSE_THREADS_MAX));<a name="line.1796"></a>
+<span class="sourceLineNo">1797</span>    return getOpenAndCloseThreadPool(maxThreads, threadNamePrefix);<a name="line.1797"></a>
 <span class="sourceLineNo">1798</span>  }<a name="line.1798"></a>
 <span class="sourceLineNo">1799</span><a name="line.1799"></a>
-<span class="sourceLineNo">1800</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.1800"></a>
-<span class="sourceLineNo">1801</span>  // HRegion accessors<a name="line.1801"></a>
-<span class="sourceLineNo">1802</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.1802"></a>
-<span class="sourceLineNo">1803</span><a name="line.1803"></a>
-<span class="sourceLineNo">1804</span>  @Override<a name="line.1804"></a>
-<span class="sourceLineNo">1805</span>  public HTableDescriptor getTableDesc() {<a name="line.1805"></a>
-<span class="sourceLineNo">1806</span>    return this.htableDescriptor;<a name="line.1806"></a>
-<span class="sourceLineNo">1807</span>  }<a name="line.1807"></a>
-<span class="sourceLineNo">1808</span><a name="line.1808"></a>
-<span class="sourceLineNo">1809</span>  /** @return WAL in use for this region */<a name="line.1809"></a>
-<span class="sourceLineNo">1810</span>  public WAL getWAL() {<a name="line.1810"></a>
-<span class="sourceLineNo">1811</span>    return this.wal;<a name="line.1811"></a>
-<span class="sourceLineNo">1812</span>  }<a name="line.1812"></a>
-<span class="sourceLineNo">1813</span><a name="line.1813"></a>
-<span class="sourceLineNo">1814</span>  /**<a name="line.1814"></a>
-<span class="sourceLineNo">1815</span>   * @return split policy for this region.<a name="line.1815"></a>
-<span class="sourceLineNo">1816</span>   */<a name="line.1816"></a>
-<span class="sourceLineNo">1817</span>  public RegionSplitPolicy getSplitPolicy() {<a name="line.1817"></a>
-<span class="sourceLineNo">1818</span>    return this.splitPolicy;<a name="line.1818"></a>
-<span class="sourceLineNo">1819</span>  }<a name="line.1819"></a>
-<span class="sourceLineNo">1820</span><a name="line.1820"></a>
-<span class="sourceLineNo">1821</span>  /**<a name="line.1821"></a>
-<span class="sourceLineNo">1822</span>   * A split takes the config from the parent region &amp; passes it to the daughter<a name="line.1822"></a>
-<span class="sourceLineNo">1823</span>   * region's constructor. If 'conf' was passed, you would end up using the HTD<a name="line.1823"></a>
-<span class="sourceLineNo">1824</span>   * of the parent region in addition to the new daughter HTD. Pass 'baseConf'<a name="line.1824"></a>
-<span class="sourceLineNo">1825</span>   * to the daughter regions to avoid this tricky dedupe problem.<a name="line.1825"></a>
-<span class="sourceLineNo">1826</span>   * @return Configuration object<a name="line.1826"></a>
-<span class="sourceLineNo">1827</span>   */<a name="line.1827"></a>
-<span class="sourceLineNo">1828</span>  Configuration getBaseConf() {<a name="line.1828"></a>
-<span class="sourceLineNo">1829</span>    return this.baseConf;<a name="line.1829"></a>
-<span class="sourceLineNo">1830</span>  }<a name="line.1830"></a>
-<span class="sourceLineNo">1831</span><a name="line.1831"></a>
-<span class="sourceLineNo">1832</span>  /** @return {@link FileSystem} being used by this region */<a name="line.1832"></a>
-<span class="sourceLineNo">1833</span>  public FileSystem getFilesystem() {<a name="line.1833"></a>
-<span class="sourceLineNo">1834</span>    return fs.getFileSystem();<a name="line.1834"></a>
-<span class="sourceLineNo">1835</span>  }<a name="line.1835"></a>
-<span class="sourceLineNo">1836</span><a name="line.1836"></a>
-<span class="sourceLineNo">1837</span>  /** @return the {@link HRegionFileSystem} used by this region */<a name="line.1837"></a>
-<span class="sourceLineNo">1838</span>  public HRegionFileSystem getRegionFileSystem() {<a name="line.1838"></a>
-<span class="sourceLineNo">1839</span>    return this.fs;<a name="line.1839"></a>
-<span class="sourceLineNo">1840</span>  }<a name="line.1840"></a>
-<span class="sourceLineNo">1841</span><a name="line.1841"></a>
-<span class="sourceLineNo">1842</span>  @Override<a name="line.1842"></a>
-<span class="sourceLineNo">1843</span>  public long getEarliestFlushTimeForAllStores() {<a name="line.1843"></a>
-<span class="sourceLineNo">1844</span>    return Collections.min(lastStoreFlushTimeMap.values());<a name="line.1844"></a>
-<span class="sourceLineNo">1845</span>  }<a name="line.1845"></a>
-<span class="sourceLineNo">1846</span><a name="line.1846"></a>
-<span class="sourceLineNo">1847</span>  @Override<a name="line.1847"></a>
-<span class="sourceLineNo">1848</span>  public long getOldestHfileTs(boolean majorCompactionOnly) throws IOException {<a name="line.1848"></a>
-<span class="sourceLineNo">1849</span>    long result = Long.MAX_VALUE;<a name="line.1849"></a>
-<span class="sourceLineNo">1850</span>    for (Store store : getStores()) {<a name="line.1850"></a>
-<span class="sourceLineNo">1851</span>      Collection&lt;StoreFile&gt; storeFiles = store.getStorefiles();<a name="line.1851"></a>
-<span class="sourceLineNo">1852</span>      if (storeFiles == null) continue;<a name="line.1852"></a>
-<span class="sourceLineNo">1853</span>      for (StoreFile file : storeFiles) {<a name="line.1853"></a>
-<span class="sourceLineNo">1854</span>        StoreFileReader sfReader = file.getReader();<a name="line.1854"></a>
-<span class="sourceLineNo">1855</span>        if (sfReader == null) continue;<a name="line.1855"></a>
-<span class="sourceLineNo">1856</span>        HFile.Reader reader = sfReader.getHFileReader();<a name="line.1856"></a>
-<span class="sourceLineNo">1857</span>        if (reader == null) continue;<a name="line.1857"></a>
-<span class="sourceLineNo">1858</span>        if (majorCompactionOnly) {<a name="line.1858"></a>
-<span class="sourceLineNo">1859</span>          byte[] val = reader.loadFileInfo().get(StoreFile.MAJOR_COMPACTION_KEY);<a name="line.1859"></a>
-<span class="sourceLineNo">1860</span>          if (val == null || !Bytes.toBoolean(val)) continue;<a name="line.1860"></a>
-<span class="sourceLineNo">1861</span>        }<a name="line.1861"></a>
-<span class="sourceLineNo">1862</span>        result = Math.min(result, reader.getFileContext().getFileCreateTime());<a name="line.1862"></a>
-<span class="sourceLineNo">1863</span>      }<a name="line.1863"></a>
-<span class="sourceLineNo">1864</span>    }<a name="line.1864"></a>
-<span class="sourceLineNo">1865</span>    return result == Long.MAX_VALUE ? 0 : result;<a name="line.1865"></a>
+<span class="sourceLineNo">1800</span>  protected ThreadPoolExecutor getStoreFileOpenAndCloseThreadPool(<a name="line.1800"></a>
+<span class="sourceLineNo">1801</span>      final String threadNamePrefix) {<a name="line.1801"></a>
+<span class="sourceLineNo">1802</span>    int numStores = Math.max(1, this.htableDescriptor.getFamilies().size());<a name="line.1802"></a>
+<span class="sourceLineNo">1803</span>    int maxThreads = Math.max(1,<a name="line.1803"></a>
+<span class="sourceLineNo">1804</span>        conf.getInt(HConstants.HSTORE_OPEN_AND_CLOSE_THREADS_MAX,<a name="line.1804"></a>
+<span class="sourceLineNo">1805</span>            HConstants.DEFAULT_HSTORE_OPEN_AND_CLOSE_THREADS_MAX)<a name="line.1805"></a>
+<span class="sourceLineNo">1806</span>            / numStores);<a name="line.1806"></a>
+<span class="sourceLineNo">1807</span>    return getOpenAndCloseThreadPool(maxThreads, threadNamePrefix);<a name="line.1807"></a>
+<span class="sourceLineNo">1808</span>  }<a name="line.1808"></a>
+<span class="sourceLineNo">1809</span><a name="line.1809"></a>
+<span class="sourceLineNo">1810</span>  static ThreadPoolExecutor getOpenAndCloseThreadPool(int maxThreads,<a name="line.1810"></a>
+<span class="sourceLineNo">1811</span>      final String threadNamePrefix) {<a name="line.1811"></a>
+<span class="sourceLineNo">1812</span>    return Threads.getBoundedCachedThreadPool(maxThreads, 30L, TimeUnit.SECONDS,<a name="line.1812"></a>
+<span class="sourceLineNo">1813</span>      new ThreadFactory() {<a name="line.1813"></a>
+<span class="sourceLineNo">1814</span>        private int count = 1;<a name="line.1814"></a>
+<span class="sourceLineNo">1815</span><a name="line.1815"></a>
+<span class="sourceLineNo">1816</span>        @Override<a name="line.1816"></a>
+<span class="sourceLineNo">1817</span>        public Thread newThread(Runnable r) {<a name="line.1817"></a>
+<span class="sourceLineNo">1818</span>          return new Thread(r, threadNamePrefix + "-" + count++);<a name="line.1818"></a>
+<span class="sourceLineNo">1819</span>        }<a name="line.1819"></a>
+<span class="sourceLineNo">1820</span>      });<a name="line.1820"></a>
+<span class="sourceLineNo">1821</span>  }<a name="line.1821"></a>
+<span class="sourceLineNo">1822</span><a name="line.1822"></a>
+<span class="sourceLineNo">1823</span>   /**<a name="line.1823"></a>
+<span class="sourceLineNo">1824</span>    * @return True if its worth doing a flush before we put up the close flag.<a name="line.1824"></a>
+<span class="sourceLineNo">1825</span>    */<a name="line.1825"></a>
+<span class="sourceLineNo">1826</span>  private boolean worthPreFlushing() {<a name="line.1826"></a>
+<span class="sourceLineNo">1827</span>    return this.memstoreDataSize.get() &gt;<a name="line.1827"></a>
+<span class="sourceLineNo">1828</span>      this.conf.getLong("hbase.hregion.preclose.flush.size", 1024 * 1024 * 5);<a name="line.1828"></a>
+<span class="sourceLineNo">1829</span>  }<a name="line.1829"></a>
+<span class="sourceLineNo">1830</span><a name="line.1830"></a>
+<span class="sourceLineNo">1831</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.1831"></a>
+<span class="sourceLineNo">1832</span>  // HRegion accessors<a name="line.1832"></a>
+<span class="sourceLineNo">1833</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.1833"></a>
+<span class="sourceLineNo">1834</span><a name="line.1834"></a>
+<span class="sourceLineNo">1835</span>  @Override<a name="line.1835"></a>
+<span class="sourceLineNo">1836</span>  public HTableDescriptor getTableDesc() {<a name="line.1836"></a>
+<span class="sourceLineNo">1837</span>    return this.htableDescriptor;<a name="line.1837"></a>
+<span class="sourceLineNo">1838</span>  }<a name="line.1838"></a>
+<span class="sourceLineNo">1839</span><a name="line.1839"></a>
+<span class="sourceLineNo">1840</span>  /** @return WAL in use for this region */<a name="line.1840"></a>
+<span class="sourceLineNo">1841</span>  public WAL getWAL() {<a name="line.1841"></a>
+<span class="sourceLineNo">1842</span>    return this.wal;<a name="line.1842"></a>
+<span class="sourceLineNo">1843</span>  }<a name="line.1843"></a>
+<span class="sourceLineNo">1844</span><a name="line.1844"></a>
+<span class="sourceLineNo">1845</span>  /**<a name="line.1845"></a>
+<span class="sourceLineNo">1846</span>   * @return split policy for this region.<a name="line.1846"></a>
+<span class="sourceLineNo">1847</span>   */<a name="line.1847"></a>
+<span class="sourceLineNo">1848</span>  public RegionSplitPolicy getSplitPolicy() {<a name="line.1848"></a>
+<span class="sourceLineNo">1849</span>    return this.splitPolicy;<a name="line.1849"></a>
+<span class="sourceLineNo">1850</span>  }<a name="line.1850"></a>
+<span class="sourceLineNo">1851</span><a name="line.1851"></a>
+<span class="sourceLineNo">1852</span>  /**<a name="line.1852"></a>
+<span class="sourceLineNo">1853</span>   * A split takes the config from the parent region &amp; passes it to the daughter<a name="line.1853"></a>
+<span class="sourceLineNo">1854</span>   * region's constructor. If 'conf' was passed, you would end up using the HTD<a name="line.1854"></a>
+<span class="sourceLineNo">1855</span>   * of the parent region in addition to the new daughter HTD. Pass 'baseConf'<a name="line.1855"></a>
+<span class="sourceLineNo">1856</span>   * to the daughter regions to avoid this tricky dedupe problem.<a name="line.1856"></a>
+<span class="sourceLineNo">1857</span>   * @return Configuration object<a name="line.1857"></a>
+<span class="sourceLineNo">1858</span>   */<a name="line.1858"></a>
+<span class="sourceLineNo">1859</span>  Configuration getBaseConf() {<a name="line.1859"></a>
+<span class="sourceLineNo">1860</span>    return this.baseConf;<a name="line.1860"></a>
+<span class="sourceLineNo">1861</span>  }<a name="line.1861"></a>
+<span class="sourceLineNo">1862</span><a name="line.1862"></a>
+<span class="sourceLineNo">1863</span>  /** @return {@link FileSystem} being used by this region */<a name="line.1863"></a>
+<span class="sourceLineNo">1864</span>  public FileSystem getFilesystem() {<a name="line.1864"></a>
+<span class="sourceLineNo">1865</span>    return fs.getFileSystem();<a name="line.1865"></a>
 <span class="sourceLineNo">1866</span>  }<a name="line.1866"></a>
 <span class="sourceLineNo">1867</span><a name="line.1867"></a>
-<span class="sourceLineNo">1868</span>  RegionLoad.Builder setCompleteSequenceId(RegionLoad.Builder regionLoadBldr) {<a name="line.1868"></a>
-<span class="sourceLineNo">1869</span>    long lastFlushOpSeqIdLocal = this.lastFlushOpSeqId;<a name="line.1869"></a>
-<span class="sourceLineNo">1870</span>    byte[] encodedRegionName = this.getRegionInfo().getEncodedNameAsBytes();<a name="line.1870"></a>
-<span class="sourceLineNo">1871</span>    regionLoadBldr.clearStoreCompleteSequenceId();<a name="line.1871"></a>
-<span class="sourceLineNo">1872</span>    for (byte[] familyName : this.stores.keySet()) {<a name="line.1872"></a>
-<span class="sourceLineNo">1873</span>      long earliest = this.wal.getEarliestMemstoreSeqNum(encodedRegionName, familyName);<a name="line.1873"></a>
-<span class="sourceLineNo">1874</span>      // Subtract - 1 to go earlier than the current oldest, unflushed edit in memstore; this will<a name="line.1874"></a>
-<span class="sourceLineNo">1875</span>      // give us a sequence id that is for sure flushed. We want edit replay to start after this<a name="line.1875"></a>
-<span class="sourceLineNo">1876</span>      // sequence id in this region. If NO_SEQNUM, use the regions maximum flush id.<a name="line.1876"></a>
-<span class="sourceLineNo">1877</span>      long csid = (earliest == HConstants.NO_SEQNUM)? lastFlushOpSeqIdLocal: earliest - 1;<a name="line.1877"></a>
-<span class="sourceLineNo">1878</span>      regionLoadBldr.addStoreCompleteSequenceId(StoreSequenceId.newBuilder()<a name="line.1878"></a>
-<span class="sourceLineNo">1879</span>          .setFamilyName(UnsafeByteOperations.unsafeWrap(familyName)).setSequenceId(csid).build());<a name="line.1879"></a>
-<span class="sourceLineNo">1880</span>    }<a name="line.1880"></a>
-<span class="sourceLineNo">1881</span>    return regionLoadBldr.setCompleteSequenceId(getMaxFlushedSeqId());<a name="line.1881"></a>
-<span class="sourceLineNo">1882</span>  }<a name="line.1882"></a>
-<span class="sourceLineNo">1883</span><a name="line.1883"></a>
-<span class="sourceLineNo">1884</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.1884"></a>
-<span class="sourceLineNo">1885</span>  // HRegion maintenance.<a name="line.1885"></a>
-<span class="sourceLineNo">1886</span>  //<a name="line.1886"></a>
-<span class="sourceLineNo">1887</span>  // These methods are meant to be called periodically by the HRegionServer for<a name="line.1887"></a>
-<span class="sourceLineNo">1888</span>  // upkeep.<a name="line.1888"></a>
-<span class="sourceLineNo">1889</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.1889"></a>
-<span class="sourceLineNo">1890</span><a name="line.1890"></a>
-<span class="sourceLineNo">1891</span>  /** @return returns size of largest HStore. */<a name="line.1891"></a>
-<span class="sourceLineNo">1892</span>  public long getLargestHStoreSize() {<a name="line.1892"></a>
-<span class="sourceLineNo">1893</span>    long size = 0;<a name="line.1893"></a>
-<span class="sourceLineNo">1894</span>    for (Store h : stores.values()) {<a name="line.1894"></a>
-<span class="sourceLineNo">1895</span>      long storeSize = h.getSize();<a name="line.1895"></a>
-<span class="sourceLineNo">1896</span>      if (storeSize &gt; size) {<a name="line.1896"></a>
-<span class="sourceLineNo">1897</span>        size = storeSize;<a name="line.1897"></a>
-<span class="sourceLineNo">1898</span>      }<a name="line.1898"></a>
-<span class="sourceLineNo">1899</span>    }<a name="line.1899"></a>
-<span class="sourceLineNo">1900</span>    return size;<a name="line.1900"></a>
-<span class="sourceLineNo">1901</span>  }<a name="line.1901"></a>
-<span class="sourceLineNo">1902</span><a name="line.1902"></a>
-<span class="sourceLineNo">1903</span>  /*<a name="line.1903"></a>
-<span class="sourceLineNo">1904</span>   * Do preparation for pending compaction.<a name="line.1904"></a>
-<span class="sourceLineNo">1905</span>   * @throws IOException<a name="line.1905"></a>
-<span class="sourceLineNo">1906</span>   */<a name="line.1906"></a>
-<span class="sourceLineNo">1907</span>  protected void doRegionCompactionPrep() throws IOException {<a name="line.1907"></a>
-<span class="sourceLineNo">1908</span>  }<a name="line.1908"></a>
-<span class="sourceLineNo">1909</span><a name="line.1909"></a>
-<span class="sourceLineNo">1910</span>  @Override<a name="line.1910"></a>
-<span class="sourceLineNo">1911</span>  public void triggerMajorCompaction() throws IOException {<a name="line.1911"></a>
-<span class="sourceLineNo">1912</span>    for (Store s : getStores()) {<a name="line.1912"></a>
-<span class="sourceLineNo">1913</span>      s.triggerMajorCompaction();<a name="line.1913"></a>
-<span class="sourceLineNo">1914</span>    }<a name="line.1914"></a>
-<span class="sourceLineNo">1915</span>  }<a name="line.1915"></a>
-<span class="sourceLineNo">1916</span><a name="line.1916"></a>
-<span class="sourceLineNo">1917</span>  @Override<a name="line.1917"></a>
-<span class="sourceLineNo">1918</span>  public void compact(final boolean majorCompaction) throws IOException {<a name="line.1918"></a>
-<span class="sourceLineNo">1919</span>    if (majorCompaction) {<a name="line.1919"></a>
-<span class="sourceLineNo">1920</span>      triggerMajorCompaction();<a name="line.1920"></a>
-<span class="sourceLineNo">1921</span>    }<a name="line.1921"></a>
-<span class="sourceLineNo">1922</span>    for (Store s : getStores()) {<a name="line.1922"></a>
-<span class="sourceLineNo">1923</span>      CompactionContext compaction = s.requestCompaction();<a name="line.1923"></a>
-<span class="sourceLineNo">1924</span>      if (compaction != null) {<a name="line.1924"></a>
-<span class="sourceLineNo">1925</span>        ThroughputController controller = null;<a name="line.1925"></a>
-<span class="sourceLineNo">1926</span>        if (rsServices != null) {<a name="line.1926"></a>
-<span class="sourceLineNo">1927</span>          controller = CompactionThroughputControllerFactory.create(rsServices, conf);<a name="line.1927"></a>
-<span class="sourceLineNo">1928</span>        }<a name="line.1928"></a>
-<span class="sourceLineNo">1929</span>        if (controller == null) {<a name="line.1929"></a>
-<span class="sourceLineNo">1930</span>          controller = NoLimitThroughputController.INSTANCE;<a name="line.1930"></a>
-<span class="sourceLineNo">1931</span>        }<a name="line.1931"></a>
-<span class="sourceLineNo">1932</span>        compact(compaction, s, controller, null);<a name="line.1932"></a>
-<span class="sourceLineNo">1933</span>      }<a name="line.1933"></a>
-<span class="sourceLineNo">1934</span>    }<a name="line.1934"></a>
-<span class="sourceLineNo">1935</span>  }<a name="line.1935"></a>
-<span class="sourceLineNo">1936</span><a name="line.1936"></a>
-<span class="sourceLineNo">1937</span>  /**<a name="line.1937"></a>
-<span class="sourceLineNo">1938</span>   * This is a helper function that compact all the stores synchronously<a name="line.1938"></a>
-<span class="sourceLineNo">1939</span>   * It is used by utilities and testing<a name="line.1939"></a>
-<span class="sourceLineNo">1940</span>   *<a name="line.1940"></a>
-<span class="sourceLineNo">1941</span>   * @throws IOException e<a name="line.1941"></a>
-<span class="sourceLineNo">1942</span>   */<a name="line.1942"></a>
-<span class="sourceLineNo">1943</span>  public void compactStores() throws IOException {<a name="line.1943"></a>
-<span class="sourceLineNo">1944</span>    for (Store s : getStores()) {<a name="line.1944"></a>
-<span class="sourceLineNo">1945</span>      CompactionContext compaction = s.requestCompaction();<a name="line.1945"></a>
-<span class="sourceLineNo">1946</span>      if (compaction != null) {<a name="line.1946"></a>
-<span class="sourceLineNo">1947</span>        compact(compaction, s, NoLimitThroughputController.INSTANCE, null);<a name="line.1947"></a>
-<span class="sourceLineNo">1948</span>      }<a name="line.1948"></a>
-<span class="sourceLineNo">1949</span>    }<a name="line.1949"></a>
-<span class="sourceLineNo">1950</span>  }<a name="line.1950"></a>
-<span class="sourceLineNo">1951</span><a name="line.1951"></a>
-<span class="sourceLineNo">1952</span>  /**<a name="line.1952"></a>
-<span class="sourceLineNo">1953</span>   * This is a helper function that compact the given store<a name="line.1953"></a>
-<span class="sourceLineNo">1954</span>   * It is used by utilities and testing<a name="line.1954"></a>
-<span class="sourceLineNo">1955</span>   *<a name="line.1955"></a>
-<span class="sourceLineNo">1956</span>   * @throws IOException e<a name="line.1956"></a>
-<span class="sourceLineNo">1957</span>   */<a name="line.1957"></a>
-<span class="sourceLineNo">1958</span>  @VisibleForTesting<a name="line.1958"></a>
-<span class="sourceLineNo">1959</span>  void compactStore(byte[] family, ThroughputController throughputController)<a name="line.1959"></a>
-<span class="sourceLineNo">1960</span>      throws IOException {<a name="line.1960"></a>
-<span class="sourceLineNo">1961</span>    Store s = getStore(family);<a name="line.1961"></a>
-<span class="sourceLineNo">1962</span>    CompactionContext compaction = s.requestCompaction();<a name="line.1962"></a>
-<span class="sourceLineNo">1963</span>    if (compaction != null) {<a name="line.1963"></a>
-<span class="sourceLineNo">1964</span>      compact(compaction, s, throughputController, null);<a name="line.1964"></a>
+<span class="sourceLineNo">1868</span>  /** @return the {@link HRegionFileSystem} used by this region */<a name="line.1868"></a>
+<span class="sourceLineNo">1869</span>  public HRegionFileSystem getRegionFileSystem() {<a name="line.1869"></a>
+<span class="sourceLineNo">1870</span>    return this.fs;<a name="line.1870"></a>
+<span class="sourceLineNo">1871</span>  }<a name="line.1871"></a>
+<span class="sourceLineNo">1872</span><a name="line.1872"></a>
+<span class="sourceLineNo">1873</span>  @Override<a name="line.1873"></a>
+<span class="sourceLineNo">1874</span>  public long getEarliestFlushTimeForAllStores() {<a name="line.1874"></a>
+<span class="sourceLineNo">1875</span>    return Collections.min(lastStoreFlushTimeMap.values());<a name="line.1875"></a>
+<span class="sourceLineNo">1876</span>  }<a name="line.1876"></a>
+<span class="sourceLineNo">1877</span><a name="line.1877"></a>
+<span class="sourceLineNo">1878</span>  @Override<a name="line.1878"></a>
+<span class="sourceLineNo">1879</span>  public long getOldestHfileTs(boolean majorCompactionOnly) throws IOException {<a name="line.1879"></a>
+<span class="sourceLineNo">1880</span>    long result = Long.MAX_VALUE;<a name="line.1880"></a>
+<span class="sourceLineNo">1881</span>    for (Store store : getStores()) {<a name="line.1881"></a>
+<span class="sourceLineNo">1882</span>      Collection&lt;StoreFile&gt; storeFiles = store.getStorefiles();<a name="line.1882"></a>
+<span class="sourceLineNo">1883</span>      if (storeFiles == null) continue;<a name="line.1883"></a>
+<span class="sourceLineNo">1884</span>      for (StoreFile file : storeFiles) {<a name="line.1884"></a>
+<span class="sourceLineNo">1885</span>        StoreFileReader sfReader = file.getReader();<a name="line.1885"></a>
+<span class="sourceLineNo">1886</span>        if (sfReader == null) continue;<a name="line.1886"></a>
+<span class="sourceLineNo">1887</span>        HFile.Reader reader = sfReader.getHFileReader();<a name="line.1887"></a>
+<span class="sourceLineNo">1888</span>        if (reader == null) continue;<a name="line.1888"></a>
+<span class="sourceLineNo">1889</span>        if (majorCompactionOnly) {<a name="line.1889"></a>
+<span class="sourceLineNo">1890</span>          byte[] val = reader.loadFileInfo().get(StoreFile.MAJOR_COMPACTION_KEY);<a name="line.1890"></a>
+<span class="sourceLineNo">1891</span>          if (val == null || !Bytes.toBoolean(val)) continue;<a name="line.1891"></a>
+<span class="sourceLineNo">1892</span>        }<a name="line.1892"></a>
+<span class="sourceLineNo">1893</span>        result = Math.min(result, reader.getFileContext().getFileCreateTime());<a name="line.1893"></a>
+<span class="sourceLineNo">1894</span>      }<a name="line.1894"></a>
+<span class="sourceLineNo">1895</span>    }<a name="line.1895"></a>
+<span class="sourceLineNo">1896</span>    return result == Long.MAX_VALUE ? 0 : result;<a name="line.1896"></a>
+<span class="sourceLineNo">1897</span>  }<a name="line.1897"></a>
+<span class="sourceLineNo">1898</span><a name="line.1898"></a>
+<span class="sourceLineNo">1899</span>  RegionLoad.Builder setCompleteSequenceId(RegionLoad.Builder regionLoadBldr) {<a name="line.1899"></a>
+<span class="sourceLineNo">1900</span>    long lastFlushOpSeqIdLocal = this.lastFlushOpSeqId;<a name="line.1900"></a>
+<span class="sourceLineNo">1901</span>    byte[] encodedRegionName = this.getRegionInfo().getEncodedNameAsBytes();<a name="line.1901"></a>
+<span class="sourceLineNo">1902</span>    regionLoadBldr.clearStoreCompleteSequenceId();<a name="line.1902"></a>
+<span class="sourceLineNo">1903</span>    for (byte[] familyName : this.stores.keySet()) {<a name="line.1903"></a>
+<span class="sourceLineNo">1904</span>      long earliest = this.wal.getEarliestMemstoreSeqNum(encodedRegionName, familyName);<a name="line.1904"></a>
+<span class="sourceLineNo">1905</span>      // Subtract - 1 to go earlier than the current oldest, unflushed edit in memstore; this will<a name="line.1905"></a>
+<span class="sourceLineNo">1906</span>      // give us a sequence id that is for sure flushed. We want edit replay to start after this<a name="line.1906"></a>
+<span class="sourceLineNo">1907</span>      // sequence id in this region. If NO_SEQNUM, use the regions maximum flush id.<a name="line.1907"></a>
+<span class="sourceLineNo">1908</span>      long csid = (earliest == HConstants.NO_SEQNUM)? lastFlushOpSeqIdLocal: earliest - 1;<a name="line.1908"></a>
+<span class="sourceLineNo">1909</span>      regionLoadBldr.addStoreCompleteSequenceId(StoreSequenceId.newBuilder()<a name="line.1909"></a>
+<span class="sourceLineNo">1910</span>          .setFamilyName(UnsafeByteOperations.unsafeWrap(familyName)).setSequenceId(csid).build());<a name="line.1910"></a>
+<span class="sourceLineNo">1911</span>    }<a name="line.1911"></a>
+<span class="sourceLineNo">1912</span>    return regionLoadBldr.setCompleteSequenceId(getMaxFlushedSeqId());<a name="line.1912"></a>
+<span class="sourceLineNo">1913</span>  }<a name="line.1913"></a>
+<span class="sourceLineNo">1914</span><a name="line.1914"></a>
+<span class="sourceLineNo">1915</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.1915"></a>
+<span class="sourceLineNo">1916</span>  // HRegion maintenance.<a name="line.1916"></a>
+<span class="sourceLineNo">1917</span>  //<a name="line.1917"></a>
+<span class="sourceLineNo">1918</span>  // These methods are meant to be called periodically by the HRegionServer for<a name="line.1918"></a>
+<span class="sourceLineNo">1919</span>  // upkeep.<a name="line.1919"></a>
+<span class="sourceLineNo">1920</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.1920"></a>
+<span class="sourceLineNo">1921</span><a name="line.1921"></a>
+<span class="sourceLineNo">1922</span>  /** @return returns size of largest HStore. */<a name="line.1922"></a>
+<span class="sourceLineNo">1923</span>  public long getLargestHStoreSize() {<a name="line.1923"></a>
+<span class="sourceLineNo">1924</span>    long size = 0;<a name="line.1924"></a>
+<span class="sourceLineNo">1925</span>    for (Store h : stores.values()) {<a name="line.1925"></a>
+<span class="sourceLineNo">1926</span>      long storeSize = h.getSize();<a name="line.1926"></a>
+<span class="sourceLineNo">1927</span>      if (storeSize &gt; size) {<a name="line.1927"></a>
+<span class="sourceLineNo">1928</span>        size = storeSize;<a name="line.1928"></a>
+<span class="sourceLineNo">1929</span>      }<a name="line.1929"></a>
+<span class="sourceLineNo">1930</span>    }<a name="line.1930"></a>
+<span class="sourceLineNo">1931</span>    return size;<a name="line.1931"></a>
+<span class="sourceLineNo">1932</span>  }<a name="line.1932"></a>
+<span class="sourceLineNo">1933</span><a name="line.1933"></a>
+<span class="sourceLineNo">1934</span>  /*<a name="line.1934"></a>
+<span class="sourceLineNo">1935</span>   * Do preparation for pending compaction.<a name="line.1935"></a>
+<span class="sourceLineNo">1936</span>   * @throws IOException<a name="line.1936"></a>
+<span class="sourceLineNo">1937</span>   */<a name="line.1937"></a>
+<span class="sourceLineNo">1938</span>  protected void doRegionCompactionPrep() throws IOException {<a name="line.1938"></a>
+<span class="sourceLineNo">1939</span>  }<a name="line.1939"></a>
+<span class="sourceLineNo">1940</span><a name="line.1940"></a>
+<span class="sourceLineNo">1941</span>  @Override<a name="line.1941"></a>
+<span class="sourceLineNo">1942</span>  public void triggerMajorCompaction() throws IOException {<a name="line.1942"></a>
+<span class="sourceLineNo">1943</span>    for (Store s : getStores()) {<a name="line.1943"></a>
+<span class="sourceLineNo">1944</span>      s.triggerMajorCompaction();<a name="line.1944"></a>
+<span class="sourceLineNo">1945</span>    }<a name="line.1945"></a>
+<span class="sourceLineNo">1946</span>  }<a name="line.1946"></a>
+<span class="sourceLineNo">1947</span><a name="line.1947"></a>
+<span class="sourceLineNo">1948</span>  @Override<a name="line.1948"></a>
+<span class="sourceLineNo">1949</span>  public void compact(final boolean majorCompaction) throws IOException {<a name="line.1949"></a>
+<span class="sourceLineNo">1950</span>    if (majorCompaction) {<a name="line.1950"></a>
+<span class="sourceLineNo">1951</span>      triggerMajorCompaction();<a name="line.1951"></a>
+<span class="sourceLineNo">1952</span>    }<a name="line.1952"></a>
+<span class="sourceLineNo">1953</span>    for (Store s : getStores()) {<a name="line.1953"></a>
+<span class="sourceLineNo">1954</span>      CompactionContext compaction = s.requestCompaction();<a name="line.1954"></a>
+<span class="sourceLineNo">1955</span>      if (compaction != null) {<a name="line.1955"></a>
+<span class="sourceLineNo">1956</span>        ThroughputController controller = null;<a name="line.1956"></a>
+<span class="sourceLineNo">1957</span>        if (rsServices != null) {<a name="line.1957"></a>
+<span class="sourceLineNo">1958</span>          controller = CompactionThroughputControllerFactory.create(rsServices, conf);<a name="line.1958"></a>
+<span class="sourceLineNo">1959</span>        }<a name="line.1959"></a>
+<span class="sourceLineNo">1960</span>        if (controller == null) {<a name="line.1960"></a>
+<span class="sourceLineNo">1961</span>          controller = NoLimitThroughputController.INSTANCE;<a name="line.1961"></a>
+<span class="sourceLineNo">1962</span>        }<a name="line.1962"></a>
+<span class="sourceLineNo">1963</span>        compact(compaction, s, controller, null);<a name="line.1963"></a>
+<span class="sourceLineNo">1964</span>      }<a name="line.1964"></a>
 <span class="sourceLineNo">1965</span>    }<a name="line.1965"></a>
 <span class="sourceLineNo">1966</span>  }<a name="line.1966"></a>
 <span class="sourceLineNo">1967</span><a name="line.1967"></a>
-<span class="sourceLineNo">1968</span>  /*<a name="line.1968"></a>
-<span class="sourceLineNo">1969</span>   * Called by compaction thread and after region is opened to compact the<a name="line.1969"></a>
-<span class="sourceLineNo">1970</span>   * HStores if necessary.<a name="line.1970"></a>
+<span class="sourceLineNo">1968</span>  /**<a name="line.1968"></a>
+<span class="sourceLineNo">1969</span>   * This is a helper function that compact all the stores synchronously<a name="line.1969"></a>
+<span class="sourceLineNo">1970</span>   * It is used by utilities and testing<a name="line.1970"></a>
 <span class="sourceLineNo">1971</span>   *<a name="line.1971"></a>
-<span class="sourceLineNo">1972</span>   * &lt;p&gt;This operation could block for a long time, so don't call it from a<a name="line.1972"></a>
-<span class="sourceLineNo">1973</span>   * time-sensitive thread.<a name="line.1973"></a>
-<span class="sourceLineNo">1974</span>   *<a name="line.1974"></a>
-<span class="sourceLineNo">1975</span>   * Note that no locking is necessary at this level because compaction only<a name="line.1975"></a>
-<span class="sourceLineNo">1976</span>   * conflicts with a region split, and that cannot happen because the region<a name="line.1976"></a>
-<span class="sourceLineNo">1977</span>   * server does them sequentially and not in parallel.<a name="line.1977"></a>
-<span class="sourceLineNo">1978</span>   *<a name="line.1978"></a>
-<span class="sourceLineNo">1979</span>   * @param compaction Compaction details, obtained by requestCompaction()<a name="line.1979"></a>
-<span class="sourceLineNo">1980</span>   * @param throughputController<a name="line.1980"></a>
-<span class="sourceLineNo">1981</span>   * @return whether the compaction completed<a name="line.1981"></a>
-<span class="sourceLineNo">1982</span>   */<a name="line.1982"></a>
-<span class="sourceLineNo">1983</span>  public boolean compact(CompactionContext compaction, Store store,<a name="line.1983"></a>
-<span class="sourceLineNo">1984</span>      ThroughputController throughputController) throws IOException {<a name="line.1984"></a>
-<span class="sourceLineNo">1985</span>    return compact(compaction, store, throughputController, null);<a name="line.1985"></a>
-<span class="sourceLineNo">1986</span>  }<a name="line.1986"></a>
-<span class="sourceLineNo">1987</span><a name="line.1987"></a>
-<span class="sourceLineNo">1988</span>  public boolean compact(CompactionContext compaction, Store store,<a name="line.1988"></a>
-<span class="sourceLineNo">1989</span>      ThroughputController throughputController, User user) throws IOException {<a name="line.1989"></a>
-<span class="sourceLineNo">1990</span>    assert compaction != null &amp;&amp; compaction.hasSelection();<a name="line.1990"></a>
-<span class="sourceLineNo">1991</span>    assert !compaction.getRequest().getFiles().isEmpty();<a name="line.1991"></a>
-<span class="sourceLineNo">1992</span>    if (this.closing.get() || this.closed.get()) {<a name="line.1992"></a>
-<span class="sourceLineNo">1993</span>      LOG.debug("Skipping compaction on " + this + " because closing/closed");<a name="line.1993"></a>
-<span class="sourceLineNo">1994</span>      store.cancelRequestedCompaction(compaction);<a name="line.1994"></a>
-<span class="sourceLineNo">1995</span>      return false;<a name="line.1995"></a>
+<span class="sourceLineNo">1972</span>   * @throws IOException e<a name="line.1972"></a>
+<span class="sourceLineNo">1973</span>   */<a name="line.1973"></a>
+<span class="sourceLineNo">1974</span>  public void compactStores() throws IOException {<a name="line.1974"></a>
+<span class="sourceLineNo">1975</span>    for (Store s : getStores()) {<a name="line.1975"></a>
+<span class="sourceLineNo">1976</span>      CompactionContext compaction = s.requestCompaction();<a name="line.1976"></a>
+<span class="sourceLineNo">1977</span>      if (compaction != null) {<a name="line.1977"></a>
+<span class="sourceLineNo">1978</span>        compact(compaction, s, NoLimitThroughputController.INSTANCE, null);<a name="line.1978"></a>
+<span class="sourceLineNo">1979</span>      }<a name="line.1979"></a>
+<span class="sourceLineNo">1980</span>    }<a name="line.1980"></a>
+<span class="sourceLineNo">1981</span>  }<a name="line.1981"></a>
+<span class="sourceLineNo">1982</span><a name="line.1982"></a>
+<span class="sourceLineNo">1983</span>  /**<a name="line.1983"></a>
+<span class="sourceLineNo">1984</span>   * This is a helper function that compact the given store<a name="line.1984"></a>
+<span class="sourceLineNo">1985</span>   * It is used by utilities and testing<a name="line.1985"></a>
+<span class="sourceLineNo">1986</span>   *<a name="line.1986"></a>
+<span class="sourceLineNo">1987</span>   * @throws IOException e<a name="line.1987"></a>
+<span class="sourceLineNo">1988</span>   */<a name="line.1988"></a>
+<span class="sourceLineNo">1989</span>  @VisibleForTesting<a name="line.1989"></a>
+<span class="sourceLineNo">1990</span>  void compactStore(byte[] family, ThroughputController throughputController)<a name="line.1990"></a>
+<span class="sourceLineNo">1991</span>      throws IOException {<a name="line.1991"></a>
+<span class="sourceLineNo">1992</span>    Store s = getStore(family);<a name="line.1992"></a>
+<span class="sourceLineNo">1993</span>    CompactionContext compaction = s.requestCompaction();<a name="line.1993"></a>
+<span class="sourceLineNo">1994</span>    if (compaction != null) {<a name="line.1994"></a>
+<span class="sourceLineNo">1995</span>      compact(compaction, s, throughputController, null);<a name="line.1995"></a>
 <span class="sourceLineNo">1996</span>    }<a name="line.1996"></a>
-<span class="sourceLineNo">1997</span>    MonitoredTask status = null;<a name="line.1997"></a>
-<span class="sourceLineNo">1998</span>    boolean requestNeedsCancellation = true;<a name="line.1998"></a>
-<span class="sourceLineNo">1999</span>    /*<a name="line.1999"></a>
-<span class="sourceLineNo">2000</span>     * We are trying to remove / relax the region read lock for compaction.<a name="line.2000"></a>
-<span class="sourceLineNo">2001</span>     * Let's see what are the potential race conditions among the operations (user scan,<a name="line.2001"></a>
-<span class="sourceLineNo">2002</span>     * region split, region close and region bulk load).<a name="line.2002"></a>
-<span class="sourceLineNo">2003</span>     *<a name="line.2003"></a>
-<span class="sourceLineNo">2004</span>     *  user scan ---&gt; region read lock<a name="line.2004"></a>
-<span class="sourceLineNo">2005</span>     *  region split --&gt; region close first --&gt; region write lock<a name="line.2005"></a>
-<span class="sourceLineNo">2006</span>     *  region close --&gt; region write lock<a name="line.2006"></a>
-<span class="sourceLineNo">2007</span>     *  region bulk load --&gt; region write lock<a name="line.2007"></a>
-<span class="sourceLineNo">2008</span>     *<a name="line.2008"></a>
-<span class="sourceLineNo">2009</span>     * read lock is compatible with read lock. ---&gt; no problem with user scan/read<a name="line.2009"></a>
-<span class="sourceLineNo">2010</span>     * region bulk load does not cause problem for compaction (no consistency problem, store lock<a name="line.2010"></a>
-<span class="sourceLineNo">2011</span>     *  will help the store file accounting).<a name="line.2011"></a>
-<span class="sourceLineNo">2012</span>     * They can run almost concurrently at the region level.<a name="line.2012"></a>
-<span class="sourceLineNo">2013</span>     *<a name="line.2013"></a>
-<span class="sourceLineNo">2014</span>     * The only remaining race condition is between the region close and compaction.<a name="line.2014"></a>
-<span class="sourceLineNo">2015</span>     * So we will evaluate, below, how region close intervenes with compaction if compaction does<a name="line.2015"></a>
-<span class="sourceLineNo">2016</span>     * not acquire region read lock.<a name="line.2016"></a>
-<span class="sourceLineNo">2017</span>     *<a name="line.2017"></a>
-<span class="sourceLineNo">2018</span>     * Here are the steps for compaction:<a name="line.2018"></a>
-<span class="sourceLineNo">2019</span>     * 1. obtain list of StoreFile's<a name="line.2019"></a>
-<span class="sourceLineNo">2020</span>     * 2. create StoreFileScanner's based on list from #1<a name="line.2020"></a>
-<span class="sourceLineNo">2021</span>     * 3. perform compaction and save resulting files under tmp dir<a name="line.2021"></a>
-<span class="sourceLineNo">2022</span>     * 4. swap in compacted files<a name="line.2022"></a>
-<span class="sourceLineNo">2023</span>     *<a name="line.2023"></a>
-<span class="sourceLineNo">2024</span>     * #1 is guarded by store lock. This patch does not change this --&gt; no worse or better<a name="line.2024"></a>
-<span class="sourceLineNo">2025</span>     * For #2, we obtain smallest read point (for region) across all the Scanners (for both default<a name="line.2025"></a>
-<span class="sourceLineNo">2026</span>     * compactor and stripe compactor).<a name="line.2026"></a>
-<span class="sourceLineNo">2027</span>     * The read points are for user scans. Region keeps the read points for all currently open<a name="line.2027"></a>
-<span class="sourceLineNo">2028</span>     * user scanners.<a name="line.2028"></a>
-<span class="sourceLineNo">2029</span>     * Compaction needs to know the smallest read point so that during re-write of the hfiles,<a name="line.2029"></a>
-<span class="sourceLineNo">2030</span>     * it can remove the mvcc points for the cells if their mvccs are older than the smallest<a name="line.2030"></a>
-<span class="sourceLineNo">2031</span>     * since they are not needed anymore.<a name="line.2031"></a>
-<span class="sourceLineNo">2032</span>     * This will not conflict with compaction.<a name="line.2032"></a>
-<span class="sourceLineNo">2033</span>     * For #3, it can be performed in parallel to other operations.<a name="line.2033"></a>
-<span class="sourceLineNo">2034</span>     * For #4 bulk load and compaction don't conflict with each other on the region level<a name="line.2034"></a>
-<span class="sourceLineNo">2035</span>     *   (for multi-family atomicy).<a name="line.2035"></a>
-<span class="sourceLineNo">2036</span>     * Region close and compaction are guarded pretty well by the 'writestate'.<a name="line.2036"></a>
-<span class="sourceLineNo">2037</span>     * In HRegion#doClose(), we have :<a name="line.2037"></a>
-<span class="sourceLineNo">2038</span>     * synchronized (writestate) {<a name="line.2038"></a>
-<span class="sourceLineNo">2039</span>     *   // Disable compacting and flushing by background threads for this<a name="line.2039"></a>
-<span class="sourceLineNo">2040</span>     *   // region.<a name="line.2040"></a>
-<span class="sourceLineNo">2041</span>     *   canFlush = !writestate.readOnly;<a name="line.2041"></a>
-<span class="sourceLineNo">2042</span>     *   writestate.writesEnabled = false;<a name="line.2042"></a>
-<span class="sourceLineNo">2043</span>     *   LOG.debug("Closing " + this + ": disabling compactions &amp; flushes");<a name="line.2043"></a>
-<span class="sourceLineNo">2044</span>     *   waitForFlushesAndCompactions();<a name="line.2044"></a>
-<span class="sourceLineNo">2045</span>     * }<a name="line.2045"></a>
-<span class="sourceLineNo">2046</span>     * waitForFlushesAndCompactions() would wait for writestate.compacting to come down to 0.<a name="line.2046"></a>
-<span class="sourceLineNo">2047</span>     * and in HRegion.compact()<a name="line.2047"></a>
-<span class="sourceLineNo">2048</span>     *  try {<a name="line.2048"></a>
-<span class="sourceLineNo">2049</span>     *    synchronized (writestate) {<a name="line.2049"></a>
-<span class="sourceLineNo">2050</span>     *    if (writestate.writesEnabled) {<a name="line.2050"></a>
-<span class="sourceLineNo">2051</span>     *      wasStateSet = true;<a name="line.2051"></a>
-<span class="sourceLineNo">2052</span>     *      ++writestate.compacting;<a name="line.2052"></a>
-<span class="sourceLineNo">2053</span>     *    } else {<a name="line.2053"></a>
-<span class="sourceLineNo">2054</span>     *      String msg = "NOT compacting region " + this + ". Writes disabled.";<a name="line.2054"></a>
-<span class="sourceLineNo">2055</span>     *      LOG.info(msg);<a name="line.2055"></a>
-<span class="sourceLineNo">2056</span>     *      status.abort(msg);<a name="line.2056"></a>
-<span class="sourceLineNo">2057</span>     *      return false;<a name="line.2057"></a>
-<span class="sourceLineNo">2058</span>     *    }<a name="line.2058"></a>
-<span class="sourceLineNo">2059</span>     *  }<a name="line.2059"></a>
-<span class="sourceLineNo">2060</span>     * Also in compactor.performCompaction():<a name="line.2060"></a>
-<span class="sourceLineNo">2061</span>     * check periodically to see if a system stop is requested<a name="line.2061"></a>
-<span class="sourceLineNo">2062</span>     * if (closeCheckInterval &gt; 0) {<a name="line.2062"></a>
-<span class="sourceLineNo">2063</span>     *   bytesWritten += len;<a name="line.2063"></a>
-<span class="sourceLineNo">2064</span>     *   if (bytesWritten &gt; closeCheckInterval) {<a name="line.2064"></a>
-<span class="sourceLineNo">2065</span>     *     bytesWritten = 0;<a name="line.2065"></a>
-<span class="sourceLineNo">2066</span>     *     if (!store.areWritesEnabled()) {<a name="line.2066"></a>
-<span class="sourceLineNo">2067</span>     *       progress.cancel();<a name="line.2067"></a>
-<span class="sourceLineNo">2068</span>     *       return false;<a name="line.2068"></a>
-<span class="sourceLineNo">2069</span>     *     }<a name="line.2069"></a>
-<span class="sourceLineNo">2070</span>     *   }<a name="line.2070"></a>
-<span class="sourceLineNo">2071</span>     * }<a name="line.2071"></a>
-<span class="sourceLineNo">2072</span>     */<a name="line.2072"></a>
-<span class="sourceLineNo">2073</span>    try {<a name="line.2073"></a>
-<span class="sourceLineNo">2074</span>      byte[] cf = Bytes.toBytes(store.getColumnFamilyName());<a name="line.2074"></a>
-<span class="sourceLineNo">2075</span>      if (stores.get(cf) != store) {<a name="line.2075"></a>
-<span class="sourceLineNo">2076</span>        LOG.warn("Store " + store.getColumnFamilyName() + " on region " + this<a name="line.2076"></a>
-<span class="sourceLineNo">2077</span>            + " has been re-instantiated, cancel this compaction request. "<a name="line.2077"></a>
-<span class="sourceLineNo">2078</span>            + " It may be caused by the roll back of split transaction");<a name="line.2078"></a>
-<span class="sourceLineNo">2079</span>        return false;<a name="line.2079"></a>
-<span class="sourceLineNo">2080</span>      }<a name="line.2080"></a>
-<span class="sourceLineNo">2081</span><a name="line.2081"></a>
-<span class="sourceLineNo">2082</span>      status = TaskMonitor.get().createStatus("Compacting " + store + " in " + this);<a name="line.2082"></a>
-<span class="sourceLineNo">2083</span>      if (this.closed.get()) {<a name="line.2083"></a>
-<span class="sourceLineNo">2084</span>        String msg = "Skipping compaction on " + this + " because closed";<a name="line.2084"></a>
-<span class="sourceLineNo">2085</span>        LOG.debug(msg);<a name="line.2085"></a>
-<span class="sourceLineNo">2086</span>        status.abort(msg);<a name="line.2086"></a>
-<span class="sourceLineNo">2087</span>        return false;<a name="line.2087"></a>
-<span class="sourceLineNo">2088</span>      }<a name="line.2088"></a>
-<span class="sourceLineNo">2089</span>      boolean wasStateSet = false;<a name="line.2089"></a>
-<span class="sourceLineNo">2090</span>      try {<a name="line.2090"></a>
-<span class="sourceLineNo">2091</span>        synchronized (writestate) {<a name="line.2091"></a>
-<span class="sourceLineNo">2092</span>          if (writestate.writesEnabled) {<a name="line.2092"></a>
-<span class="sourceLineNo">2093</span>            wasStateSet = true;<a name="line.2093"></a>
-<span class="sourceLineNo">2094</span>            writestate.compacting.incrementAndGet();<a name="line.2094"></a>
-<span class="sourceLineNo">2095</span>          } else {<a name="line.2095"></a>
-<span class="sourceLineNo">2096</span>            String msg = "NOT compacting region " + this + ". Writes disabled.";<a name="line.2096"></a>
-<span class="sourceLineNo">2097</span>            LOG.info(msg);<a name="line.2097"></a>
-<span class="sourceLineNo">2098</span>            status.abort(msg);<a name="line.2098"></a>
-<span class="sourceLineNo">2099</span>            return false;<a name="line.2099"></a>
-<span class="sourceLineNo">2100</span>          }<a name="line.2100"></a>
-<span class="sourceLineNo">2101</span>        }<a name="line.2101"></a>
-<span class="sourceLineNo">2102</span>        LOG.info("Starting compaction on " + store + " in region " + this<a name="line.2102"></a>
-<span class="sourceLineNo">2103</span>            + (compaction.getRequest().isOffPeak()?" as an off-peak compaction":""));<a name="line.2103"></a>
-<span class="sourceLineNo">2104</span>        doRegionCompactionPrep();<a name="line.2104"></a>
-<span class="sourceLineNo">2105</span>        try {<a name="line.2105"></a>
-<span class="sourceLineNo">2106</span>          status.setStatus("Compacting store " + store);<a name="line.2106"></a>
-<span class="sourceLineNo">2107</span>          // We no longer need to cancel the request on the way out of this<a name="line.2107"></a>
-<span class="sourceLineNo">2108</span>          // method because Store#compact will clean up unconditionally<a name="line.2108"></a>
-<span class="sourceLineNo">2109</span>          requestNeedsCancellation = false;<a name="line.2109"></a>
-<span class="sourceLineNo">2110</span>          store.compact(compaction, throughputController, user);<a name="line.2110"></a>
-<span class="sourceLineNo">2111</span>        } catch (InterruptedIOException iioe) {<a name="line.2111"></a>
-<span class="sourceLineNo">2112</span>          String msg = "compaction interrupted";<a name="line.2112"></a>
-<span class="sourceLineNo">2113</span>          LOG.info(msg, iioe);<a name="line.2113"></a>
-<span class="sourceLineNo">2114</span>          status.abort(msg);<a name="line.2114"></a>
-<span class="sourceLineNo">2115</span>          return false;<a name="line.2115"></a>
-<span class="sourceLineNo">2116</span>        }<a name="line.2116"></a>
-<span class="sourceLineNo">2117</span>      } finally {<a name="line.2117"></a>
-<span class="sourceLineNo">2118</span>        if (wasStateSet) {<a name="line.2118"></a>
-<span class="sourceLineNo">2119</span>          synchronized (writestate) {<a name="line.2119"></a>
-<span class="sourceLineNo">2120</span>            writestate.compacting.decrementAndGet();<a name="line.2120"></a>
-<span class="sourceLineNo">2121</span>            if (writestate.compacting.get() &lt;= 0) {<a name="line.2121"></a>
-<span class="sourceLineNo">2122</span>              writestate.notifyAll();<a name="line.2122"></a>
-<span class="sourceLineNo">2123</span>            }<a name="line.2123"></a>
-<span class="sourceLineNo">2124</span>          }<a name="line.2124"></a>
-<span class="sourceLineNo">2125</span>        }<a name="line.2125"></a>
-<span class="sourceLineNo">2126</span>      }<a name="line.2126"></a>
-<span class="sourceLineNo">2127</span>      status.markComplete("Compaction complete");<a name="line.2127"></a>
-<span class="sourceLineNo">2128</span>      return true;<a name="line.2128"></a>
-<span class="sourceLineNo">2129</span>    } finally {<a name="line.2129"></a>
-<span class="sourceLineNo">2130</span>      if (requestNeedsCancellation) store.cancelRequestedCompaction(compaction);<a name="line.2130"></a>
-<span class="sourceLineNo">2131</span>      if (status != null) status.cleanup();<a name="line.2131"></a>
-<span class="sourceLineNo">2132</span>    }<a name="line.2132"></a>
-<span class="sourceLineNo">2133</span>  }<a name="line.2133"></a>
-<span class="sourceLineNo">2134</span><a name="line.2134"></a>
-<span class="sourceLineNo">2135</span>  @Override<a name="line.2135"></a>
-<span class="sourceLineNo">2136</span>  public FlushResult flush(boolean force) throws IOException {<a name="line.2136"></a>
-<span class="sourceLineNo">2137</span>    return flushcache(force, false);<a name="line.2137"></a>
-<span class="sourceLineNo">2138</span>  }<a name="line.2138"></a>
-<span class="sourceLineNo">2139</span><a name="line.2139"></a>
-<span class="sourceLineNo">2140</span>  /**<a name="line.2140"></a>
-<span class="sourceLineNo">2141</span>   * Flush the cache.<a name="line.2141"></a>
-<span class="sourceLineNo">2142</span>   *<a name="line.2142"></a>
-<span class="sourceLineNo">2143</span>   * When this method is called the cache will be flushed unless:<a name="line.2143"></a>
-<span class="sourceLineNo">2144</span>   * &lt;ol&gt;<a name="line.2144"></a>
-<span class="sourceLineNo">2145</span>   *   &lt;li&gt;the cache is empty&lt;/li&gt;<a name="line.2145"></a>
-<span class="sourceLineNo">2146</span>   *   &lt;li&gt;the region is closed.&lt;/li&gt;<a name="line.2146"></a>
-<span class="sourceLineNo">2147</span>   *   &lt;li&gt;a flush is already in progress&lt;/li&gt;<a name="line.2147"></a>
-<span class="sourceLineNo">2148</span>   *   &lt;li&gt;writes are disabled&lt;/li&gt;<a name="line.2148"></a>
-<span class="sourceLineNo">2149</span>   * &lt;/ol&gt;<a name="line.2149"></a>
-<span class="sourceLineNo">2150</span>   *<a name="line.2150"></a>
-<span class="sourceLineNo">2151</span>   * &lt;p&gt;This method may block for some time, so it should not be called from a<a name="line.2151"></a>
-<span class="sourceLineNo">2152</span>   * time-sensitive thread.<a name="line.2152"></a>
-<span class="sourceLineNo">2153</span>   * @param forceFlushAllStores whether we want to flush all stores<a name="line.2153"></a>
-<span class="sourceLineNo">2154</span>   * @param writeFlushRequestWalMarker whether to write the flush request marker to WAL<a name="line.2154"></a>
-<span class="sourceLineNo">2155</span>   * @return whether the flush is success and whether the region needs compacting<a name="line.2155"></a>
-<span class="sourceLineNo">2156</span>   *<a name="line.2156"></a>
-<span class="sourceLineNo">2157</span>   * @throws IOException general io exceptions<a name="line.2157"></a>
-<span class="sourceLineNo">2158</span>   * @throws DroppedSnapshotException Thrown when replay of wal is required<a name="line.2158"></a>
-<span class="sourceLineNo">2159</span>   * because a Snapshot was not properly persisted. The region is put in closing mode, and the<a name="line.2159"></a>
-<span class="sourceLineNo">2160</span>   * caller MUST abort after this.<a name="line.2160"></a>
-<span class="sourceLineNo">2161</span>   */<a name="line.2161"></a>
-<span class="sourceLineNo">2162</span>  public FlushResult flushcache(boolean forceFlushAllStores, boolean writeFlushRequestWalMarker)<a name="line.2162"></a>
-<span class="sourceLineNo">2163</span>      throws IOException {<a name="line.2163"></a>
-<span class="sourceLineNo">2164</span>    // fail-fast instead of waiting on the lock<a name="line.2164"></a>
-<span class="sourceLineNo">2165</span>    if (this.closing.get()) {<a name="line.2165"></a>
-<span class="sourceLineNo">2166</span>      String msg = "Skipping flush on " + this + " because closing";<a name="line.2166"></a>
-<span class="sourceLineNo">2167</span>      LOG.debug(msg);<a name="line.2167"></a>
-<span class="sourceLineNo">2168</span>      return new FlushResultImpl(FlushResult.Result.CANNOT_FLUSH, msg, false);<a name="line.2168"></a>
-<span class="sourceLineNo">2169</span>    }<a name="line.2169"></a>
-<span class="sourceLineNo">2170</span>    MonitoredTask status = TaskMonitor.get().createStatus("Flushing " + this);<a name="line.2170"></a>
-<span class="sourceLineNo">2171</span>    status.setStatus("Acquiring readlock on region");<a name="line.2171"></a>
-<span class="sourceLineNo">2172</span>    // block waiting for the lock for flushing cache<a name="line.2172"></a>
-<span class="sourceLineNo">2173</span>    lock.readLock().lock();<a name="line.2173"></a>
-<span class="sourceLineNo">2174</span>    try {<a name="line.2174"></a>
-<span class="sourceLineNo">2175</span>      if (this.closed.get()) {<a name="line.2175"></a>
-<span class="sourceLineNo">2176</span>        String msg = "Skipping flush on " + this + " because closed";<a name="line.2176"></a>
-<span class="sourceLineNo">2177</span>        LOG.debug(msg);<a name="line.2177"></a>
-<span class="sourceLineNo">2178</span>        status.abort(msg);<a name="line.2178"></a>
-<span class="sourceLineNo">2179</span>        return new FlushResultImpl(FlushResult.Result.CANNOT_FLUSH, msg, false);<a name="line.2179"></a>
-<span class="sourceLineNo">2180</span>      }<a name="line.2180"></a>
-<span class="sourceLineNo">2181</span>      if (coprocessorHost != null) {<a name="line.2181"></a>
-<span class="sourceLineNo">2182</span>        status.setStatus("Running coprocessor pre-flush hooks");<a name="line.2182"></a>
-<span class="sourceLineNo">2183</span>        coprocessorHost.preFlush();<a name="line.2183"></a>
-<span class="sourceLineNo">2184</span>      }<a name="line.2184"></a>
-<span class="sourceLineNo">2185</span>      // TODO: this should be managed within memstore with the snapshot, updated only after flush<a name="line.2185"></a>
-<span class="sourceLineNo">2186</span>      // successful<a name="line.2186"></a>
-<span class="sourceLineNo">2187</span>      if (numMutationsWithoutWAL.sum() &gt; 0) {<a name="line.2187"></a>
-<span class="sourceLineNo">2188</span>        numMutationsWithoutWAL.reset();<a name="line.2188"></a>
-<span class="sourceLineNo">2189</span>        dataInMemoryWithoutWAL.reset();<a name="line.2189"></a>
-<span class="sourceLineNo">2190</span>      }<a name="line.2190"></a>
-<span class="sourceLineNo">2191</span>      synchronized (writestate) {<a name="line.2191"></a>
-<span class="sourceLineNo">2192</span>        if (!writestate.flushing &amp;&amp; writestate.writesEnabled) {<a name="line.2192"></a>
-<span class="sourceLineNo">2193</span>          this.writestate.flushing = true;<a name="line.2193"></a>
-<span class="sourceLineNo">2194</span>        } else {<a name="line.2194"></a>
-<span class="sourceLineNo">2195</span>          if (LOG.isDebugEnabled()) {<a name="line.2195"></a>
-<span class="sourceLineNo">2196</span>            LOG.debug("NOT flushing memstore for region " + this<a name="line.2196"></a>
-<span class="sourceLineNo">2197</span>                + ", flushing=" + writestate.flushing + ", writesEnabled="<a name="line.2197"></a>
-<span class="sourceLineNo">2198</span>                + writestate.writesEnabled);<a name="line.2198"></a>
-<span class="sourceLineNo">2199</span>          }<a name="line.2199"></a>
-<span class="sourceLineNo">2200</span>          String msg = "Not flushing since "<a name="line.2200"></a>
-<span class="sourceLineNo">2201</span>              + (writestate.flushing ? "already flushing"<a name="line.2201"></a>
-<span class="sourceLineNo">2202</span>              : "writes not enabled");<a name="line.2202"></a>
-<span class="sourceLineNo">2203</span>          status.abort(msg);<a name="line.2203"></a>
-<span class="sourceLineNo">2204</span>          return new FlushResultImpl(FlushResult.Result.CANNOT_FLUSH, msg, false);<a name="line.2204"></a>
-<span class="sourceLineNo">2205</span>        }<a name="line.2205"></a>
-<span class="sourceLineNo">2206</span>      }<a name="line.2206"></a>
-<span class="sourceLineNo">2207</span><a name="line.2207"></a>
-<span class="sourceLineNo">2208</span>      try {<a name="line.2208"></a>
-<span class="sourceLineNo">2209</span>        Collection&lt;Store&gt; specificStoresToFlush =<a name="line.2209"></a>
-<span class="sourceLineNo">2210</span>            forceFlushAllStores ? stores.values() : flushPolicy.selectStoresToFlush();<a name="line.2210"></a>
-<span class="sourceLineNo">2211</span>        FlushResult fs = internalFlushcache(specificStoresToFlush,<a name="line.2211"></a>
-<span class="sourceLineNo">2212</span>          status, writeFlushRequestWalMarker);<a name="line.2212"></a>
-<span class="sourceLineNo">2213</span><a name="line.2213"></a>
-<span class="sourceLineNo">2214</span>        if (coprocessorHost != null) {<a name="line.2214"></a>
-<span class="sourceLineNo">2215</span>          status.setStatus("Running post-flush coprocessor hooks");<a name="line.2215"></a>
-<span class="sourceLineNo">2216</span>          coprocessorHost.postFlush();<a name="line.2216"></a>
-<span class="sourceLineNo">2217</span>        }<a name="line.2217"></a>
-<span class="sourceLineNo">2218</span><a name="line.2218"></a>
-<span class="sourceLineNo">2219</span>        status.markComplete("Flush successful");<a name="line.2219"></a>
-<span class="sourceLineNo">2220</span>        return fs;<a name="line.2220"></a>
-<span class="sourceLineNo">2221</span>      } finally {<a name="line.2221"></a>
-<span class="sourceLineNo">2222</span>        synchronized (writestate) {<a name="line.2222"></a>
-<span class="sourceLineNo">2223</span>          writestate.flushing = false;<a name="line.2223"></a>
-<span class="sourceLineNo">2224</span>          this.writestate.flushRequested = false;<a name="line.2224"></a>
-<span class="sourceLineNo">2225</span>          writestate.notifyAll();<a name="line.2225"></a>
-<span class="sourceLineNo">2226</span>        }<a name="line.2226"></a>
-<span class="sourceLineNo">2227</span>      }<a name="line.2227"></a>
-<span class="sourceLineNo">2228</span>    } finally {<a name="line.2228"></a>
-<span class="sourceLineNo">2229</span>      lock.readLock().unlock();<a name="line.2229"></a>
-<span class="sourceLineNo">2230</span>      status.cleanup();<a name="line.2230"></a>
-<span class="sourceLineNo">2231</span>    }<a name="line.2231"></a>
-<span class="sourceLineNo">2232</span>  }<a name="line.2232"></a>
-<span class="sourceLineNo">2233</span><a name="line.2233"></a>
-<span class="sourceLineNo">2234</span>  /**<a name="line.2234"></a>
-<span class="sourceLineNo">2235</span>   * Should the store be flushed because it is old enough.<a name="line.2235"></a>
-<span class="sourceLineNo">2236</span>   * &lt;p&gt;<a name="line.2236"></a>
-<span class="sourceLineNo">2237</span>   * Every FlushPolicy should call this to determine whether a store is old enough to flush (except<a name="line.2237"></a>
-<span class="sourceLineNo">2238</span>   * that you always flush all stores). Otherwise the method will always<a name="line.2238"></a>
-<span class="sourceLineNo">2239</span>   * returns true which will make a lot of flush requests.<a name="line.2239"></a>
-<span class="sourceLineNo">2240</span>   */<a name="line.2240"></a>
-<span class="sourceLineNo">2241</span>  boolean shouldFlushStore(Store store) {<a name="line.2241"></a>
-<span class="sourceLineNo">2242</span>    long earliest = this.wal.getEarliestMemstoreSeqNum(getRegionInfo().getEncodedNameAsBytes(),<a name="line.2242"></a>
-<span class="sourceLineNo">2243</span>      store.getFamily().getName()) - 1;<a name="line.2243"></a>
-<span class="sourceLineNo">2244</span>    if (earliest &gt; 0 &amp;&amp; earliest + flushPerChanges &lt; mvcc.getReadPoint()) {<a name="line.2244"></a>
-<span class="sourceLineNo">2245</span>      if (LOG.isDebugEnabled()) {<a name="line.2245"></a>
-<span class="sourceLineNo">2246</span>        LOG.debug("Flush column family " + store.getColumnFamilyName() + " of " +<a name="line.2246"></a>
-<span class="sourceLineNo">2247</span>          getRegionInfo().getEncodedName() + " because unflushed sequenceid=" + earliest +<a name="line.2247"></a>
-<span class="sourceLineNo">2248</span>          " is &gt; " + this.flushPerChanges + " from current=" + mvcc.getReadPoint());<a name="line.2248"></a>
-<span class="sourceLineNo">2249</span>      }<a name="line.2249"></a>
-<span class="sourceLineNo">2250</span>      return true;<a name="line.2250"></a>
-<span class="sourceLineNo">2251</span>    }<a name="line.2251"></a>
-<span class="sourceLineNo">2252</span>    if (this.flushCheckInterval &lt;= 0) {<a name="line.2252"></a>
-<span class="sourceLineNo">2253</span>      return false;<a name="line.2253"></a>
-<span class="sourceLineNo">2254</span>    }<a name="line.2254"></a>
-<span class="sourceLineNo">2255</span>    long now = EnvironmentEdgeManager.currentTime();<a name="line.2255"></a>
-<span class="sourceLineNo">2256</span>    if (store.timeOfOldestEdit() &lt; now - this.flushCheckInterval) {<a name="line.2256"></a>
-<span class="sourceLineNo">2257</span>      if (LOG.isDebugEnabled()) {<a name="line.2257"></a>
-<span class="sourceLineNo">2258</span>        LOG.debug("Flush column family: " + store.getColumnFamilyName() + " of " +<a name="line.2258"></a>
-<span class="sourceLineNo">2259</span>          getRegionInfo().getEncodedName() + " because time of oldest edit=" +<a name="line.2259"></a>
-<span class="sourceLineNo">2260</span>            store.timeOfOldestEdit() + " is &gt; " + this.flushCheckInterval + " from now =" + now);<a name="line.2260"></a>
-<span class="sourceLineNo">2261</span>      }<a name="line.2261"></a>
-<span class="sourceLineNo">2262</span>      return true;<a name="line.2262"></a>
-<span class="sourceLineNo">2263</span>    }<a name="line.2263"></a>
-<span class="sourceLineNo">2264</span>    return false;<a name="line.2264"></a>
-<span class="sourceLineNo">2265</span>  }<a name="line.2265"></a>
-<span class="sourceLineNo">2266</span><a name="line.2266"></a>
-<span class="sourceLineNo">2267</span>  /**<a name="line.2267"></a>
-<span class="sourceLineNo">2268</span>   * Should the memstore be flushed now<a name="line.2268"></a>
-<span class="sourceLineNo">2269</span>   */<a name="line.2269"></a>
-<span class="sourceLineNo">2270</span>  boolean shouldFlush(final StringBuffer whyFlush) {<a name="line.2270"></a>
-<span class="sourceLineNo">2271</span>    whyFlush.setLength(0);<a name="line.2271"></a>
-<span class="sourceLineNo">2272</span>    // This is a rough measure.<a name="line.2272"></a>
-<span class="sourceLineNo">2273</span>    if (this.maxFlushedSeqId &gt; 0<a name="line.2273"></a>
-<span class="sourceLineNo">2274</span>          &amp;&amp; (this.maxFlushedSeqId + this.flushPerChanges &lt; this.mvcc.getReadPoint())) {<a name="line.2274"></a>
-<span class="sourceLineNo">2275</span>      whyFlush.append("more than max edits, " + this.flushPerChanges + ", since last flush");<a name="line.2275"></a>
-<span class="sourceLineNo">2276</span>      return true;<a name="line.2276"></a>
-<span class="sourceLineNo">2277</span>    }<a name="line.2277"></a>
-<span class="sourceLineNo">2278</span>    long modifiedFlushCheckInterval = flushCheckInterval;<a name="line.2278"></a>
-<span class="sourceLineNo">2279</span>    if (getRegionInfo().isSystemTable() &amp;&amp;<a name="line.2279"></a>
-<span class="sourceLineNo">2280</span>        getRegionInfo().getReplicaId() == HRegionInfo.DEFAULT_REPLICA_ID) {<a name="line.2280"></a>
-<span class="sourceLineNo">2281</span>      modifiedFlushCheckInterval = SYSTEM_CACHE_FLUSH_INTERVAL;<a name="line.2281"></a>
+<span class="sourceLineNo">1997</span>  }<a name="line.1997"></a>
+<span class="sourceLineNo">1998</span><a name="line.1998"></a>
+<span class="sourceLineNo">1999</span>  /*<a name="line.1999"></a>
+<span class="sourceLineNo">2000</span>   * Called by compaction thread and after region is opened to compact the<a name="line.2000"></a>
+<span class="sourceLineNo">2001</span>   * HStores if necessary.<a name="line.2001"></a>
+<span class="sourceLineNo">2002</span>   *<a name="line.2002"></a>
+<span class="sourceLineNo">2003</span>   * &lt;p&gt;This operation could block for a long time, so don't call it from a<a name="line.2003"></a>
+<span class="sourceLineNo">2004</span>   * time-sensitive thread.<a name="line.2004"></a>
+<span class="sourceLineNo">2005</span>   *<a name="line.2005"></a>
+<span class="sourceLineNo">2006</span>   * Note that no locking is necessary at this level because compaction only<a name="line.2006"></a>
+<span class="sourceLineNo">2007</span>   * conflicts with a region split, and that cannot happen because the region<a name="line.2007"></a>
+<span class="sourceLineNo">2008</span>   * server does them sequentially and not in parallel.<a name="line.2008"></a>
+<span class="sourceLineNo">2009</span>   *<a name="line.2009"></a>
+<span class="sourceLineNo">2010</span>   * @param compaction Compaction details, obtained by requestCompaction()<a name="line.2010"></a>
+<span class="sourceLineNo">2011</span>   * @param throughputController<a name="line.2011"></a>
+<span class="sourceLineNo">2012</span>   * @return whether the compaction completed<a name="line.2012"></a>
+<span class="sourceLineNo">2013</span>   */<a name="line.2013"></a>
+<span class="sourceLineNo">2014</span>  public boolean compact(CompactionContext compaction, Store store,<a name="line.2014"></a>
+<span class="sourceLineNo">2015</span>      ThroughputController throughputController) throws IOException {<a name="line.2015"></a>
+<span class="sourceLineNo">2016</span>    return compact(compaction, store, throughputController, null);<a name="line.2016"></a>
+<span class="sourceLineNo">2017</span>  }<a name="line.2017"></a>
+<span class="sourceLineNo">2018</span><a name="line.2018"></a>
+<span class="sourceLineNo">2019</span>  public boolean compact(CompactionContext compaction, Store store,<a name="line.2019"></a>
+<span class="sourceLineNo">2020</span>      ThroughputController throughputController, User user) throws IOException {<a name="line.2020"></a>
+<span class="sourceLineNo">2021</span>    assert compaction != null &amp;&amp; compaction.hasSelection();<a name="line.2021"></a>
+<span class="sourceLineNo">2022</span>    assert !compaction.getRequest().getFiles().isEmpty();<a name="line.2022"></a>
+<span class="sourceLineNo">2023</span>    if (this.closing.get() || this.closed.get()) {<a name="line.2023"></a>
+<span class="sourceLineNo">2024</span>      LOG.debug("Skipping compaction on " + this + " because closing/closed");<a name="line.2024"></a>
+<span class="sourceLineNo">2025</span>      store.cancelRequestedCompaction(compaction);<a name="line.2025"></a>
+<span class="sourceLineNo">2026</span>      return false;<a name="line.2026"></a>
+<span class="sourceLineNo">2027</span>    }<a name="line.2027"></a>
+<span class="sourceLineNo">2028</span>    MonitoredTask status = null;<a name="line.2028"></a>
+<span class="sourceLineNo">2029</span>    boolean requestNeedsCancellation = true;<a name="line.2029"></a>
+<span class="sourceLineNo">2030</span>    /*<a name="line.2030"></a>
+<span class="sourceLineNo">2031</span>     * We are trying to remove / relax the region read lock for compaction.<a name="line.2031"></a>
+<span class="sourceLineNo">2032</span>     * Let's see what are the potential race conditions among the operations (user scan,<a name="line.2032"></a>
+<span class="sourceLineNo">2033</span>     * region split, region close and region bulk load).<a name="line.2033"></a>
+<span class="sourceLineNo">2034</span>     *<a name="line.2034"></a>
+<span class="sourceLineNo">2035</span>     *  user scan ---&gt; region read lock<a name="line.2035"></a>
+<span class="sourceLineNo">2036</span>     *  region split --&gt; region close first --&gt; region write lock<a name="line.2036"></a>
+<span class="sourceLineNo">2037</span>     *  region close --&gt; region write lock<a name="line.2037"></a>
+<span class="sourceLineNo">2038</span>     *  region bulk load --&gt; region write lock<a name="line.2038"></a>
+<span class="sourceLineNo">2039</span>     *<a name="line.2039"></a>
+<span class="sourceLineNo">2040</span>     * read lock is compatible with read lock. ---&gt; no problem with user scan/read<a name="line.2040"></a>
+<span class="sourceLineNo">2041</span>     * region bulk load does not cause problem for compaction (no consistency problem, store lock<a name="line.2041"></a>
+<span class="sourceLineNo">2042</span>     *  will help the store file accounting).<a name="line.2042"></a>
+<span class="sourceLineNo">2043</span>     * They can run almost concurrently at the region level.<a name="line.2043"></a>
+<span class="sourceLineNo">2044</span>     *<a name="line.2044"></a>
+<span class="sourceLineNo">2045</span>     * The only remaining race condition is between the region close and compaction.<a name="line.2045"></a>
+<span class="sourceLineNo">2046</span>     * So we will evaluate, below, how region close intervenes with compaction if compaction does<a name="line.2046"></a>
+<span class="sourceLineNo">2047</span>     * not acquire region read lock.<a name="line.2047"></a>
+<span class="sourceLineNo">2048</span>     *<a name="line.2048"></a>
+<span class="sourceLineNo">2049</span>     * Here are the steps for compaction:<a name="line.2049"></a>
+<span class="sourceLineNo">2050</span>     * 1. obtain list of StoreFile's<a name="line.2050"></a>
+<span class="sourceLineNo">2051</span>     * 2. create StoreFileScanner's based on list from #1<a name="line.2051"></a>
+<span class="sourceLineNo">2052</span>     * 3. perform compaction and save resulting files under tmp dir<a name="line.2052"></a>
+<span class="sourceLineNo">2053</span>     * 4. swap in compacted files<a name="line.2053"></a>
+<span class="sourceLineNo">2054</span>     *<a name="line.2054"></a>
+<span class="sourceLineNo">2055</span>     * #1 is guarded by store lock. This patch does not change this --&gt; no worse or better<a name="line.2055"></a>
+<span class="sourceLineNo">2056</span>     * For #2, we obtain smallest read point (for region) across all the Scanners (for both default<a name="line.2056"></a>
+<span class="sourceLineNo">2057</span>     * compactor and stripe compactor).<a name="line.2057"></a>
+<span class="sourceLineNo">2058</span>     * The read points are for user scans. Region keeps the read points for all currently open<a name="line.2058"></a>
+<span class="sourceLineNo">2059</span>     * user scanners.<a name="line.2059"></a>
+<span class="sourceLineNo">2060</span>     * Compaction needs to know the smallest read point so that during re-write of the hfiles,<a name="line.2060"></a>
+<span class="sourceLineNo">2061</span>     * it can remove the mvcc points for the cells if their mvccs are older than the smallest<a name="line.2061"></a>
+<span class="sourceLineNo">2062</span>     * since they are not needed anymore.<a name="line.2062"></a>
+<span class="sourceLineNo">2063</span>     * This will not conflict with compaction.<a name="line.2063"></a>
+<span class="sourceLineNo">2064</span>     * For #3, it can be performed in parallel to other operations.<a name="line.2064"></a>
+<span class="sourceLineNo">2065</span>     * For #4 bulk load and compaction don't conflict with each other on the region level<a name="line.2065"></a>
+<span class="sourceLineNo">2066</span>     *   (for multi-family atomicy).<a name="line.2066"></a>
+<span class="sourceLineNo">2067</span>     * Region close and compaction are guarded pretty well by the 'writestate'.<a name="line.2067"></a>
+<span class="sourceLineNo">2068</span>     * In HRegion#doClose(), we have :<a name="line.2068"></a>
+<span class="sourceLineNo">2069</span>     * synchronized (writestate) {<a name="line.2069"></a>
+<span class="sourceLineNo">2070</span>     *   // Disable compacting and flushing by background threads for this<a name="line.2070"></a>
+<span class="sourceLineNo">2071</span>     *   // region.<a name="line.2071"></a>
+<span class="sourceLineNo">2072</span>     *   canFlush = !writestate.readOnly;<a name="line.2072"></a>
+<span class="sourceLineNo">2073</span>     *   writestate.writesEnabled = false;<a name="line.2073"></a>
+<span class="sourceLineNo">2074</span>     *   LOG.debug("Closing " + this + ": disabling compactions &amp; flushes");<a name="line.2074"></a>
+<span class="sourceLineNo">2075</span>     *   waitForFlushesAndCompactions();<a name="line.2075"></a>
+<span class="sourceLineNo">2076</span>     * }<a name="line.2076"></a>
+<span class="sourceLineNo">2077</span>     * waitForFlushesAndCompactions() would wait for writestate.compacting to come down to 0.<a name="line.2077"></a>
+<span class="sourceLineNo">2078</span>     * and in HRegion.compact()<a name="line.2078"></a>
+<span class="sourceLineNo">2079</span>     *  try {<a name="line.2079"></a>
+<span class="sourceLineNo">2080</span>     *    synchronized (writestate) {<a name="line.2080"></a>
+<span class="sourceLineNo">2081</span>     *    if (writestate.writesEnabled) {<a name="line.2081"></a>
+<span class="sourceLineNo">2082</span>     *      wasStateSet = true;<a name="line.2082"></a>
+<span class="sourceLineNo">2083</span>     *      ++writestate.compacting;<a name="line.2083"></a>
+<span class="sourceLineNo">2084</span>     *    } else {<a name="line.2084"></a>
+<span class="sourceLineNo">2085</span>     *      String msg = "NOT compacting region " + this + ". Writes disabled.";<a name="line.2085"></a>
+<span class="sourceLineNo">2086</span>     *      LOG.info(msg);<a name="line.2086"></a>
+<span class="sourceLineNo">2087</span>     *      status.abort(msg);<a name="line.2087"></a>
+<span class="sourceLineNo">2088</span>     *      return false;<a name="line.2088"></a>
+<span class="sourceLineNo">2089</span>     *    }<a name="line.2089"></a>
+<span class="sourceLineNo">2090</span>     *  }<a name="line.2090"></a>
+<span class="sourceLineNo">2091</span>     * Also in compactor.performCompaction():<a name="line.2091"></a>
+<span class="sourceLineNo">2092</span>     * check periodically to see if a system stop is requested<a name="line.2092"></a>
+<span class="sourceLineNo">2093</span>     * if (closeCheckInterval &gt; 0) {<a name="line.2093"></a>
+<span class="sourceLineNo">2094</span>     *   bytesWritten += len;<a name="line.2094"></a>
+<span class="sourceLineNo">2095</span>     *   if (bytesWritten &gt; closeCheckInterval) {<a name="line.2095"></a>
+<span class="sourceLineNo">2096</span>     *     bytesWritten = 0;<a name="line.2096"></a>
+<span class="sourceLineNo">2097</span>     *     if (!store.areWritesEnabled()) {<a name="line.2097"></a>
+<span class="sourceLineNo">2098</span>     *       progress.cancel();<a name="line.2098"></a>
+<span class="sourceLineNo">2099</span>     *       return false;<a name="line.2099"></a>
+<span class="sourceLineNo">2100</span>     *     }<a name="line.2100"></a>
+<span class="sourceLineNo">2101</span>     *   }<a name="line.2101"></a>
+<span class="sourceLineNo">2102</span>     * }<a name="line.2102"></a>
+<span class="sourceLineNo">2103</span>     */<a name="line.2103"></a>
+<span class="sourceLineNo">2104</span>    try {<a name="line.2104"></a>
+<span class="sourceLineNo">2105</span>      byte[] cf = Bytes.toBytes(store.getColumnFamilyName());<a name="line.2105"></a>
+<span class="sourceLineNo">2106</span>      if (stores.get(cf) != store) {<a name="line.2106"></a>
+<span class="sourceLineNo">2107</span>        LOG.warn("Store " + store.getColumnFamilyName() + " on region " + this<a name="line.2107"></a>
+<span class="sourceLineNo">2108</span>            + " has been re-instantiated, cancel this compaction request. "<a name="line.2108"></a>
+<span class="sourceLineNo">2109</span>            + " It may be caused by the roll back of split transaction");<a name="line.2109"></a>
+<span class="sourceLineNo">2110</span>        return false;<a name="line.2110"></a>
+<span class="sourceLineNo">2111</span>      }<a name="line.2111"></a>
+<span class="sourceLineNo">2112</span><a name="line.2112"></a>
+<span class="sourceLineNo">2113</span>      status = TaskMonitor.get().createStatus("Compacting " + store + " in " + this);<a name="line.2113"></a>
+<span class="sourceLineNo">2114</span>      if (this.closed.get()) {<a name="line.2114"></a>
+<span class="sourceLineNo">2115</span>        String msg = "Skipping compaction on " + this + " because closed";<a name="line.2115"></a>
+<span class="sourceLineNo">2116</span>        LOG.debug(msg);<a name="line.2116"></a>
+<span class="sourceLineNo">2117</span>        status.abort(msg);<a name="line.2117"></a>
+<span class="sourceLineNo">2118</span>        return false;<a name="line.2118"></a>
+<span class="sourceLineNo">2119</span>      }<a name="line.2119"></a>

<TRUNCATED>

Mime
View raw message