Search in sources :

Example 1 with ScanPerNextResultScanner

use of org.apache.hadoop.hbase.client.ScanPerNextResultScanner in project hbase by apache.

the class TestScannerHeartbeatMessages method testEquivalenceOfScanWithHeartbeats.

/**
 * Test the equivalence of a scan versus the same scan executed when heartbeat messages are
 * necessary
 * @param scan The scan configuration being tested
 * @param rowSleepTime The time to sleep between fetches of row cells
 * @param cfSleepTime The time to sleep between fetches of column family cells
 * @param sleepBeforeCf set to true when column family sleeps should occur before the cells for
 *          that column family are fetched
 */
private void testEquivalenceOfScanWithHeartbeats(final Scan scan, int rowSleepTime, int cfSleepTime, boolean sleepBeforeCf) throws Exception {
    disableSleeping();
    AsyncTable<AdvancedScanResultConsumer> table = CONN.getTable(TABLE_NAME);
    final ResultScanner scanner = new ScanPerNextResultScanner(table, scan);
    final ResultScanner scannerWithHeartbeats = new ScanPerNextResultScanner(table, scan);
    Result r1 = null;
    Result r2 = null;
    while ((r1 = scanner.next()) != null) {
        // Enforce the specified sleep conditions during calls to the heartbeat scanner
        configureSleepTime(rowSleepTime, cfSleepTime, sleepBeforeCf);
        r2 = scannerWithHeartbeats.next();
        disableSleeping();
        assertTrue(r2 != null);
        try {
            Result.compareResults(r1, r2);
        } catch (Exception e) {
            fail(e.getMessage());
        }
    }
    assertTrue(scannerWithHeartbeats.next() == null);
    scanner.close();
    scannerWithHeartbeats.close();
}
Also used : ScanPerNextResultScanner(org.apache.hadoop.hbase.client.ScanPerNextResultScanner) ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) ScanPerNextResultScanner(org.apache.hadoop.hbase.client.ScanPerNextResultScanner) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) IOException(java.io.IOException) AdvancedScanResultConsumer(org.apache.hadoop.hbase.client.AdvancedScanResultConsumer) Result(org.apache.hadoop.hbase.client.Result)

Aggregations

IOException (java.io.IOException)1 AdvancedScanResultConsumer (org.apache.hadoop.hbase.client.AdvancedScanResultConsumer)1 Result (org.apache.hadoop.hbase.client.Result)1 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)1 ScanPerNextResultScanner (org.apache.hadoop.hbase.client.ScanPerNextResultScanner)1 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)1