Exemplo n.º 1
0
 /**
  * A utility to build a GetOnlineRegionResponse.
  *
  * @param regions
  * @return the response
  */
 public static GetOnlineRegionResponse buildGetOnlineRegionResponse(
     final List<HRegionInfo> regions) {
   GetOnlineRegionResponse.Builder builder = GetOnlineRegionResponse.newBuilder();
   for (HRegionInfo region : regions) {
     builder.addRegionInfo(HRegionInfo.convert(region));
   }
   return builder.build();
 }
Exemplo n.º 2
0
  @Override
  public void serializeStateData(final OutputStream stream) throws IOException {
    super.serializeStateData(stream);

    MasterProcedureProtos.TruncateTableStateData.Builder state =
        MasterProcedureProtos.TruncateTableStateData.newBuilder()
            .setUserInfo(MasterProcedureUtil.toProtoUserInfo(this.user))
            .setPreserveSplits(preserveSplits);
    if (hTableDescriptor != null) {
      state.setTableSchema(hTableDescriptor.convert());
    } else {
      state.setTableName(ProtobufUtil.toProtoTableName(tableName));
    }
    if (regions != null) {
      for (HRegionInfo hri : regions) {
        state.addRegionInfo(HRegionInfo.convert(hri));
      }
    }
    state.build().writeDelimitedTo(stream);
  }
Exemplo n.º 3
0
  @Override
  public void deserializeStateData(final InputStream stream) throws IOException {
    super.deserializeStateData(stream);

    MasterProcedureProtos.TruncateTableStateData state =
        MasterProcedureProtos.TruncateTableStateData.parseDelimitedFrom(stream);
    user = MasterProcedureUtil.toUserInfo(state.getUserInfo());
    if (state.hasTableSchema()) {
      hTableDescriptor = HTableDescriptor.convert(state.getTableSchema());
      tableName = hTableDescriptor.getTableName();
    } else {
      tableName = ProtobufUtil.toTableName(state.getTableName());
    }
    preserveSplits = state.getPreserveSplits();
    if (state.getRegionInfoCount() == 0) {
      regions = null;
    } else {
      regions = new ArrayList<HRegionInfo>(state.getRegionInfoCount());
      for (HBaseProtos.RegionInfo hri : state.getRegionInfoList()) {
        regions.add(HRegionInfo.convert(hri));
      }
    }
  }