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


Java WALKey.getOrigLogSeqNum方法代码示例

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


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

示例1: buildReplicateWALEntryRequest

import org.apache.hadoop.hbase.wal.WALKey; //导入方法依赖的package包/类
/**
 * Create a new ReplicateWALEntryRequest from a list of HLog entries
 *
 * @param entries the HLog entries to be replicated
 * @param encodedRegionName alternative region name to use if not null
 * @return a pair of ReplicateWALEntryRequest and a CellScanner over all the WALEdit values
 * found.
 */
public static Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner>
    buildReplicateWALEntryRequest(final Entry[] entries, byte[] encodedRegionName) {
  // Accumulate all the KVs seen in here.
  List<List<? extends Cell>> allCells = new ArrayList<List<? extends Cell>>(entries.length);
  int size = 0;
  WALProtos.FamilyScope.Builder scopeBuilder = WALProtos.FamilyScope.newBuilder();
  AdminProtos.WALEntry.Builder entryBuilder = AdminProtos.WALEntry.newBuilder();
  AdminProtos.ReplicateWALEntryRequest.Builder builder =
    AdminProtos.ReplicateWALEntryRequest.newBuilder();
  HBaseProtos.UUID.Builder uuidBuilder = HBaseProtos.UUID.newBuilder();
  for (Entry entry: entries) {
    entryBuilder.clear();
    // TODO: this duplicates a lot in WALKey#getBuilder
    WALProtos.WALKey.Builder keyBuilder = entryBuilder.getKeyBuilder();
    WALKey key = entry.getKey();
    keyBuilder.setEncodedRegionName(
      ByteStringer.wrap(encodedRegionName == null
          ? key.getEncodedRegionName()
          : encodedRegionName));
    keyBuilder.setTableName(ByteStringer.wrap(key.getTablename().getName()));
    keyBuilder.setLogSequenceNumber(key.getLogSeqNum());
    keyBuilder.setWriteTime(key.getWriteTime());
    if (key.getNonce() != HConstants.NO_NONCE) {
      keyBuilder.setNonce(key.getNonce());
    }
    if (key.getNonceGroup() != HConstants.NO_NONCE) {
      keyBuilder.setNonceGroup(key.getNonceGroup());
    }
    for(UUID clusterId : key.getClusterIds()) {
      uuidBuilder.setLeastSigBits(clusterId.getLeastSignificantBits());
      uuidBuilder.setMostSigBits(clusterId.getMostSignificantBits());
      keyBuilder.addClusterIds(uuidBuilder.build());
    }
    if(key.getOrigLogSeqNum() > 0) {
      keyBuilder.setOrigSequenceNumber(key.getOrigLogSeqNum());
    }
    WALEdit edit = entry.getEdit();
    NavigableMap<byte[], Integer> scopes = key.getScopes();
    if (scopes != null && !scopes.isEmpty()) {
      for (Map.Entry<byte[], Integer> scope: scopes.entrySet()) {
        scopeBuilder.setFamily(ByteStringer.wrap(scope.getKey()));
        WALProtos.ScopeType scopeType =
            WALProtos.ScopeType.valueOf(scope.getValue().intValue());
        scopeBuilder.setScopeType(scopeType);
        keyBuilder.addScopes(scopeBuilder.build());
      }
    }
    List<Cell> cells = edit.getCells();
    // Add up the size.  It is used later serializing out the cells.
    for (Cell cell: cells) {
      size += CellUtil.estimatedSerializedSizeOf(cell);
    }
    // Collect up the cells
    allCells.add(cells);
    // Write out how many cells associated with this entry.
    entryBuilder.setAssociatedCellCount(cells.size());
    builder.addEntry(entryBuilder.build());
  }
  return new Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner>(builder.build(),
    getCellScanner(allCells, size));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:70,代码来源:ReplicationProtbufUtil.java

示例2: buildReplicateWALEntryRequest

import org.apache.hadoop.hbase.wal.WALKey; //导入方法依赖的package包/类
/**
 * Create a new ReplicateWALEntryRequest from a list of WAL entries
 *
 * @param entries the WAL entries to be replicated
 * @return a pair of ReplicateWALEntryRequest and a CellScanner over all the WALEdit values
 * found.
 */
public static Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner>
    buildReplicateWALEntryRequest(final Entry[] entries) {
  // Accumulate all the Cells seen in here.
  List<List<? extends Cell>> allCells = new ArrayList<List<? extends Cell>>(entries.length);
  int size = 0;
  WALProtos.FamilyScope.Builder scopeBuilder = WALProtos.FamilyScope.newBuilder();
  AdminProtos.WALEntry.Builder entryBuilder = AdminProtos.WALEntry.newBuilder();
  AdminProtos.ReplicateWALEntryRequest.Builder builder =
    AdminProtos.ReplicateWALEntryRequest.newBuilder();
  HBaseProtos.UUID.Builder uuidBuilder = HBaseProtos.UUID.newBuilder();
  for (Entry entry: entries) {
    entryBuilder.clear();
    // TODO: this duplicates a lot in WALKey#getBuilder
    WALProtos.WALKey.Builder keyBuilder = entryBuilder.getKeyBuilder();
    WALKey key = entry.getKey();
    keyBuilder.setEncodedRegionName(
      ByteStringer.wrap(key.getEncodedRegionName()));
    keyBuilder.setTableName(ByteStringer.wrap(key.getTablename().getName()));
    keyBuilder.setLogSequenceNumber(key.getLogSeqNum());
    keyBuilder.setWriteTime(key.getWriteTime());
    if (key.getNonce() != HConstants.NO_NONCE) {
      keyBuilder.setNonce(key.getNonce());
    }
    if (key.getNonceGroup() != HConstants.NO_NONCE) {
      keyBuilder.setNonceGroup(key.getNonceGroup());
    }
    for(UUID clusterId : key.getClusterIds()) {
      uuidBuilder.setLeastSigBits(clusterId.getLeastSignificantBits());
      uuidBuilder.setMostSigBits(clusterId.getMostSignificantBits());
      keyBuilder.addClusterIds(uuidBuilder.build());
    }
    if(key.getOrigLogSeqNum() > 0) {
      keyBuilder.setOrigSequenceNumber(key.getOrigLogSeqNum());
    }
    WALEdit edit = entry.getEdit();
    NavigableMap<byte[], Integer> scopes = key.getScopes();
    if (scopes != null && !scopes.isEmpty()) {
      for (Map.Entry<byte[], Integer> scope: scopes.entrySet()) {
        scopeBuilder.setFamily(ByteStringer.wrap(scope.getKey()));
        WALProtos.ScopeType scopeType =
            WALProtos.ScopeType.valueOf(scope.getValue().intValue());
        scopeBuilder.setScopeType(scopeType);
        keyBuilder.addScopes(scopeBuilder.build());
      }
    }
    List<Cell> cells = edit.getCells();
    // Add up the size.  It is used later serializing out the cells.
    for (Cell cell: cells) {
      size += CellUtil.estimatedSerializedSizeOf(cell);
    }
    // Collect up the cells
    allCells.add(cells);
    // Write out how many cells associated with this entry.
    entryBuilder.setAssociatedCellCount(cells.size());
    builder.addEntry(entryBuilder.build());
  }
  return new Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner>(builder.build(),
    getCellScanner(allCells, size));
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:67,代码来源:ReplicationProtbufUtil.java


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