HBASE-3219 Split parents are reassigned on restart and on disable/enable

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1033782 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-11-11 00:19:52 +00:00
parent 4bf998de8e
commit 6881c2fac0
4 changed files with 47 additions and 4 deletions

View File

@ -674,6 +674,7 @@ Release 0.90.0 - Unreleased
HBASE-3214 TestMasterFailover.testMasterFailoverWithMockedRITOnDeadRS is
failing (Gary via jgray)
HBASE-3216 Move HBaseFsck from client to util
HBASE-3219 Split parents are reassigned on restart and on disable/enable
IMPROVEMENTS

View File

@ -149,6 +149,28 @@ public class MetaReader {
*/
public static Map<HRegionInfo,HServerAddress> fullScan(
CatalogTracker catalogTracker, final Set<String> disabledTables)
throws IOException {
return fullScan(catalogTracker, disabledTables, false);
}
/**
* Performs a full scan of <code>.META.</code>, skipping regions from any
* tables in the specified set of disabled tables.
* <p>
* Returns a map of every region to it's currently assigned server, according
* to META. If the region does not have an assignment it will have a null
* value in the map.
*
* @param catalogTracker
* @param disabledTables set of disabled tables that will not be returned
* @param excludeOfflinedSplitParents If true, do not include offlined split
* parents in the return.
* @return map of regions to their currently assigned server
* @throws IOException
*/
public static Map<HRegionInfo,HServerAddress> fullScan(
CatalogTracker catalogTracker, final Set<String> disabledTables,
final boolean excludeOfflinedSplitParents)
throws IOException {
final Map<HRegionInfo,HServerAddress> regions =
new TreeMap<HRegionInfo,HServerAddress>();
@ -158,9 +180,12 @@ public class MetaReader {
if (r == null || r.isEmpty()) return true;
Pair<HRegionInfo,HServerAddress> region = metaRowToRegionPair(r);
if (region == null) return true;
HRegionInfo hri = region.getFirst();
if (disabledTables.contains(
region.getFirst().getTableDesc().getNameAsString())) return true;
regions.put(region.getFirst(), region.getSecond());
hri.getTableDesc().getNameAsString())) return true;
// Are we to include split parents in the list?
if (excludeOfflinedSplitParents && hri.isSplitParent()) return true;
regions.put(hri, region.getSecond());
return true;
}
};
@ -415,6 +440,21 @@ public class MetaReader {
*/
public static List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker,
byte [] tableName)
throws IOException {
return getTableRegions(catalogTracker, tableName, false);
}
/**
* Gets all of the regions of the specified table.
* @param catalogTracker
* @param tableName
* @param excludeOfflinedSplitParents If true, do not include offlined split
* parents in the return.
* @return Ordered list of {@link HRegionInfo}.
* @throws IOException
*/
public static List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker,
byte [] tableName, final boolean excludeOfflinedSplitParents)
throws IOException {
if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
// If root, do a bit of special handling.
@ -446,6 +486,8 @@ public class MetaReader {
data.getValue(HConstants.CATALOG_FAMILY,
HConstants.REGIONINFO_QUALIFIER));
if (info.getTableDesc().getNameAsString().equals(tableString)) {
// Are we to include split parents in the list?
if (excludeOfflinedSplitParents && info.isSplitParent()) continue;
regions.add(info);
} else {
break;

View File

@ -1105,7 +1105,7 @@ public class AssignmentManager extends ZooKeeperListener {
// Scan META for all user regions, skipping any disabled tables
Map<HRegionInfo,HServerAddress> allRegions =
MetaReader.fullScan(catalogTracker, this.zkTable.getDisabledTables());
MetaReader.fullScan(catalogTracker, this.zkTable.getDisabledTables(), true);
if (allRegions == null || allRegions.isEmpty()) return;
// Determine what type of assignment to do on startup

View File

@ -87,7 +87,7 @@ public class EnableTableHandler extends EventHandler {
// Get the regions of this table. We're done when all listed
// tables are onlined.
List<HRegionInfo> regionsInMeta =
MetaReader.getTableRegions(this.ct, tableName);
MetaReader.getTableRegions(this.ct, tableName, true);
int countOfRegionsInTable = regionsInMeta.size();
List<HRegionInfo> regions = regionsToAssign(regionsInMeta);
if (regions.size() == 0) {