Index: src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java =================================================================== --- src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java (revision 1006040) +++ src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java (working copy) @@ -27,6 +27,7 @@ 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.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 @@ 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,14 +65,16 @@ @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 { UTIL.shutdownMiniCluster(); } @@ -78,50 +82,52 @@ @Test public void testGetRegionsCatalogTables() throws IOException, InterruptedException { List 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 regions = MetaReader.getTableRegions(CT, nameBytes); + List regions = MetaReader.getTableRegions(ct, nameBytes); assertEquals(regionCount, regions.size()); Pair 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 Index: src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (revision 1006040) +++ src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (working copy) @@ -380,9 +380,6 @@ } 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 @@ } 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;