Author: stack
Date: Sat Oct 9 03:46:52 2010
New Revision: 1006107
URL: http://svn.apache.org/viewvc?rev=1006107&view=rev
Log:
HBASE-3098 TestMetaReaderEditor is broken in TRUNK; hangs
Modified:
hbase/trunk/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java
hbase/trunk/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java
Modified:
hbase/trunk/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java?rev=1006107&r1=1006106&r2=1006107&view=diff
==============================================================================
---
hbase/trunk/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java
(original)
+++
hbase/trunk/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java
Sat Oct 9 03:46:52 2010
@@ -380,9 +380,6 @@ public class CatalogTracker {
}
Throwable t = null;
try {
- // Am expecting only two possible exceptions here; unable
- // to connect to the regionserver or NotServingRegionException wrapped
- // in the hadoop rpc RemoteException.
return metaServer.getRegionInfo(regionName) != null;
} catch (ConnectException e) {
t = e;
@@ -393,6 +390,13 @@ public class CatalogTracker {
} else {
throw e;
}
+ } catch (IOException e) {
+ Throwable cause = e.getCause();
+ if (cause != null && cause instanceof EOFException) {
+ t = cause;
+ } else {
+ throw e;
+ }
}
LOG.info("Failed verification of " + Bytes.toString(regionName) + "; " +
t);
return false;
Modified:
hbase/trunk/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java?rev=1006107&r1=1006106&r2=1006107&view=diff
==============================================================================
---
hbase/trunk/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java
(original)
+++
hbase/trunk/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java
Sat Oct 9 03:46:52 2010
@@ -27,6 +27,7 @@ import java.util.concurrent.atomic.Atomi
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
@@ -40,6 +41,7 @@ import org.apache.hadoop.hbase.util.Byte
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.junit.AfterClass;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -49,8 +51,8 @@ import org.junit.Test;
public class TestMetaReaderEditor {
private static final Log LOG = LogFactory.getLog(TestMetaReaderEditor.class);
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
- private static ZooKeeperWatcher ZKW;
- private static CatalogTracker CT;
+ private ZooKeeperWatcher zkw;
+ private CatalogTracker ct;
private final static Abortable ABORTABLE = new Abortable() {
private final AtomicBoolean abort = new AtomicBoolean(false);
@@ -63,12 +65,14 @@ public class TestMetaReaderEditor {
@BeforeClass public static void beforeClass() throws Exception {
UTIL.startMiniCluster();
- ZKW = new ZooKeeperWatcher(UTIL.getConfiguration(),
- "TestMetaReaderEditor", ABORTABLE);
- HConnection connection =
- HConnectionManager.getConnection(UTIL.getConfiguration());
- CT = new CatalogTracker(ZKW, connection, ABORTABLE);
- CT.start();
+ }
+
+ @Before public void setup() throws IOException, InterruptedException {
+ Configuration c = new Configuration(UTIL.getConfiguration());
+ zkw = new ZooKeeperWatcher(c, "TestMetaReaderEditor", ABORTABLE);
+ HConnection connection = HConnectionManager.getConnection(c);
+ ct = new CatalogTracker(zkw, connection, ABORTABLE);
+ ct.start();
}
@AfterClass public static void afterClass() throws IOException {
@@ -78,50 +82,52 @@ public class TestMetaReaderEditor {
@Test public void testGetRegionsCatalogTables()
throws IOException, InterruptedException {
List<HRegionInfo> regions =
- MetaReader.getTableRegions(CT, HConstants.META_TABLE_NAME);
+ MetaReader.getTableRegions(ct, HConstants.META_TABLE_NAME);
assertTrue(regions.size() >= 1);
- assertTrue(MetaReader.getTableRegionsAndLocations(CT,
+ assertTrue(MetaReader.getTableRegionsAndLocations(ct,
Bytes.toString(HConstants.META_TABLE_NAME)).size() >= 1);
- assertTrue(MetaReader.getTableRegionsAndLocations(CT,
+ assertTrue(MetaReader.getTableRegionsAndLocations(ct,
Bytes.toString(HConstants.ROOT_TABLE_NAME)).size() == 1);
}
@Test public void testTableExists() throws IOException {
final String name = "testTableExists";
final byte [] nameBytes = Bytes.toBytes(name);
- assertFalse(MetaReader.tableExists(CT, name));
+ assertFalse(MetaReader.tableExists(ct, name));
UTIL.createTable(nameBytes, HConstants.CATALOG_FAMILY);
- assertTrue(MetaReader.tableExists(CT, name));
+ assertTrue(MetaReader.tableExists(ct, name));
HBaseAdmin admin = UTIL.getHBaseAdmin();
admin.disableTable(name);
admin.deleteTable(name);
- assertFalse(MetaReader.tableExists(CT, name));
- assertTrue(MetaReader.tableExists(CT,
+ assertFalse(MetaReader.tableExists(ct, name));
+ assertTrue(MetaReader.tableExists(ct,
Bytes.toString(HConstants.META_TABLE_NAME)));
- assertTrue(MetaReader.tableExists(CT,
+ assertTrue(MetaReader.tableExists(ct,
Bytes.toString(HConstants.ROOT_TABLE_NAME)));
}
@Test public void testGetRegion() throws IOException, InterruptedException {
final String name = "testGetRegion";
+ LOG.info("Started " + name);
final byte [] nameBytes = Bytes.toBytes(name);
HTable t = UTIL.createTable(nameBytes, HConstants.CATALOG_FAMILY);
int regionCount = UTIL.createMultiRegions(t, HConstants.CATALOG_FAMILY);
// Test it works getting a region from user table.
- List<HRegionInfo> regions = MetaReader.getTableRegions(CT, nameBytes);
+ List<HRegionInfo> regions = MetaReader.getTableRegions(ct, nameBytes);
assertEquals(regionCount, regions.size());
Pair<HRegionInfo, HServerAddress> pair =
- MetaReader.getRegion(CT, regions.get(0).getRegionName());
+ MetaReader.getRegion(ct, regions.get(0).getRegionName());
assertEquals(regions.get(0).getEncodedName(),
pair.getFirst().getEncodedName());
// Test get on non-existent region.
- pair = MetaReader.getRegion(CT, Bytes.toBytes("nonexistent-region"));
+ pair = MetaReader.getRegion(ct, Bytes.toBytes("nonexistent-region"));
assertNull(pair);
// Test it works getting a region from meta/root.
pair =
- MetaReader.getRegion(CT,
HRegionInfo.FIRST_META_REGIONINFO.getRegionName());
+ MetaReader.getRegion(ct,
HRegionInfo.FIRST_META_REGIONINFO.getRegionName());
assertEquals(HRegionInfo.FIRST_META_REGIONINFO.getEncodedName(),
pair.getFirst().getEncodedName());
+ LOG.info("Finished " + name);
}
-}
+}
\ No newline at end of file