Exemple #1
0
 protected static List<HRegionInfo> getRegionInfoList(ServerName serverName, String tableName)
     throws IOException {
   List<HRegionInfo> onlineRegions = new ArrayList<>();
   for (HRegionInfo onlineRegion : CommandAdapter.getOnlineRegions(null, admin, serverName)) {
     if (onlineRegion.getTableNameAsString().equals(tableName)) {
       onlineRegions.add(onlineRegion);
     }
   }
   return onlineRegions;
 }
Exemple #2
0
 protected HServerLoad.RegionLoad getRegionLoad(HRegionInfo regionInfo, ServerName serverName)
     throws IOException {
   HServerLoad serverLoad = admin.getClusterStatus().getLoad(serverName);
   Map<byte[], HServerLoad.RegionLoad> regionsLoad = serverLoad.getRegionsLoad();
   for (Map.Entry<byte[], HServerLoad.RegionLoad> entry : regionsLoad.entrySet()) {
     if (Arrays.equals(entry.getKey(), regionInfo.getRegionName())) {
       return entry.getValue();
     }
   }
   return null;
 }
Exemple #3
0
  protected void waitForMoving(HRegionInfo hRegionInfo, ServerName serverName) throws Exception {
    Map<byte[], HServerLoad.RegionLoad> regionsLoad = null;
    for (int i = 0; i < MAX_WAIT_ITERATION; i++) {
      HServerLoad load = admin.getClusterStatus().getLoad(serverName);
      regionsLoad = load.getRegionsLoad();
      for (byte[] regionName : regionsLoad.keySet()) {
        if (Arrays.equals(regionName, hRegionInfo.getRegionName())) return;
      }
      admin.move(hRegionInfo.getEncodedNameAsBytes(), serverName.getServerName().getBytes());
      Thread.sleep(WAIT_INTERVAL);
    }

    System.out.println("hRegionInfo = " + Bytes.toString(hRegionInfo.getRegionName()));
    for (Map.Entry<byte[], HServerLoad.RegionLoad> entry : regionsLoad.entrySet()) {
      System.out.println(
          "regionsLoad = " + Bytes.toString(entry.getKey()) + " - " + entry.getValue());
    }

    Assert.fail(Util.getMethodName() + " failed");
  }
Exemple #4
0
 protected void move(HRegionInfo regionInfo, ServerName serverName) throws Exception {
   admin.move(regionInfo.getEncodedName().getBytes(), serverName.getServerName().getBytes());
   waitForMoving(regionInfo, serverName);
 }