HBASE-4889 HRegionInfo.isMetaTable() should be true for -ROOT- regions

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1208006 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-11-29 18:29:31 +00:00
parent e0a283fa3c
commit 8db322ebdd
9 changed files with 24 additions and 20 deletions

View File

@ -600,12 +600,12 @@ implements WritableComparable<HRegionInfo> {
* either <code>.META.</code> or <code>-ROOT-</code>
*/
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());
}
/**

View File

@ -359,8 +359,7 @@ public class AssignmentManager extends ZooKeeperListener {
// its a clean cluster startup, else its a failover.
boolean regionsToProcess = false;
for (Map.Entry<HRegionInfo, ServerName> 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);

View File

@ -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);

View File

@ -1095,7 +1095,7 @@ public class HBaseFsck {
throws IOException, KeeperException, InterruptedException {
List <HbckInfo> 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<HRegionInfo> filterOnlyMetaRegions(List<HRegionInfo> regions) {
List<HRegionInfo> ret = Lists.newArrayList();
for (HRegionInfo hri : regions) {
if (hri.isMetaRegion() || hri.isRootRegion()) {
if (hri.isMetaTable()) {
ret.add(hri);
}
}

View File

@ -1137,7 +1137,7 @@ public class TestAdmin {
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
List<HRegionInfo> 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<HRegionInfo> 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<HRegionInfo> 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<HRegionInfo> 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<HRegionInfo> 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<HRegionInfo> 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

View File

@ -688,7 +688,7 @@ public class TestMasterObserver {
int moveCnt = openRegions.size()/2;
for (int i=0; i<moveCnt; i++) {
HRegionInfo info = openRegions.get(i);
if (!(info.isMetaRegion() || info.isRootRegion())) {
if (!info.isMetaTable()) {
master.move(openRegions.get(i).getEncodedNameAsBytes(), destRS);
}
}

View File

@ -219,7 +219,7 @@ public class TestDistributedLogSplitting {
Iterator<HRegionInfo> 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<HRegionInfo> hris = hrs.getOnlineRegions();
for (HRegionInfo hri : hris) {
if (hri.isMetaRegion() || hri.isRootRegion()) {
if (hri.isMetaTable()) {
continue;
}
LOG.debug("adding data to rs = " + rst.getName() +

View File

@ -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;
}
}

View File

@ -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());
}
}