Amend HBASE-8209. Revert changes to HBaseTestingUtility#waitUntilAllRegionsAssigned

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1462639 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2013-03-29 20:50:11 +00:00
parent b73cacfd8d
commit 7ae8a946ee
9 changed files with 28 additions and 45 deletions

View File

@ -2164,45 +2164,29 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
* @param countOfRegions How many regions in .META. * @param countOfRegions How many regions in .META.
* @throws IOException * @throws IOException
*/ */
public void waitUntilAllRegionsAssigned(final byte[] tableName, final int countOfRegions) public void waitUntilAllRegionsAssigned(final int countOfRegions)
throws IOException { throws IOException {
int retries = 30; // We may wait up to 30 seconds
int rows = 0;
HTable meta = new HTable(getConfiguration(), HConstants.META_TABLE_NAME); HTable meta = new HTable(getConfiguration(), HConstants.META_TABLE_NAME);
try { while (true) {
do { int rows = 0;
Scan scan = new Scan(); Scan scan = new Scan();
scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER); ResultScanner s = meta.getScanner(scan);
ResultScanner s = meta.getScanner(scan); for (Result r = null; (r = s.next()) != null;) {
try { byte [] b =
for (Result r = null; (r = s.next()) != null;) { r.getValue(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
byte[] b = r.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); if (b == null || b.length <= 0) {
HRegionInfo hri = HRegionInfo.parseFromOrNull(b);
if (hri != null && Bytes.equals(hri.getTableName(), tableName)) {
b = r.getValue(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
if (b == null || b.length <= 0) {
continue;
}
rows++;
}
}
} finally {
s.close();
}
// If I get to here and all rows have a Server, then all have been assigned.
if (rows == countOfRegions) {
break; break;
} }
LOG.info("Found=" + rows); rows++;
Threads.sleep(1000); }
} while (--retries > 0); s.close();
} finally { // If I get to here and all rows have a Server, then all have been assigned.
meta.close(); if (rows == countOfRegions) {
} break;
if (rows != countOfRegions) { }
throw new IOException("Timed out waiting for " + countOfRegions + " regions of " + LOG.info("Found=" + rows);
Bytes.toStringBinary(tableName) + " to come online"); Threads.sleep(200);
} }
} }

View File

@ -77,7 +77,7 @@ public class TestHTableMultiplexer {
HTable ht = TEST_UTIL.createTable(TABLE, new byte[][] { FAMILY }, VERSION, HTable ht = TEST_UTIL.createTable(TABLE, new byte[][] { FAMILY }, VERSION,
Bytes.toBytes("aaaaa"), Bytes.toBytes("zzzzz"), NUM_REGIONS); Bytes.toBytes("aaaaa"), Bytes.toBytes("zzzzz"), NUM_REGIONS);
TEST_UTIL.waitUntilAllRegionsAssigned(TABLE, NUM_REGIONS); TEST_UTIL.waitUntilAllRegionsAssigned(NUM_REGIONS);
byte[][] startRows = ht.getStartKeys(); byte[][] startRows = ht.getStartKeys();
byte[][] endRows = ht.getEndKeys(); byte[][] endRows = ht.getEndKeys();

View File

@ -91,7 +91,7 @@ public class TestCoprocessorEndpoint {
HTableDescriptor desc = new HTableDescriptor(TEST_TABLE); HTableDescriptor desc = new HTableDescriptor(TEST_TABLE);
desc.addFamily(new HColumnDescriptor(TEST_FAMILY)); desc.addFamily(new HColumnDescriptor(TEST_FAMILY));
admin.createTable(desc, new byte[][]{ROWS[rowSeperator1], ROWS[rowSeperator2]}); admin.createTable(desc, new byte[][]{ROWS[rowSeperator1], ROWS[rowSeperator2]});
util.waitUntilAllRegionsAssigned(TEST_TABLE, 3); util.waitUntilAllRegionsAssigned(3);
admin.close(); admin.close();
HTable table = new HTable(conf, TEST_TABLE); HTable table = new HTable(conf, TEST_TABLE);

View File

@ -1110,7 +1110,7 @@ public class TestMasterObserver {
try { try {
int countOfRegions = UTIL.createMultiRegions(table, TEST_FAMILY); int countOfRegions = UTIL.createMultiRegions(table, TEST_FAMILY);
UTIL.waitUntilAllRegionsAssigned(TEST_TABLE, countOfRegions); UTIL.waitUntilAllRegionsAssigned(countOfRegions);
NavigableMap<HRegionInfo, ServerName> regions = table.getRegionLocations(); NavigableMap<HRegionInfo, ServerName> regions = table.getRegionLocations();
Map.Entry<HRegionInfo, ServerName> firstGoodPair = null; Map.Entry<HRegionInfo, ServerName> firstGoodPair = null;

View File

@ -75,7 +75,7 @@ public class TestRegionServerCoprocessorExceptionWithAbort {
byte[] TEST_FAMILY = Bytes.toBytes("aaa"); byte[] TEST_FAMILY = Bytes.toBytes("aaa");
HTable table = TEST_UTIL.createTable(TEST_TABLE, TEST_FAMILY); HTable table = TEST_UTIL.createTable(TEST_TABLE, TEST_FAMILY);
TEST_UTIL.waitUntilAllRegionsAssigned(TEST_TABLE, TEST_UTIL.createMultiRegions(table, TEST_FAMILY)); TEST_UTIL.waitUntilAllRegionsAssigned(TEST_UTIL.createMultiRegions(table, TEST_FAMILY));
// Note which regionServer will abort (after put is attempted). // Note which regionServer will abort (after put is attempted).
final HRegionServer regionServer = TEST_UTIL.getRSForFirstRegionInTable(TEST_TABLE); final HRegionServer regionServer = TEST_UTIL.getRSForFirstRegionInTable(TEST_TABLE);

View File

@ -91,7 +91,7 @@ public class TestRegionServerCoprocessorExceptionWithRemove {
byte[] TEST_FAMILY = Bytes.toBytes("aaa"); byte[] TEST_FAMILY = Bytes.toBytes("aaa");
HTable table = TEST_UTIL.createTable(TEST_TABLE, TEST_FAMILY); HTable table = TEST_UTIL.createTable(TEST_TABLE, TEST_FAMILY);
TEST_UTIL.waitUntilAllRegionsAssigned(TEST_TABLE, TEST_UTIL.waitUntilAllRegionsAssigned(
TEST_UTIL.createMultiRegions(table, TEST_FAMILY)); TEST_UTIL.createMultiRegions(table, TEST_FAMILY));
// Note which regionServer that should survive the buggy coprocessor's // Note which regionServer that should survive the buggy coprocessor's
// prePut(). // prePut().

View File

@ -59,12 +59,11 @@ public class TestMasterTransitions {
@BeforeClass public static void beforeAllTests() throws Exception { @BeforeClass public static void beforeAllTests() throws Exception {
TEST_UTIL.getConfiguration().setBoolean("dfs.support.append", true); TEST_UTIL.getConfiguration().setBoolean("dfs.support.append", true);
TEST_UTIL.startMiniCluster(2); TEST_UTIL.startMiniCluster(2);
byte[] tableName = Bytes.toBytes(TABLENAME);
// Create a table of three families. This will assign a region. // Create a table of three families. This will assign a region.
TEST_UTIL.createTable(tableName, FAMILIES); TEST_UTIL.createTable(Bytes.toBytes(TABLENAME), FAMILIES);
HTable t = new HTable(TEST_UTIL.getConfiguration(), TABLENAME); HTable t = new HTable(TEST_UTIL.getConfiguration(), TABLENAME);
int countOfRegions = TEST_UTIL.createMultiRegions(t, getTestFamily()); int countOfRegions = TEST_UTIL.createMultiRegions(t, getTestFamily());
TEST_UTIL.waitUntilAllRegionsAssigned(tableName, countOfRegions); TEST_UTIL.waitUntilAllRegionsAssigned(countOfRegions);
addToEachStartKey(countOfRegions); addToEachStartKey(countOfRegions);
t.close(); t.close();
} }

View File

@ -102,7 +102,7 @@ public class TestHLogFiltering {
table.flushCommits(); table.flushCommits();
} }
} }
TEST_UTIL.waitUntilAllRegionsAssigned(TABLE_NAME, NUM_RS); TEST_UTIL.waitUntilAllRegionsAssigned(NUM_RS);
} }
@Test @Test

View File

@ -141,7 +141,7 @@ public class TestMiniClusterLoadSequential {
protected void createPreSplitLoadTestTable(HTableDescriptor htd, HColumnDescriptor hcd) protected void createPreSplitLoadTestTable(HTableDescriptor htd, HColumnDescriptor hcd)
throws IOException { throws IOException {
int numRegions = HBaseTestingUtility.createPreSplitLoadTestTable(conf, htd, hcd); int numRegions = HBaseTestingUtility.createPreSplitLoadTestTable(conf, htd, hcd);
TEST_UTIL.waitUntilAllRegionsAssigned(htd.getName(), numRegions); TEST_UTIL.waitUntilAllRegionsAssigned(numRegions);
} }
protected void prepareForLoadTest() throws IOException { protected void prepareForLoadTest() throws IOException {