public void prepareMutationsForMerge(
      HRegionInfo mergedRegion,
      HRegionInfo regionA,
      HRegionInfo regionB,
      ServerName serverName,
      List<Mutation> mutations,
      int regionReplication)
      throws IOException {
    HRegionInfo copyOfMerged = new HRegionInfo(mergedRegion);

    // Put for parent
    Put putOfMerged = MetaTableAccessor.makePutFromRegionInfo(copyOfMerged);
    putOfMerged.add(HConstants.CATALOG_FAMILY, HConstants.MERGEA_QUALIFIER, regionA.toByteArray());
    putOfMerged.add(HConstants.CATALOG_FAMILY, HConstants.MERGEB_QUALIFIER, regionB.toByteArray());
    mutations.add(putOfMerged);
    // Deletes for merging regions
    Delete deleteA = MetaTableAccessor.makeDeleteFromRegionInfo(regionA);
    Delete deleteB = MetaTableAccessor.makeDeleteFromRegionInfo(regionB);
    mutations.add(deleteA);
    mutations.add(deleteB);

    // Add empty locations for region replicas of the merged region so that number of replicas can
    // be cached whenever the primary region is looked up from meta
    for (int i = 1; i < regionReplication; i++) {
      addEmptyLocation(putOfMerged, i);
    }

    // The merged is a new region, openSeqNum = 1 is fine.
    addLocation(putOfMerged, serverName, 1);
  }
Пример #2
0
 static CellProtos.Cell getRegionInfo(final ByteString row, final HRegionInfo hri) {
   CellProtos.Cell.Builder cellBuilder = getBaseCellBuilder(row);
   cellBuilder.setQualifier(REGIONINFO_QUALIFIER_BYTESTRING);
   cellBuilder.setValue(HBaseZeroCopyByteString.wrap(hri.toByteArray()));
   return cellBuilder.build();
 }