protected void waitForDelete(String tableName) throws Exception { for (int i = 0; i < MAX_WAIT_ITERATION; i++) { if (!admin.tableExists(tableName)) { return; } Thread.sleep(WAIT_INTERVAL); } Assert.fail(getMethodName() + " failed"); }
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"); }
protected void waitForSplitting(String tableName, int regionCount) throws IOException, InterruptedException { int regionCountActual = 0; for (int i = 0; i < MAX_WAIT_ITERATION; i++) { try (HTable table = new HTable(conf, tableName)) { regionCountActual = 0; NavigableMap<HRegionInfo, ServerName> regionLocations = table.getRegionLocations(); for (Map.Entry<HRegionInfo, ServerName> entry : regionLocations.entrySet()) { HServerLoad serverLoad = admin.getClusterStatus().getLoad(entry.getValue()); for (HServerLoad.RegionLoad regionLoad : serverLoad.getRegionsLoad().values()) { if (Arrays.equals(entry.getKey().getRegionName(), regionLoad.getName())) regionCountActual++; } } if (regionCountActual == regionCount) { return; } } Thread.sleep(WAIT_INTERVAL); } Assert.assertEquals(getMethodName() + " failed - ", regionCount, regionCountActual); }