Beispiel #1
0
  @Test
  public void testCloseRegionIfInvalidRegionNameIsPassed() throws Exception {
    String tbName = "TestCloseRegionIfInvalidRegionName";
    byte[] TABLENAME = Bytes.toBytes(tbName);
    HBaseAdmin admin = createTable(TABLENAME);

    HRegionInfo info = null;
    HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
    List<HRegionInfo> onlineRegions = rs.getOnlineRegions();
    for (HRegionInfo regionInfo : onlineRegions) {
      if (!regionInfo.isMetaRegion() && !regionInfo.isRootRegion()) {
        if (regionInfo.getRegionNameAsString().contains(tbName)) {
          info = regionInfo;
          admin.closeRegionWithEncodedRegionName("sample", rs.getServerInfo().getHostnamePort());
        }
      }
    }
    onlineRegions = rs.getOnlineRegions();
    assertTrue(
        "The region should be present in online regions list.", onlineRegions.contains(info));
  }
Beispiel #2
0
  @Test
  public void testCloseRegionWhenServerNameIsEmpty() throws Exception {
    String tbName = "TestHBACloseRegionWhenServerNameIsEmpty";
    byte[] TABLENAME = Bytes.toBytes(tbName);
    HBaseAdmin admin = createTable(TABLENAME);

    HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);

    try {
      List<HRegionInfo> onlineRegions = rs.getOnlineRegions();
      for (HRegionInfo regionInfo : onlineRegions) {
        if (!regionInfo.isMetaRegion() && !regionInfo.isRootRegion()) {
          if (regionInfo.getRegionNameAsString().contains(tbName)) {
            admin.closeRegionWithEncodedRegionName(regionInfo.getEncodedName(), " ");
          }
        }
      }
      fail("The test should throw exception if the servername passed is empty.");
    } catch (IllegalArgumentException e) {
    }
  }
Beispiel #3
0
  @Test
  public void testShouldCloseTheRegionBasedOnTheEncodedRegionName() throws Exception {
    String tbName = "TestHBACloseRegion";
    byte[] TABLENAME = Bytes.toBytes(tbName);
    HBaseAdmin admin = createTable(TABLENAME);

    HRegionInfo info = null;
    HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
    List<HRegionInfo> onlineRegions = rs.getOnlineRegions();
    for (HRegionInfo regionInfo : onlineRegions) {
      if (!regionInfo.isMetaRegion() && !regionInfo.isRootRegion()) {
        info = regionInfo;
        admin.closeRegionWithEncodedRegionName(
            regionInfo.getEncodedName(), rs.getServerInfo().getHostnamePort());
      }
    }
    Thread.sleep(1000);
    onlineRegions = rs.getOnlineRegions();
    assertFalse(
        "The region should not be present in online regions list.", onlineRegions.contains(info));
  }