當前位置: 首頁>>代碼示例>>Java>>正文


Java Result.compareResults方法代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.client.Result.compareResults方法的典型用法代碼示例。如果您正苦於以下問題:Java Result.compareResults方法的具體用法?Java Result.compareResults怎麽用?Java Result.compareResults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.hbase.client.Result的用法示例。


在下文中一共展示了Result.compareResults方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: compareResults

import org.apache.hadoop.hbase.client.Result; //導入方法依賴的package包/類
/**
 * 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);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:24,代碼來源:TestPartialResultsFromClientSide.java

示例2: testEquivalenceOfScanWithHeartbeats

import org.apache.hadoop.hbase.client.Result; //導入方法依賴的package包/類
/**
 * 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
 * @throws Exception
 */
public void testEquivalenceOfScanWithHeartbeats(final Scan scan, int rowSleepTime,
    int cfSleepTime, boolean sleepBeforeCf) throws Exception {
  disableSleeping();
  final ResultScanner scanner = TABLE.getScanner(scan);
  final ResultScanner scannerWithHeartbeats = TABLE.getScanner(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();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:38,代碼來源:TestScannerHeartbeatMessages.java

示例3: map

import org.apache.hadoop.hbase.client.Result; //導入方法依賴的package包/類
/**
 * Map method that compares every scanned row with the equivalent from
 * a distant cluster.
 * @param row  The current table row key.
 * @param value  The columns.
 * @param context  The current context.
 * @throws IOException When something is broken with the data.
 */
@Override
public void map(ImmutableBytesWritable row, final Result value,
                Context context)
    throws IOException {
  if (replicatedScanner == null) {
    Configuration conf = context.getConfiguration();
    final Scan scan = new Scan();
    scan.setCaching(conf.getInt(TableInputFormat.SCAN_CACHEDROWS, 1));
    long startTime = conf.getLong(NAME + ".startTime", 0);
    long endTime = conf.getLong(NAME + ".endTime", Long.MAX_VALUE);
    String families = conf.get(NAME + ".families", null);
    if(families != null) {
      String[] fams = families.split(",");
      for(String fam : fams) {
        scan.addFamily(Bytes.toBytes(fam));
      }
    }
    scan.setTimeRange(startTime, endTime);
    int versions = conf.getInt(NAME+".versions", -1);
    LOG.info("Setting number of version inside map as: " + versions);
    if (versions >= 0) {
      scan.setMaxVersions(versions);
    }

    final TableSplit tableSplit = (TableSplit)(context.getInputSplit());
    HConnectionManager.execute(new HConnectable<Void>(conf) {
      @Override
      public Void connect(HConnection conn) throws IOException {
        String zkClusterKey = conf.get(NAME + ".peerQuorumAddress");
        Configuration peerConf = HBaseConfiguration.createClusterConf(conf,
            zkClusterKey, PEER_CONFIG_PREFIX);

        TableName tableName = TableName.valueOf(conf.get(NAME + ".tableName"));
        replicatedTable = new HTable(peerConf, tableName);
        scan.setStartRow(value.getRow());
        scan.setStopRow(tableSplit.getEndRow());
        replicatedScanner = replicatedTable.getScanner(scan);
        return null;
      }
    });
    currentCompareRowInPeerTable = replicatedScanner.next();
  }
  while (true) {
    if (currentCompareRowInPeerTable == null) {
      // reach the region end of peer table, row only in source table
      logFailRowAndIncreaseCounter(context, Counters.ONLY_IN_SOURCE_TABLE_ROWS, value);
      break;
    }
    int rowCmpRet = Bytes.compareTo(value.getRow(), currentCompareRowInPeerTable.getRow());
    if (rowCmpRet == 0) {
      // rowkey is same, need to compare the content of the row
      try {
        Result.compareResults(value, currentCompareRowInPeerTable);
        context.getCounter(Counters.GOODROWS).increment(1);
      } catch (Exception e) {
        logFailRowAndIncreaseCounter(context, Counters.CONTENT_DIFFERENT_ROWS, value);
        LOG.error("Exception while comparing row : " + e);
      }
      currentCompareRowInPeerTable = replicatedScanner.next();
      break;
    } else if (rowCmpRet < 0) {
      // row only exists in source table
      logFailRowAndIncreaseCounter(context, Counters.ONLY_IN_SOURCE_TABLE_ROWS, value);
      break;
    } else {
      // row only exists in peer table
      logFailRowAndIncreaseCounter(context, Counters.ONLY_IN_PEER_TABLE_ROWS,
        currentCompareRowInPeerTable);
      currentCompareRowInPeerTable = replicatedScanner.next();
    }
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:81,代碼來源:VerifyReplication.java


注:本文中的org.apache.hadoop.hbase.client.Result.compareResults方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。