diff --git a/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java b/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java index 0c1fa3fe4c2..2a24d0bcad1 100644 --- a/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java +++ b/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java @@ -600,12 +600,12 @@ implements WritableComparable { * either .META. or -ROOT- */ public boolean isMetaTable() { - return Bytes.equals(tableName, HRegionInfo.FIRST_META_REGIONINFO.getTableName()); + return isRootRegion() || isMetaRegion(); } /** @return true if this region is a meta region */ public boolean isMetaRegion() { - return isMetaTable(); + return Bytes.equals(tableName, HRegionInfo.FIRST_META_REGIONINFO.getTableName()); } /** diff --git a/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java b/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java index c3420e5c526..680b426aa5a 100644 --- a/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java +++ b/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java @@ -359,8 +359,7 @@ public class AssignmentManager extends ZooKeeperListener { // its a clean cluster startup, else its a failover. boolean regionsToProcess = false; for (Map.Entry e: this.regions.entrySet()) { - if (!e.getKey().isMetaRegion() - && !e.getKey().isRootRegion() + if (!e.getKey().isMetaTable() && e.getValue() != null) { LOG.debug("Found " + e + " out on cluster"); regionsToProcess = true; @@ -489,7 +488,7 @@ public class AssignmentManager extends ZooKeeperListener { // Just insert region into RIT // If this never updates the timeout will trigger new assignment - if (regionInfo.isMetaRegion() || regionInfo.isRootRegion()) { + if (regionInfo.isMetaTable()) { regionsInTransition.put(encodedRegionName, new RegionState( regionInfo, RegionState.State.OPENING, data.getStamp(), data .getOrigin())); @@ -1514,7 +1513,7 @@ public class AssignmentManager extends ZooKeeperListener { } private void debugLog(HRegionInfo region, String string) { - if (region.isMetaTable() || region.isRootRegion()) { + if (region.isMetaTable()) { LOG.info(string); } else { LOG.debug(string); diff --git a/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java b/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java index f5e1dd9f454..f171a5a3b8d 100644 --- a/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java +++ b/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java @@ -141,7 +141,7 @@ public class OpenedRegionHandler extends EventHandler implements TotesHRegionInf } private void debugLog(HRegionInfo region, String string) { - if (region.isMetaTable() || region.isRootRegion()) { + if (region.isMetaTable()) { LOG.info(string); } else { LOG.debug(string); diff --git a/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java index b5e7015d060..80cb7fd2f11 100644 --- a/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java +++ b/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java @@ -1095,7 +1095,7 @@ public class HBaseFsck { throws IOException, KeeperException, InterruptedException { List metaRegions = Lists.newArrayList(); for (HbckInfo value : regionInfo.values()) { - if (value.metaEntry.isMetaTable()) { + if (value.metaEntry.isMetaRegion()) { metaRegions.add(value); } } @@ -1501,7 +1501,7 @@ public class HBaseFsck { private List filterOnlyMetaRegions(List regions) { List ret = Lists.newArrayList(); for (HRegionInfo hri : regions) { - if (hri.isMetaRegion() || hri.isRootRegion()) { + if (hri.isMetaTable()) { ret.add(hri); } } diff --git a/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java b/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java index 940d7265b38..c0b09224b48 100644 --- a/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java +++ b/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java @@ -1137,7 +1137,7 @@ public class TestAdmin { HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME); List onlineRegions = rs.getOnlineRegions(); for (HRegionInfo regionInfo : onlineRegions) { - if (!regionInfo.isMetaRegion() && !regionInfo.isRootRegion()) { + if (!regionInfo.isMetaTable()) { info = regionInfo; admin.closeRegionWithEncodedRegionName(regionInfo.getEncodedName(), rs .getServerName().getServerName()); @@ -1158,7 +1158,7 @@ public class TestAdmin { HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME); List onlineRegions = rs.getOnlineRegions(); for (HRegionInfo regionInfo : onlineRegions) { - if (!regionInfo.isMetaRegion() && !regionInfo.isRootRegion()) { + if (!regionInfo.isMetaTable()) { if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion1")) { info = regionInfo; admin.closeRegionWithEncodedRegionName("sample", rs.getServerName() @@ -1180,7 +1180,7 @@ public class TestAdmin { HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME); List onlineRegions = rs.getOnlineRegions(); for (HRegionInfo regionInfo : onlineRegions) { - if (!regionInfo.isMetaRegion() && !regionInfo.isRootRegion()) { + if (!regionInfo.isMetaTable()) { if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion2")) { info = regionInfo; @@ -1211,7 +1211,7 @@ public class TestAdmin { try { List onlineRegions = rs.getOnlineRegions(); for (HRegionInfo regionInfo : onlineRegions) { - if (!regionInfo.isMetaRegion() && !regionInfo.isRootRegion()) { + if (!regionInfo.isMetaTable()) { if (regionInfo.getRegionNameAsString() .contains("TestHBACloseRegion3")) { admin.closeRegionWithEncodedRegionName(regionInfo.getEncodedName(), @@ -1235,7 +1235,7 @@ public class TestAdmin { try { List onlineRegions = rs.getOnlineRegions(); for (HRegionInfo regionInfo : onlineRegions) { - if (!regionInfo.isMetaRegion() && !regionInfo.isRootRegion()) { + if (!regionInfo.isMetaTable()) { if (regionInfo.getRegionNameAsString() .contains("TestHBACloseRegionWhenServerNameIsEmpty")) { admin.closeRegionWithEncodedRegionName(regionInfo.getEncodedName(), @@ -1258,7 +1258,7 @@ public class TestAdmin { List onlineRegions = rs.getOnlineRegions(); for (HRegionInfo regionInfo : onlineRegions) { - if (!regionInfo.isMetaRegion() && !regionInfo.isRootRegion()) { + if (!regionInfo.isMetaTable()) { if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion4")) { info = regionInfo; admin.closeRegionWithEncodedRegionName(regionInfo diff --git a/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java b/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java index 1a531572eae..d82022f53d2 100644 --- a/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java +++ b/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java @@ -688,7 +688,7 @@ public class TestMasterObserver { int moveCnt = openRegions.size()/2; for (int i=0; i it = regions.iterator(); while (it.hasNext()) { HRegionInfo region = it.next(); - if (region.isMetaRegion() || region.isRootRegion()) { + if (region.isMetaTable()) { it.remove(); } } @@ -339,7 +339,7 @@ public class TestDistributedLogSplitting { HRegionServer hrs = rst.getRegionServer(); List hris = hrs.getOnlineRegions(); for (HRegionInfo hri : hris) { - if (hri.isMetaRegion() || hri.isRootRegion()) { + if (hri.isMetaTable()) { continue; } LOG.debug("adding data to rs = " + rst.getName() + diff --git a/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java b/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java index d7fcf1fa324..e1f98af1bf1 100644 --- a/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java +++ b/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java @@ -197,8 +197,7 @@ public class TestOpenedRegionHandler { HRegion region = null; while (iterator.hasNext()) { region = iterator.next(); - if (!region.getRegionInfo().isMetaRegion() - && !region.getRegionInfo().isRootRegion()) { + if (!region.getRegionInfo().isMetaTable()) { break; } } diff --git a/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java b/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java index 477e77237a8..baca241a395 100644 --- a/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java +++ b/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java @@ -113,4 +113,10 @@ public class TestHRegionInfo { } catch (IllegalArgumentException iae) { } } + + @Test + public void testMetaTables() { + assertTrue(HRegionInfo.ROOT_REGIONINFO.isMetaTable()); + assertTrue(HRegionInfo.FIRST_META_REGIONINFO.isMetaTable()); + } }