当前位置: 首页>>代码示例>>Java>>正文


Java WALEdit.size方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.regionserver.wal.WALEdit.size方法的典型用法代码示例。如果您正苦于以下问题:Java WALEdit.size方法的具体用法?Java WALEdit.size怎么用?Java WALEdit.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.regionserver.wal.WALEdit的用法示例。


在下文中一共展示了WALEdit.size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: countDistinctRowKeys

import org.apache.hadoop.hbase.regionserver.wal.WALEdit; //导入方法依赖的package包/类
/**
 * Count the number of different row keys in the given edit because of mini-batching. We assume
 * that there's at least one Cell in the WALEdit.
 * @param edit edit to count row keys from
 * @return number of different row keys
 */
private int countDistinctRowKeys(WALEdit edit) {
  List<Cell> cells = edit.getCells();
  int distinctRowKeys = 1;
  Cell lastCell = cells.get(0);
  for (int i = 0; i < edit.size(); i++) {
    if (!CellUtil.matchingRow(cells.get(i), lastCell)) {
      distinctRowKeys++;
    }
  }
  return distinctRowKeys;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:ReplicationSource.java

示例2: readAllEntriesToReplicateOrNextFile

import org.apache.hadoop.hbase.regionserver.wal.WALEdit; //导入方法依赖的package包/类
/**
 * Read all the entries from the current log files and retain those that need to be replicated.
 * Else, process the end of the current file.
 * @param currentWALisBeingWrittenTo is the current WAL being written to
 * @param entries resulting entries to be replicated
 * @return true if we got nothing and went to the next file, false if we got entries
 * @throws IOException
 */
protected boolean readAllEntriesToReplicateOrNextFile(boolean currentWALisBeingWrittenTo,
    List<WAL.Entry> entries) throws IOException {
  long seenEntries = 0;
  if (LOG.isTraceEnabled()) {
    LOG.trace("Seeking in " + this.currentPath + " at position "
        + this.repLogReader.getPosition());
  }
  this.repLogReader.seek();
  long positionBeforeRead = this.repLogReader.getPosition();
  WAL.Entry entry = this.repLogReader.readNextAndSetPosition();
  while (entry != null) {
    metrics.incrLogEditsRead();
    seenEntries++;

    // don't replicate if the log entries have already been consumed by the cluster
    if (replicationEndpoint.canReplicateToSameCluster()
        || !entry.getKey().getClusterIds().contains(peerClusterId)) {
      // Remove all KVs that should not be replicated
      entry = walEntryFilter.filter(entry);
      WALEdit edit = null;
      WALKey logKey = null;
      if (entry != null) {
        edit = entry.getEdit();
        logKey = entry.getKey();
      }

      if (edit != null && edit.size() != 0) {
        // Mark that the current cluster has the change
        logKey.addClusterId(clusterId);
        currentNbOperations += countDistinctRowKeys(edit);
        entries.add(entry);
        currentSize += entry.getEdit().heapSize();
      } else {
        metrics.incrLogEditsFiltered();
      }
    }
    // Stop if too many entries or too big
    // FIXME check the relationship between single wal group and overall
    if (currentSize >= replicationQueueSizeCapacity
        || entries.size() >= replicationQueueNbCapacity) {
      break;
    }
    try {
      entry = this.repLogReader.readNextAndSetPosition();
    } catch (IOException ie) {
      LOG.debug("Break on IOE: " + ie.getMessage());
      break;
    }
  }
  metrics.incrLogReadInBytes(this.repLogReader.getPosition() - positionBeforeRead);
  if (currentWALisBeingWrittenTo) {
    return false;
  }
  // If we didn't get anything and the queue has an object, it means we
  // hit the end of the file for sure
  return seenEntries == 0 && processEndOfFile();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:66,代码来源:ReplicationSource.java


注:本文中的org.apache.hadoop.hbase.regionserver.wal.WALEdit.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。