/** * 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(); }
@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); }
@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)); } } }