public List<RegionInfo> createMultiRegionsInMeta(final Configuration conf,
    final TableDescriptor htd, byte[][] startKeys) throws IOException {
    Table meta = getConnection().getTable(TableName.META_TABLE_NAME);
    Arrays.sort(startKeys, Bytes.BYTES_COMPARATOR);
    List<RegionInfo> newRegions = new ArrayList<>(startKeys.length);
    MetaTableAccessor.updateTableState(getConnection(), htd.getTableName(),
      TableState.State.ENABLED);
    // add custom ones
    for (int i = 0; i < startKeys.length; i++) {
      int j = (i + 1) % startKeys.length;
      RegionInfo hri = RegionInfoBuilder.newBuilder(htd.getTableName()).setStartKey(startKeys[i])
        .setEndKey(startKeys[j]).build();
      MetaTableAccessor.addRegionsToMeta(getConnection(), Collections.singletonList(hri), 1);
      newRegions.add(hri);
    }

    meta.close();
    return newRegions;
  }
Create rows in hbase:meta for regions of the specified table with the specified start keys. The
first startKey should be a 0 length byte array if you want to form a proper range of regions.
@return list of region info for regions added to meta
hbase-testing-util/src/main/java/org/apache/hadoop/hbase/HBaseTestingUtility.java