public RegionReplicaReplayCallable(
     ClusterConnection connection,
     RpcControllerFactory rpcControllerFactory,
     TableName tableName,
     HRegionLocation location,
     HRegionInfo regionInfo,
     byte[] row,
     List<Entry> entries,
     AtomicLong skippedEntries) {
   super(connection, rpcControllerFactory, location, tableName, row, regionInfo.getReplicaId());
   this.entries = entries;
   this.skippedEntries = skippedEntries;
   this.initialEncodedRegionName = regionInfo.getEncodedNameAsBytes();
 }
Exemplo n.º 2
0
 /**
  * Convert a HRegionInfo to a RegionInfo
  *
  * @param info the HRegionInfo to convert
  * @return the converted RegionInfo
  */
 public static RegionInfo convert(final HRegionInfo info) {
   if (info == null) return null;
   RegionInfo.Builder builder = RegionInfo.newBuilder();
   builder.setTableName(ProtobufUtil.toProtoTableName(info.getTable()));
   builder.setRegionId(info.getRegionId());
   if (info.getStartKey() != null) {
     builder.setStartKey(ByteStringer.wrap(info.getStartKey()));
   }
   if (info.getEndKey() != null) {
     builder.setEndKey(ByteStringer.wrap(info.getEndKey()));
   }
   builder.setOffline(info.isOffline());
   builder.setSplit(info.isSplit());
   builder.setReplicaId(info.getReplicaId());
   return builder.build();
 }
Exemplo n.º 3
0
  @Override
  public int compareTo(HRegionInfo o) {
    if (o == null) {
      return 1;
    }

    // Are regions of same table?
    int result = this.tableName.compareTo(o.tableName);
    if (result != 0) {
      return result;
    }

    // Compare start keys.
    result = Bytes.compareTo(this.startKey, o.startKey);
    if (result != 0) {
      return result;
    }

    // Compare end keys.
    result = Bytes.compareTo(this.endKey, o.endKey);

    if (result != 0) {
      if (this.getStartKey().length != 0 && this.getEndKey().length == 0) {
        return 1; // this is last region
      }
      if (o.getStartKey().length != 0 && o.getEndKey().length == 0) {
        return -1; // o is the last region
      }
      return result;
    }

    // regionId is usually milli timestamp -- this defines older stamps
    // to be "smaller" than newer stamps in sort order.
    if (this.regionId > o.regionId) {
      return 1;
    } else if (this.regionId < o.regionId) {
      return -1;
    }

    int replicaDiff = this.getReplicaId() - o.getReplicaId();
    if (replicaDiff != 0) return replicaDiff;

    if (this.offLine == o.offLine) return 0;
    if (this.offLine == true) return -1;

    return 1;
  }