HBASE-8226. HBaseTestingUtility#waitUntilAllRegionsAssigned won't return if it counts 'too many' regions
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1463070 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
abee4b2756
commit
bab650d19f
|
@ -2159,37 +2159,56 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait until <code>countOfRegion</code> in .META. have a non-empty
|
* Wait until all regions for a table in .META. have a non-empty
|
||||||
* info:server. This means all regions have been deployed, master has been
|
* info:server, up to 60 seconds. This means all regions have been deployed,
|
||||||
* informed and updated .META. with the regions deployed server.
|
* master has been informed and updated .META. with the regions deployed
|
||||||
* @param countOfRegions How many regions in .META.
|
* server.
|
||||||
|
* @param tableName the table name
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void waitUntilAllRegionsAssigned(final int countOfRegions)
|
public void waitUntilAllRegionsAssigned(final byte[] tableName) throws IOException {
|
||||||
throws IOException {
|
waitUntilAllRegionsAssigned(tableName, 60000);
|
||||||
HTable meta = new HTable(getConfiguration(), HConstants.META_TABLE_NAME);
|
}
|
||||||
while (true) {
|
|
||||||
int rows = 0;
|
/**
|
||||||
Scan scan = new Scan();
|
* Wait until all regions for a table in .META. have a non-empty
|
||||||
scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
|
* info:server, or until timeout. This means all regions have been deployed,
|
||||||
ResultScanner s = meta.getScanner(scan);
|
* master has been informed and updated .META. with the regions deployed
|
||||||
for (Result r = null; (r = s.next()) != null;) {
|
* server.
|
||||||
byte [] b =
|
* @param tableName the table name
|
||||||
r.getValue(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
|
* @param timeout timeout, in milliseconds
|
||||||
if (b == null || b.length <= 0) {
|
* @throws IOException
|
||||||
break;
|
*/
|
||||||
|
public void waitUntilAllRegionsAssigned(final byte[] tableName, final long timeout)
|
||||||
|
throws IOException {
|
||||||
|
final HTable meta = new HTable(getConfiguration(), HConstants.META_TABLE_NAME);
|
||||||
|
try {
|
||||||
|
waitFor(timeout, 200, true, new Predicate<IOException>() {
|
||||||
|
@Override
|
||||||
|
public boolean evaluate() throws IOException {
|
||||||
|
boolean allRegionsAssigned = true;
|
||||||
|
Scan scan = new Scan();
|
||||||
|
scan.addFamily(HConstants.CATALOG_FAMILY);
|
||||||
|
ResultScanner s = meta.getScanner(scan);
|
||||||
|
try {
|
||||||
|
Result r;
|
||||||
|
while ((r = s.next()) != null) {
|
||||||
|
byte [] b = r.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
|
||||||
|
HRegionInfo info = HRegionInfo.parseFromOrNull(b);
|
||||||
|
if (info != null && Bytes.equals(info.getTableName(), tableName)) {
|
||||||
|
b = r.getValue(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
|
||||||
|
allRegionsAssigned &= (b != null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
s.close();
|
||||||
|
}
|
||||||
|
return allRegionsAssigned;
|
||||||
}
|
}
|
||||||
rows++;
|
});
|
||||||
}
|
} finally {
|
||||||
s.close();
|
meta.close();
|
||||||
// If I get to here and all rows have a Server, then all have been assigned.
|
|
||||||
if (rows == countOfRegions) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
LOG.info("Found=" + rows);
|
|
||||||
Threads.sleep(200);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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(NUM_REGIONS);
|
TEST_UTIL.waitUntilAllRegionsAssigned(TABLE);
|
||||||
|
|
||||||
byte[][] startRows = ht.getStartKeys();
|
byte[][] startRows = ht.getStartKeys();
|
||||||
byte[][] endRows = ht.getEndKeys();
|
byte[][] endRows = ht.getEndKeys();
|
||||||
|
|
|
@ -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(3);
|
util.waitUntilAllRegionsAssigned(TEST_TABLE);
|
||||||
admin.close();
|
admin.close();
|
||||||
|
|
||||||
HTable table = new HTable(conf, TEST_TABLE);
|
HTable table = new HTable(conf, TEST_TABLE);
|
||||||
|
|
|
@ -1109,8 +1109,8 @@ public class TestMasterObserver {
|
||||||
HTable table = UTIL.createTable(TEST_TABLE, TEST_FAMILY);
|
HTable table = UTIL.createTable(TEST_TABLE, TEST_FAMILY);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int countOfRegions = UTIL.createMultiRegions(table, TEST_FAMILY);
|
UTIL.createMultiRegions(table, TEST_FAMILY);
|
||||||
UTIL.waitUntilAllRegionsAssigned(countOfRegions);
|
UTIL.waitUntilAllRegionsAssigned(TEST_TABLE);
|
||||||
|
|
||||||
NavigableMap<HRegionInfo, ServerName> regions = table.getRegionLocations();
|
NavigableMap<HRegionInfo, ServerName> regions = table.getRegionLocations();
|
||||||
Map.Entry<HRegionInfo, ServerName> firstGoodPair = null;
|
Map.Entry<HRegionInfo, ServerName> firstGoodPair = null;
|
||||||
|
|
|
@ -75,7 +75,8 @@ 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_UTIL.createMultiRegions(table, TEST_FAMILY));
|
TEST_UTIL.createMultiRegions(table, TEST_FAMILY);
|
||||||
|
TEST_UTIL.waitUntilAllRegionsAssigned(TEST_TABLE);
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
|
@ -91,8 +91,8 @@ 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_UTIL.createMultiRegions(table, TEST_FAMILY);
|
||||||
TEST_UTIL.createMultiRegions(table, TEST_FAMILY));
|
TEST_UTIL.waitUntilAllRegionsAssigned(TEST_TABLE);
|
||||||
// Note which regionServer that should survive the buggy coprocessor's
|
// Note which regionServer that should survive the buggy coprocessor's
|
||||||
// prePut().
|
// prePut().
|
||||||
HRegionServer regionServer =
|
HRegionServer regionServer =
|
||||||
|
|
|
@ -60,10 +60,11 @@ public class TestMasterTransitions {
|
||||||
TEST_UTIL.getConfiguration().setBoolean("dfs.support.append", true);
|
TEST_UTIL.getConfiguration().setBoolean("dfs.support.append", true);
|
||||||
TEST_UTIL.startMiniCluster(2);
|
TEST_UTIL.startMiniCluster(2);
|
||||||
// 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(Bytes.toBytes(TABLENAME), FAMILIES);
|
byte[] tableName = Bytes.toBytes(TABLENAME);
|
||||||
|
TEST_UTIL.createTable(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(countOfRegions);
|
TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
|
||||||
addToEachStartKey(countOfRegions);
|
addToEachStartKey(countOfRegions);
|
||||||
t.close();
|
t.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class TestHLogFiltering {
|
||||||
table.flushCommits();
|
table.flushCommits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TEST_UTIL.waitUntilAllRegionsAssigned(NUM_RS);
|
TEST_UTIL.waitUntilAllRegionsAssigned(TABLE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -140,8 +140,8 @@ 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);
|
HBaseTestingUtility.createPreSplitLoadTestTable(conf, htd, hcd);
|
||||||
TEST_UTIL.waitUntilAllRegionsAssigned(numRegions);
|
TEST_UTIL.waitUntilAllRegionsAssigned(htd.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void prepareForLoadTest() throws IOException {
|
protected void prepareForLoadTest() throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue