Java Code Examples for org.apache.hadoop.hbase.regionserver.HRegion#FlushResult
The following examples show how to use
org.apache.hadoop.hbase.regionserver.HRegion#FlushResult .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransactionProcessorTest.java From phoenix-tephra with Apache License 2.0 | 4 votes |
@Test public void testDataJanitorRegionScanner() throws Exception { String tableName = "TestRegionScanner"; byte[] familyBytes = Bytes.toBytes("f"); byte[] columnBytes = Bytes.toBytes("c"); HRegion region = createRegion(tableName, familyBytes, TimeUnit.HOURS.toMillis(3)); try { region.initialize(); TransactionStateCache cache = new TransactionStateCacheSupplier(conf).get(); LOG.info("Coprocessor is using transaction state: " + waitForTransactionState(cache)); for (int i = 1; i <= 8; i++) { for (int k = 1; k <= i; k++) { Put p = new Put(Bytes.toBytes(i)); p.add(familyBytes, columnBytes, V[k], Bytes.toBytes(V[k])); region.put(p); } } List<Cell> results = Lists.newArrayList(); // force a flush to clear the data // during flush, the coprocessor should drop all KeyValues with timestamps in the invalid set LOG.info("Flushing region " + region.getRegionNameAsString()); HRegion.FlushResult flushResult = region.flushcache(); Assert.assertTrue("Unexpected flush result: " + flushResult.toString(), flushResult.isFlushSucceeded()); // now a normal scan should only return the valid rows // do not use a filter here to test that cleanup works on flush Scan scan = new Scan(); scan.setMaxVersions(10); RegionScanner regionScanner = region.getScanner(scan); // first returned value should be "4" with version "4" results.clear(); assertTrue(regionScanner.next(results)); assertKeyValueMatches(results, 4, new long[] {V[4]}); results.clear(); assertTrue(regionScanner.next(results)); assertKeyValueMatches(results, 5, new long[] {V[4]}); results.clear(); assertTrue(regionScanner.next(results)); assertKeyValueMatches(results, 6, new long[] {V[6], V[4]}); results.clear(); assertTrue(regionScanner.next(results)); assertKeyValueMatches(results, 7, new long[] {V[6], V[4]}); results.clear(); assertFalse(regionScanner.next(results)); assertKeyValueMatches(results, 8, new long[] {V[8], V[6], V[4]}); } finally { region.close(); } }
Example 2
Source File: TransactionProcessorTest.java From phoenix-tephra with Apache License 2.0 | 4 votes |
@Test public void testDataJanitorRegionScanner() throws Exception { String tableName = "TestRegionScanner"; byte[] familyBytes = Bytes.toBytes("f"); byte[] columnBytes = Bytes.toBytes("c"); HRegion region = createRegion(tableName, familyBytes, TimeUnit.HOURS.toMillis(3)); try { region.initialize(); TransactionStateCache cache = new TransactionStateCacheSupplier(conf).get(); LOG.info("Coprocessor is using transaction state: " + waitForTransactionState(cache)); for (int i = 1; i <= 8; i++) { for (int k = 1; k <= i; k++) { Put p = new Put(Bytes.toBytes(i)); p.add(familyBytes, columnBytes, V[k], Bytes.toBytes(V[k])); region.put(p); } } List<Cell> results = Lists.newArrayList(); // force a flush to clear the data // during flush, the coprocessor should drop all KeyValues with timestamps in the invalid set LOG.info("Flushing region " + region.getRegionNameAsString()); HRegion.FlushResult flushResult = region.flushcache(); Assert.assertTrue("Unexpected flush result: " + flushResult, flushResult.isFlushSucceeded()); // now a normal scan should only return the valid rows // do not use a filter here to test that cleanup works on flush Scan scan = new Scan(); scan.setMaxVersions(10); RegionScanner regionScanner = region.getScanner(scan); // first returned value should be "4" with version "4" results.clear(); assertTrue(regionScanner.next(results)); assertKeyValueMatches(results, 4, new long[]{V[4]}); results.clear(); assertTrue(regionScanner.next(results)); assertKeyValueMatches(results, 5, new long[] {V[4]}); results.clear(); assertTrue(regionScanner.next(results)); assertKeyValueMatches(results, 6, new long[]{V[6], V[4]}); results.clear(); assertTrue(regionScanner.next(results)); assertKeyValueMatches(results, 7, new long[]{V[6], V[4]}); results.clear(); assertFalse(regionScanner.next(results)); assertKeyValueMatches(results, 8, new long[] {V[8], V[6], V[4]}); } finally { region.close(); } }
Example 3
Source File: TransactionProcessorTest.java From phoenix-tephra with Apache License 2.0 | 4 votes |
@Test public void testDataJanitorRegionScanner() throws Exception { String tableName = "TestRegionScanner"; byte[] familyBytes = Bytes.toBytes("f"); byte[] columnBytes = Bytes.toBytes("c"); HRegion region = createRegion(tableName, familyBytes, TimeUnit.HOURS.toMillis(3)); try { region.initialize(); TransactionStateCache cache = new TransactionStateCacheSupplier(conf).get(); LOG.info("Coprocessor is using transaction state: " + waitForTransactionState(cache)); for (int i = 1; i <= 8; i++) { for (int k = 1; k <= i; k++) { Put p = new Put(Bytes.toBytes(i)); p.add(familyBytes, columnBytes, V[k], Bytes.toBytes(V[k])); region.put(p); } } List<Cell> results = Lists.newArrayList(); // force a flush to clear the data // during flush, the coprocessor should drop all KeyValues with timestamps in the invalid set LOG.info("Flushing region " + region.getRegionNameAsString()); HRegion.FlushResult flushResult = region.flushcache(); Assert.assertTrue("Unexpected flush result: " + flushResult, flushResult.isFlushSucceeded()); // now a normal scan should only return the valid rows // do not use a filter here to test that cleanup works on flush Scan scan = new Scan(); scan.setMaxVersions(10); RegionScanner regionScanner = region.getScanner(scan); // first returned value should be "4" with version "4" results.clear(); assertTrue(regionScanner.next(results)); assertKeyValueMatches(results, 4, new long[] {V[4]}); results.clear(); assertTrue(regionScanner.next(results)); assertKeyValueMatches(results, 5, new long[] {V[4]}); results.clear(); assertTrue(regionScanner.next(results)); assertKeyValueMatches(results, 6, new long[] {V[6], V[4]}); results.clear(); assertTrue(regionScanner.next(results)); assertKeyValueMatches(results, 7, new long[] {V[6], V[4]}); results.clear(); assertFalse(regionScanner.next(results)); assertKeyValueMatches(results, 8, new long[] {V[8], V[6], V[4]}); } finally { region.close(); } }