You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2013/04/01 02:57:41 UTC
svn commit: r1463072 - in
/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase: ./ coprocessor/
master/ util/
Author: apurtell
Date: Mon Apr 1 00:57:40 2013
New Revision: 1463072
URL: http://svn.apache.org/r1463072
Log:
HBASE-8226. HBaseTestingUtility#waitUntilAllRegionsAssigned won't return if it counts 'too many' regions
Modified:
hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java
hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java
hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java
hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/util/TestMiniClusterLoadSequential.java
Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=1463072&r1=1463071&r2=1463072&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java Mon Apr 1 00:57:40 2013
@@ -1827,37 +1827,66 @@ public class HBaseTestingUtility {
}
}
+ /**
+ * Wait until all regions for a table in .META. have a non-empty
+ * info:server, up to 60 seconds. This means all regions have been deployed,
+ * master has been informed and updated .META. with the regions deployed
+ * server.
+ * @param tableName the table name
+ * @throws IOException
+ */
+ public void waitUntilAllRegionsAssigned(final byte[] tableName) throws IOException {
+ waitUntilAllRegionsAssigned(tableName, 60000);
+ }
/**
- * Wait until <code>countOfRegion</code> in .META. have a non-empty
- * info:server. This means all regions have been deployed, master has been
- * informed and updated .META. with the regions deployed server.
- * @param countOfRegions How many regions in .META.
+ * Wait until all regions for a table in .META. have a non-empty
+ * info:server, or until timeout. This means all regions have been
+ * deployed, master has been informed and updated .META. with the regions
+ * deployed server.
+ * @param tableName the table name
+ * @param timeout timeout, in milliseconds
* @throws IOException
*/
- public void waitUntilAllRegionsAssigned(final int countOfRegions)
- throws IOException {
+ public void waitUntilAllRegionsAssigned(final byte[] tableName, final long timeout)
+ throws IOException {
+ long deadline = System.currentTimeMillis() + timeout;
HTable meta = new HTable(getConfiguration(), HConstants.META_TABLE_NAME);
- while (true) {
- int rows = 0;
- Scan scan = new Scan();
- scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
- ResultScanner s = meta.getScanner(scan);
- for (Result r = null; (r = s.next()) != null;) {
- byte [] b =
- r.getValue(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
- if (b == null || b.length <= 0) {
- break;
+ try {
+ while (true) {
+ 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 = Writables.getHRegionInfoOrNull(b);
+ if (info != null && Bytes.equals(info.getTableName(), tableName)) {
+ b = r.getValue(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
+ allRegionsAssigned &= (b != null);
+ }
+ }
+ } finally {
+ s.close();
+ }
+ if (allRegionsAssigned) {
+ return;
+ }
+ long now = System.currentTimeMillis();
+ if (now > deadline) {
+ throw new IOException("Timeout waiting for all regions of " +
+ Bytes.toStringBinary(tableName) + " to be assigned");
+ }
+ try {
+ Thread.sleep(deadline - now < 200 ? deadline - now : 200);
+ } catch (InterruptedException e) {
+ throw new IOException(e);
}
- rows++;
- }
- s.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);
+ } finally {
+ meta.close();
}
}
Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java?rev=1463072&r1=1463071&r2=1463072&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java Mon Apr 1 00:57:40 2013
@@ -747,8 +747,8 @@ public class TestMasterObserver {
cp.resetStates();
HTable table = UTIL.createTable(TEST_TABLE, TEST_FAMILY);
- int countOfRegions = UTIL.createMultiRegions(table, TEST_FAMILY);
- UTIL.waitUntilAllRegionsAssigned(countOfRegions);
+ UTIL.createMultiRegions(table, TEST_FAMILY);
+ UTIL.waitUntilAllRegionsAssigned(TEST_TABLE);
NavigableMap<HRegionInfo, ServerName> regions = table.getRegionLocations();
Map.Entry<HRegionInfo, ServerName> firstGoodPair = null;
Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java?rev=1463072&r1=1463071&r2=1463072&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java Mon Apr 1 00:57:40 2013
@@ -109,8 +109,8 @@ public class TestRegionServerCoprocessor
byte[] TEST_FAMILY = Bytes.toBytes("aaa");
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).
final HRegionServer regionServer =
Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java?rev=1463072&r1=1463071&r2=1463072&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java Mon Apr 1 00:57:40 2013
@@ -92,8 +92,8 @@ public class TestRegionServerCoprocessor
byte[] TEST_FAMILY = Bytes.toBytes("aaa");
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
// prePut().
HRegionServer regionServer =
Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java?rev=1463072&r1=1463071&r2=1463072&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestMasterTransitions.java Mon Apr 1 00:57:40 2013
@@ -59,10 +59,11 @@ public class TestMasterTransitions {
TEST_UTIL.getConfiguration().setBoolean("dfs.support.append", true);
TEST_UTIL.startMiniCluster(2);
// 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);
int countOfRegions = TEST_UTIL.createMultiRegions(t, getTestFamily());
- TEST_UTIL.waitUntilAllRegionsAssigned(countOfRegions);
+ TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
addToEachStartKey(countOfRegions);
t.close();
}
Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/util/TestMiniClusterLoadSequential.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/util/TestMiniClusterLoadSequential.java?rev=1463072&r1=1463071&r2=1463072&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/util/TestMiniClusterLoadSequential.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/util/TestMiniClusterLoadSequential.java Mon Apr 1 00:57:40 2013
@@ -136,8 +136,8 @@ public class TestMiniClusterLoadSequenti
protected void createPreSplitLoadTestTable(HTableDescriptor htd, HColumnDescriptor hcd)
throws IOException {
- int numRegions = HBaseTestingUtility.createPreSplitLoadTestTable(conf, htd, hcd);
- TEST_UTIL.waitUntilAllRegionsAssigned(numRegions);
+ HBaseTestingUtility.createPreSplitLoadTestTable(conf, htd, hcd);
+ TEST_UTIL.waitUntilAllRegionsAssigned(htd.getName());
}
protected void prepareForLoadTest() throws IOException {