hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [01/11] hbase-site git commit: Published site at .
Date Mon, 08 Jan 2018 15:31:16 GMT
Repository: hbase-site
Updated Branches:
  refs/heads/asf-site a4ad3e636 -> 123d826c8


http://git-wip-us.apache.org/repos/asf/hbase-site/blob/123d826c/testdevapidocs/src-html/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.IOThrowingRunnable.html
----------------------------------------------------------------------
diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.IOThrowingRunnable.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.IOThrowingRunnable.html
index 6d723a9..f4327b3 100644
--- a/testdevapidocs/src-html/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.IOThrowingRunnable.html
+++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.IOThrowingRunnable.html
@@ -32,39 +32,39 @@
 <span class="sourceLineNo">024</span>import java.util.HashSet;<a name="line.24"></a>
 <span class="sourceLineNo">025</span>import java.util.Map;<a name="line.25"></a>
 <span class="sourceLineNo">026</span>import java.util.concurrent.atomic.AtomicLong;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import java.util.concurrent.atomic.AtomicReference;<a name="line.27"></a>
-<span class="sourceLineNo">028</span><a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.conf.Configuration;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.Cell;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.CellScanner;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.HBaseTestingUtility;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.HColumnDescriptor;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.HTableDescriptor;<a name="line.34"></a>
-<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.NamespaceDescriptor;<a name="line.35"></a>
-<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.TableName;<a name="line.36"></a>
-<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.client.Admin;<a name="line.37"></a>
-<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.client.Connection;<a name="line.38"></a>
-<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.client.Get;<a name="line.39"></a>
-<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.client.Result;<a name="line.40"></a>
-<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.client.ResultScanner;<a name="line.41"></a>
-<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.client.Scan;<a name="line.42"></a>
-<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.client.SnapshotDescription;<a name="line.43"></a>
-<span class="sourceLineNo">044</span>import org.apache.hadoop.hbase.client.SnapshotType;<a name="line.44"></a>
-<span class="sourceLineNo">045</span>import org.apache.hadoop.hbase.client.Table;<a name="line.45"></a>
-<span class="sourceLineNo">046</span>import org.apache.hadoop.hbase.master.HMaster;<a name="line.46"></a>
-<span class="sourceLineNo">047</span>import org.apache.hadoop.hbase.quotas.SnapshotQuotaObserverChore.SnapshotWithSize;<a name="line.47"></a>
-<span class="sourceLineNo">048</span>import org.apache.hadoop.hbase.quotas.SpaceQuotaHelperForTests.NoFilesToDischarge;<a name="line.48"></a>
-<span class="sourceLineNo">049</span>import org.apache.hadoop.hbase.quotas.SpaceQuotaHelperForTests.SpaceQuotaSnapshotPredicate;<a name="line.49"></a>
-<span class="sourceLineNo">050</span>import org.apache.hadoop.hbase.testclassification.MediumTests;<a name="line.50"></a>
-<span class="sourceLineNo">051</span>import org.junit.AfterClass;<a name="line.51"></a>
-<span class="sourceLineNo">052</span>import org.junit.Before;<a name="line.52"></a>
-<span class="sourceLineNo">053</span>import org.junit.BeforeClass;<a name="line.53"></a>
-<span class="sourceLineNo">054</span>import org.junit.Rule;<a name="line.54"></a>
-<span class="sourceLineNo">055</span>import org.junit.Test;<a name="line.55"></a>
-<span class="sourceLineNo">056</span>import org.junit.experimental.categories.Category;<a name="line.56"></a>
-<span class="sourceLineNo">057</span>import org.junit.rules.TestName;<a name="line.57"></a>
-<span class="sourceLineNo">058</span>import org.slf4j.Logger;<a name="line.58"></a>
-<span class="sourceLineNo">059</span>import org.slf4j.LoggerFactory;<a name="line.59"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.conf.Configuration;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.Cell;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.CellScanner;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.HBaseTestingUtility;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.HColumnDescriptor;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.HTableDescriptor;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.NamespaceDescriptor;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.TableName;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.client.Admin;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.client.Connection;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.client.Get;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.client.Result;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.client.ResultScanner;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.client.Scan;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.client.SnapshotDescription;<a name="line.41"></a>
+<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.client.SnapshotType;<a name="line.42"></a>
+<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.client.Table;<a name="line.43"></a>
+<span class="sourceLineNo">044</span>import org.apache.hadoop.hbase.master.HMaster;<a name="line.44"></a>
+<span class="sourceLineNo">045</span>import org.apache.hadoop.hbase.quotas.SnapshotQuotaObserverChore.SnapshotWithSize;<a name="line.45"></a>
+<span class="sourceLineNo">046</span>import org.apache.hadoop.hbase.quotas.SpaceQuotaHelperForTests.NoFilesToDischarge;<a name="line.46"></a>
+<span class="sourceLineNo">047</span>import org.apache.hadoop.hbase.quotas.SpaceQuotaHelperForTests.SpaceQuotaSnapshotPredicate;<a name="line.47"></a>
+<span class="sourceLineNo">048</span>import org.apache.hadoop.hbase.regionserver.HStore;<a name="line.48"></a>
+<span class="sourceLineNo">049</span>import org.apache.hadoop.hbase.testclassification.MediumTests;<a name="line.49"></a>
+<span class="sourceLineNo">050</span>import org.junit.AfterClass;<a name="line.50"></a>
+<span class="sourceLineNo">051</span>import org.junit.Before;<a name="line.51"></a>
+<span class="sourceLineNo">052</span>import org.junit.BeforeClass;<a name="line.52"></a>
+<span class="sourceLineNo">053</span>import org.junit.Rule;<a name="line.53"></a>
+<span class="sourceLineNo">054</span>import org.junit.Test;<a name="line.54"></a>
+<span class="sourceLineNo">055</span>import org.junit.experimental.categories.Category;<a name="line.55"></a>
+<span class="sourceLineNo">056</span>import org.junit.rules.TestName;<a name="line.56"></a>
+<span class="sourceLineNo">057</span>import org.slf4j.Logger;<a name="line.57"></a>
+<span class="sourceLineNo">058</span>import org.slf4j.LoggerFactory;<a name="line.58"></a>
+<span class="sourceLineNo">059</span><a name="line.59"></a>
 <span class="sourceLineNo">060</span>import org.apache.hbase.thirdparty.com.google.common.collect.HashMultimap;<a name="line.60"></a>
 <span class="sourceLineNo">061</span>import org.apache.hbase.thirdparty.com.google.common.collect.Iterables;<a name="line.61"></a>
 <span class="sourceLineNo">062</span>import org.apache.hbase.thirdparty.com.google.common.collect.Multimap;<a name="line.62"></a>
@@ -247,132 +247,137 @@
 <span class="sourceLineNo">239</span>    helper.writeData(tn1, 256L * SpaceQuotaHelperForTests.ONE_KILOBYTE);<a name="line.239"></a>
 <span class="sourceLineNo">240</span>    admin.flush(tn1);<a name="line.240"></a>
 <span class="sourceLineNo">241</span><a name="line.241"></a>
-<span class="sourceLineNo">242</span>    final AtomicReference&lt;Long&gt; lastSeenSize = new AtomicReference&lt;&gt;();<a name="line.242"></a>
-<span class="sourceLineNo">243</span>    // Wait for the Master chore to run to see the usage (with a fudge factor)<a name="line.243"></a>
-<span class="sourceLineNo">244</span>    TEST_UTIL.waitFor(30_000, new SpaceQuotaSnapshotPredicate(conn, tn1) {<a name="line.244"></a>
-<span class="sourceLineNo">245</span>      @Override<a name="line.245"></a>
-<span class="sourceLineNo">246</span>      boolean evaluate(SpaceQuotaSnapshot snapshot) throws Exception {<a name="line.246"></a>
-<span class="sourceLineNo">247</span>        lastSeenSize.set(snapshot.getUsage());<a name="line.247"></a>
-<span class="sourceLineNo">248</span>        return snapshot.getUsage() &gt; 230L * SpaceQuotaHelperForTests.ONE_KILOBYTE;<a name="line.248"></a>
-<span class="sourceLineNo">249</span>      }<a name="line.249"></a>
-<span class="sourceLineNo">250</span>    });<a name="line.250"></a>
-<span class="sourceLineNo">251</span><a name="line.251"></a>
-<span class="sourceLineNo">252</span>    // Create a snapshot on the table<a name="line.252"></a>
-<span class="sourceLineNo">253</span>    final String snapshotName = tn1 + "snapshot";<a name="line.253"></a>
-<span class="sourceLineNo">254</span>    admin.snapshot(new SnapshotDescription(snapshotName, tn1, SnapshotType.SKIPFLUSH));<a name="line.254"></a>
-<span class="sourceLineNo">255</span><a name="line.255"></a>
-<span class="sourceLineNo">256</span>    // Get the snapshots<a name="line.256"></a>
-<span class="sourceLineNo">257</span>    Multimap&lt;TableName,String&gt; snapshotsToCompute = testChore.getSnapshotsToComputeSize();<a name="line.257"></a>
-<span class="sourceLineNo">258</span>    assertEquals(<a name="line.258"></a>
-<span class="sourceLineNo">259</span>        "Expected to see the single snapshot: " + snapshotsToCompute, 1, snapshotsToCompute.size());<a name="line.259"></a>
-<span class="sourceLineNo">260</span><a name="line.260"></a>
-<span class="sourceLineNo">261</span>    // Get the size of our snapshot<a name="line.261"></a>
-<span class="sourceLineNo">262</span>    Multimap&lt;TableName,SnapshotWithSize&gt; snapshotsWithSize = testChore.computeSnapshotSizes(<a name="line.262"></a>
-<span class="sourceLineNo">263</span>        snapshotsToCompute);<a name="line.263"></a>
-<span class="sourceLineNo">264</span>    assertEquals(1, snapshotsWithSize.size());<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    SnapshotWithSize sws = Iterables.getOnlyElement(snapshotsWithSize.get(tn1));<a name="line.265"></a>
-<span class="sourceLineNo">266</span>    assertEquals(snapshotName, sws.getName());<a name="line.266"></a>
-<span class="sourceLineNo">267</span>    // The snapshot should take up no space since the table refers to it completely<a name="line.267"></a>
-<span class="sourceLineNo">268</span>    assertEquals(0, sws.getSize());<a name="line.268"></a>
-<span class="sourceLineNo">269</span><a name="line.269"></a>
-<span class="sourceLineNo">270</span>    // Write some more data, flush it, and then major_compact the table<a name="line.270"></a>
-<span class="sourceLineNo">271</span>    helper.writeData(tn1, 256L * SpaceQuotaHelperForTests.ONE_KILOBYTE);<a name="line.271"></a>
-<span class="sourceLineNo">272</span>    admin.flush(tn1);<a name="line.272"></a>
-<span class="sourceLineNo">273</span>    TEST_UTIL.compact(tn1, true);<a name="line.273"></a>
-<span class="sourceLineNo">274</span><a name="line.274"></a>
-<span class="sourceLineNo">275</span>    // Test table should reflect it's original size since ingest was deterministic<a name="line.275"></a>
-<span class="sourceLineNo">276</span>    TEST_UTIL.waitFor(30_000, new SpaceQuotaSnapshotPredicate(conn, tn1) {<a name="line.276"></a>
-<span class="sourceLineNo">277</span>      @Override<a name="line.277"></a>
-<span class="sourceLineNo">278</span>      boolean evaluate(SpaceQuotaSnapshot snapshot) throws Exception {<a name="line.278"></a>
-<span class="sourceLineNo">279</span>        LOG.debug("Current usage=" + snapshot.getUsage() + " lastSeenSize=" + lastSeenSize.get());<a name="line.279"></a>
-<span class="sourceLineNo">280</span>        return closeInSize(<a name="line.280"></a>
-<span class="sourceLineNo">281</span>            snapshot.getUsage(), lastSeenSize.get(), SpaceQuotaHelperForTests.ONE_KILOBYTE);<a name="line.281"></a>
-<span class="sourceLineNo">282</span>      }<a name="line.282"></a>
-<span class="sourceLineNo">283</span>    });<a name="line.283"></a>
-<span class="sourceLineNo">284</span><a name="line.284"></a>
-<span class="sourceLineNo">285</span>    // Wait for no compacted files on the regions of our table<a name="line.285"></a>
-<span class="sourceLineNo">286</span>    TEST_UTIL.waitFor(30_000, new NoFilesToDischarge(TEST_UTIL.getMiniHBaseCluster(), tn1));<a name="line.286"></a>
-<span class="sourceLineNo">287</span><a name="line.287"></a>
-<span class="sourceLineNo">288</span>    // Still should see only one snapshot<a name="line.288"></a>
-<span class="sourceLineNo">289</span>    snapshotsToCompute = testChore.getSnapshotsToComputeSize();<a name="line.289"></a>
-<span class="sourceLineNo">290</span>    assertEquals(<a name="line.290"></a>
-<span class="sourceLineNo">291</span>        "Expected to see the single snapshot: " + snapshotsToCompute, 1, snapshotsToCompute.size());<a name="line.291"></a>
-<span class="sourceLineNo">292</span>    snapshotsWithSize = testChore.computeSnapshotSizes(<a name="line.292"></a>
-<span class="sourceLineNo">293</span>            snapshotsToCompute);<a name="line.293"></a>
-<span class="sourceLineNo">294</span>    assertEquals(1, snapshotsWithSize.size());<a name="line.294"></a>
-<span class="sourceLineNo">295</span>    sws = Iterables.getOnlyElement(snapshotsWithSize.get(tn1));<a name="line.295"></a>
-<span class="sourceLineNo">296</span>    assertEquals(snapshotName, sws.getName());<a name="line.296"></a>
-<span class="sourceLineNo">297</span>    // The snapshot should take up the size the table originally took up<a name="line.297"></a>
-<span class="sourceLineNo">298</span>    assertEquals(lastSeenSize.get().longValue(), sws.getSize());<a name="line.298"></a>
-<span class="sourceLineNo">299</span>  }<a name="line.299"></a>
-<span class="sourceLineNo">300</span><a name="line.300"></a>
-<span class="sourceLineNo">301</span>  @Test<a name="line.301"></a>
-<span class="sourceLineNo">302</span>  public void testPersistingSnapshotsForNamespaces() throws Exception {<a name="line.302"></a>
-<span class="sourceLineNo">303</span>    Multimap&lt;TableName,SnapshotWithSize&gt; snapshotsWithSizes = HashMultimap.create();<a name="line.303"></a>
-<span class="sourceLineNo">304</span>    TableName tn1 = TableName.valueOf("ns1:tn1");<a name="line.304"></a>
-<span class="sourceLineNo">305</span>    TableName tn2 = TableName.valueOf("ns1:tn2");<a name="line.305"></a>
-<span class="sourceLineNo">306</span>    TableName tn3 = TableName.valueOf("ns2:tn1");<a name="line.306"></a>
-<span class="sourceLineNo">307</span>    TableName tn4 = TableName.valueOf("ns2:tn2");<a name="line.307"></a>
-<span class="sourceLineNo">308</span>    TableName tn5 = TableName.valueOf("tn1");<a name="line.308"></a>
-<span class="sourceLineNo">309</span><a name="line.309"></a>
-<span class="sourceLineNo">310</span>    snapshotsWithSizes.put(tn1, new SnapshotWithSize("", 1024L));<a name="line.310"></a>
-<span class="sourceLineNo">311</span>    snapshotsWithSizes.put(tn2, new SnapshotWithSize("", 1024L));<a name="line.311"></a>
-<span class="sourceLineNo">312</span>    snapshotsWithSizes.put(tn3, new SnapshotWithSize("", 512L));<a name="line.312"></a>
-<span class="sourceLineNo">313</span>    snapshotsWithSizes.put(tn4, new SnapshotWithSize("", 1024L));<a name="line.313"></a>
-<span class="sourceLineNo">314</span>    snapshotsWithSizes.put(tn5, new SnapshotWithSize("", 3072L));<a name="line.314"></a>
-<span class="sourceLineNo">315</span><a name="line.315"></a>
-<span class="sourceLineNo">316</span>    Map&lt;String,Long&gt; nsSizes = testChore.groupSnapshotSizesByNamespace(snapshotsWithSizes);<a name="line.316"></a>
-<span class="sourceLineNo">317</span>    assertEquals(3, nsSizes.size());<a name="line.317"></a>
-<span class="sourceLineNo">318</span>    assertEquals(2048L, (long) nsSizes.get("ns1"));<a name="line.318"></a>
-<span class="sourceLineNo">319</span>    assertEquals(1536L, (long) nsSizes.get("ns2"));<a name="line.319"></a>
-<span class="sourceLineNo">320</span>    assertEquals(3072L, (long) nsSizes.get(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR));<a name="line.320"></a>
-<span class="sourceLineNo">321</span>  }<a name="line.321"></a>
-<span class="sourceLineNo">322</span><a name="line.322"></a>
-<span class="sourceLineNo">323</span>  private long count(Table t) throws IOException {<a name="line.323"></a>
-<span class="sourceLineNo">324</span>    try (ResultScanner rs = t.getScanner(new Scan())) {<a name="line.324"></a>
-<span class="sourceLineNo">325</span>      long sum = 0;<a name="line.325"></a>
-<span class="sourceLineNo">326</span>      for (Result r : rs) {<a name="line.326"></a>
-<span class="sourceLineNo">327</span>        while (r.advance()) {<a name="line.327"></a>
-<span class="sourceLineNo">328</span>          sum++;<a name="line.328"></a>
-<span class="sourceLineNo">329</span>        }<a name="line.329"></a>
-<span class="sourceLineNo">330</span>      }<a name="line.330"></a>
-<span class="sourceLineNo">331</span>      return sum;<a name="line.331"></a>
-<span class="sourceLineNo">332</span>    }<a name="line.332"></a>
-<span class="sourceLineNo">333</span>  }<a name="line.333"></a>
-<span class="sourceLineNo">334</span><a name="line.334"></a>
-<span class="sourceLineNo">335</span>  private long extractSnapshotSize(<a name="line.335"></a>
-<span class="sourceLineNo">336</span>      Table quotaTable, TableName tn, String snapshot) throws IOException {<a name="line.336"></a>
-<span class="sourceLineNo">337</span>    Get g = QuotaTableUtil.makeGetForSnapshotSize(tn, snapshot);<a name="line.337"></a>
-<span class="sourceLineNo">338</span>    Result r = quotaTable.get(g);<a name="line.338"></a>
-<span class="sourceLineNo">339</span>    assertNotNull(r);<a name="line.339"></a>
-<span class="sourceLineNo">340</span>    CellScanner cs = r.cellScanner();<a name="line.340"></a>
-<span class="sourceLineNo">341</span>    cs.advance();<a name="line.341"></a>
-<span class="sourceLineNo">342</span>    Cell c = cs.current();<a name="line.342"></a>
-<span class="sourceLineNo">343</span>    assertNotNull(c);<a name="line.343"></a>
-<span class="sourceLineNo">344</span>    return QuotaTableUtil.extractSnapshotSize(<a name="line.344"></a>
-<span class="sourceLineNo">345</span>        c.getValueArray(), c.getValueOffset(), c.getValueLength());<a name="line.345"></a>
-<span class="sourceLineNo">346</span>  }<a name="line.346"></a>
-<span class="sourceLineNo">347</span><a name="line.347"></a>
-<span class="sourceLineNo">348</span>  private void verify(Table t, IOThrowingRunnable test) throws IOException {<a name="line.348"></a>
-<span class="sourceLineNo">349</span>    admin.disableTable(t.getName());<a name="line.349"></a>
-<span class="sourceLineNo">350</span>    admin.truncateTable(t.getName(), false);<a name="line.350"></a>
-<span class="sourceLineNo">351</span>    test.run();<a name="line.351"></a>
-<span class="sourceLineNo">352</span>  }<a name="line.352"></a>
-<span class="sourceLineNo">353</span><a name="line.353"></a>
-<span class="sourceLineNo">354</span>  @FunctionalInterface<a name="line.354"></a>
-<span class="sourceLineNo">355</span>  private interface IOThrowingRunnable {<a name="line.355"></a>
-<span class="sourceLineNo">356</span>    void run() throws IOException;<a name="line.356"></a>
+<span class="sourceLineNo">242</span>    final long snapshotSize = TEST_UTIL.getMiniHBaseCluster().getRegions(tn1).stream()<a name="line.242"></a>
+<span class="sourceLineNo">243</span>        .flatMap(r -&gt; r.getStores().stream()).mapToLong(HStore::getHFilesSize).sum();<a name="line.243"></a>
+<span class="sourceLineNo">244</span><a name="line.244"></a>
+<span class="sourceLineNo">245</span>    // Wait for the Master chore to run to see the usage (with a fudge factor)<a name="line.245"></a>
+<span class="sourceLineNo">246</span>    TEST_UTIL.waitFor(30_000, new SpaceQuotaSnapshotPredicate(conn, tn1) {<a name="line.246"></a>
+<span class="sourceLineNo">247</span>      @Override<a name="line.247"></a>
+<span class="sourceLineNo">248</span>      boolean evaluate(SpaceQuotaSnapshot snapshot) throws Exception {<a name="line.248"></a>
+<span class="sourceLineNo">249</span>        return snapshot.getUsage() == snapshotSize;<a name="line.249"></a>
+<span class="sourceLineNo">250</span>      }<a name="line.250"></a>
+<span class="sourceLineNo">251</span>    });<a name="line.251"></a>
+<span class="sourceLineNo">252</span><a name="line.252"></a>
+<span class="sourceLineNo">253</span>    // Create a snapshot on the table<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    final String snapshotName = tn1 + "snapshot";<a name="line.254"></a>
+<span class="sourceLineNo">255</span>    admin.snapshot(new SnapshotDescription(snapshotName, tn1, SnapshotType.SKIPFLUSH));<a name="line.255"></a>
+<span class="sourceLineNo">256</span><a name="line.256"></a>
+<span class="sourceLineNo">257</span>    // Get the snapshots<a name="line.257"></a>
+<span class="sourceLineNo">258</span>    Multimap&lt;TableName,String&gt; snapshotsToCompute = testChore.getSnapshotsToComputeSize();<a name="line.258"></a>
+<span class="sourceLineNo">259</span>    assertEquals(<a name="line.259"></a>
+<span class="sourceLineNo">260</span>        "Expected to see the single snapshot: " + snapshotsToCompute, 1, snapshotsToCompute.size());<a name="line.260"></a>
+<span class="sourceLineNo">261</span><a name="line.261"></a>
+<span class="sourceLineNo">262</span>    // Get the size of our snapshot<a name="line.262"></a>
+<span class="sourceLineNo">263</span>    Multimap&lt;TableName,SnapshotWithSize&gt; snapshotsWithSize = testChore.computeSnapshotSizes(<a name="line.263"></a>
+<span class="sourceLineNo">264</span>        snapshotsToCompute);<a name="line.264"></a>
+<span class="sourceLineNo">265</span>    assertEquals(1, snapshotsWithSize.size());<a name="line.265"></a>
+<span class="sourceLineNo">266</span>    SnapshotWithSize sws = Iterables.getOnlyElement(snapshotsWithSize.get(tn1));<a name="line.266"></a>
+<span class="sourceLineNo">267</span>    assertEquals(snapshotName, sws.getName());<a name="line.267"></a>
+<span class="sourceLineNo">268</span>    // The snapshot should take up no space since the table refers to it completely<a name="line.268"></a>
+<span class="sourceLineNo">269</span>    assertEquals(0, sws.getSize());<a name="line.269"></a>
+<span class="sourceLineNo">270</span><a name="line.270"></a>
+<span class="sourceLineNo">271</span>    // Write some more data, flush it, and then major_compact the table<a name="line.271"></a>
+<span class="sourceLineNo">272</span>    helper.writeData(tn1, 256L * SpaceQuotaHelperForTests.ONE_KILOBYTE);<a name="line.272"></a>
+<span class="sourceLineNo">273</span>    admin.flush(tn1);<a name="line.273"></a>
+<span class="sourceLineNo">274</span>    TEST_UTIL.compact(tn1, true);<a name="line.274"></a>
+<span class="sourceLineNo">275</span><a name="line.275"></a>
+<span class="sourceLineNo">276</span>    // Test table should reflect it's original size since ingest was deterministic<a name="line.276"></a>
+<span class="sourceLineNo">277</span>    TEST_UTIL.waitFor(30_000, new SpaceQuotaSnapshotPredicate(conn, tn1) {<a name="line.277"></a>
+<span class="sourceLineNo">278</span>      private final long regionSize = TEST_UTIL.getMiniHBaseCluster().getRegions(tn1).stream()<a name="line.278"></a>
+<span class="sourceLineNo">279</span>          .flatMap(r -&gt; r.getStores().stream()).mapToLong(HStore::getHFilesSize).sum();<a name="line.279"></a>
+<span class="sourceLineNo">280</span><a name="line.280"></a>
+<span class="sourceLineNo">281</span>      @Override<a name="line.281"></a>
+<span class="sourceLineNo">282</span>      boolean evaluate(SpaceQuotaSnapshot snapshot) throws Exception {<a name="line.282"></a>
+<span class="sourceLineNo">283</span>        LOG.debug("Current usage=" + snapshot.getUsage() + " snapshotSize=" + snapshotSize);<a name="line.283"></a>
+<span class="sourceLineNo">284</span>        // The usage of table space consists of region size and snapshot size<a name="line.284"></a>
+<span class="sourceLineNo">285</span>        return closeInSize(snapshot.getUsage(), snapshotSize + regionSize,<a name="line.285"></a>
+<span class="sourceLineNo">286</span>            SpaceQuotaHelperForTests.ONE_KILOBYTE);<a name="line.286"></a>
+<span class="sourceLineNo">287</span>      }<a name="line.287"></a>
+<span class="sourceLineNo">288</span>    });<a name="line.288"></a>
+<span class="sourceLineNo">289</span><a name="line.289"></a>
+<span class="sourceLineNo">290</span>    // Wait for no compacted files on the regions of our table<a name="line.290"></a>
+<span class="sourceLineNo">291</span>    TEST_UTIL.waitFor(30_000, new NoFilesToDischarge(TEST_UTIL.getMiniHBaseCluster(), tn1));<a name="line.291"></a>
+<span class="sourceLineNo">292</span><a name="line.292"></a>
+<span class="sourceLineNo">293</span>    // Still should see only one snapshot<a name="line.293"></a>
+<span class="sourceLineNo">294</span>    snapshotsToCompute = testChore.getSnapshotsToComputeSize();<a name="line.294"></a>
+<span class="sourceLineNo">295</span>    assertEquals(<a name="line.295"></a>
+<span class="sourceLineNo">296</span>        "Expected to see the single snapshot: " + snapshotsToCompute, 1, snapshotsToCompute.size());<a name="line.296"></a>
+<span class="sourceLineNo">297</span>    snapshotsWithSize = testChore.computeSnapshotSizes(<a name="line.297"></a>
+<span class="sourceLineNo">298</span>            snapshotsToCompute);<a name="line.298"></a>
+<span class="sourceLineNo">299</span>    assertEquals(1, snapshotsWithSize.size());<a name="line.299"></a>
+<span class="sourceLineNo">300</span>    sws = Iterables.getOnlyElement(snapshotsWithSize.get(tn1));<a name="line.300"></a>
+<span class="sourceLineNo">301</span>    assertEquals(snapshotName, sws.getName());<a name="line.301"></a>
+<span class="sourceLineNo">302</span>    // The snapshot should take up the size the table originally took up<a name="line.302"></a>
+<span class="sourceLineNo">303</span>    assertEquals(snapshotSize, sws.getSize());<a name="line.303"></a>
+<span class="sourceLineNo">304</span>  }<a name="line.304"></a>
+<span class="sourceLineNo">305</span><a name="line.305"></a>
+<span class="sourceLineNo">306</span>  @Test<a name="line.306"></a>
+<span class="sourceLineNo">307</span>  public void testPersistingSnapshotsForNamespaces() throws Exception {<a name="line.307"></a>
+<span class="sourceLineNo">308</span>    Multimap&lt;TableName,SnapshotWithSize&gt; snapshotsWithSizes = HashMultimap.create();<a name="line.308"></a>
+<span class="sourceLineNo">309</span>    TableName tn1 = TableName.valueOf("ns1:tn1");<a name="line.309"></a>
+<span class="sourceLineNo">310</span>    TableName tn2 = TableName.valueOf("ns1:tn2");<a name="line.310"></a>
+<span class="sourceLineNo">311</span>    TableName tn3 = TableName.valueOf("ns2:tn1");<a name="line.311"></a>
+<span class="sourceLineNo">312</span>    TableName tn4 = TableName.valueOf("ns2:tn2");<a name="line.312"></a>
+<span class="sourceLineNo">313</span>    TableName tn5 = TableName.valueOf("tn1");<a name="line.313"></a>
+<span class="sourceLineNo">314</span><a name="line.314"></a>
+<span class="sourceLineNo">315</span>    snapshotsWithSizes.put(tn1, new SnapshotWithSize("", 1024L));<a name="line.315"></a>
+<span class="sourceLineNo">316</span>    snapshotsWithSizes.put(tn2, new SnapshotWithSize("", 1024L));<a name="line.316"></a>
+<span class="sourceLineNo">317</span>    snapshotsWithSizes.put(tn3, new SnapshotWithSize("", 512L));<a name="line.317"></a>
+<span class="sourceLineNo">318</span>    snapshotsWithSizes.put(tn4, new SnapshotWithSize("", 1024L));<a name="line.318"></a>
+<span class="sourceLineNo">319</span>    snapshotsWithSizes.put(tn5, new SnapshotWithSize("", 3072L));<a name="line.319"></a>
+<span class="sourceLineNo">320</span><a name="line.320"></a>
+<span class="sourceLineNo">321</span>    Map&lt;String,Long&gt; nsSizes = testChore.groupSnapshotSizesByNamespace(snapshotsWithSizes);<a name="line.321"></a>
+<span class="sourceLineNo">322</span>    assertEquals(3, nsSizes.size());<a name="line.322"></a>
+<span class="sourceLineNo">323</span>    assertEquals(2048L, (long) nsSizes.get("ns1"));<a name="line.323"></a>
+<span class="sourceLineNo">324</span>    assertEquals(1536L, (long) nsSizes.get("ns2"));<a name="line.324"></a>
+<span class="sourceLineNo">325</span>    assertEquals(3072L, (long) nsSizes.get(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR));<a name="line.325"></a>
+<span class="sourceLineNo">326</span>  }<a name="line.326"></a>
+<span class="sourceLineNo">327</span><a name="line.327"></a>
+<span class="sourceLineNo">328</span>  private long count(Table t) throws IOException {<a name="line.328"></a>
+<span class="sourceLineNo">329</span>    try (ResultScanner rs = t.getScanner(new Scan())) {<a name="line.329"></a>
+<span class="sourceLineNo">330</span>      long sum = 0;<a name="line.330"></a>
+<span class="sourceLineNo">331</span>      for (Result r : rs) {<a name="line.331"></a>
+<span class="sourceLineNo">332</span>        while (r.advance()) {<a name="line.332"></a>
+<span class="sourceLineNo">333</span>          sum++;<a name="line.333"></a>
+<span class="sourceLineNo">334</span>        }<a name="line.334"></a>
+<span class="sourceLineNo">335</span>      }<a name="line.335"></a>
+<span class="sourceLineNo">336</span>      return sum;<a name="line.336"></a>
+<span class="sourceLineNo">337</span>    }<a name="line.337"></a>
+<span class="sourceLineNo">338</span>  }<a name="line.338"></a>
+<span class="sourceLineNo">339</span><a name="line.339"></a>
+<span class="sourceLineNo">340</span>  private long extractSnapshotSize(<a name="line.340"></a>
+<span class="sourceLineNo">341</span>      Table quotaTable, TableName tn, String snapshot) throws IOException {<a name="line.341"></a>
+<span class="sourceLineNo">342</span>    Get g = QuotaTableUtil.makeGetForSnapshotSize(tn, snapshot);<a name="line.342"></a>
+<span class="sourceLineNo">343</span>    Result r = quotaTable.get(g);<a name="line.343"></a>
+<span class="sourceLineNo">344</span>    assertNotNull(r);<a name="line.344"></a>
+<span class="sourceLineNo">345</span>    CellScanner cs = r.cellScanner();<a name="line.345"></a>
+<span class="sourceLineNo">346</span>    cs.advance();<a name="line.346"></a>
+<span class="sourceLineNo">347</span>    Cell c = cs.current();<a name="line.347"></a>
+<span class="sourceLineNo">348</span>    assertNotNull(c);<a name="line.348"></a>
+<span class="sourceLineNo">349</span>    return QuotaTableUtil.extractSnapshotSize(<a name="line.349"></a>
+<span class="sourceLineNo">350</span>        c.getValueArray(), c.getValueOffset(), c.getValueLength());<a name="line.350"></a>
+<span class="sourceLineNo">351</span>  }<a name="line.351"></a>
+<span class="sourceLineNo">352</span><a name="line.352"></a>
+<span class="sourceLineNo">353</span>  private void verify(Table t, IOThrowingRunnable test) throws IOException {<a name="line.353"></a>
+<span class="sourceLineNo">354</span>    admin.disableTable(t.getName());<a name="line.354"></a>
+<span class="sourceLineNo">355</span>    admin.truncateTable(t.getName(), false);<a name="line.355"></a>
+<span class="sourceLineNo">356</span>    test.run();<a name="line.356"></a>
 <span class="sourceLineNo">357</span>  }<a name="line.357"></a>
 <span class="sourceLineNo">358</span><a name="line.358"></a>
-<span class="sourceLineNo">359</span>  /**<a name="line.359"></a>
-<span class="sourceLineNo">360</span>   * Computes if {@code size2} is within {@code delta} of {@code size1}, inclusive.<a name="line.360"></a>
-<span class="sourceLineNo">361</span>   */<a name="line.361"></a>
-<span class="sourceLineNo">362</span>  boolean closeInSize(long size1, long size2, long delta) {<a name="line.362"></a>
-<span class="sourceLineNo">363</span>    long lower = size1 - delta;<a name="line.363"></a>
-<span class="sourceLineNo">364</span>    long upper = size1 + delta;<a name="line.364"></a>
-<span class="sourceLineNo">365</span>    return lower &lt;= size2 &amp;&amp; size2 &lt;= upper;<a name="line.365"></a>
-<span class="sourceLineNo">366</span>  }<a name="line.366"></a>
-<span class="sourceLineNo">367</span>}<a name="line.367"></a>
+<span class="sourceLineNo">359</span>  @FunctionalInterface<a name="line.359"></a>
+<span class="sourceLineNo">360</span>  private interface IOThrowingRunnable {<a name="line.360"></a>
+<span class="sourceLineNo">361</span>    void run() throws IOException;<a name="line.361"></a>
+<span class="sourceLineNo">362</span>  }<a name="line.362"></a>
+<span class="sourceLineNo">363</span><a name="line.363"></a>
+<span class="sourceLineNo">364</span>  /**<a name="line.364"></a>
+<span class="sourceLineNo">365</span>   * Computes if {@code size2} is within {@code delta} of {@code size1}, inclusive.<a name="line.365"></a>
+<span class="sourceLineNo">366</span>   */<a name="line.366"></a>
+<span class="sourceLineNo">367</span>  boolean closeInSize(long size1, long size2, long delta) {<a name="line.367"></a>
+<span class="sourceLineNo">368</span>    long lower = size1 - delta;<a name="line.368"></a>
+<span class="sourceLineNo">369</span>    long upper = size1 + delta;<a name="line.369"></a>
+<span class="sourceLineNo">370</span>    return lower &lt;= size2 &amp;&amp; size2 &lt;= upper;<a name="line.370"></a>
+<span class="sourceLineNo">371</span>  }<a name="line.371"></a>
+<span class="sourceLineNo">372</span>}<a name="line.372"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/123d826c/testdevapidocs/src-html/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.html
----------------------------------------------------------------------
diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.html
index 6d723a9..f4327b3 100644
--- a/testdevapidocs/src-html/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.html
+++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.html
@@ -32,39 +32,39 @@
 <span class="sourceLineNo">024</span>import java.util.HashSet;<a name="line.24"></a>
 <span class="sourceLineNo">025</span>import java.util.Map;<a name="line.25"></a>
 <span class="sourceLineNo">026</span>import java.util.concurrent.atomic.AtomicLong;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import java.util.concurrent.atomic.AtomicReference;<a name="line.27"></a>
-<span class="sourceLineNo">028</span><a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.conf.Configuration;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.Cell;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.CellScanner;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.HBaseTestingUtility;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.HColumnDescriptor;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.HTableDescriptor;<a name="line.34"></a>
-<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.NamespaceDescriptor;<a name="line.35"></a>
-<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.TableName;<a name="line.36"></a>
-<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.client.Admin;<a name="line.37"></a>
-<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.client.Connection;<a name="line.38"></a>
-<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.client.Get;<a name="line.39"></a>
-<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.client.Result;<a name="line.40"></a>
-<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.client.ResultScanner;<a name="line.41"></a>
-<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.client.Scan;<a name="line.42"></a>
-<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.client.SnapshotDescription;<a name="line.43"></a>
-<span class="sourceLineNo">044</span>import org.apache.hadoop.hbase.client.SnapshotType;<a name="line.44"></a>
-<span class="sourceLineNo">045</span>import org.apache.hadoop.hbase.client.Table;<a name="line.45"></a>
-<span class="sourceLineNo">046</span>import org.apache.hadoop.hbase.master.HMaster;<a name="line.46"></a>
-<span class="sourceLineNo">047</span>import org.apache.hadoop.hbase.quotas.SnapshotQuotaObserverChore.SnapshotWithSize;<a name="line.47"></a>
-<span class="sourceLineNo">048</span>import org.apache.hadoop.hbase.quotas.SpaceQuotaHelperForTests.NoFilesToDischarge;<a name="line.48"></a>
-<span class="sourceLineNo">049</span>import org.apache.hadoop.hbase.quotas.SpaceQuotaHelperForTests.SpaceQuotaSnapshotPredicate;<a name="line.49"></a>
-<span class="sourceLineNo">050</span>import org.apache.hadoop.hbase.testclassification.MediumTests;<a name="line.50"></a>
-<span class="sourceLineNo">051</span>import org.junit.AfterClass;<a name="line.51"></a>
-<span class="sourceLineNo">052</span>import org.junit.Before;<a name="line.52"></a>
-<span class="sourceLineNo">053</span>import org.junit.BeforeClass;<a name="line.53"></a>
-<span class="sourceLineNo">054</span>import org.junit.Rule;<a name="line.54"></a>
-<span class="sourceLineNo">055</span>import org.junit.Test;<a name="line.55"></a>
-<span class="sourceLineNo">056</span>import org.junit.experimental.categories.Category;<a name="line.56"></a>
-<span class="sourceLineNo">057</span>import org.junit.rules.TestName;<a name="line.57"></a>
-<span class="sourceLineNo">058</span>import org.slf4j.Logger;<a name="line.58"></a>
-<span class="sourceLineNo">059</span>import org.slf4j.LoggerFactory;<a name="line.59"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.conf.Configuration;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.Cell;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.CellScanner;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.HBaseTestingUtility;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.HColumnDescriptor;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.HTableDescriptor;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.NamespaceDescriptor;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.TableName;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.client.Admin;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.client.Connection;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.client.Get;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.client.Result;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.client.ResultScanner;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.client.Scan;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.client.SnapshotDescription;<a name="line.41"></a>
+<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.client.SnapshotType;<a name="line.42"></a>
+<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.client.Table;<a name="line.43"></a>
+<span class="sourceLineNo">044</span>import org.apache.hadoop.hbase.master.HMaster;<a name="line.44"></a>
+<span class="sourceLineNo">045</span>import org.apache.hadoop.hbase.quotas.SnapshotQuotaObserverChore.SnapshotWithSize;<a name="line.45"></a>
+<span class="sourceLineNo">046</span>import org.apache.hadoop.hbase.quotas.SpaceQuotaHelperForTests.NoFilesToDischarge;<a name="line.46"></a>
+<span class="sourceLineNo">047</span>import org.apache.hadoop.hbase.quotas.SpaceQuotaHelperForTests.SpaceQuotaSnapshotPredicate;<a name="line.47"></a>
+<span class="sourceLineNo">048</span>import org.apache.hadoop.hbase.regionserver.HStore;<a name="line.48"></a>
+<span class="sourceLineNo">049</span>import org.apache.hadoop.hbase.testclassification.MediumTests;<a name="line.49"></a>
+<span class="sourceLineNo">050</span>import org.junit.AfterClass;<a name="line.50"></a>
+<span class="sourceLineNo">051</span>import org.junit.Before;<a name="line.51"></a>
+<span class="sourceLineNo">052</span>import org.junit.BeforeClass;<a name="line.52"></a>
+<span class="sourceLineNo">053</span>import org.junit.Rule;<a name="line.53"></a>
+<span class="sourceLineNo">054</span>import org.junit.Test;<a name="line.54"></a>
+<span class="sourceLineNo">055</span>import org.junit.experimental.categories.Category;<a name="line.55"></a>
+<span class="sourceLineNo">056</span>import org.junit.rules.TestName;<a name="line.56"></a>
+<span class="sourceLineNo">057</span>import org.slf4j.Logger;<a name="line.57"></a>
+<span class="sourceLineNo">058</span>import org.slf4j.LoggerFactory;<a name="line.58"></a>
+<span class="sourceLineNo">059</span><a name="line.59"></a>
 <span class="sourceLineNo">060</span>import org.apache.hbase.thirdparty.com.google.common.collect.HashMultimap;<a name="line.60"></a>
 <span class="sourceLineNo">061</span>import org.apache.hbase.thirdparty.com.google.common.collect.Iterables;<a name="line.61"></a>
 <span class="sourceLineNo">062</span>import org.apache.hbase.thirdparty.com.google.common.collect.Multimap;<a name="line.62"></a>
@@ -247,132 +247,137 @@
 <span class="sourceLineNo">239</span>    helper.writeData(tn1, 256L * SpaceQuotaHelperForTests.ONE_KILOBYTE);<a name="line.239"></a>
 <span class="sourceLineNo">240</span>    admin.flush(tn1);<a name="line.240"></a>
 <span class="sourceLineNo">241</span><a name="line.241"></a>
-<span class="sourceLineNo">242</span>    final AtomicReference&lt;Long&gt; lastSeenSize = new AtomicReference&lt;&gt;();<a name="line.242"></a>
-<span class="sourceLineNo">243</span>    // Wait for the Master chore to run to see the usage (with a fudge factor)<a name="line.243"></a>
-<span class="sourceLineNo">244</span>    TEST_UTIL.waitFor(30_000, new SpaceQuotaSnapshotPredicate(conn, tn1) {<a name="line.244"></a>
-<span class="sourceLineNo">245</span>      @Override<a name="line.245"></a>
-<span class="sourceLineNo">246</span>      boolean evaluate(SpaceQuotaSnapshot snapshot) throws Exception {<a name="line.246"></a>
-<span class="sourceLineNo">247</span>        lastSeenSize.set(snapshot.getUsage());<a name="line.247"></a>
-<span class="sourceLineNo">248</span>        return snapshot.getUsage() &gt; 230L * SpaceQuotaHelperForTests.ONE_KILOBYTE;<a name="line.248"></a>
-<span class="sourceLineNo">249</span>      }<a name="line.249"></a>
-<span class="sourceLineNo">250</span>    });<a name="line.250"></a>
-<span class="sourceLineNo">251</span><a name="line.251"></a>
-<span class="sourceLineNo">252</span>    // Create a snapshot on the table<a name="line.252"></a>
-<span class="sourceLineNo">253</span>    final String snapshotName = tn1 + "snapshot";<a name="line.253"></a>
-<span class="sourceLineNo">254</span>    admin.snapshot(new SnapshotDescription(snapshotName, tn1, SnapshotType.SKIPFLUSH));<a name="line.254"></a>
-<span class="sourceLineNo">255</span><a name="line.255"></a>
-<span class="sourceLineNo">256</span>    // Get the snapshots<a name="line.256"></a>
-<span class="sourceLineNo">257</span>    Multimap&lt;TableName,String&gt; snapshotsToCompute = testChore.getSnapshotsToComputeSize();<a name="line.257"></a>
-<span class="sourceLineNo">258</span>    assertEquals(<a name="line.258"></a>
-<span class="sourceLineNo">259</span>        "Expected to see the single snapshot: " + snapshotsToCompute, 1, snapshotsToCompute.size());<a name="line.259"></a>
-<span class="sourceLineNo">260</span><a name="line.260"></a>
-<span class="sourceLineNo">261</span>    // Get the size of our snapshot<a name="line.261"></a>
-<span class="sourceLineNo">262</span>    Multimap&lt;TableName,SnapshotWithSize&gt; snapshotsWithSize = testChore.computeSnapshotSizes(<a name="line.262"></a>
-<span class="sourceLineNo">263</span>        snapshotsToCompute);<a name="line.263"></a>
-<span class="sourceLineNo">264</span>    assertEquals(1, snapshotsWithSize.size());<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    SnapshotWithSize sws = Iterables.getOnlyElement(snapshotsWithSize.get(tn1));<a name="line.265"></a>
-<span class="sourceLineNo">266</span>    assertEquals(snapshotName, sws.getName());<a name="line.266"></a>
-<span class="sourceLineNo">267</span>    // The snapshot should take up no space since the table refers to it completely<a name="line.267"></a>
-<span class="sourceLineNo">268</span>    assertEquals(0, sws.getSize());<a name="line.268"></a>
-<span class="sourceLineNo">269</span><a name="line.269"></a>
-<span class="sourceLineNo">270</span>    // Write some more data, flush it, and then major_compact the table<a name="line.270"></a>
-<span class="sourceLineNo">271</span>    helper.writeData(tn1, 256L * SpaceQuotaHelperForTests.ONE_KILOBYTE);<a name="line.271"></a>
-<span class="sourceLineNo">272</span>    admin.flush(tn1);<a name="line.272"></a>
-<span class="sourceLineNo">273</span>    TEST_UTIL.compact(tn1, true);<a name="line.273"></a>
-<span class="sourceLineNo">274</span><a name="line.274"></a>
-<span class="sourceLineNo">275</span>    // Test table should reflect it's original size since ingest was deterministic<a name="line.275"></a>
-<span class="sourceLineNo">276</span>    TEST_UTIL.waitFor(30_000, new SpaceQuotaSnapshotPredicate(conn, tn1) {<a name="line.276"></a>
-<span class="sourceLineNo">277</span>      @Override<a name="line.277"></a>
-<span class="sourceLineNo">278</span>      boolean evaluate(SpaceQuotaSnapshot snapshot) throws Exception {<a name="line.278"></a>
-<span class="sourceLineNo">279</span>        LOG.debug("Current usage=" + snapshot.getUsage() + " lastSeenSize=" + lastSeenSize.get());<a name="line.279"></a>
-<span class="sourceLineNo">280</span>        return closeInSize(<a name="line.280"></a>
-<span class="sourceLineNo">281</span>            snapshot.getUsage(), lastSeenSize.get(), SpaceQuotaHelperForTests.ONE_KILOBYTE);<a name="line.281"></a>
-<span class="sourceLineNo">282</span>      }<a name="line.282"></a>
-<span class="sourceLineNo">283</span>    });<a name="line.283"></a>
-<span class="sourceLineNo">284</span><a name="line.284"></a>
-<span class="sourceLineNo">285</span>    // Wait for no compacted files on the regions of our table<a name="line.285"></a>
-<span class="sourceLineNo">286</span>    TEST_UTIL.waitFor(30_000, new NoFilesToDischarge(TEST_UTIL.getMiniHBaseCluster(), tn1));<a name="line.286"></a>
-<span class="sourceLineNo">287</span><a name="line.287"></a>
-<span class="sourceLineNo">288</span>    // Still should see only one snapshot<a name="line.288"></a>
-<span class="sourceLineNo">289</span>    snapshotsToCompute = testChore.getSnapshotsToComputeSize();<a name="line.289"></a>
-<span class="sourceLineNo">290</span>    assertEquals(<a name="line.290"></a>
-<span class="sourceLineNo">291</span>        "Expected to see the single snapshot: " + snapshotsToCompute, 1, snapshotsToCompute.size());<a name="line.291"></a>
-<span class="sourceLineNo">292</span>    snapshotsWithSize = testChore.computeSnapshotSizes(<a name="line.292"></a>
-<span class="sourceLineNo">293</span>            snapshotsToCompute);<a name="line.293"></a>
-<span class="sourceLineNo">294</span>    assertEquals(1, snapshotsWithSize.size());<a name="line.294"></a>
-<span class="sourceLineNo">295</span>    sws = Iterables.getOnlyElement(snapshotsWithSize.get(tn1));<a name="line.295"></a>
-<span class="sourceLineNo">296</span>    assertEquals(snapshotName, sws.getName());<a name="line.296"></a>
-<span class="sourceLineNo">297</span>    // The snapshot should take up the size the table originally took up<a name="line.297"></a>
-<span class="sourceLineNo">298</span>    assertEquals(lastSeenSize.get().longValue(), sws.getSize());<a name="line.298"></a>
-<span class="sourceLineNo">299</span>  }<a name="line.299"></a>
-<span class="sourceLineNo">300</span><a name="line.300"></a>
-<span class="sourceLineNo">301</span>  @Test<a name="line.301"></a>
-<span class="sourceLineNo">302</span>  public void testPersistingSnapshotsForNamespaces() throws Exception {<a name="line.302"></a>
-<span class="sourceLineNo">303</span>    Multimap&lt;TableName,SnapshotWithSize&gt; snapshotsWithSizes = HashMultimap.create();<a name="line.303"></a>
-<span class="sourceLineNo">304</span>    TableName tn1 = TableName.valueOf("ns1:tn1");<a name="line.304"></a>
-<span class="sourceLineNo">305</span>    TableName tn2 = TableName.valueOf("ns1:tn2");<a name="line.305"></a>
-<span class="sourceLineNo">306</span>    TableName tn3 = TableName.valueOf("ns2:tn1");<a name="line.306"></a>
-<span class="sourceLineNo">307</span>    TableName tn4 = TableName.valueOf("ns2:tn2");<a name="line.307"></a>
-<span class="sourceLineNo">308</span>    TableName tn5 = TableName.valueOf("tn1");<a name="line.308"></a>
-<span class="sourceLineNo">309</span><a name="line.309"></a>
-<span class="sourceLineNo">310</span>    snapshotsWithSizes.put(tn1, new SnapshotWithSize("", 1024L));<a name="line.310"></a>
-<span class="sourceLineNo">311</span>    snapshotsWithSizes.put(tn2, new SnapshotWithSize("", 1024L));<a name="line.311"></a>
-<span class="sourceLineNo">312</span>    snapshotsWithSizes.put(tn3, new SnapshotWithSize("", 512L));<a name="line.312"></a>
-<span class="sourceLineNo">313</span>    snapshotsWithSizes.put(tn4, new SnapshotWithSize("", 1024L));<a name="line.313"></a>
-<span class="sourceLineNo">314</span>    snapshotsWithSizes.put(tn5, new SnapshotWithSize("", 3072L));<a name="line.314"></a>
-<span class="sourceLineNo">315</span><a name="line.315"></a>
-<span class="sourceLineNo">316</span>    Map&lt;String,Long&gt; nsSizes = testChore.groupSnapshotSizesByNamespace(snapshotsWithSizes);<a name="line.316"></a>
-<span class="sourceLineNo">317</span>    assertEquals(3, nsSizes.size());<a name="line.317"></a>
-<span class="sourceLineNo">318</span>    assertEquals(2048L, (long) nsSizes.get("ns1"));<a name="line.318"></a>
-<span class="sourceLineNo">319</span>    assertEquals(1536L, (long) nsSizes.get("ns2"));<a name="line.319"></a>
-<span class="sourceLineNo">320</span>    assertEquals(3072L, (long) nsSizes.get(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR));<a name="line.320"></a>
-<span class="sourceLineNo">321</span>  }<a name="line.321"></a>
-<span class="sourceLineNo">322</span><a name="line.322"></a>
-<span class="sourceLineNo">323</span>  private long count(Table t) throws IOException {<a name="line.323"></a>
-<span class="sourceLineNo">324</span>    try (ResultScanner rs = t.getScanner(new Scan())) {<a name="line.324"></a>
-<span class="sourceLineNo">325</span>      long sum = 0;<a name="line.325"></a>
-<span class="sourceLineNo">326</span>      for (Result r : rs) {<a name="line.326"></a>
-<span class="sourceLineNo">327</span>        while (r.advance()) {<a name="line.327"></a>
-<span class="sourceLineNo">328</span>          sum++;<a name="line.328"></a>
-<span class="sourceLineNo">329</span>        }<a name="line.329"></a>
-<span class="sourceLineNo">330</span>      }<a name="line.330"></a>
-<span class="sourceLineNo">331</span>      return sum;<a name="line.331"></a>
-<span class="sourceLineNo">332</span>    }<a name="line.332"></a>
-<span class="sourceLineNo">333</span>  }<a name="line.333"></a>
-<span class="sourceLineNo">334</span><a name="line.334"></a>
-<span class="sourceLineNo">335</span>  private long extractSnapshotSize(<a name="line.335"></a>
-<span class="sourceLineNo">336</span>      Table quotaTable, TableName tn, String snapshot) throws IOException {<a name="line.336"></a>
-<span class="sourceLineNo">337</span>    Get g = QuotaTableUtil.makeGetForSnapshotSize(tn, snapshot);<a name="line.337"></a>
-<span class="sourceLineNo">338</span>    Result r = quotaTable.get(g);<a name="line.338"></a>
-<span class="sourceLineNo">339</span>    assertNotNull(r);<a name="line.339"></a>
-<span class="sourceLineNo">340</span>    CellScanner cs = r.cellScanner();<a name="line.340"></a>
-<span class="sourceLineNo">341</span>    cs.advance();<a name="line.341"></a>
-<span class="sourceLineNo">342</span>    Cell c = cs.current();<a name="line.342"></a>
-<span class="sourceLineNo">343</span>    assertNotNull(c);<a name="line.343"></a>
-<span class="sourceLineNo">344</span>    return QuotaTableUtil.extractSnapshotSize(<a name="line.344"></a>
-<span class="sourceLineNo">345</span>        c.getValueArray(), c.getValueOffset(), c.getValueLength());<a name="line.345"></a>
-<span class="sourceLineNo">346</span>  }<a name="line.346"></a>
-<span class="sourceLineNo">347</span><a name="line.347"></a>
-<span class="sourceLineNo">348</span>  private void verify(Table t, IOThrowingRunnable test) throws IOException {<a name="line.348"></a>
-<span class="sourceLineNo">349</span>    admin.disableTable(t.getName());<a name="line.349"></a>
-<span class="sourceLineNo">350</span>    admin.truncateTable(t.getName(), false);<a name="line.350"></a>
-<span class="sourceLineNo">351</span>    test.run();<a name="line.351"></a>
-<span class="sourceLineNo">352</span>  }<a name="line.352"></a>
-<span class="sourceLineNo">353</span><a name="line.353"></a>
-<span class="sourceLineNo">354</span>  @FunctionalInterface<a name="line.354"></a>
-<span class="sourceLineNo">355</span>  private interface IOThrowingRunnable {<a name="line.355"></a>
-<span class="sourceLineNo">356</span>    void run() throws IOException;<a name="line.356"></a>
+<span class="sourceLineNo">242</span>    final long snapshotSize = TEST_UTIL.getMiniHBaseCluster().getRegions(tn1).stream()<a name="line.242"></a>
+<span class="sourceLineNo">243</span>        .flatMap(r -&gt; r.getStores().stream()).mapToLong(HStore::getHFilesSize).sum();<a name="line.243"></a>
+<span class="sourceLineNo">244</span><a name="line.244"></a>
+<span class="sourceLineNo">245</span>    // Wait for the Master chore to run to see the usage (with a fudge factor)<a name="line.245"></a>
+<span class="sourceLineNo">246</span>    TEST_UTIL.waitFor(30_000, new SpaceQuotaSnapshotPredicate(conn, tn1) {<a name="line.246"></a>
+<span class="sourceLineNo">247</span>      @Override<a name="line.247"></a>
+<span class="sourceLineNo">248</span>      boolean evaluate(SpaceQuotaSnapshot snapshot) throws Exception {<a name="line.248"></a>
+<span class="sourceLineNo">249</span>        return snapshot.getUsage() == snapshotSize;<a name="line.249"></a>
+<span class="sourceLineNo">250</span>      }<a name="line.250"></a>
+<span class="sourceLineNo">251</span>    });<a name="line.251"></a>
+<span class="sourceLineNo">252</span><a name="line.252"></a>
+<span class="sourceLineNo">253</span>    // Create a snapshot on the table<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    final String snapshotName = tn1 + "snapshot";<a name="line.254"></a>
+<span class="sourceLineNo">255</span>    admin.snapshot(new SnapshotDescription(snapshotName, tn1, SnapshotType.SKIPFLUSH));<a name="line.255"></a>
+<span class="sourceLineNo">256</span><a name="line.256"></a>
+<span class="sourceLineNo">257</span>    // Get the snapshots<a name="line.257"></a>
+<span class="sourceLineNo">258</span>    Multimap&lt;TableName,String&gt; snapshotsToCompute = testChore.getSnapshotsToComputeSize();<a name="line.258"></a>
+<span class="sourceLineNo">259</span>    assertEquals(<a name="line.259"></a>
+<span class="sourceLineNo">260</span>        "Expected to see the single snapshot: " + snapshotsToCompute, 1, snapshotsToCompute.size());<a name="line.260"></a>
+<span class="sourceLineNo">261</span><a name="line.261"></a>
+<span class="sourceLineNo">262</span>    // Get the size of our snapshot<a name="line.262"></a>
+<span class="sourceLineNo">263</span>    Multimap&lt;TableName,SnapshotWithSize&gt; snapshotsWithSize = testChore.computeSnapshotSizes(<a name="line.263"></a>
+<span class="sourceLineNo">264</span>        snapshotsToCompute);<a name="line.264"></a>
+<span class="sourceLineNo">265</span>    assertEquals(1, snapshotsWithSize.size());<a name="line.265"></a>
+<span class="sourceLineNo">266</span>    SnapshotWithSize sws = Iterables.getOnlyElement(snapshotsWithSize.get(tn1));<a name="line.266"></a>
+<span class="sourceLineNo">267</span>    assertEquals(snapshotName, sws.getName());<a name="line.267"></a>
+<span class="sourceLineNo">268</span>    // The snapshot should take up no space since the table refers to it completely<a name="line.268"></a>
+<span class="sourceLineNo">269</span>    assertEquals(0, sws.getSize());<a name="line.269"></a>
+<span class="sourceLineNo">270</span><a name="line.270"></a>
+<span class="sourceLineNo">271</span>    // Write some more data, flush it, and then major_compact the table<a name="line.271"></a>
+<span class="sourceLineNo">272</span>    helper.writeData(tn1, 256L * SpaceQuotaHelperForTests.ONE_KILOBYTE);<a name="line.272"></a>
+<span class="sourceLineNo">273</span>    admin.flush(tn1);<a name="line.273"></a>
+<span class="sourceLineNo">274</span>    TEST_UTIL.compact(tn1, true);<a name="line.274"></a>
+<span class="sourceLineNo">275</span><a name="line.275"></a>
+<span class="sourceLineNo">276</span>    // Test table should reflect it's original size since ingest was deterministic<a name="line.276"></a>
+<span class="sourceLineNo">277</span>    TEST_UTIL.waitFor(30_000, new SpaceQuotaSnapshotPredicate(conn, tn1) {<a name="line.277"></a>
+<span class="sourceLineNo">278</span>      private final long regionSize = TEST_UTIL.getMiniHBaseCluster().getRegions(tn1).stream()<a name="line.278"></a>
+<span class="sourceLineNo">279</span>          .flatMap(r -&gt; r.getStores().stream()).mapToLong(HStore::getHFilesSize).sum();<a name="line.279"></a>
+<span class="sourceLineNo">280</span><a name="line.280"></a>
+<span class="sourceLineNo">281</span>      @Override<a name="line.281"></a>
+<span class="sourceLineNo">282</span>      boolean evaluate(SpaceQuotaSnapshot snapshot) throws Exception {<a name="line.282"></a>
+<span class="sourceLineNo">283</span>        LOG.debug("Current usage=" + snapshot.getUsage() + " snapshotSize=" + snapshotSize);<a name="line.283"></a>
+<span class="sourceLineNo">284</span>        // The usage of table space consists of region size and snapshot size<a name="line.284"></a>
+<span class="sourceLineNo">285</span>        return closeInSize(snapshot.getUsage(), snapshotSize + regionSize,<a name="line.285"></a>
+<span class="sourceLineNo">286</span>            SpaceQuotaHelperForTests.ONE_KILOBYTE);<a name="line.286"></a>
+<span class="sourceLineNo">287</span>      }<a name="line.287"></a>
+<span class="sourceLineNo">288</span>    });<a name="line.288"></a>
+<span class="sourceLineNo">289</span><a name="line.289"></a>
+<span class="sourceLineNo">290</span>    // Wait for no compacted files on the regions of our table<a name="line.290"></a>
+<span class="sourceLineNo">291</span>    TEST_UTIL.waitFor(30_000, new NoFilesToDischarge(TEST_UTIL.getMiniHBaseCluster(), tn1));<a name="line.291"></a>
+<span class="sourceLineNo">292</span><a name="line.292"></a>
+<span class="sourceLineNo">293</span>    // Still should see only one snapshot<a name="line.293"></a>
+<span class="sourceLineNo">294</span>    snapshotsToCompute = testChore.getSnapshotsToComputeSize();<a name="line.294"></a>
+<span class="sourceLineNo">295</span>    assertEquals(<a name="line.295"></a>
+<span class="sourceLineNo">296</span>        "Expected to see the single snapshot: " + snapshotsToCompute, 1, snapshotsToCompute.size());<a name="line.296"></a>
+<span class="sourceLineNo">297</span>    snapshotsWithSize = testChore.computeSnapshotSizes(<a name="line.297"></a>
+<span class="sourceLineNo">298</span>            snapshotsToCompute);<a name="line.298"></a>
+<span class="sourceLineNo">299</span>    assertEquals(1, snapshotsWithSize.size());<a name="line.299"></a>
+<span class="sourceLineNo">300</span>    sws = Iterables.getOnlyElement(snapshotsWithSize.get(tn1));<a name="line.300"></a>
+<span class="sourceLineNo">301</span>    assertEquals(snapshotName, sws.getName());<a name="line.301"></a>
+<span class="sourceLineNo">302</span>    // The snapshot should take up the size the table originally took up<a name="line.302"></a>
+<span class="sourceLineNo">303</span>    assertEquals(snapshotSize, sws.getSize());<a name="line.303"></a>
+<span class="sourceLineNo">304</span>  }<a name="line.304"></a>
+<span class="sourceLineNo">305</span><a name="line.305"></a>
+<span class="sourceLineNo">306</span>  @Test<a name="line.306"></a>
+<span class="sourceLineNo">307</span>  public void testPersistingSnapshotsForNamespaces() throws Exception {<a name="line.307"></a>
+<span class="sourceLineNo">308</span>    Multimap&lt;TableName,SnapshotWithSize&gt; snapshotsWithSizes = HashMultimap.create();<a name="line.308"></a>
+<span class="sourceLineNo">309</span>    TableName tn1 = TableName.valueOf("ns1:tn1");<a name="line.309"></a>
+<span class="sourceLineNo">310</span>    TableName tn2 = TableName.valueOf("ns1:tn2");<a name="line.310"></a>
+<span class="sourceLineNo">311</span>    TableName tn3 = TableName.valueOf("ns2:tn1");<a name="line.311"></a>
+<span class="sourceLineNo">312</span>    TableName tn4 = TableName.valueOf("ns2:tn2");<a name="line.312"></a>
+<span class="sourceLineNo">313</span>    TableName tn5 = TableName.valueOf("tn1");<a name="line.313"></a>
+<span class="sourceLineNo">314</span><a name="line.314"></a>
+<span class="sourceLineNo">315</span>    snapshotsWithSizes.put(tn1, new SnapshotWithSize("", 1024L));<a name="line.315"></a>
+<span class="sourceLineNo">316</span>    snapshotsWithSizes.put(tn2, new SnapshotWithSize("", 1024L));<a name="line.316"></a>
+<span class="sourceLineNo">317</span>    snapshotsWithSizes.put(tn3, new SnapshotWithSize("", 512L));<a name="line.317"></a>
+<span class="sourceLineNo">318</span>    snapshotsWithSizes.put(tn4, new SnapshotWithSize("", 1024L));<a name="line.318"></a>
+<span class="sourceLineNo">319</span>    snapshotsWithSizes.put(tn5, new SnapshotWithSize("", 3072L));<a name="line.319"></a>
+<span class="sourceLineNo">320</span><a name="line.320"></a>
+<span class="sourceLineNo">321</span>    Map&lt;String,Long&gt; nsSizes = testChore.groupSnapshotSizesByNamespace(snapshotsWithSizes);<a name="line.321"></a>
+<span class="sourceLineNo">322</span>    assertEquals(3, nsSizes.size());<a name="line.322"></a>
+<span class="sourceLineNo">323</span>    assertEquals(2048L, (long) nsSizes.get("ns1"));<a name="line.323"></a>
+<span class="sourceLineNo">324</span>    assertEquals(1536L, (long) nsSizes.get("ns2"));<a name="line.324"></a>
+<span class="sourceLineNo">325</span>    assertEquals(3072L, (long) nsSizes.get(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR));<a name="line.325"></a>
+<span class="sourceLineNo">326</span>  }<a name="line.326"></a>
+<span class="sourceLineNo">327</span><a name="line.327"></a>
+<span class="sourceLineNo">328</span>  private long count(Table t) throws IOException {<a name="line.328"></a>
+<span class="sourceLineNo">329</span>    try (ResultScanner rs = t.getScanner(new Scan())) {<a name="line.329"></a>
+<span class="sourceLineNo">330</span>      long sum = 0;<a name="line.330"></a>
+<span class="sourceLineNo">331</span>      for (Result r : rs) {<a name="line.331"></a>
+<span class="sourceLineNo">332</span>        while (r.advance()) {<a name="line.332"></a>
+<span class="sourceLineNo">333</span>          sum++;<a name="line.333"></a>
+<span class="sourceLineNo">334</span>        }<a name="line.334"></a>
+<span class="sourceLineNo">335</span>      }<a name="line.335"></a>
+<span class="sourceLineNo">336</span>      return sum;<a name="line.336"></a>
+<span class="sourceLineNo">337</span>    }<a name="line.337"></a>
+<span class="sourceLineNo">338</span>  }<a name="line.338"></a>
+<span class="sourceLineNo">339</span><a name="line.339"></a>
+<span class="sourceLineNo">340</span>  private long extractSnapshotSize(<a name="line.340"></a>
+<span class="sourceLineNo">341</span>      Table quotaTable, TableName tn, String snapshot) throws IOException {<a name="line.341"></a>
+<span class="sourceLineNo">342</span>    Get g = QuotaTableUtil.makeGetForSnapshotSize(tn, snapshot);<a name="line.342"></a>
+<span class="sourceLineNo">343</span>    Result r = quotaTable.get(g);<a name="line.343"></a>
+<span class="sourceLineNo">344</span>    assertNotNull(r);<a name="line.344"></a>
+<span class="sourceLineNo">345</span>    CellScanner cs = r.cellScanner();<a name="line.345"></a>
+<span class="sourceLineNo">346</span>    cs.advance();<a name="line.346"></a>
+<span class="sourceLineNo">347</span>    Cell c = cs.current();<a name="line.347"></a>
+<span class="sourceLineNo">348</span>    assertNotNull(c);<a name="line.348"></a>
+<span class="sourceLineNo">349</span>    return QuotaTableUtil.extractSnapshotSize(<a name="line.349"></a>
+<span class="sourceLineNo">350</span>        c.getValueArray(), c.getValueOffset(), c.getValueLength());<a name="line.350"></a>
+<span class="sourceLineNo">351</span>  }<a name="line.351"></a>
+<span class="sourceLineNo">352</span><a name="line.352"></a>
+<span class="sourceLineNo">353</span>  private void verify(Table t, IOThrowingRunnable test) throws IOException {<a name="line.353"></a>
+<span class="sourceLineNo">354</span>    admin.disableTable(t.getName());<a name="line.354"></a>
+<span class="sourceLineNo">355</span>    admin.truncateTable(t.getName(), false);<a name="line.355"></a>
+<span class="sourceLineNo">356</span>    test.run();<a name="line.356"></a>
 <span class="sourceLineNo">357</span>  }<a name="line.357"></a>
 <span class="sourceLineNo">358</span><a name="line.358"></a>
-<span class="sourceLineNo">359</span>  /**<a name="line.359"></a>
-<span class="sourceLineNo">360</span>   * Computes if {@code size2} is within {@code delta} of {@code size1}, inclusive.<a name="line.360"></a>
-<span class="sourceLineNo">361</span>   */<a name="line.361"></a>
-<span class="sourceLineNo">362</span>  boolean closeInSize(long size1, long size2, long delta) {<a name="line.362"></a>
-<span class="sourceLineNo">363</span>    long lower = size1 - delta;<a name="line.363"></a>
-<span class="sourceLineNo">364</span>    long upper = size1 + delta;<a name="line.364"></a>
-<span class="sourceLineNo">365</span>    return lower &lt;= size2 &amp;&amp; size2 &lt;= upper;<a name="line.365"></a>
-<span class="sourceLineNo">366</span>  }<a name="line.366"></a>
-<span class="sourceLineNo">367</span>}<a name="line.367"></a>
+<span class="sourceLineNo">359</span>  @FunctionalInterface<a name="line.359"></a>
+<span class="sourceLineNo">360</span>  private interface IOThrowingRunnable {<a name="line.360"></a>
+<span class="sourceLineNo">361</span>    void run() throws IOException;<a name="line.361"></a>
+<span class="sourceLineNo">362</span>  }<a name="line.362"></a>
+<span class="sourceLineNo">363</span><a name="line.363"></a>
+<span class="sourceLineNo">364</span>  /**<a name="line.364"></a>
+<span class="sourceLineNo">365</span>   * Computes if {@code size2} is within {@code delta} of {@code size1}, inclusive.<a name="line.365"></a>
+<span class="sourceLineNo">366</span>   */<a name="line.366"></a>
+<span class="sourceLineNo">367</span>  boolean closeInSize(long size1, long size2, long delta) {<a name="line.367"></a>
+<span class="sourceLineNo">368</span>    long lower = size1 - delta;<a name="line.368"></a>
+<span class="sourceLineNo">369</span>    long upper = size1 + delta;<a name="line.369"></a>
+<span class="sourceLineNo">370</span>    return lower &lt;= size2 &amp;&amp; size2 &lt;= upper;<a name="line.370"></a>
+<span class="sourceLineNo">371</span>  }<a name="line.371"></a>
+<span class="sourceLineNo">372</span>}<a name="line.372"></a>
 
 
 


Mime
View raw message