Java Code Examples for org.apache.hadoop.hbase.client.RegionInfo#getRegionName()

The following examples show how to use org.apache.hadoop.hbase.client.RegionInfo#getRegionName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HBCKMetaTableAccessor.java    From hbase-operator-tools with Apache License 2.0 6 votes vote down vote up
/**
 * Generates and returns a Put containing the region into for the catalog table
 */
public static Put makePutFromRegionInfo(RegionInfo region, long ts) throws IOException {
  Put put = new Put(region.getRegionName(), ts);
  //copied from MetaTableAccessor
  put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
    .setRow(put.getRow())
    .setFamily(HConstants.CATALOG_FAMILY)
    .setQualifier(HConstants.REGIONINFO_QUALIFIER)
    .setTimestamp(put.getTimestamp())
    .setType(Cell.Type.Put)
    // Serialize the Default Replica HRI otherwise scan of hbase:meta
    // shows an info:regioninfo value with encoded name and region
    // name that differs from that of the hbase;meta row.
    .setValue(RegionInfo.toByteArray(RegionReplicaUtil.getRegionInfoForDefaultReplica(region)))
    .build());
  return put;
}
 
Example 2
Source File: TestHBCKMetaTableAccessor.java    From hbase-operator-tools with Apache License 2.0 6 votes vote down vote up
@Test
public void testAddRegionToMeta() throws Exception {
  RegionInfo regionInfo = createTableAnddeleteFirstRegion();
  HBCKMetaTableAccessor.addRegionToMeta(TEST_UTIL.getConnection(), regionInfo);
  Connection connection = TEST_UTIL.getConnection();
  Table meta = connection.getTable(TableName.META_TABLE_NAME);
  Get get = new Get(regionInfo.getRegionName());
  Result r = meta.get(get);
  assertNotNull(r);
  assertFalse(r.isEmpty());
  RegionInfo returnedRI = RegionInfo.parseFrom(r.getValue(HConstants.CATALOG_FAMILY,
    HConstants.REGIONINFO_QUALIFIER));
  assertEquals(regionInfo, returnedRI);
  String state = Bytes.toString(r.getValue(HConstants.CATALOG_FAMILY,
    HConstants.STATE_QUALIFIER));
  assertEquals(RegionState.State.valueOf(state), RegionState.State.CLOSED);
}
 
Example 3
Source File: TestRegionServerOnlineConfigChange.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  try (RegionLocator locator = hbaseTestingUtility.getConnection().getRegionLocator(TABLE1)) {
    RegionInfo firstHRI = locator.getAllRegionLocations().get(0).getRegion();
    r1name = firstHRI.getRegionName();
    rs1 = hbaseTestingUtility.getHBaseCluster().getRegionServer(
      hbaseTestingUtility.getHBaseCluster().getServerWith(r1name));
    r1 = rs1.getRegion(r1name);
  }
}
 
Example 4
Source File: HBCKMetaTableAccessor.java    From hbase-operator-tools with Apache License 2.0 5 votes vote down vote up
/**
 * Delete the passed <code>RegionInfo</code> from the <code>hbase:meta</code> table.
 *
 * @param connection connection we're using
 * @param regionInfo the regionInfo to delete from the meta table
 * @throws IOException if it's not able to delete the regionInfo
 */
public static void deleteRegionInfo(Connection connection, RegionInfo regionInfo)
    throws IOException {
  Delete delete = new Delete(regionInfo.getRegionName());
  delete.addFamily(HConstants.CATALOG_FAMILY, HConstants.LATEST_TIMESTAMP);
  deleteFromMetaTable(connection, delete);
  LOG.info("Deleted {}", regionInfo.getRegionNameAsString());
}
 
Example 5
Source File: TestHBaseFsckCleanReplicationBarriers.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void addStateAndBarrier(RegionInfo region, RegionState.State state, long... barriers)
    throws IOException {
  Put put = new Put(region.getRegionName(), EnvironmentEdgeManager.currentTime());
  if (state != null) {
    put.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER,
      Bytes.toBytes(state.name()));
  }
  for (int i = 0; i < barriers.length; i++) {
    put.addColumn(HConstants.REPLICATION_BARRIER_FAMILY, HConstants.SEQNUM_QUALIFIER,
      put.getTimestamp() - barriers.length + i, Bytes.toBytes(barriers[i]));
  }
  try (Table table = UTIL.getConnection().getTable(TableName.META_TABLE_NAME)) {
    table.put(put);
  }
}
 
Example 6
Source File: TestReplicationBarrierCleaner.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void addBarrier(RegionInfo region, long... barriers) throws IOException {
  Put put = new Put(region.getRegionName(), EnvironmentEdgeManager.currentTime());
  for (int i = 0; i < barriers.length; i++) {
    put.addColumn(HConstants.REPLICATION_BARRIER_FAMILY, HConstants.SEQNUM_QUALIFIER,
      put.getTimestamp() - barriers.length + i, Bytes.toBytes(barriers[i]));
  }
  try (Table table = UTIL.getConnection().getTable(TableName.META_TABLE_NAME)) {
    table.put(put);
  }
}
 
Example 7
Source File: TestMetaTableAccessor.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Tests whether maximum of masters system time versus RSs local system time is used
 */
@Test
public void testMastersSystemTimeIsUsedInUpdateLocations() throws IOException {
  long regionId = System.currentTimeMillis();
  RegionInfo regionInfo = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
    .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
    .setRegionId(regionId).setReplicaId(0).build();

  ServerName sn = ServerName.valueOf("bar", 0, 0);
  try (Table meta = MetaTableAccessor.getMetaHTable(connection)) {
    List<RegionInfo> regionInfos = Lists.newArrayList(regionInfo);
    MetaTableAccessor.addRegionsToMeta(connection, regionInfos, 1);

    long masterSystemTime = EnvironmentEdgeManager.currentTime() + 123456789;
    MetaTableAccessor.updateRegionLocation(connection, regionInfo, sn, 1, masterSystemTime);

    Get get = new Get(regionInfo.getRegionName());
    Result result = meta.get(get);
    Cell serverCell = result.getColumnLatestCell(HConstants.CATALOG_FAMILY,
      CatalogFamilyFormat.getServerColumn(0));
    Cell startCodeCell = result.getColumnLatestCell(HConstants.CATALOG_FAMILY,
      CatalogFamilyFormat.getStartCodeColumn(0));
    Cell seqNumCell = result.getColumnLatestCell(HConstants.CATALOG_FAMILY,
      CatalogFamilyFormat.getSeqNumColumn(0));
    assertNotNull(serverCell);
    assertNotNull(startCodeCell);
    assertNotNull(seqNumCell);
    assertTrue(serverCell.getValueLength() > 0);
    assertTrue(startCodeCell.getValueLength() > 0);
    assertTrue(seqNumCell.getValueLength() > 0);
    assertEquals(masterSystemTime, serverCell.getTimestamp());
    assertEquals(masterSystemTime, startCodeCell.getTimestamp());
    assertEquals(masterSystemTime, seqNumCell.getTimestamp());
  }
}
 
Example 8
Source File: TestMetaTableAccessor.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Test
public void testMetaLocationForRegionReplicasIsRemovedAtTableDeletion() throws IOException {
  long regionId = System.currentTimeMillis();
  RegionInfo primary = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
    .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
    .setRegionId(regionId).setReplicaId(0).build();

  Table meta = MetaTableAccessor.getMetaHTable(connection);
  try {
    List<RegionInfo> regionInfos = Lists.newArrayList(primary);
    MetaTableAccessor.addRegionsToMeta(connection, regionInfos, 3);
    MetaTableAccessor.removeRegionReplicasFromMeta(Sets.newHashSet(primary.getRegionName()), 1, 2,
      connection);
    Get get = new Get(primary.getRegionName());
    Result result = meta.get(get);
    for (int replicaId = 0; replicaId < 3; replicaId++) {
      Cell serverCell = result.getColumnLatestCell(HConstants.CATALOG_FAMILY,
        CatalogFamilyFormat.getServerColumn(replicaId));
      Cell startCodeCell = result.getColumnLatestCell(HConstants.CATALOG_FAMILY,
        CatalogFamilyFormat.getStartCodeColumn(replicaId));
      Cell stateCell = result.getColumnLatestCell(HConstants.CATALOG_FAMILY,
        CatalogFamilyFormat.getRegionStateColumn(replicaId));
      Cell snCell = result.getColumnLatestCell(HConstants.CATALOG_FAMILY,
        CatalogFamilyFormat.getServerNameColumn(replicaId));
      if (replicaId == 0) {
        assertNotNull(stateCell);
      } else {
        assertNull(serverCell);
        assertNull(startCodeCell);
        assertNull(stateCell);
        assertNull(snCell);
      }
    }
  } finally {
    meta.close();
  }
}
 
Example 9
Source File: TestSerialReplicationChecker.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void addParents(RegionInfo region, List<RegionInfo> parents) throws IOException {
  Put put = new Put(region.getRegionName(), EnvironmentEdgeManager.currentTime());
  put.addColumn(HConstants.REPLICATION_BARRIER_FAMILY,
    MetaTableAccessor.REPLICATION_PARENT_QUALIFIER, MetaTableAccessor.getParentsBytes(parents));
  try (Table table = UTIL.getConnection().getTable(TableName.META_TABLE_NAME)) {
    table.put(put);
  }
}
 
Example 10
Source File: TestSerialReplicationChecker.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void setState(RegionInfo region, RegionState.State state) throws IOException {
  Put put = new Put(region.getRegionName(), EnvironmentEdgeManager.currentTime());
  put.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER,
    Bytes.toBytes(state.name()));
  try (Table table = UTIL.getConnection().getTable(TableName.META_TABLE_NAME)) {
    table.put(put);
  }
}
 
Example 11
Source File: TestSerialReplicationChecker.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void addStateAndBarrier(RegionInfo region, RegionState.State state, long... barriers)
    throws IOException {
  Put put = new Put(region.getRegionName(), EnvironmentEdgeManager.currentTime());
  if (state != null) {
    put.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER,
      Bytes.toBytes(state.name()));
  }
  for (int i = 0; i < barriers.length; i++) {
    put.addColumn(HConstants.REPLICATION_BARRIER_FAMILY, HConstants.SEQNUM_QUALIFIER,
      put.getTimestamp() - barriers.length + i, Bytes.toBytes(barriers[i]));
  }
  try (Table table = UTIL.getConnection().getTable(TableName.META_TABLE_NAME)) {
    table.put(put);
  }
}
 
Example 12
Source File: MetaTableAccessor.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Deletes merge qualifiers for the specified merge region.
 * @param connection connection we're using
 * @param mergeRegion the merged region
 */
public static void deleteMergeQualifiers(Connection connection, final RegionInfo mergeRegion)
  throws IOException {
  Delete delete = new Delete(mergeRegion.getRegionName());
  // NOTE: We are doing a new hbase:meta read here.
  Cell[] cells = getRegionResult(connection, mergeRegion.getRegionName()).rawCells();
  if (cells == null || cells.length == 0) {
    return;
  }
  List<byte[]> qualifiers = new ArrayList<>();
  for (Cell cell : cells) {
    if (!isMergeQualifierPrefix(cell)) {
      continue;
    }
    byte[] qualifier = CellUtil.cloneQualifier(cell);
    qualifiers.add(qualifier);
    delete.addColumns(HConstants.CATALOG_FAMILY, qualifier, HConstants.LATEST_TIMESTAMP);
  }

  // There will be race condition that a GCMultipleMergedRegionsProcedure is scheduled while
  // the previous GCMultipleMergedRegionsProcedure is still going on, in this case, the second
  // GCMultipleMergedRegionsProcedure could delete the merged region by accident!
  if (qualifiers.isEmpty()) {
    LOG.info("No merged qualifiers for region " + mergeRegion.getRegionNameAsString() +
      " in meta table, they are cleaned up already, Skip.");
    return;
  }

  deleteFromMetaTable(connection, delete);
  LOG.info("Deleted merge references in " + mergeRegion.getRegionNameAsString() +
    ", deleted qualifiers " +
    qualifiers.stream().map(Bytes::toStringBinary).collect(Collectors.joining(", ")));
}
 
Example 13
Source File: MetaTableAccessor.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Deletes the specified regions from META.
 * @param connection connection we're using
 * @param regionsInfo list of regions to be deleted from META
 */
private static void deleteRegionInfos(Connection connection, List<RegionInfo> regionsInfo,
  long ts) throws IOException {
  List<Delete> deletes = new ArrayList<>(regionsInfo.size());
  for (RegionInfo hri : regionsInfo) {
    Delete e = new Delete(hri.getRegionName());
    e.addFamily(HConstants.CATALOG_FAMILY, ts);
    deletes.add(e);
  }
  deleteFromMetaTable(connection, deletes);
  LOG.info("Deleted {} regions from META", regionsInfo.size());
  LOG.debug("Deleted regions: {}", regionsInfo);
}
 
Example 14
Source File: MetaTableAccessor.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Deletes the specified region from META.
 * @param connection connection we're using
 * @param regionInfo region to be deleted from META
 */
public static void deleteRegionInfo(Connection connection, RegionInfo regionInfo)
  throws IOException {
  Delete delete = new Delete(regionInfo.getRegionName());
  delete.addFamily(HConstants.CATALOG_FAMILY, HConstants.LATEST_TIMESTAMP);
  deleteFromMetaTable(connection, delete);
  LOG.info("Deleted " + regionInfo.getRegionNameAsString());
}
 
Example 15
Source File: MetaTableAccessor.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Generates and returns a Delete containing the region info for the catalog table
 */
private static Delete makeDeleteFromRegionInfo(RegionInfo regionInfo, long ts) {
  if (regionInfo == null) {
    throw new IllegalArgumentException("Can't make a delete for null region");
  }
  Delete delete = new Delete(regionInfo.getRegionName());
  delete.addFamily(HConstants.CATALOG_FAMILY, ts);
  return delete;
}
 
Example 16
Source File: TestHBCK2.java    From hbase-operator-tools with Apache License 2.0 5 votes vote down vote up
private RegionState.State getCurrentRegionState(RegionInfo regionInfo) throws IOException{
  Table metaTable = TEST_UTIL.getConnection().getTable(TableName.valueOf("hbase:meta"));
  Get get = new Get(regionInfo.getRegionName());
  get.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER);
  Result result = metaTable.get(get);
  byte[] currentStateValue = result.getValue(HConstants.CATALOG_FAMILY,
    HConstants.STATE_QUALIFIER);
  return currentStateValue != null ?
    RegionState.State.valueOf(Bytes.toString(currentStateValue))
    : null;
}
 
Example 17
Source File: HBaseFsck.java    From hbase with Apache License 2.0 4 votes vote down vote up
public void checkRegionBoundaries() {
  try {
    ByteArrayComparator comparator = new ByteArrayComparator();
    List<RegionInfo> regions = MetaTableAccessor.getAllRegions(connection, true);
    final RegionBoundariesInformation currentRegionBoundariesInformation =
        new RegionBoundariesInformation();
    Path hbaseRoot = CommonFSUtils.getRootDir(getConf());
    for (RegionInfo regionInfo : regions) {
      Path tableDir = CommonFSUtils.getTableDir(hbaseRoot, regionInfo.getTable());
      currentRegionBoundariesInformation.regionName = regionInfo.getRegionName();
      // For each region, get the start and stop key from the META and compare them to the
      // same information from the Stores.
      Path path = new Path(tableDir, regionInfo.getEncodedName());
      FileSystem fs = path.getFileSystem(getConf());
      FileStatus[] files = fs.listStatus(path);
      // For all the column families in this region...
      byte[] storeFirstKey = null;
      byte[] storeLastKey = null;
      for (FileStatus file : files) {
        String fileName = file.getPath().toString();
        fileName = fileName.substring(fileName.lastIndexOf("/") + 1);
        if (!fileName.startsWith(".") && !fileName.endsWith("recovered.edits")) {
          FileStatus[] storeFiles = fs.listStatus(file.getPath());
          // For all the stores in this column family.
          for (FileStatus storeFile : storeFiles) {
            HFile.Reader reader = HFile.createReader(fs, storeFile.getPath(),
              CacheConfig.DISABLED, true, getConf());
            if ((reader.getFirstKey() != null)
                && ((storeFirstKey == null) || (comparator.compare(storeFirstKey,
                    ((KeyValue.KeyOnlyKeyValue) reader.getFirstKey().get()).getKey()) > 0))) {
              storeFirstKey = ((KeyValue.KeyOnlyKeyValue)reader.getFirstKey().get()).getKey();
            }
            if ((reader.getLastKey() != null)
                && ((storeLastKey == null) || (comparator.compare(storeLastKey,
                    ((KeyValue.KeyOnlyKeyValue)reader.getLastKey().get()).getKey())) < 0)) {
              storeLastKey = ((KeyValue.KeyOnlyKeyValue)reader.getLastKey().get()).getKey();
            }
            reader.close();
          }
        }
      }
      currentRegionBoundariesInformation.metaFirstKey = regionInfo.getStartKey();
      currentRegionBoundariesInformation.metaLastKey = regionInfo.getEndKey();
      currentRegionBoundariesInformation.storesFirstKey = keyOnly(storeFirstKey);
      currentRegionBoundariesInformation.storesLastKey = keyOnly(storeLastKey);
      if (currentRegionBoundariesInformation.metaFirstKey.length == 0)
        currentRegionBoundariesInformation.metaFirstKey = null;
      if (currentRegionBoundariesInformation.metaLastKey.length == 0)
        currentRegionBoundariesInformation.metaLastKey = null;

      // For a region to be correct, we need the META start key to be smaller or equal to the
      // smallest start key from all the stores, and the start key from the next META entry to
      // be bigger than the last key from all the current stores. First region start key is null;
      // Last region end key is null; some regions can be empty and not have any store.

      boolean valid = true;
      // Checking start key.
      if ((currentRegionBoundariesInformation.storesFirstKey != null)
          && (currentRegionBoundariesInformation.metaFirstKey != null)) {
        valid = valid
            && comparator.compare(currentRegionBoundariesInformation.storesFirstKey,
              currentRegionBoundariesInformation.metaFirstKey) >= 0;
      }
      // Checking stop key.
      if ((currentRegionBoundariesInformation.storesLastKey != null)
          && (currentRegionBoundariesInformation.metaLastKey != null)) {
        valid = valid
            && comparator.compare(currentRegionBoundariesInformation.storesLastKey,
              currentRegionBoundariesInformation.metaLastKey) < 0;
      }
      if (!valid) {
        errors.reportError(ERROR_CODE.BOUNDARIES_ERROR, "Found issues with regions boundaries",
          tablesInfo.get(regionInfo.getTable()));
        LOG.warn("Region's boundaries not aligned between stores and META for:");
        LOG.warn(Objects.toString(currentRegionBoundariesInformation));
      }
    }
  } catch (IOException e) {
    LOG.error(e.toString(), e);
  }
}
 
Example 18
Source File: MetaTableAccessor.java    From hbase with Apache License 2.0 4 votes vote down vote up
public static Put makePutForReplicationBarrier(RegionInfo regionInfo, long openSeqNum, long ts)
  throws IOException {
  Put put = new Put(regionInfo.getRegionName(), ts);
  addReplicationBarrier(put, openSeqNum);
  return put;
}
 
Example 19
Source File: TestMetaTableAccessor.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Test
public void testMastersSystemTimeIsUsedInMergeRegions() throws IOException {
  long regionId = System.currentTimeMillis();

  RegionInfo regionInfoA = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
    .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(new byte[] { 'a' }).setSplit(false)
    .setRegionId(regionId).setReplicaId(0).build();

  RegionInfo regionInfoB = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
    .setStartKey(new byte[] { 'a' }).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
    .setRegionId(regionId).setReplicaId(0).build();
  RegionInfo mergedRegionInfo =
    RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName()))
      .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
      .setRegionId(regionId).setReplicaId(0).build();

  ServerName sn = ServerName.valueOf("bar", 0, 0);
  try (Table meta = MetaTableAccessor.getMetaHTable(connection)) {
    List<RegionInfo> regionInfos = Lists.newArrayList(regionInfoA, regionInfoB);
    MetaTableAccessor.addRegionsToMeta(connection, regionInfos, 1);

    // write the serverName column with a big current time, but set the masters time as even
    // bigger. When region merge deletes the rows for regionA and regionB, the serverName columns
    // should not be seen by the following get
    long serverNameTime = EnvironmentEdgeManager.currentTime() + 100000000;
    long masterSystemTime = EnvironmentEdgeManager.currentTime() + 123456789;

    // write the serverName columns
    MetaTableAccessor.updateRegionLocation(connection, regionInfoA, sn, 1, serverNameTime);

    // assert that we have the serverName column with expected ts
    Get get = new Get(mergedRegionInfo.getRegionName());
    Result result = meta.get(get);
    Cell serverCell = result.getColumnLatestCell(HConstants.CATALOG_FAMILY,
      CatalogFamilyFormat.getServerColumn(0));
    assertNotNull(serverCell);
    assertEquals(serverNameTime, serverCell.getTimestamp());

    ManualEnvironmentEdge edge = new ManualEnvironmentEdge();
    edge.setValue(masterSystemTime);
    EnvironmentEdgeManager.injectEdge(edge);
    try {
      // now merge the regions, effectively deleting the rows for region a and b.
      MetaTableAccessor.mergeRegions(connection, mergedRegionInfo,
        getMapOfRegionsToSeqNum(regionInfoA, regionInfoB), sn, 1);
    } finally {
      EnvironmentEdgeManager.reset();
    }

    result = meta.get(get);
    serverCell = result.getColumnLatestCell(HConstants.CATALOG_FAMILY,
      CatalogFamilyFormat.getServerColumn(0));
    Cell startCodeCell = result.getColumnLatestCell(HConstants.CATALOG_FAMILY,
      CatalogFamilyFormat.getStartCodeColumn(0));
    Cell seqNumCell = result.getColumnLatestCell(HConstants.CATALOG_FAMILY,
      CatalogFamilyFormat.getSeqNumColumn(0));
    assertNull(serverCell);
    assertNull(startCodeCell);
    assertNull(seqNumCell);
  }
}
 
Example 20
Source File: TestMetaTableAccessor.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Test
public void testEmptyMetaDaughterLocationDuringSplit() throws IOException {
  long regionId = System.currentTimeMillis();
  ServerName serverName0 = ServerName.valueOf("foo", 60010, random.nextLong());
  RegionInfo parent = RegionInfoBuilder.newBuilder(TableName.valueOf("table_foo"))
    .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
    .setRegionId(regionId).setReplicaId(0).build();
  RegionInfo splitA = RegionInfoBuilder.newBuilder(TableName.valueOf("table_foo"))
    .setStartKey(HConstants.EMPTY_START_ROW).setEndKey(Bytes.toBytes("a")).setSplit(false)
    .setRegionId(regionId + 1).setReplicaId(0).build();
  RegionInfo splitB = RegionInfoBuilder.newBuilder(TableName.valueOf("table_foo"))
    .setStartKey(Bytes.toBytes("a")).setEndKey(HConstants.EMPTY_END_ROW).setSplit(false)
    .setRegionId(regionId + 1).setReplicaId(0).build();

  Table meta = MetaTableAccessor.getMetaHTable(connection);
  try {
    List<RegionInfo> regionInfos = Lists.newArrayList(parent);
    MetaTableAccessor.addRegionsToMeta(connection, regionInfos, 3);

    MetaTableAccessor.splitRegion(connection, parent, -1L, splitA, splitB, serverName0, 3);
    Get get1 = new Get(splitA.getRegionName());
    Result resultA = meta.get(get1);
    Cell serverCellA = resultA.getColumnLatestCell(HConstants.CATALOG_FAMILY,
      CatalogFamilyFormat.getServerColumn(splitA.getReplicaId()));
    Cell startCodeCellA = resultA.getColumnLatestCell(HConstants.CATALOG_FAMILY,
      CatalogFamilyFormat.getStartCodeColumn(splitA.getReplicaId()));
    assertNull(serverCellA);
    assertNull(startCodeCellA);

    Get get2 = new Get(splitA.getRegionName());
    Result resultB = meta.get(get2);
    Cell serverCellB = resultB.getColumnLatestCell(HConstants.CATALOG_FAMILY,
      CatalogFamilyFormat.getServerColumn(splitB.getReplicaId()));
    Cell startCodeCellB = resultB.getColumnLatestCell(HConstants.CATALOG_FAMILY,
      CatalogFamilyFormat.getStartCodeColumn(splitB.getReplicaId()));
    assertNull(serverCellB);
    assertNull(startCodeCellB);
  } finally {
    if (meta != null) {
      meta.close();
    }
  }
}