Java Code Examples for org.apache.hadoop.hbase.client.Result#compareResults()

The following examples show how to use org.apache.hadoop.hbase.client.Result#compareResults() . 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: TestPartialResultsFromClientSide.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Compares two results and fails the test if the results are different
 * @param r1
 * @param r2
 * @param message
 */
static void compareResults(Result r1, Result r2, final String message) {
  if (LOG.isInfoEnabled()) {
    if (message != null) LOG.info(message);
    LOG.info("r1: " + r1);
    LOG.info("r2: " + r2);
  }

  final String failureMessage = "Results r1:" + r1 + " \nr2:" + r2 + " are not equivalent";
  if (r1 == null && r2 == null) fail(failureMessage);
  else if (r1 == null || r2 == null) fail(failureMessage);

  try {
    Result.compareResults(r1, r2);
  } catch (Exception e) {
    fail(failureMessage);
  }
}
 
Example 2
Source File: VerifyReplication.java    From hbase with Apache License 2.0 6 votes vote down vote up
private void logFailRowAndIncreaseCounter(Context context, Counters counter, Result row) {
  if (sleepMsBeforeReCompare > 0) {
    Threads.sleep(sleepMsBeforeReCompare);
    try {
      Result sourceResult = sourceTable.get(new Get(row.getRow()));
      Result replicatedResult = replicatedTable.get(new Get(row.getRow()));
      Result.compareResults(sourceResult, replicatedResult);
      if (!sourceResult.isEmpty()) {
        context.getCounter(Counters.GOODROWS).increment(1);
        if (verbose) {
          LOG.info("Good row key (with recompare): " + delimiter + Bytes.toStringBinary(row.getRow())
          + delimiter);
        }
      }
      return;
    } catch (Exception e) {
      LOG.error("recompare fail after sleep, rowkey=" + delimiter +
          Bytes.toStringBinary(row.getRow()) + delimiter);
    }
  }
  context.getCounter(counter).increment(1);
  context.getCounter(Counters.BADROWS).increment(1);
  LOG.error(counter.toString() + ", rowkey=" + delimiter + Bytes.toStringBinary(row.getRow()) +
      delimiter);
}
 
Example 3
Source File: TestScannerHeartbeatMessages.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}