http://git-wip-us.apache.org/repos/asf/hbase-site/blob/d851cda6/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HStore.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HStore.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HStore.html index c82bf55..172b7a3 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HStore.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HStore.html @@ -1718,1082 +1718,1081 @@ <span class="sourceLineNo">1710</span><a name="line.1710"></a> <span class="sourceLineNo">1711</span> @Override<a name="line.1711"></a> <span class="sourceLineNo">1712</span> public boolean hasReferences() {<a name="line.1712"></a> -<span class="sourceLineNo">1713</span> List<HStoreFile> reloadedStoreFiles = null;<a name="line.1713"></a> -<span class="sourceLineNo">1714</span> // Grab the read lock here, because we need to ensure that: only when the atomic<a name="line.1714"></a> -<span class="sourceLineNo">1715</span> // replaceStoreFiles(..) finished, we can get all the complete store file list.<a name="line.1715"></a> -<span class="sourceLineNo">1716</span> this.lock.readLock().lock();<a name="line.1716"></a> -<span class="sourceLineNo">1717</span> try {<a name="line.1717"></a> -<span class="sourceLineNo">1718</span> // Merge the current store files with compacted files here due to HBASE-20940.<a name="line.1718"></a> -<span class="sourceLineNo">1719</span> Collection<HStoreFile> allStoreFiles = new ArrayList<>(getStorefiles());<a name="line.1719"></a> -<span class="sourceLineNo">1720</span> allStoreFiles.addAll(getCompactedFiles());<a name="line.1720"></a> -<span class="sourceLineNo">1721</span> return StoreUtils.hasReferences(allStoreFiles);<a name="line.1721"></a> -<span class="sourceLineNo">1722</span> } finally {<a name="line.1722"></a> -<span class="sourceLineNo">1723</span> this.lock.readLock().unlock();<a name="line.1723"></a> -<span class="sourceLineNo">1724</span> }<a name="line.1724"></a> -<span class="sourceLineNo">1725</span> }<a name="line.1725"></a> -<span class="sourceLineNo">1726</span><a name="line.1726"></a> -<span class="sourceLineNo">1727</span> /**<a name="line.1727"></a> -<span class="sourceLineNo">1728</span> * getter for CompactionProgress object<a name="line.1728"></a> -<span class="sourceLineNo">1729</span> * @return CompactionProgress object; can be null<a name="line.1729"></a> -<span class="sourceLineNo">1730</span> */<a name="line.1730"></a> -<span class="sourceLineNo">1731</span> public CompactionProgress getCompactionProgress() {<a name="line.1731"></a> -<span class="sourceLineNo">1732</span> return this.storeEngine.getCompactor().getProgress();<a name="line.1732"></a> -<span class="sourceLineNo">1733</span> }<a name="line.1733"></a> -<span class="sourceLineNo">1734</span><a name="line.1734"></a> -<span class="sourceLineNo">1735</span> @Override<a name="line.1735"></a> -<span class="sourceLineNo">1736</span> public boolean shouldPerformMajorCompaction() throws IOException {<a name="line.1736"></a> -<span class="sourceLineNo">1737</span> for (HStoreFile sf : this.storeEngine.getStoreFileManager().getStorefiles()) {<a name="line.1737"></a> -<span class="sourceLineNo">1738</span> // TODO: what are these reader checks all over the place?<a name="line.1738"></a> -<span class="sourceLineNo">1739</span> if (sf.getReader() == null) {<a name="line.1739"></a> -<span class="sourceLineNo">1740</span> LOG.debug("StoreFile {} has null Reader", sf);<a name="line.1740"></a> -<span class="sourceLineNo">1741</span> return false;<a name="line.1741"></a> -<span class="sourceLineNo">1742</span> }<a name="line.1742"></a> -<span class="sourceLineNo">1743</span> }<a name="line.1743"></a> -<span class="sourceLineNo">1744</span> return storeEngine.getCompactionPolicy().shouldPerformMajorCompaction(<a name="line.1744"></a> -<span class="sourceLineNo">1745</span> this.storeEngine.getStoreFileManager().getStorefiles());<a name="line.1745"></a> -<span class="sourceLineNo">1746</span> }<a name="line.1746"></a> -<span class="sourceLineNo">1747</span><a name="line.1747"></a> -<span class="sourceLineNo">1748</span> public Optional<CompactionContext> requestCompaction() throws IOException {<a name="line.1748"></a> -<span class="sourceLineNo">1749</span> return requestCompaction(NO_PRIORITY, CompactionLifeCycleTracker.DUMMY, null);<a name="line.1749"></a> -<span class="sourceLineNo">1750</span> }<a name="line.1750"></a> -<span class="sourceLineNo">1751</span><a name="line.1751"></a> -<span class="sourceLineNo">1752</span> public Optional<CompactionContext> requestCompaction(int priority,<a name="line.1752"></a> -<span class="sourceLineNo">1753</span> CompactionLifeCycleTracker tracker, User user) throws IOException {<a name="line.1753"></a> -<span class="sourceLineNo">1754</span> // don't even select for compaction if writes are disabled<a name="line.1754"></a> -<span class="sourceLineNo">1755</span> if (!this.areWritesEnabled()) {<a name="line.1755"></a> -<span class="sourceLineNo">1756</span> return Optional.empty();<a name="line.1756"></a> -<span class="sourceLineNo">1757</span> }<a name="line.1757"></a> -<span class="sourceLineNo">1758</span> // Before we do compaction, try to get rid of unneeded files to simplify things.<a name="line.1758"></a> -<span class="sourceLineNo">1759</span> removeUnneededFiles();<a name="line.1759"></a> -<span class="sourceLineNo">1760</span><a name="line.1760"></a> -<span class="sourceLineNo">1761</span> final CompactionContext compaction = storeEngine.createCompaction();<a name="line.1761"></a> -<span class="sourceLineNo">1762</span> CompactionRequestImpl request = null;<a name="line.1762"></a> -<span class="sourceLineNo">1763</span> this.lock.readLock().lock();<a name="line.1763"></a> -<span class="sourceLineNo">1764</span> try {<a name="line.1764"></a> -<span class="sourceLineNo">1765</span> synchronized (filesCompacting) {<a name="line.1765"></a> -<span class="sourceLineNo">1766</span> // First, see if coprocessor would want to override selection.<a name="line.1766"></a> -<span class="sourceLineNo">1767</span> if (this.getCoprocessorHost() != null) {<a name="line.1767"></a> -<span class="sourceLineNo">1768</span> final List<HStoreFile> candidatesForCoproc = compaction.preSelect(this.filesCompacting);<a name="line.1768"></a> -<span class="sourceLineNo">1769</span> boolean override = getCoprocessorHost().preCompactSelection(this,<a name="line.1769"></a> -<span class="sourceLineNo">1770</span> candidatesForCoproc, tracker, user);<a name="line.1770"></a> -<span class="sourceLineNo">1771</span> if (override) {<a name="line.1771"></a> -<span class="sourceLineNo">1772</span> // Coprocessor is overriding normal file selection.<a name="line.1772"></a> -<span class="sourceLineNo">1773</span> compaction.forceSelect(new CompactionRequestImpl(candidatesForCoproc));<a name="line.1773"></a> -<span class="sourceLineNo">1774</span> }<a name="line.1774"></a> -<span class="sourceLineNo">1775</span> }<a name="line.1775"></a> -<span class="sourceLineNo">1776</span><a name="line.1776"></a> -<span class="sourceLineNo">1777</span> // Normal case - coprocessor is not overriding file selection.<a name="line.1777"></a> -<span class="sourceLineNo">1778</span> if (!compaction.hasSelection()) {<a name="line.1778"></a> -<span class="sourceLineNo">1779</span> boolean isUserCompaction = priority == Store.PRIORITY_USER;<a name="line.1779"></a> -<span class="sourceLineNo">1780</span> boolean mayUseOffPeak = offPeakHours.isOffPeakHour() &&<a name="line.1780"></a> -<span class="sourceLineNo">1781</span> offPeakCompactionTracker.compareAndSet(false, true);<a name="line.1781"></a> -<span class="sourceLineNo">1782</span> try {<a name="line.1782"></a> -<span class="sourceLineNo">1783</span> compaction.select(this.filesCompacting, isUserCompaction,<a name="line.1783"></a> -<span class="sourceLineNo">1784</span> mayUseOffPeak, forceMajor && filesCompacting.isEmpty());<a name="line.1784"></a> -<span class="sourceLineNo">1785</span> } catch (IOException e) {<a name="line.1785"></a> -<span class="sourceLineNo">1786</span> if (mayUseOffPeak) {<a name="line.1786"></a> -<span class="sourceLineNo">1787</span> offPeakCompactionTracker.set(false);<a name="line.1787"></a> -<span class="sourceLineNo">1788</span> }<a name="line.1788"></a> -<span class="sourceLineNo">1789</span> throw e;<a name="line.1789"></a> -<span class="sourceLineNo">1790</span> }<a name="line.1790"></a> -<span class="sourceLineNo">1791</span> assert compaction.hasSelection();<a name="line.1791"></a> -<span class="sourceLineNo">1792</span> if (mayUseOffPeak && !compaction.getRequest().isOffPeak()) {<a name="line.1792"></a> -<span class="sourceLineNo">1793</span> // Compaction policy doesn't want to take advantage of off-peak.<a name="line.1793"></a> -<span class="sourceLineNo">1794</span> offPeakCompactionTracker.set(false);<a name="line.1794"></a> -<span class="sourceLineNo">1795</span> }<a name="line.1795"></a> -<span class="sourceLineNo">1796</span> }<a name="line.1796"></a> -<span class="sourceLineNo">1797</span> if (this.getCoprocessorHost() != null) {<a name="line.1797"></a> -<span class="sourceLineNo">1798</span> this.getCoprocessorHost().postCompactSelection(<a name="line.1798"></a> -<span class="sourceLineNo">1799</span> this, ImmutableList.copyOf(compaction.getRequest().getFiles()), tracker,<a name="line.1799"></a> -<span class="sourceLineNo">1800</span> compaction.getRequest(), user);<a name="line.1800"></a> -<span class="sourceLineNo">1801</span> }<a name="line.1801"></a> -<span class="sourceLineNo">1802</span> // Finally, we have the resulting files list. Check if we have any files at all.<a name="line.1802"></a> -<span class="sourceLineNo">1803</span> request = compaction.getRequest();<a name="line.1803"></a> -<span class="sourceLineNo">1804</span> Collection<HStoreFile> selectedFiles = request.getFiles();<a name="line.1804"></a> -<span class="sourceLineNo">1805</span> if (selectedFiles.isEmpty()) {<a name="line.1805"></a> -<span class="sourceLineNo">1806</span> return Optional.empty();<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> addToCompactingFiles(selectedFiles);<a name="line.1809"></a> -<span class="sourceLineNo">1810</span><a name="line.1810"></a> -<span class="sourceLineNo">1811</span> // If we're enqueuing a major, clear the force flag.<a name="line.1811"></a> -<span class="sourceLineNo">1812</span> this.forceMajor = this.forceMajor && !request.isMajor();<a name="line.1812"></a> -<span class="sourceLineNo">1813</span><a name="line.1813"></a> -<span class="sourceLineNo">1814</span> // Set common request properties.<a name="line.1814"></a> -<span class="sourceLineNo">1815</span> // Set priority, either override value supplied by caller or from store.<a name="line.1815"></a> -<span class="sourceLineNo">1816</span> request.setPriority((priority != Store.NO_PRIORITY) ? priority : getCompactPriority());<a name="line.1816"></a> -<span class="sourceLineNo">1817</span> request.setDescription(getRegionInfo().getRegionNameAsString(), getColumnFamilyName());<a name="line.1817"></a> -<span class="sourceLineNo">1818</span> request.setTracker(tracker);<a name="line.1818"></a> -<span class="sourceLineNo">1819</span> }<a name="line.1819"></a> -<span class="sourceLineNo">1820</span> } finally {<a name="line.1820"></a> -<span class="sourceLineNo">1821</span> this.lock.readLock().unlock();<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> if (LOG.isDebugEnabled()) {<a name="line.1824"></a> -<span class="sourceLineNo">1825</span> LOG.debug(getRegionInfo().getEncodedName() + " - " + getColumnFamilyName()<a name="line.1825"></a> -<span class="sourceLineNo">1826</span> + ": Initiating " + (request.isMajor() ? "major" : "minor") + " compaction"<a name="line.1826"></a> -<span class="sourceLineNo">1827</span> + (request.isAllFiles() ? " (all files)" : ""));<a name="line.1827"></a> -<span class="sourceLineNo">1828</span> }<a name="line.1828"></a> -<span class="sourceLineNo">1829</span> this.region.reportCompactionRequestStart(request.isMajor());<a name="line.1829"></a> -<span class="sourceLineNo">1830</span> return Optional.of(compaction);<a name="line.1830"></a> -<span class="sourceLineNo">1831</span> }<a name="line.1831"></a> -<span class="sourceLineNo">1832</span><a name="line.1832"></a> -<span class="sourceLineNo">1833</span> /** Adds the files to compacting files. filesCompacting must be locked. */<a name="line.1833"></a> -<span class="sourceLineNo">1834</span> private void addToCompactingFiles(Collection<HStoreFile> filesToAdd) {<a name="line.1834"></a> -<span class="sourceLineNo">1835</span> if (CollectionUtils.isEmpty(filesToAdd)) {<a name="line.1835"></a> -<span class="sourceLineNo">1836</span> return;<a name="line.1836"></a> -<span class="sourceLineNo">1837</span> }<a name="line.1837"></a> -<span class="sourceLineNo">1838</span> // Check that we do not try to compact the same StoreFile twice.<a name="line.1838"></a> -<span class="sourceLineNo">1839</span> if (!Collections.disjoint(filesCompacting, filesToAdd)) {<a name="line.1839"></a> -<span class="sourceLineNo">1840</span> Preconditions.checkArgument(false, "%s overlaps with %s", filesToAdd, filesCompacting);<a name="line.1840"></a> -<span class="sourceLineNo">1841</span> }<a name="line.1841"></a> -<span class="sourceLineNo">1842</span> filesCompacting.addAll(filesToAdd);<a name="line.1842"></a> -<span class="sourceLineNo">1843</span> Collections.sort(filesCompacting, storeEngine.getStoreFileManager().getStoreFileComparator());<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> private void removeUnneededFiles() throws IOException {<a name="line.1846"></a> -<span class="sourceLineNo">1847</span> if (!conf.getBoolean("hbase.store.delete.expired.storefile", true)) return;<a name="line.1847"></a> -<span class="sourceLineNo">1848</span> if (getColumnFamilyDescriptor().getMinVersions() > 0) {<a name="line.1848"></a> -<span class="sourceLineNo">1849</span> LOG.debug("Skipping expired store file removal due to min version being {}",<a name="line.1849"></a> -<span class="sourceLineNo">1850</span> getColumnFamilyDescriptor().getMinVersions());<a name="line.1850"></a> -<span class="sourceLineNo">1851</span> return;<a name="line.1851"></a> -<span class="sourceLineNo">1852</span> }<a name="line.1852"></a> -<span class="sourceLineNo">1853</span> this.lock.readLock().lock();<a name="line.1853"></a> -<span class="sourceLineNo">1854</span> Collection<HStoreFile> delSfs = null;<a name="line.1854"></a> -<span class="sourceLineNo">1855</span> try {<a name="line.1855"></a> -<span class="sourceLineNo">1856</span> synchronized (filesCompacting) {<a name="line.1856"></a> -<span class="sourceLineNo">1857</span> long cfTtl = getStoreFileTtl();<a name="line.1857"></a> -<span class="sourceLineNo">1858</span> if (cfTtl != Long.MAX_VALUE) {<a name="line.1858"></a> -<span class="sourceLineNo">1859</span> delSfs = storeEngine.getStoreFileManager().getUnneededFiles(<a name="line.1859"></a> -<span class="sourceLineNo">1860</span> EnvironmentEdgeManager.currentTime() - cfTtl, filesCompacting);<a name="line.1860"></a> -<span class="sourceLineNo">1861</span> addToCompactingFiles(delSfs);<a name="line.1861"></a> -<span class="sourceLineNo">1862</span> }<a name="line.1862"></a> -<span class="sourceLineNo">1863</span> }<a name="line.1863"></a> -<span class="sourceLineNo">1864</span> } finally {<a name="line.1864"></a> -<span class="sourceLineNo">1865</span> this.lock.readLock().unlock();<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> if (CollectionUtils.isEmpty(delSfs)) {<a name="line.1868"></a> -<span class="sourceLineNo">1869</span> return;<a name="line.1869"></a> -<span class="sourceLineNo">1870</span> }<a name="line.1870"></a> -<span class="sourceLineNo">1871</span><a name="line.1871"></a> -<span class="sourceLineNo">1872</span> Collection<HStoreFile> newFiles = Collections.emptyList(); // No new files.<a name="line.1872"></a> -<span class="sourceLineNo">1873</span> writeCompactionWalRecord(delSfs, newFiles);<a name="line.1873"></a> -<span class="sourceLineNo">1874</span> replaceStoreFiles(delSfs, newFiles);<a name="line.1874"></a> -<span class="sourceLineNo">1875</span> completeCompaction(delSfs);<a name="line.1875"></a> -<span class="sourceLineNo">1876</span> LOG.info("Completed removal of " + delSfs.size() + " unnecessary (expired) file(s) in "<a name="line.1876"></a> -<span class="sourceLineNo">1877</span> + this + " of " + this.getRegionInfo().getRegionNameAsString()<a name="line.1877"></a> -<span class="sourceLineNo">1878</span> + "; total size for store is "<a name="line.1878"></a> -<span class="sourceLineNo">1879</span> + TraditionalBinaryPrefix.long2String(storeSize.get(), "", 1));<a name="line.1879"></a> -<span class="sourceLineNo">1880</span> }<a name="line.1880"></a> -<span class="sourceLineNo">1881</span><a name="line.1881"></a> -<span class="sourceLineNo">1882</span> public void cancelRequestedCompaction(CompactionContext compaction) {<a name="line.1882"></a> -<span class="sourceLineNo">1883</span> finishCompactionRequest(compaction.getRequest());<a name="line.1883"></a> -<span class="sourceLineNo">1884</span> }<a name="line.1884"></a> -<span class="sourceLineNo">1885</span><a name="line.1885"></a> -<span class="sourceLineNo">1886</span> private void finishCompactionRequest(CompactionRequestImpl cr) {<a name="line.1886"></a> -<span class="sourceLineNo">1887</span> this.region.reportCompactionRequestEnd(cr.isMajor(), cr.getFiles().size(), cr.getSize());<a name="line.1887"></a> -<span class="sourceLineNo">1888</span> if (cr.isOffPeak()) {<a name="line.1888"></a> -<span class="sourceLineNo">1889</span> offPeakCompactionTracker.set(false);<a name="line.1889"></a> -<span class="sourceLineNo">1890</span> cr.setOffPeak(false);<a name="line.1890"></a> -<span class="sourceLineNo">1891</span> }<a name="line.1891"></a> -<span class="sourceLineNo">1892</span> synchronized (filesCompacting) {<a name="line.1892"></a> -<span class="sourceLineNo">1893</span> filesCompacting.removeAll(cr.getFiles());<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><a name="line.1896"></a> -<span class="sourceLineNo">1897</span> /**<a name="line.1897"></a> -<span class="sourceLineNo">1898</span> * Validates a store file by opening and closing it. In HFileV2 this should not be an expensive<a name="line.1898"></a> -<span class="sourceLineNo">1899</span> * operation.<a name="line.1899"></a> -<span class="sourceLineNo">1900</span> * @param path the path to the store file<a name="line.1900"></a> -<span class="sourceLineNo">1901</span> */<a name="line.1901"></a> -<span class="sourceLineNo">1902</span> private void validateStoreFile(Path path) throws IOException {<a name="line.1902"></a> -<span class="sourceLineNo">1903</span> HStoreFile storeFile = null;<a name="line.1903"></a> -<span class="sourceLineNo">1904</span> try {<a name="line.1904"></a> -<span class="sourceLineNo">1905</span> storeFile = createStoreFileAndReader(path);<a name="line.1905"></a> -<span class="sourceLineNo">1906</span> } catch (IOException e) {<a name="line.1906"></a> -<span class="sourceLineNo">1907</span> LOG.error("Failed to open store file : {}, keeping it in tmp location", path, e);<a name="line.1907"></a> -<span class="sourceLineNo">1908</span> throw e;<a name="line.1908"></a> -<span class="sourceLineNo">1909</span> } finally {<a name="line.1909"></a> -<span class="sourceLineNo">1910</span> if (storeFile != null) {<a name="line.1910"></a> -<span class="sourceLineNo">1911</span> storeFile.closeStoreFile(false);<a name="line.1911"></a> -<span class="sourceLineNo">1912</span> }<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> /**<a name="line.1916"></a> -<span class="sourceLineNo">1917</span> * <p>It works by processing a compaction that's been written to disk.<a name="line.1917"></a> -<span class="sourceLineNo">1918</span> *<a name="line.1918"></a> -<span class="sourceLineNo">1919</span> * <p>It is usually invoked at the end of a compaction, but might also be<a name="line.1919"></a> -<span class="sourceLineNo">1920</span> * invoked at HStore startup, if the prior execution died midway through.<a name="line.1920"></a> -<span class="sourceLineNo">1921</span> *<a name="line.1921"></a> -<span class="sourceLineNo">1922</span> * <p>Moving the compacted TreeMap into place means:<a name="line.1922"></a> -<span class="sourceLineNo">1923</span> * <pre><a name="line.1923"></a> -<span class="sourceLineNo">1924</span> * 1) Unload all replaced StoreFile, close and collect list to delete.<a name="line.1924"></a> -<span class="sourceLineNo">1925</span> * 2) Compute new store size<a name="line.1925"></a> -<span class="sourceLineNo">1926</span> * </pre><a name="line.1926"></a> -<span class="sourceLineNo">1927</span> *<a name="line.1927"></a> -<span class="sourceLineNo">1928</span> * @param compactedFiles list of files that were compacted<a name="line.1928"></a> -<span class="sourceLineNo">1929</span> */<a name="line.1929"></a> -<span class="sourceLineNo">1930</span> @VisibleForTesting<a name="line.1930"></a> -<span class="sourceLineNo">1931</span> protected void completeCompaction(Collection<HStoreFile> compactedFiles)<a name="line.1931"></a> -<span class="sourceLineNo">1932</span> throws IOException {<a name="line.1932"></a> -<span class="sourceLineNo">1933</span> this.storeSize.set(0L);<a name="line.1933"></a> -<span class="sourceLineNo">1934</span> this.totalUncompressedBytes.set(0L);<a name="line.1934"></a> -<span class="sourceLineNo">1935</span> for (HStoreFile hsf : this.storeEngine.getStoreFileManager().getStorefiles()) {<a name="line.1935"></a> -<span class="sourceLineNo">1936</span> StoreFileReader r = hsf.getReader();<a name="line.1936"></a> -<span class="sourceLineNo">1937</span> if (r == null) {<a name="line.1937"></a> -<span class="sourceLineNo">1938</span> LOG.warn("StoreFile {} has a null Reader", hsf);<a name="line.1938"></a> -<span class="sourceLineNo">1939</span> continue;<a name="line.1939"></a> -<span class="sourceLineNo">1940</span> }<a name="line.1940"></a> -<span class="sourceLineNo">1941</span> this.storeSize.addAndGet(r.length());<a name="line.1941"></a> -<span class="sourceLineNo">1942</span> this.totalUncompressedBytes.addAndGet(r.getTotalUncompressedBytes());<a name="line.1942"></a> -<span class="sourceLineNo">1943</span> }<a name="line.1943"></a> -<span class="sourceLineNo">1944</span> }<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> * @param wantedVersions How many versions were asked for.<a name="line.1947"></a> -<span class="sourceLineNo">1948</span> * @return wantedVersions or this families' {@link HConstants#VERSIONS}.<a name="line.1948"></a> -<span class="sourceLineNo">1949</span> */<a name="line.1949"></a> -<span class="sourceLineNo">1950</span> int versionsToReturn(final int wantedVersions) {<a name="line.1950"></a> -<span class="sourceLineNo">1951</span> if (wantedVersions <= 0) {<a name="line.1951"></a> -<span class="sourceLineNo">1952</span> throw new IllegalArgumentException("Number of versions must be > 0");<a name="line.1952"></a> -<span class="sourceLineNo">1953</span> }<a name="line.1953"></a> -<span class="sourceLineNo">1954</span> // Make sure we do not return more than maximum versions for this store.<a name="line.1954"></a> -<span class="sourceLineNo">1955</span> int maxVersions = this.family.getMaxVersions();<a name="line.1955"></a> -<span class="sourceLineNo">1956</span> return wantedVersions > maxVersions ? maxVersions: wantedVersions;<a name="line.1956"></a> -<span class="sourceLineNo">1957</span> }<a name="line.1957"></a> -<span class="sourceLineNo">1958</span><a name="line.1958"></a> -<span class="sourceLineNo">1959</span> @Override<a name="line.1959"></a> -<span class="sourceLineNo">1960</span> public boolean canSplit() {<a name="line.1960"></a> -<span class="sourceLineNo">1961</span> this.lock.readLock().lock();<a name="line.1961"></a> -<span class="sourceLineNo">1962</span> try {<a name="line.1962"></a> -<span class="sourceLineNo">1963</span> // Not split-able if we find a reference store file present in the store.<a name="line.1963"></a> -<span class="sourceLineNo">1964</span> boolean result = !hasReferences();<a name="line.1964"></a> -<span class="sourceLineNo">1965</span> if (!result) {<a name="line.1965"></a> -<span class="sourceLineNo">1966</span> LOG.trace("Not splittable; has references: {}", this);<a name="line.1966"></a> -<span class="sourceLineNo">1967</span> }<a name="line.1967"></a> -<span class="sourceLineNo">1968</span> return result;<a name="line.1968"></a> -<span class="sourceLineNo">1969</span> } finally {<a name="line.1969"></a> -<span class="sourceLineNo">1970</span> this.lock.readLock().unlock();<a name="line.1970"></a> -<span class="sourceLineNo">1971</span> }<a name="line.1971"></a> -<span class="sourceLineNo">1972</span> }<a name="line.1972"></a> -<span class="sourceLineNo">1973</span><a name="line.1973"></a> -<span class="sourceLineNo">1974</span> /**<a name="line.1974"></a> -<span class="sourceLineNo">1975</span> * Determines if Store should be split.<a name="line.1975"></a> -<span class="sourceLineNo">1976</span> */<a name="line.1976"></a> -<span class="sourceLineNo">1977</span> public Optional<byte[]> getSplitPoint() {<a name="line.1977"></a> -<span class="sourceLineNo">1978</span> this.lock.readLock().lock();<a name="line.1978"></a> -<span class="sourceLineNo">1979</span> try {<a name="line.1979"></a> -<span class="sourceLineNo">1980</span> // Should already be enforced by the split policy!<a name="line.1980"></a> -<span class="sourceLineNo">1981</span> assert !this.getRegionInfo().isMetaRegion();<a name="line.1981"></a> -<span class="sourceLineNo">1982</span> // Not split-able if we find a reference store file present in the store.<a name="line.1982"></a> -<span class="sourceLineNo">1983</span> if (hasReferences()) {<a name="line.1983"></a> -<span class="sourceLineNo">1984</span> LOG.trace("Not splittable; has references: {}", this);<a name="line.1984"></a> -<span class="sourceLineNo">1985</span> return Optional.empty();<a name="line.1985"></a> -<span class="sourceLineNo">1986</span> }<a name="line.1986"></a> -<span class="sourceLineNo">1987</span> return this.storeEngine.getStoreFileManager().getSplitPoint();<a name="line.1987"></a> -<span class="sourceLineNo">1988</span> } catch(IOException e) {<a name="line.1988"></a> -<span class="sourceLineNo">1989</span> LOG.warn("Failed getting store size for {}", this, e);<a name="line.1989"></a> -<span class="sourceLineNo">1990</span> } finally {<a name="line.1990"></a> -<span class="sourceLineNo">1991</span> this.lock.readLock().unlock();<a name="line.1991"></a> -<span class="sourceLineNo">1992</span> }<a name="line.1992"></a> -<span class="sourceLineNo">1993</span> return Optional.empty();<a name="line.1993"></a> -<span class="sourceLineNo">1994</span> }<a name="line.1994"></a> -<span class="sourceLineNo">1995</span><a name="line.1995"></a> -<span class="sourceLineNo">1996</span> @Override<a name="line.1996"></a> -<span class="sourceLineNo">1997</span> public long getLastCompactSize() {<a name="line.1997"></a> -<span class="sourceLineNo">1998</span> return this.lastCompactSize;<a name="line.1998"></a> -<span class="sourceLineNo">1999</span> }<a name="line.1999"></a> -<span class="sourceLineNo">2000</span><a name="line.2000"></a> -<span class="sourceLineNo">2001</span> @Override<a name="line.2001"></a> -<span class="sourceLineNo">2002</span> public long getSize() {<a name="line.2002"></a> -<span class="sourceLineNo">2003</span> return storeSize.get();<a name="line.2003"></a> -<span class="sourceLineNo">2004</span> }<a name="line.2004"></a> -<span class="sourceLineNo">2005</span><a name="line.2005"></a> -<span class="sourceLineNo">2006</span> public void triggerMajorCompaction() {<a name="line.2006"></a> -<span class="sourceLineNo">2007</span> this.forceMajor = true;<a name="line.2007"></a> -<span class="sourceLineNo">2008</span> }<a name="line.2008"></a> -<span class="sourceLineNo">2009</span><a name="line.2009"></a> -<span class="sourceLineNo">2010</span> //////////////////////////////////////////////////////////////////////////////<a name="line.2010"></a> -<span class="sourceLineNo">2011</span> // File administration<a name="line.2011"></a> -<span class="sourceLineNo">2012</span> //////////////////////////////////////////////////////////////////////////////<a name="line.2012"></a> -<span class="sourceLineNo">2013</span><a name="line.2013"></a> -<span class="sourceLineNo">2014</span> /**<a name="line.2014"></a> -<span class="sourceLineNo">2015</span> * Return a scanner for both the memstore and the HStore files. Assumes we are not in a<a name="line.2015"></a> -<span class="sourceLineNo">2016</span> * compaction.<a name="line.2016"></a> -<span class="sourceLineNo">2017</span> * @param scan Scan to apply when scanning the stores<a name="line.2017"></a> -<span class="sourceLineNo">2018</span> * @param targetCols columns to scan<a name="line.2018"></a> -<span class="sourceLineNo">2019</span> * @return a scanner over the current key values<a name="line.2019"></a> -<span class="sourceLineNo">2020</span> * @throws IOException on failure<a name="line.2020"></a> -<span class="sourceLineNo">2021</span> */<a name="line.2021"></a> -<span class="sourceLineNo">2022</span> public KeyValueScanner getScanner(Scan scan, final NavigableSet<byte[]> targetCols, long readPt)<a name="line.2022"></a> -<span class="sourceLineNo">2023</span> throws IOException {<a name="line.2023"></a> -<span class="sourceLineNo">2024</span> lock.readLock().lock();<a name="line.2024"></a> -<span class="sourceLineNo">2025</span> try {<a name="line.2025"></a> -<span class="sourceLineNo">2026</span> ScanInfo scanInfo;<a name="line.2026"></a> -<span class="sourceLineNo">2027</span> if (this.getCoprocessorHost() != null) {<a name="line.2027"></a> -<span class="sourceLineNo">2028</span> scanInfo = this.getCoprocessorHost().preStoreScannerOpen(this);<a name="line.2028"></a> -<span class="sourceLineNo">2029</span> } else {<a name="line.2029"></a> -<span class="sourceLineNo">2030</span> scanInfo = getScanInfo();<a name="line.2030"></a> -<span class="sourceLineNo">2031</span> }<a name="line.2031"></a> -<span class="sourceLineNo">2032</span> return createScanner(scan, scanInfo, targetCols, readPt);<a name="line.2032"></a> -<span class="sourceLineNo">2033</span> } finally {<a name="line.2033"></a> -<span class="sourceLineNo">2034</span> lock.readLock().unlock();<a name="line.2034"></a> -<span class="sourceLineNo">2035</span> }<a name="line.2035"></a> -<span class="sourceLineNo">2036</span> }<a name="line.2036"></a> -<span class="sourceLineNo">2037</span><a name="line.2037"></a> -<span class="sourceLineNo">2038</span> // HMobStore will override this method to return its own implementation.<a name="line.2038"></a> -<span class="sourceLineNo">2039</span> protected KeyValueScanner createScanner(Scan scan, ScanInfo scanInfo,<a name="line.2039"></a> -<span class="sourceLineNo">2040</span> NavigableSet<byte[]> targetCols, long readPt) throws IOException {<a name="line.2040"></a> -<span class="sourceLineNo">2041</span> return scan.isReversed() ? new ReversedStoreScanner(this, scanInfo, scan, targetCols, readPt)<a name="line.2041"></a> -<span class="sourceLineNo">2042</span> : new StoreScanner(this, scanInfo, scan, targetCols, readPt);<a name="line.2042"></a> -<span class="sourceLineNo">2043</span> }<a name="line.2043"></a> -<span class="sourceLineNo">2044</span><a name="line.2044"></a> -<span class="sourceLineNo">2045</span> /**<a name="line.2045"></a> -<span class="sourceLineNo">2046</span> * Recreates the scanners on the current list of active store file scanners<a name="line.2046"></a> -<span class="sourceLineNo">2047</span> * @param currentFileScanners the current set of active store file scanners<a name="line.2047"></a> -<span class="sourceLineNo">2048</span> * @param cacheBlocks cache the blocks or not<a name="line.2048"></a> -<span class="sourceLineNo">2049</span> * @param usePread use pread or not<a name="line.2049"></a> -<span class="sourceLineNo">2050</span> * @param isCompaction is the scanner for compaction<a name="line.2050"></a> -<span class="sourceLineNo">2051</span> * @param matcher the scan query matcher<a name="line.2051"></a> -<span class="sourceLineNo">2052</span> * @param startRow the scan's start row<a name="line.2052"></a> -<span class="sourceLineNo">2053</span> * @param includeStartRow should the scan include the start row<a name="line.2053"></a> -<span class="sourceLineNo">2054</span> * @param stopRow the scan's stop row<a name="line.2054"></a> -<span class="sourceLineNo">2055</span> * @param includeStopRow should the scan include the stop row<a name="line.2055"></a> -<span class="sourceLineNo">2056</span> * @param readPt the read point of the current scane<a name="line.2056"></a> -<span class="sourceLineNo">2057</span> * @param includeMemstoreScanner whether the current scanner should include memstorescanner<a name="line.2057"></a> -<span class="sourceLineNo">2058</span> * @return list of scanners recreated on the current Scanners<a name="line.2058"></a> -<span class="sourceLineNo">2059</span> * @throws IOException<a name="line.2059"></a> -<span class="sourceLineNo">2060</span> */<a name="line.2060"></a> -<span class="sourceLineNo">2061</span> public List<KeyValueScanner> recreateScanners(List<KeyValueScanner> currentFileScanners,<a name="line.2061"></a> -<span class="sourceLineNo">2062</span> boolean cacheBlocks, boolean usePread, boolean isCompaction, ScanQueryMatcher matcher,<a name="line.2062"></a> -<span class="sourceLineNo">2063</span> byte[] startRow, boolean includeStartRow, byte[] stopRow, boolean includeStopRow, long readPt,<a name="line.2063"></a> -<span class="sourceLineNo">2064</span> boolean includeMemstoreScanner) throws IOException {<a name="line.2064"></a> -<span class="sourceLineNo">2065</span> this.lock.readLock().lock();<a name="line.2065"></a> -<span class="sourceLineNo">2066</span> try {<a name="line.2066"></a> -<span class="sourceLineNo">2067</span> Map<String, HStoreFile> name2File =<a name="line.2067"></a> -<span class="sourceLineNo">2068</span> new HashMap<>(getStorefilesCount() + getCompactedFilesCount());<a name="line.2068"></a> -<span class="sourceLineNo">2069</span> for (HStoreFile file : getStorefiles()) {<a name="line.2069"></a> -<span class="sourceLineNo">2070</span> name2File.put(file.getFileInfo().getActiveFileName(), file);<a name="line.2070"></a> -<span class="sourceLineNo">2071</span> }<a name="line.2071"></a> -<span class="sourceLineNo">2072</span> Collection<HStoreFile> compactedFiles = getCompactedFiles();<a name="line.2072"></a> -<span class="sourceLineNo">2073</span> for (HStoreFile file : IterableUtils.emptyIfNull(compactedFiles)) {<a name="line.2073"></a> -<span class="sourceLineNo">2074</span> name2File.put(file.getFileInfo().getActiveFileName(), file);<a name="line.2074"></a> -<span class="sourceLineNo">2075</span> }<a name="line.2075"></a> -<span class="sourceLineNo">2076</span> List<HStoreFile> filesToReopen = new ArrayList<>();<a name="line.2076"></a> -<span class="sourceLineNo">2077</span> for (KeyValueScanner kvs : currentFileScanners) {<a name="line.2077"></a> -<span class="sourceLineNo">2078</span> assert kvs.isFileScanner();<a name="line.2078"></a> -<span class="sourceLineNo">2079</span> if (kvs.peek() == null) {<a name="line.2079"></a> -<span class="sourceLineNo">2080</span> continue;<a name="line.2080"></a> -<span class="sourceLineNo">2081</span> }<a name="line.2081"></a> -<span class="sourceLineNo">2082</span> filesToReopen.add(name2File.get(kvs.getFilePath().getName()));<a name="line.2082"></a> -<span class="sourceLineNo">2083</span> }<a name="line.2083"></a> -<span class="sourceLineNo">2084</span> if (filesToReopen.isEmpty()) {<a name="line.2084"></a> -<span class="sourceLineNo">2085</span> return null;<a name="line.2085"></a> -<span class="sourceLineNo">2086</span> }<a name="line.2086"></a> -<span class="sourceLineNo">2087</span> return getScanners(filesToReopen, cacheBlocks, false, false, matcher, startRow,<a name="line.2087"></a> -<span class="sourceLineNo">2088</span> includeStartRow, stopRow, includeStopRow, readPt, false);<a name="line.2088"></a> -<span class="sourceLineNo">2089</span> } finally {<a name="line.2089"></a> -<span class="sourceLineNo">2090</span> this.lock.readLock().unlock();<a name="line.2090"></a> -<span class="sourceLineNo">2091</span> }<a name="line.2091"></a> -<span class="sourceLineNo">2092</span> }<a name="line.2092"></a> -<span class="sourceLineNo">2093</span><a name="line.2093"></a> -<span class="sourceLineNo">2094</span> @Override<a name="line.2094"></a> -<span class="sourceLineNo">2095</span> public String toString() {<a name="line.2095"></a> -<span class="sourceLineNo">2096</span> return this.getColumnFamilyName();<a name="line.2096"></a> -<span class="sourceLineNo">2097</span> }<a name="line.2097"></a> -<span class="sourceLineNo">2098</span><a name="line.2098"></a> -<span class="sourceLineNo">2099</span> @Override<a name="line.2099"></a> -<span class="sourceLineNo">2100</span> public int getStorefilesCount() {<a name="line.2100"></a> -<span class="sourceLineNo">2101</span> return this.storeEngine.getStoreFileManager().getStorefileCount();<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> @Override<a name="line.2104"></a> -<span class="sourceLineNo">2105</span> public int getCompactedFilesCount() {<a name="line.2105"></a> -<span class="sourceLineNo">2106</span> return this.storeEngine.getStoreFileManager().getCompactedFilesCount();<a name="line.2106"></a> -<span class="sourceLineNo">2107</span> }<a name="line.2107"></a> -<span class="sourceLineNo">2108</span><a name="line.2108"></a> -<span class="sourceLineNo">2109</span> private LongStream getStoreFileAgeStream() {<a name="line.2109"></a> -<span class="sourceLineNo">2110</span> return this.storeEngine.getStoreFileManager().getStorefiles().stream().filter(sf -> {<a name="line.2110"></a> -<span class="sourceLineNo">2111</span> if (sf.getReader() == null) {<a name="line.2111"></a> -<span class="sourceLineNo">2112</span> LOG.warn("StoreFile {} has a null Reader", sf);<a name="line.2112"></a> -<span class="sourceLineNo">2113</span> return false;<a name="line.2113"></a> -<span class="sourceLineNo">2114</span> } else {<a name="line.2114"></a> -<span class="sourceLineNo">2115</span> return true;<a name="line.2115"></a> -<span class="sourceLineNo">2116</span> }<a name="line.2116"></a> -<span class="sourceLineNo">2117</span> }).filter(HStoreFile::isHFile).mapToLong(sf -> sf.getFileInfo().getCreatedTimestamp())<a name="line.2117"></a> -<span class="sourceLineNo">2118</span> .map(t -> EnvironmentEdgeManager.currentTime() - t);<a name="line.2118"></a> -<span class="sourceLineNo">2119</span> }<a name="line.2119"></a> -<span class="sourceLineNo">2120</span><a name="line.2120"></a> -<span class="sourceLineNo">2121</span> @Override<a name="line.2121"></a> -<span class="sourceLineNo">2122</span> public OptionalLong getMaxStoreFileAge() {<a name="line.2122"></a> -<span class="sourceLineNo">2123</span> return getStoreFileAgeStream().max();<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> @Override<a name="line.2126"></a> -<span class="sourceLineNo">2127</span> public OptionalLong getMinStoreFileAge() {<a name="line.2127"></a> -<span class="sourceLineNo">2128</span> return getStoreFileAgeStream().min();<a name="line.2128"></a> -<span class="sourceLineNo">2129</span> }<a name="line.2129"></a> -<span class="sourceLineNo">2130</span><a name="line.2130"></a> -<span class="sourceLineNo">2131</span> @Override<a name="line.2131"></a> -<span class="sourceLineNo">2132</span> public OptionalDouble getAvgStoreFileAge() {<a name="line.2132"></a> -<span class="sourceLineNo">2133</span> return getStoreFileAgeStream().average();<a name="line.2133"></a> -<span class="sourceLineNo">2134</span> }<a name="line.2134"></a> -<span class="sourceLineNo">2135</span><a name="line.2135"></a> -<span class="sourceLineNo">2136</span> @Override<a name="line.2136"></a> -<span class="sourceLineNo">2137</span> public long getNumReferenceFiles() {<a name="line.2137"></a> -<span class="sourceLineNo">2138</span> return this.storeEngine.getStoreFileManager().getStorefiles().stream()<a name="line.2138"></a> -<span class="sourceLineNo">2139</span> .filter(HStoreFile::isReference).count();<a name="line.2139"></a> -<span class="sourceLineNo">2140</span> }<a name="line.2140"></a> -<span class="sourceLineNo">2141</span><a name="line.2141"></a> -<span class="sourceLineNo">2142</span> @Override<a name="line.2142"></a> -<span class="sourceLineNo">2143</span> public long getNumHFiles() {<a name="line.2143"></a> -<span class="sourceLineNo">2144</span> return this.storeEngine.getStoreFileManager().getStorefiles().stream()<a name="line.2144"></a> -<span class="sourceLineNo">2145</span> .filter(HStoreFile::isHFile).count();<a name="line.2145"></a> -<span class="sourceLineNo">2146</span> }<a name="line.2146"></a> -<span class="sourceLineNo">2147</span><a name="line.2147"></a> -<span class="sourceLineNo">2148</span> @Override<a name="line.2148"></a> -<span class="sourceLineNo">2149</span> public long getStoreSizeUncompressed() {<a name="line.2149"></a> -<span class="sourceLineNo">2150</span> return this.totalUncompressedBytes.get();<a name="line.2150"></a> -<span class="sourceLineNo">2151</span> }<a name="line.2151"></a> -<span class="sourceLineNo">2152</span><a name="line.2152"></a> -<span class="sourceLineNo">2153</span> @Override<a name="line.2153"></a> -<span class="sourceLineNo">2154</span> public long getStorefilesSize() {<a name="line.2154"></a> -<span class="sourceLineNo">2155</span> // Include all StoreFiles<a name="line.2155"></a> -<span class="sourceLineNo">2156</span> return getStorefilesSize(this.storeEngine.getStoreFileManager().getStorefiles(), sf -> true);<a name="line.2156"></a> -<span class="sourceLineNo">2157</span> }<a name="line.2157"></a> -<span class="sourceLineNo">2158</span><a name="line.2158"></a> -<span class="sourceLineNo">2159</span> @Override<a name="line.2159"></a> -<span class="sourceLineNo">2160</span> public long getHFilesSize() {<a name="line.2160"></a> -<span class="sourceLineNo">2161</span> // Include only StoreFiles which are HFiles<a name="line.2161"></a> -<span class="sourceLineNo">2162</span> return getStorefilesSize(this.storeEngine.getStoreFileManager().getStorefiles(),<a name="line.2162"></a> -<span class="sourceLineNo">2163</span> HStoreFile::isHFile);<a name="line.2163"></a> -<span class="sourceLineNo">2164</span> }<a name="line.2164"></a> -<span class="sourceLineNo">2165</span><a name="line.2165"></a> -<span class="sourceLineNo">2166</span> private long getTotalUmcompressedBytes(List<HStoreFile> files) {<a name="line.2166"></a> -<span class="sourceLineNo">2167</span> return files.stream().filter(f -> f != null && f.getReader() != null)<a name="line.2167"></a> -<span class="sourceLineNo">2168</span> .mapToLong(f -> f.getReader().getTotalUncompressedBytes()).sum();<a name="line.2168"></a> -<span class="sourceLineNo">2169</span> }<a name="line.2169"></a> -<span class="sourceLineNo">2170</span><a name="line.2170"></a> -<span class="sourceLineNo">2171</span> private long getStorefilesSize(Collection<HStoreFile> files, Predicate<HStoreFile> predicate) {<a name="line.2171"></a> -<span class="sourceLineNo">2172</span> return files.stream().filter(f -> f != null && f.getReader() != null).filter(predicate)<a name="line.2172"></a> -<span class="sourceLineNo">2173</span> .mapToLong(f -> f.getReader().length()).sum();<a name="line.2173"></a> -<span class="sourceLineNo">2174</span> }<a name="line.2174"></a> -<span class="sourceLineNo">2175</span><a name="line.2175"></a> -<span class="sourceLineNo">2176</span> private long getStoreFileFieldSize(ToLongFunction<StoreFileReader> f) {<a name="line.2176"></a> -<span class="sourceLineNo">2177</span> return this.storeEngine.getStoreFileManager().getStorefiles().stream().filter(sf -> {<a name="line.2177"></a> -<span class="sourceLineNo">2178</span> if (sf.getReader() == null) {<a name="line.2178"></a> -<span class="sourceLineNo">2179</span> LOG.warn("StoreFile {} has a null Reader", sf);<a name="line.2179"></a> -<span class="sourceLineNo">2180</span> return false;<a name="line.2180"></a> -<span class="sourceLineNo">2181</span> } else {<a name="line.2181"></a> -<span class="sourceLineNo">2182</span> return true;<a name="line.2182"></a> -<span class="sourceLineNo">2183</span> }<a name="line.2183"></a> -<span class="sourceLineNo">2184</span> }).map(HStoreFile::getReader).mapToLong(f).sum();<a name="line.2184"></a> -<span class="sourceLineNo">2185</span> }<a name="line.2185"></a> -<span class="sourceLineNo">2186</span><a name="line.2186"></a> -<span class="sourceLineNo">2187</span> @Override<a name="line.2187"></a> -<span class="sourceLineNo">2188</span> public long getStorefilesRootLevelIndexSize() {<a name="line.2188"></a> -<span class="sourceLineNo">2189</span> return getStoreFileFieldSize(StoreFileReader::indexSize);<a name="line.2189"></a> -<span class="sourceLineNo">2190</span> }<a name="line.2190"></a> -<span class="sourceLineNo">2191</span><a name="line.2191"></a> -<span class="sourceLineNo">2192</span> @Override<a name="line.2192"></a> -<span class="sourceLineNo">2193</span> public long getTotalStaticIndexSize() {<a name="line.2193"></a> -<span class="sourceLineNo">2194</span> return getStoreFileFieldSize(StoreFileReader::getUncompressedDataIndexSize);<a name="line.2194"></a> -<span class="sourceLineNo">2195</span> }<a name="line.2195"></a> -<span class="sourceLineNo">2196</span><a name="line.2196"></a> -<span class="sourceLineNo">2197</span> @Override<a name="line.2197"></a> -<span class="sourceLineNo">2198</span> public long getTotalStaticBloomSize() {<a name="line.2198"></a> -<span class="sourceLineNo">2199</span> return getStoreFileFieldSize(StoreFileReader::getTotalBloomSize);<a name="line.2199"></a> -<span class="sourceLineNo">2200</span> }<a name="line.2200"></a> -<span class="sourceLineNo">2201</span><a name="line.2201"></a> -<span class="sourceLineNo">2202</span> @Override<a name="line.2202"></a> -<span class="sourceLineNo">2203</span> public MemStoreSize getMemStoreSize() {<a name="line.2203"></a> -<span class="sourceLineNo">2204</span> return this.memstore.size();<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> @Override<a name="line.2207"></a> -<span class="sourceLineNo">2208</span> public int getCompactPriority() {<a name="line.2208"></a> -<span class="sourceLineNo">2209</span> int priority = this.storeEngine.getStoreFileManager().getStoreCompactionPriority();<a name="line.2209"></a> -<span class="sourceLineNo">2210</span> if (priority == PRIORITY_USER) {<a name="line.2210"></a> -<span class="sourceLineNo">2211</span> LOG.warn("Compaction priority is USER despite there being no user compaction");<a name="line.2211"></a> -<span class="sourceLineNo">2212</span> }<a name="line.2212"></a> -<span class="sourceLineNo">2213</span> return priority;<a name="line.2213"></a> -<span class="sourceLineNo">2214</span> }<a name="line.2214"></a> -<span class="sourceLineNo">2215</span><a name="line.2215"></a> -<span class="sourceLineNo">2216</span> public boolean throttleCompaction(long compactionSize) {<a name="line.2216"></a> -<span class="sourceLineNo">2217</span> return storeEngine.getCompactionPolicy().throttleCompaction(compactionSize);<a name="line.2217"></a> -<span class="sourceLineNo">2218</span> }<a name="line.2218"></a> -<span class="sourceLineNo">2219</span><a name="line.2219"></a> -<span class="sourceLineNo">2220</span> public HRegion getHRegion() {<a name="line.2220"></a> -<span class="sourceLineNo">2221</span> return this.region;<a name="line.2221"></a> -<span class="sourceLineNo">2222</span> }<a name="line.2222"></a> -<span class="sourceLineNo">2223</span><a name="line.2223"></a> -<span class="sourceLineNo">2224</span> public RegionCoprocessorHost getCoprocessorHost() {<a name="line.2224"></a> -<span class="sourceLineNo">2225</span> return this.region.getCoprocessorHost();<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> @Override<a name="line.2228"></a> -<span class="sourceLineNo">2229</span> public RegionInfo getRegionInfo() {<a name="line.2229"></a> -<span class="sourceLineNo">2230</span> return this.fs.getRegionInfo();<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> @Override<a name="line.2233"></a> -<span class="sourceLineNo">2234</span> public boolean areWritesEnabled() {<a name="line.2234"></a> -<span class="sourceLineNo">2235</span> return this.region.areWritesEnabled();<a name="line.2235"></a> -<span class="sourceLineNo">2236</span> }<a name="line.2236"></a> -<span class="sourceLineNo">2237</span><a name="line.2237"></a> -<span class="sourceLineNo">2238</span> @Override<a name="line.2238"></a> -<span class="sourceLineNo">2239</span> public long getSmallestReadPoint() {<a name="line.2239"></a> -<span class="sourceLineNo">2240</span> return this.region.getSmallestReadPoint();<a name="line.2240"></a> -<span class="sourceLineNo">2241</span> }<a name="line.2241"></a> -<span class="sourceLineNo">2242</span><a name="line.2242"></a> -<span class="sourceLineNo">2243</span> /**<a name="line.2243"></a> -<span class="sourceLineNo">2244</span> * Adds or replaces the specified KeyValues.<a name="line.2244"></a> -<span class="sourceLineNo">2245</span> * <p><a name="line.2245"></a> -<span class="sourceLineNo">2246</span> * For each KeyValue specified, if a cell with the same row, family, and qualifier exists in<a name="line.2246"></a> -<span class="sourceLineNo">2247</span> * MemStore, it will be replaced. Otherwise, it will just be inserted to MemStore.<a name="line.2247"></a> -<span class="sourceLineNo">2248</span> * <p><a name="line.2248"></a> -<span class="sourceLineNo">2249</span> * This operation is atomic on each KeyValue (row/family/qualifier) but not necessarily atomic<a name="line.2249"></a> -<span class="sourceLineNo">2250</span> * across all of them.<a name="line.2250"></a> -<span class="sourceLineNo">2251</span> * @param readpoint readpoint below which we can safely remove duplicate KVs<a name="line.2251"></a> -<span class="sourceLineNo">2252</span> * @throws IOException<a name="line.2252"></a> -<span class="sourceLineNo">2253</span> */<a name="line.2253"></a> -<span class="sourceLineNo">2254</span> public void upsert(Iterable<Cell> cells, long readpoint, MemStoreSizing memstoreSizing)<a name="line.2254"></a> -<span class="sourceLineNo">2255</span> throws IOException {<a name="line.2255"></a> -<span class="sourceLineNo">2256</span> this.lock.readLock().lock();<a name="line.2256"></a> -<span class="sourceLineNo">2257</span> try {<a name="line.2257"></a> -<span class="sourceLineNo">2258</span> this.memstore.upsert(cells, readpoint, memstoreSizing);<a name="line.2258"></a> -<span class="sourceLineNo">2259</span> } finally {<a name="line.2259"></a> -<span class="sourceLineNo">2260</span> this.lock.readLock().unlock();<a name="line.2260"></a> -<span class="sourceLineNo">2261</span> }<a name="line.2261"></a> -<span class="sourceLineNo">2262</span> }<a name="line.2262"></a> -<span class="sourceLineNo">2263</span><a name="line.2263"></a> -<span class="sourceLineNo">2264</span> public StoreFlushContext createFlushContext(long cacheFlushId, FlushLifeCycleTracker tracker) {<a name="line.2264"></a> -<span class="sourceLineNo">2265</span> return new StoreFlusherImpl(cacheFlushId, tracker);<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> private final class StoreFlusherImpl implements StoreFlushContext {<a name="line.2268"></a> -<span class="sourceLineNo">2269</span><a name="line.2269"></a> -<span class="sourceLineNo">2270</span> private final FlushLifeCycleTracker tracker;<a name="line.2270"></a> -<span class="sourceLineNo">2271</span> private final long cacheFlushSeqNum;<a name="line.2271"></a> -<span class="sourceLineNo">2272</span> private MemStoreSnapshot snapshot;<a name="line.2272"></a> -<span class="sourceLineNo">2273</span> private List<Path> tempFiles;<a name="line.2273"></a> -<span class="sourceLineNo">2274</span> private List<Path> committedFiles;<a name="line.2274"></a> -<span class="sourceLineNo">2275</span> private long cacheFlushCount;<a name="line.2275"></a> -<span class="sourceLineNo">2276</span> private long cacheFlushSize;<a name="line.2276"></a> -<span class="sourceLineNo">2277</span> private long outputFileSize;<a name="line.2277"></a> -<span class="sourceLineNo">2278</span><a name="line.2278"></a> -<span class="sourceLineNo">2279</span> private StoreFlusherImpl(long cacheFlushSeqNum, FlushLifeCycleTracker tracker) {<a name="line.2279"></a> -<span class="sourceLineNo">2280</span> this.cacheFlushSeqNum = cacheFlushSeqNum;<a name="line.2280"></a> -<span class="sourceLineNo">2281</span> this.tracker = tracker;<a name="line.2281"></a> -<span class="sourceLineNo">2282</span> }<a name="line.2282"></a> -<span class="sourceLineNo">2283</span><a name="line.2283"></a> -<span class="sourceLineNo">2284</span> /**<a name="line.2284"></a> -<span class="sourceLineNo">2285</span> * This is not thread safe. The caller should have a lock on the region or the store.<a name="line.2285"></a> -<span class="sourceLineNo">2286</span> * If necessary, the lock can be added with the patch provided in HBASE-10087<a name="line.2286"></a> -<span class="sourceLineNo">2287</span> */<a name="line.2287"></a> -<span class="sourceLineNo">2288</span> @Override<a name="line.2288"></a> -<span class="sourceLineNo">2289</span> public MemStoreSize prepare() {<a name="line.2289"></a> -<span class="sourceLineNo">2290</span> // passing the current sequence number of the wal - to allow bookkeeping in the memstore<a name="line.2290"></a> -<span class="sourceLineNo">2291</span> this.snapshot = memstore.snapshot();<a name="line.2291"></a> -<span class="sourceLineNo">2292</span> this.cacheFlushCount = snapshot.getCellsCount();<a name="line.2292"></a> -<span class="sourceLineNo">2293</span> this.cacheFlushSize = snapshot.getDataSize();<a name="line.2293"></a> -<span class="sourceLineNo">2294</span> committedFiles = new ArrayList<>(1);<a name="line.2294"></a> -<span class="sourceLineNo">2295</span> return snapshot.getMemStoreSize();<a name="line.2295"></a> -<span class="sourceLineNo">2296</span> }<a name="line.2296"></a> -<span class="sourceLineNo">2297</span><a name="line.2297"></a> -<span class="sourceLineNo">2298</span> @Override<a name="line.2298"></a> -<span class="sourceLineNo">2299</span> public void flushCache(MonitoredTask status) throws IOException {<a name="line.2299"></a> -<span class="sourceLineNo">2300</span> RegionServerServices rsService = region.getRegionServerServices();<a name="line.2300"></a> -<span class="sourceLineNo">2301</span> ThroughputController throughputController =<a name="line.2301"></a> -<span class="sourceLineNo">2302</span> rsService == null ? null : rsService.getFlushThroughputController();<a name="line.2302"></a> -<span class="sourceLineNo">2303</span> tempFiles =<a name="line.2303"></a> -<span class="sourceLineNo">2304</span> HStore.this.flushCache(cacheFlushSeqNum, snapshot, status, throughputController, tracker);<a name="line.2304"></a> -<span class="sourceLineNo">2305</span> }<a name="line.2305"></a> -<span class="sourceLineNo">2306</span><a name="line.2306"></a> -<span class="sourceLineNo">2307</span> @Override<a name="line.2307"></a> -<span class="sourceLineNo">2308</span> public boolean commit(MonitoredTask status) throws IOException {<a name="line.2308"></a> -<span class="sourceLineNo">2309</span> if (CollectionUtils.isEmpty(this.tempFiles)) {<a name="line.2309"></a> -<span class="sourceLineNo">2310</span> return false;<a name="line.2310"></a> -<span class="sourceLineNo">2311</span> }<a name="line.2311"></a> -<span class="sourceLineNo">2312</span> List<HStoreFile> storeFiles = new ArrayList<>(this.tempFiles.size());<a name="line.2312"></a> -<span class="sourceLineNo">2313</span> for (Path storeFilePath : tempFiles) {<a name="line.2313"></a> -<span class="sourceLineNo">2314</span> try {<a name="line.2314"></a> -<span class="sourceLineNo">2315</span> HStoreFile sf = HStore.this.commitFile(storeFilePath, cacheFlushSeqNum, status);<a name="line.2315"></a> -<span class="sourceLineNo">2316</span> outputFileSize += sf.getReader().length();<a name="line.2316"></a> -<span class="sourceLineNo">2317</span> storeFiles.add(sf);<a name="line.2317"></a> -<span class="sourceLineNo">2318</span> } catch (IOException ex) {<a name="line.2318"></a> -<span class="sourceLineNo">2319</span> LOG.error("Failed to commit store file {}", storeFilePath, ex);<a name="line.2319"></a> -<span class="sourceLineNo">2320</span> // Try to delete the files we have committed before.<a name="line.2320"></a> -<span class="sourceLineNo">2321</span> for (HStoreFile sf : storeFiles) {<a name="line.2321"></a> -<span class="sourceLineNo">2322</span> Path pathToDelete = sf.getPath();<a name="line.2322"></a> -<span class="sourceLineNo">2323</span> try {<a name="line.2323"></a> -<span class="sourceLineNo">2324</span> sf.deleteStoreFile();<a name="line.2324"></a> -<span class="sourceLineNo">2325</span> } catch (IOException deleteEx) {<a name="line.2325"></a> -<span class="sourceLineNo">2326</span> LOG.error(HBaseMarkers.FATAL, "Failed to delete store file we committed, "<a name="line.2326"></a> -<span class="sourceLineNo">2327</span> + "halting {}", pathToDelete, ex);<a name="line.2327"></a> -<span class="sourceLineNo">2328</span> Runtime.getRuntime().halt(1);<a name="line.2328"></a> -<span class="sourceLineNo">2329</span> }<a name="line.2329"></a> -<span class="sourceLineNo">2330</span> }<a name="line.2330"></a> -<span class="sourceLineNo">2331</span> throw new IOException("Failed to commit the flush", ex);<a name="line.2331"></a> -<span class="sourceLineNo">2332</span> }<a name="line.2332"></a> -<span class="sourceLineNo">2333</span> }<a name="line.2333"></a> -<span class="sourceLineNo">2334</span><a name="line.2334"></a> -<span class="sourceLineNo">2335</span> for (HStoreFile sf : storeFiles) {<a name="line.2335"></a> -<span class="sourceLineNo">2336</span> if (HStore.this.getCoprocessorHost() != null) {<a name="line.2336"></a> -<span class="sourceLineNo">2337</span> HStore.this.getCoprocessorHost().postFlush(HStore.this, sf, tracker);<a name="line.2337"></a> -<span class="sourceLineNo">2338</span> }<a name="line.2338"></a> -<span class="sourceLineNo">2339</span> committedFiles.add(sf.getPath());<a name="line.2339"></a> -<span class="sourceLineNo">2340</span> }<a name="line.2340"></a> -<span class="sourceLineNo">2341</span><a name="line.2341"></a> -<span class="sourceLineNo">2342</span> HStore.this.flushedCellsCount.addAndGet(cacheFlushCount);<a name="line.2342"></a> -<span class="sourceLineNo">2343</span> HStore.this.flushedCellsSize.addAndGet(cacheFlushSize);<a name="line.2343"></a> -<span class="sourceLineNo">2344</span> HStore.this.flushedOutputFileSize.addAndGet(outputFileSize);<a name="line.2344"></a> -<span class="sourceLineNo">2345</span><a name="line.2345"></a> -<span class="sourceLineNo">2346</span> // Add new file to store files. Clear snapshot too while we have the Store write lock.<a name="line.2346"></a> -<span class="sourceLineNo">2347</span> return HStore.this.updateStorefiles(storeFiles, snapshot.getId());<a name="line.2347"></a> -<span class="sourceLineNo">2348</span> }<a name="line.2348"></a> -<span class="sourceLineNo">2349</span><a name="line.2349"></a> -<span class="sourceLineNo">2350</span> @Override<a name="line.2350"></a> -<span class="sourceLineNo">2351</span> public long getOutputFileSize() {<a name="line.2351"></a> -<span class="sourceLineNo">2352</span> return outputFileSize;<a name="line.2352"></a> -<span class="sourceLineNo">2353</span> }<a name="line.2353"></a> -<span class="sourceLineNo">2354</span><a name="line.2354"></a> -<span class="sourceLineNo">2355</span> @Override<a name="line.2355"></a> -<span class="sourceLineNo">2356</span> public List<Path> getCommittedFiles() {<a name="line.2356"></a> -<span class="sourceLineNo">2357</span> return committedFiles;<a name="line.2357"></a> -<span class="sourceLineNo">2358</span> }<a name="line.2358"></a> -<span class="sourceLineNo">2359</span><a name="line.2359"></a> -<span class="sourceLineNo">2360</span> /**<a name="line.2360"></a> -<span class="sourceLineNo">2361</span> * Similar to commit, but called in secondary region replicas for replaying the<a name="line.2361"></a> -<span class="sourceLineNo">2362</span> * flush cache from primary region. Adds the new files to the store, and drops the<a name="line.2362"></a> -<span class="sourceLineNo">2363</span> * snapshot depending on dropMemstoreSnapshot argument.<a name="line.2363"></a> -<span class="sourceLineNo">2364</span> * @param fileNames names of the flushed files<a name="line.2364"></a> -<span class="sourceLineNo">2365</span> * @param dropMemstoreSnapshot whether to drop the prepared memstore snapshot<a name="line.2365"></a> -<span class="sourceLineNo">2366</span> * @throws IOException<a name="line.2366"></a> -<span class="sourceLineNo">2367</span> */<a name="line.2367"></a> -<span class="sourceLineNo">2368</span> @Override<a name="line.2368"></a> -<span class="sourceLineNo">2369</span> public void replayFlush(List<String> fileNames, boolean dropMemstoreSnapshot)<a name="line.2369"></a> -<span class="sourceLineNo">2370</span> throws IOException {<a name="line.2370"></a> -<span class="sourceLineNo">2371</span> List<HStoreFile> storeFiles = new ArrayList<>(fileNames.size());<a name="line.2371"></a> -<span class="sourceLineNo">2372</span> for (String file : fileNames) {<a name="line.2372"></a> -<span class="sourceLineNo">2373</span> // open the file as a store file (hfile link, etc)<a name="line.2373"></a> -<span class="sourceLineNo">2374</span> StoreFileInfo storeFileInfo = fs.getStoreFileInfo(getColumnFamilyName(), file);<a name="line.2374"></a> -<span class="sourceLineNo">2375</span> HStoreFile storeFile = createStoreFileAndReader(storeFileInfo);<a name="line.2375"></a> -<span class="sourceLineNo">2376</span> storeFiles.add(storeFile);<a name="line.2376"></a> -<span class="sourceLineNo">2377</span> HStore.this.storeSize.addAndGet(storeFile.getReader().length());<a name="line.2377"></a> -<span class="sourceLineNo">2378</span> HStore.this.totalUncompressedBytes<a name="line.2378"></a> -<span class="sourceLineNo">2379</span> .addAndGet(storeFile.getReader().getTotalUncompressedBytes());<a name="line.2379"></a> -<span class="sourceLineNo">2380</span> if (LOG.isInfoEnabled()) {<a name="line.2380"></a> -<span class="sourceLineNo">2381</span> LOG.info("Region: " + HStore.this.getRegionInfo().getEncodedName() +<a name="line.2381"></a> -<span class="sourceLineNo">2382</span> " added " + storeFile + ", entries=" + storeFile.getReader().getEntries() +<a name="line.2382"></a> -<span class="sourceLineNo">2383</span> ", sequenceid=" + +storeFile.getReader().getSequenceID() + ", filesize="<a name="line.2383"></a> -<span class="sourceLineNo">2384</span> + TraditionalBinaryPrefix.long2String(storeFile.getReader().length(), "", 1));<a name="line.2384"></a> -<span class="sourceLineNo">2385</span> }<a name="line.2385"></a> -<span class="sourceLineNo">2386</span> }<a name="line.2386"></a> -<span class="sourceLineNo">2387</span><a name="line.2387"></a> -<span class="sourceLineNo">2388</span> long snapshotId = -1; // -1 means do not drop<a name="line.2388"></a> -<span class="sourceLineNo">2389</span> if (dropMemstoreSnapshot && snapshot != null) {<a name="line.2389"></a> -<span class="sourceLineNo">2390</span> snapshotId = snapshot.getId();<a name="line.2390"></a> -<span class="sourceLineNo">2391</span> snapshot.close();<a name="line.2391"></a> -<span class="sourceLineNo">2392</span> }<a name="line.2392"></a> -<span class="sourceLineNo">2393</span> HStore.this.updateStorefiles(storeFiles, snapshotId);<a name="line.2393"></a> -<span class="sourceLineNo">2394</span> }<a name="line.2394"></a> -<span class="sourceLineNo">2395</span><a name="line.2395"></a> -<span class="sourceLineNo">2396</span> /**<a name="line.2396"></a> -<span class="sourceLineNo">2397</span> * Abort the snapshot preparation. Drops the snapshot if any.<a name="line.2397"></a> -<span class="sourceLineNo">2398</span> * @throws IOException<a name="line.2398"></a> -<span class="sourceLineNo">2399</span> */<a name="line.2399"></a> -<span class="sourceLineNo">2400</span> @Override<a name="line.2400"></a> -<span class="sourceLineNo">2401</span> public void abort() throws IOException {<a name="line.2401"></a> -<span class="sourceLineNo">2402</span> if (snapshot != null) {<a name="line.2402"></a> -<span class="sourceLineNo">2403</span> //We need to close the snapshot when aborting, otherwise, the segment scanner<a name="line.2403"></a> -<span class="sourceLineNo">2404</span> //won't be closed. If we are using MSLAB, the chunk referenced by those scanners<a name="line.2404"></a> -<span class="sourceLineNo">2405</span> //can't be released, thus memory leak<a name="line.2405"></a> -<span class="sourceLineNo">2406</span> snapshot.close();<a name="line.2406"></a> -<span class="sourceLineNo">2407</span> HStore.this.updateStorefiles(Collections.emptyList(), snapshot.getId());<a name="line.2407"></a> -<span class="sourceLineNo">2408</span> }<a name="line.2408"></a> -<span class="sourceLineNo">2409</span> }<a name="line.2409"></a> -<span class="sourceLineNo">2410</span> }<a name="line.2410"></a> -<span class="sourceLineNo">2411</span><a name="line.2411"></a> -<span class="sourceLineNo">2412</span> @Override<a name="line.2412"></a> -<span class="sourceLineNo">2413</span> public boolean needsCompaction() {<a name="line.2413"></a> -<span class="sourceLineNo">2414</span> List<HStoreFile> filesCompactingClone = null;<a name="line.2414"></a> -<span class="sourceLineNo">2415</span> synchronized (filesCompacting) {<a name="line.2415"></a> -<span class="sourceLineNo">2416</span> filesCompactingClone = Lists.newArrayList(filesCompacting);<a name="line.2416"></a> -<span class="sourceLineNo">2417</span> }<a name="line.2417"></a> -<span class="sourceLineNo">2418</span> return this.storeEngine.needsCompaction(filesCompactingClone);<a name="line.2418"></a> -<span class="sourceLineNo">2419</span> }<a name="line.2419"></a> -<span class="sourceLineNo">2420</span><a name="line.2420"></a> -<span class="sourceLineNo">2421</span> /**<a name="line.2421"></a> -<span class="sourceLineNo">2422</span> * Used for tests.<a name="line.2422"></a> -<span class="sourceLineNo">2423</span> * @return cache configuration for this Store.<a name="line.2423"></a> -<span class="sourceLineNo">2424</span> */<a name="line.2424"></a> -<span class="sourceLineNo">2425</span> @VisibleForTesting<a name="line.2425"></a> -<span class="sourceLineNo">2426</span> public CacheConfig getCacheConfig() {<a name="line.2426"></a> -<span class="sourceLineNo">2427</span> return this.cacheConf;<a name="line.2427"></a> -<span class="sourceLineNo">2428</span> }<a name="line.2428"></a> -<span class="sourceLineNo">2429</span><a name="line.2429"></a> -<span class="sourceLineNo">2430</span> public static final long FIXED_OVERHEAD =<a name="line.2430"></a> -<span class="sourceLineNo">2431</span> ClassSize.align(ClassSize.OBJECT + (27 * ClassSize.REFERENCE) + (2 * Bytes.SIZEOF_LONG)<a name="line.2431"></a> -<span class="sourceLineNo">2432</span> + (6 * Bytes.SIZEOF_INT) + (2 * Bytes.SIZEOF_BOOLEAN));<a name="line.2432"></a> -<span class="sourceLineNo">2433</span><a name="line.2433"></a> -<span class="sourceLineNo">2434</span> public static final long DEEP_OVERHEAD = ClassSize.align(FIXED_OVERHEAD<a name="line.2434"></a> -<span class="sourceLineNo">2435</span> + ClassSize.OBJECT + ClassSize.REENTRANT_LOCK<a name="line.2435"></a> -<span class="sourceLineNo">2436</span> + ClassSize.CONCURRENT_SKIPLISTMAP<a name="line.2436"></a> -<span class="sourceLineNo">2437</span> + ClassSize.CONCURRENT_SKIPLISTMAP_ENTRY + ClassSize.OBJECT<a name="line.2437"></a> -<span class="sourceLineNo">2438</span> + ScanInfo.FIXED_OVERHEAD);<a name="line.2438"></a> -<span class="sourceLineNo">2439</span><a name="line.2439"></a> -<span class="sourceLineNo">2440</span> @Override<a name="line.2440"></a> -<span class="sourceLineNo">2441</span> public long heapSize() {<a name="line.2441"></a> -<span class="sourceLineNo">2442</span> MemStoreSize memstoreSize = this.memstore.size();<a name="line.2442"></a> -<span class="sourceLineNo">2443</span> return DEEP_OVERHEAD + memstoreSize.getHeapSize();<a name="line.2443"></a> -<span class="sourceLineNo">2444</span> }<a name="line.2444"></a> -<span class="sourceLineNo">2445</span><a name="line.2445"></a> -<span class="sourceLineNo">2446</span> @Override<a name="line.2446"></a> -<span class="sourceLineNo">2447</span> public CellComparator getComparator() {<a name="line.2447"></a> -<span class="sourceLineNo">2448</span> return comparator;<a name="line.2448"></a> -<span class="sourceLineNo">2449</span> }<a name="line.2449"></a> -<span class="sourceLineNo">2450</span><a name="line.2450"></a> -<span class="sourceLineNo">2451</span> public ScanInfo getScanInfo() {<a name="line.2451"></a> -<span class="sourceLineNo">2452</span> return scanInfo;<a name="line.2452"></a> -<span class="sourceLineNo">2453</span> }<a name="line.2453"></a> -<span class="sourceLineNo">2454</span><a name="line.2454"></a> -<span class="sourceLineNo">2455</span> /**<a name="line.2455"></a> -<span class="sourceLineNo">2456</span> * Set scan info, used by test<a name="line.2456"></a> -<span class="sourceLineNo">2457</span> * @param scanInfo new scan info to use for test<a name="line.2457"></a> -<span class="sourceLineNo">2458</span> */<a name="line.2458"></a> -<span class="sourceLineNo">2459</span> void setScanInfo(ScanInfo scanInfo) {<a name="line.2459"></a> -<span class="sourceLineNo">2460</span> this.scanInfo = scanInfo;<a name="line.2460"></a> -<span class="sourceLineNo">2461</span> }<a name="line.2461"></a> -<span class="sourceLineNo">2462</span><a name="line.2462"></a> -<span class="sourceLineNo">2463</span> @Override<a name="line.2463"></a> -<span class="sourceLineNo">2464</span> public boolean hasTooManyStoreFiles() {<a name="line.2464"></a> -<span class="sourceLineNo">2465</span> return getStorefilesCount() > this.blockingFileCount;<a name="line.2465"></a> -<span class="sourceLineNo">2466</span> }<a name="line.2466"></a> -<span class="sourceLineNo">2467</span><a name="line.2467"></a> -<span class="sourceLineNo">2468</span> @Override<a name="line.2468"></a> -<span class="sourceLineNo">2469</span> public long getFlushedCellsCount() {<a name="line.2469"></a> -<span class="sourceLineNo">2470</span> return flushedCellsCount.get();<a name="line.2470"></a> -<span class="sourceLineNo">2471</span> }<a name="line.2471"></a> -<span class="sourceLineNo">2472</span><a name="line.2472"></a> -<span class="sourceLineNo">2473</span> @Override<a name="line.2473"></a> -<span class="sourceLineNo">2474</span> public long getFlushedCellsSize() {<a name="line.2474"></a> -<span class="sourceLineNo">2475</span> return flushedCellsSize.get();<a name="line.2475"></a> -<span class="sourceLineNo">2476</span> }<a name="line.2476"></a> -<span class="sourceLineNo">2477</span><a name="line.2477"></a> -<span class="sourceLineNo">2478</span> @Override<a name="line.2478"></a> -<span class="sourceLineNo">2479</span> public long getFlushedOutputFileSize() {<a name="line.2479"></a> -<span class="sourceLineNo">2480</span> return flushedOutputFileSize.get();<a name="line.2480"></a> -<span class="sourceLineNo">2481</span> }<a name="line.2481"></a> -<span class="sourceLineNo">2482</span><a name="line.2482"></a> -<span class="sourceLineNo">2483</span> @Override<a name="line.2483"></a> -<span class="sourceLineNo">2484</span> public long getCompactedCellsCount() {<a name="line.2484"></a> -<span class="sourceLineNo">2485</span> return compactedCellsCount.get();<a name="line.2485"></a> -<span class="sourceLineNo">2486</span> }<a name="line.2486"></a> -<span class="sourceLineNo">2487</span><a name="line.2487"></a> -<span class="sourceLineNo">2488</span> @Override<a name="line.2488"></a> -<span class="sourceLineNo">2489</span> public long getCompactedCellsSize() {<a name="line.2489"></a> -<span class="sourceLineNo">2490</span> return compactedCellsSize.get();<a name="line.2490"></a> -<span class="sourceLineNo">2491</span> }<a name="line.2491"></a> -<span class="sourceLineNo">2492</span><a name="line.2492"></a> -<span class="sourceLineNo">2493</span> @Override<a name="line.2493"></a> -<span class="sourceLineNo">2494</span> public long getMajorCompactedCellsCount() {<a name="line.2494"></a> -<span class="sourceLineNo">2495</span> return majorCompactedCellsCount.get();<a name="line.2495"></a> -<span class="sourceLineNo">2496</span> }<a name="line.2496"></a> -<span class="sourceLineNo">2497</span><a name="line.2497"></a> -<span class="sourceLineNo">2498</span> @Override<a name="line.2498"></a> -<span class="sourceLineNo">2499</span> public long getMajorCompactedCellsSize() {<a name="line.2499"></a> -<span class="sourceLineNo">2500</span> return majorCompactedCellsSize.get();<a name="line.2500"></a> -<span class="sourceLineNo">2501</span> }<a name="line.2501"></a> -<span class="sourceLineNo">2502</span><a name="line.2502"></a> -<span class="sourceLineNo">2503</span> /**<a name="line.2503"></a> -<span class="sourceLineNo">2504</span> * Returns the StoreEngine that is backing this concrete implementation of Store.<a name="line.2504"></a> -<span class="sourceLineNo">2505</span> * @return Returns the {@link StoreEngine} object used internally inside this HStore object.<a name="line.2505"></a> -<span class="sourceLineNo">2506</span> */<a name="line.2506"></a> -<span class="sourceLineNo">2507</span> @VisibleForTesting<a name="line.2507"></a> -<span class="sourceLineNo">2508</span> public StoreEngine<?, ?, ?, ?> getStoreEngine() {<a name="line.2508"></a> -<span class="sourceLineNo">2509</span> return this.storeEngine;<a name="line.2509"></a> -<span class="sourceLineNo">2510</span> }<a name="line.2510"></a> -<span class="sourceLineNo">2511</span><a name="line.2511"></a> -<span class="sourceLineNo">2512</span> protected OffPeakHours getOffPeakHours() {<a name="line.2512"></a> -<span class="sourceLineNo">2513</span> return this.offPeakHours;<a name="line.2513"></a> -<span class="sourceLineNo">2514</span> }<a name="line.2514"></a> -<span class="sourceLineNo">2515</span><a name="line.2515"></a> -<span class="sourceLineNo">2516</span> /**<a name="line.2516"></a> -<span class="sourceLineNo">2517</span> * {@inheritDoc}<a name="line.2517"></a> -<span class="sourceLineNo">2518</span> */<a name="line.2518"></a> -<span class="sourceLineNo">2519</span> @Override<a name="line.2519"></a> -<span class="sourceLineNo">2520</span> public void onConfigurationChange(Configuration conf) {<a name="line.2520"></a> -<span class="sourceLineNo">2521</span> this.conf = new CompoundConfiguration()<a name="line.2521"></a> -<span class="sourceLineNo">2522</span> .add(conf)<a name="line.2522"></a> -<span class="sourceLineNo">2523</span> .addBytesMap(family.getValues());<a name="line.2523"></a> -<span class="sourceLineNo">2524</span> this.storeEngine.compactionPolicy.setConf(conf);<a name="line.2524"></a> -<span class="sourceLineNo">2525</span> this.offPeakHours = OffPeakHours.getInstance(conf);<a name="line.2525"></a> -<span class="sourceLineNo">2526</span> }<a name="line.2526"></a> -<span class="sourceLineNo">2527</span><a name="line.2527"></a> -<span class="sourceLineNo">2528</span> /**<a name="line.2528"></a> -<span class="sourceLineNo">2529</span> * {@inheritDoc}<a name="line.2529"></a> -<span class="sourceLineNo">2530</span> */<a name="line.2530"></a> -<span class="sourceLineNo">2531</span> @Override<a name="line.2531"></a> -<span class="sourceLineNo">2532</span> public void registerChildren(ConfigurationManager manager) {<a name="line.2532"></a> -<span class="sourceLineNo">2533</span> // No children to register<a name="line.2533"></a> -<span class="sourceLineNo">2534</span> }<a name="line.2534"></a> -<span class="sourceLineNo">2535</span><a name="line.2535"></a> -<span class="sourceLineNo">2536</span> /**<a name="line.2536"></a> -<span class="sourceLineNo">2537</span> * {@inheritDoc}<a name="line.2537"></a> -<span class="sourceLineNo">2538</span> */<a name="line.2538"></a> -<span class="sourceLineNo">2539</span> @Override<a name="line.2539"></a> -<span class="sourceLineNo">2540</span> public void deregisterChildren(ConfigurationManager manager) {<a name="line.2540"></a> -<span class="sourceLineNo">2541</span> // No children to deregister<a name="line.2541"></a> -<span class="sourceLineNo">2542</span> }<a name="line.2542"></a> -<span class="sourceLineNo">2543</span><a name="line.2543"></a> -<span class="sourceLineNo">2544</span> @Override<a name="line.2544"></a> -<span class="sourceLineNo">2545</span> public double getCompactionPressure() {<a name="line.2545"></a> -<span class="sourceLineNo">2546</span> return storeEngine.getStoreFileManager().getCompactionPressure();<a name="line.2546"></a> -<span class="sourceLineNo">2547</span> }<a name="line.2547"></a> -<span class="sourceLineNo">2548</span><a name="line.2548"></a> -<span class="sourceLineNo">2549</span> @Override<a name="line.2549"></a> -<span class="sourceLineNo">2550</span> public boolean isPrimaryReplicaStore() {<a name="line.2550"></a> -<span class="sourceLineNo">2551</span> return getRegionInfo().getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID;<a name="line.2551"></a> -<span class="sourceLineNo">2552</span> }<a name="line.2552"></a> -<span class="sourceLineNo">2553</span><a name="line.2553"></a> -<span class="sourceLineNo">2554</span> /**<a name="line.2554"></a> -<span class="sourceLineNo">2555</span> * Sets the store up for a region level snapshot operation.<a name="line.2555"></a> -<span class="sourceLineNo">2556</span> * @see #postSnapshotOperation()<a name="line.2556"></a> -<span class="sourceLineNo">2557</span> */<a name="line.2557"></a> -<span class="sourceLineNo">2558</span> public void preSnapshotOperation() {<a name="line.2558"></a> -<span class="sourceLineNo">2559</span> archiveLock.lock();<a name="line.2559"></a> -<span class="sourceLineNo">2560</span> }<a name="line.2560"></a> -<span class="sourceLineNo">2561</span><a name="line.2561"></a> -<span class="sourceLineNo">2562</span> /**<a name="line.2562"></a> -<span class="sourceLineNo">2563</span> * Perform tasks needed after the completion of snapshot operation.<a name="line.2563"></a> -<span class="sourceLineNo">2564</span> * @see #preSnapshotOperation()<a name="line.2564"></a> -<span class="sourceLineNo">2565</span> */<a name="line.2565"></a> -<span class="sourceLineNo">2566</span> public void postSnapshotOperation() {<a name="line.2566"></a> -<span class="sourceLineNo">2567</span> archiveLock.unlock();<a name="line.2567"></a> -<span class="sourceLineNo">2568</span> }<a name="line.2568"></a> -<span class="sourceLineNo">2569</span><a name="line.2569"></a> -<span class="sourceLineNo">2570</span> /**<a name="line.2570"></a> -<span class="sourceLineNo">2571</span> * Closes and archives the compacted files under this store<a name="line.2571"></a> -<span class="sourceLineNo">2572</span> */<a name="line.2572"></a> -<span class="sourceLineNo">2573</span> public synchronized void closeAndArchiveCompactedFiles() throws IOException {<a name="line.2573"></a> -<span class="sourceLineNo">2574</span> closeAndArchiveCompactedFiles(false);<a name="line.2574"></a> -<span class="sourceLineNo">2575</span> }<a name="line.2575"></a> -<span class="sourceLineNo">2576</span><a name="line.2576"></a> -<span class="sourceLineNo">2577</span> @VisibleForTesting<a name="line.2577"></a> -<span class="sourceLineNo">2578</span> public synchronized void closeAndArchiveCompactedFiles(boolean storeClosing) throws IOException {<a name="line.2578"></a> -<span class="sourceLineNo">2579</span> // ensure other threads do not attempt to archive the same files on close()<a name="line.2579"></a> -<span class="sourceLineNo">2580</span> archiveLock.lock();<a name="line.2580"></a> -<span class="sourceLineNo">2581</span> try {<a name="line.2581"></a> -<span class="sourceLineNo">2582</span> lock.readLock().lock();<a name="line.2582"></a> -<span class="sourceLineNo">2583</span> Collection<HStoreFile> copyCompactedfiles = null;<a name="line.2583"></a> -<span class="sourceLineNo">2584</span> try {<a name="line.2584"></a> -<span class="sourceLineNo">2585</span> Collection<HStoreFile> compactedfiles =<a name="line.2585"></a> -<span class="sourceLineNo">2586</span> this.getStoreEngine().getStoreFileManager().getCompactedfiles();<a name="line.2586"></a> -<span class="sourceLineNo">2587</span> if (CollectionUtils.isNotEmpty(compactedfiles)) {<a name="line.2587"></a> -<span class="sourceLineNo">2588</span> // Do a copy under read lock<a name="line.2588"></a> -<span class="sourceLineNo">2589</span> copyCompactedfiles = new ArrayList<>(compactedfiles);<a name="line.2589"></a> -<span class="sourceLineNo">2590</span> } else {<a name="line.2590"></a> -<span class="sourceLineNo">2591</span> LOG.trace("No compacted files to archive");<a name="line.2591"></a> -<span class="sourceLineNo">2592</span> }<a name="line.2592"></a> -<span class="sourceLineNo">2593</span> } finally {<a name="line.2593"></a> -<span class="sourceLineNo">2594</span> lock.readLock().unlock();<a name="line.2594"></a> -<span class="sourceLineNo">2595</span> }<a name="line.2595"></a> -<span class="sourceLineNo">2596</span> if (CollectionUtils.isNotEmpty(copyCompactedfiles)) {<a name="line.2596"></a> -<span class="sourceLineNo">2597</span> removeCompactedfiles(copyCompactedfiles, storeClosing);<a name="line.2597"></a> -<span class="sourceLineNo">2598</span> }<a name="line.2598"></a> -<span class="sourceLineNo">2599</span> } finally {<a name="line.2599"></a> -<span class="sourceLineNo">2600</span> archiveLock.unlock();<a name="line.2600"></a> -<span class="sourceLineNo">2601</span> }<a name="line.2601"></a> -<span class="sourceLineNo">2602</span> }<a name="line.2602"></a> -<span class="sourceLineNo">2603</span><a name="line.2603"></a> -<span class="sourceLineNo">2604</span> /**<a name="line.2604"></a> -<span class="sourceLineNo">2605</span> * Archives and removes the compacted files<a name="line.2605"></a> -<span class="sourceLineNo">2606</span> * @param compactedfiles The compacted files in this store that are not active in reads<a name="line.2606"></a> -<span class="sourceLineNo">2607</span> */<a name="line.2607"></a> -<span class="sourceLineNo">2608</span> private void removeCompactedfiles(Collection<HStoreFile> compactedfiles, boolean storeClosing)<a name="line.2608"></a> -<span class="sourceLineNo">2609</span> throws IOException {<a name="line.2609"></a> -<span class="sourceLineNo">2610</span> final List<HStoreFile> filesToRemove = new ArrayList<>(compactedfiles.size());<a name="line.2610"></a> -<span class="sourceLineNo">2611</span> final List<Long> storeFileSizes = new ArrayList<>(compactedfiles.size());<a name="line.2611"></a> -<span class="sourceLineNo">2612</span> for (final HStoreFile file : compactedfiles) {<a name="line.2612"></a> -<span class="sourceLineNo">2613</span> synchronized (file) {<a name="line.2613"></a> -<span class="sourceLineNo">2614</span> try {<a name="line.2614"></a> -<span class="sourceLineNo">2615</span> StoreFileReader r = file.getReader();<a name="line.2615"></a> -<span class="sourceLineNo">2616</span> if (r == null) {<a name="line.2616"></a> -<span class="sourceLineNo">2617</span> LOG.debug("The file {} was closed but still not archived", file);<a name="line.2617"></a> -<span class="sourceLineNo">2618</span> // HACK: Temporarily re-open the reader so we can get the size of the file. Ideally,<a name="line.2618"></a> -<span class="sourceLineNo">2619</span> // we should know the size of
<TRUNCATED>