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:
parent
4bf998de8e
commit
6881c2fac0
|
@ -674,6 +674,7 @@ Release 0.90.0 - Unreleased
|
||||||
HBASE-3214 TestMasterFailover.testMasterFailoverWithMockedRITOnDeadRS is
|
HBASE-3214 TestMasterFailover.testMasterFailoverWithMockedRITOnDeadRS is
|
||||||
failing (Gary via jgray)
|
failing (Gary via jgray)
|
||||||
HBASE-3216 Move HBaseFsck from client to util
|
HBASE-3216 Move HBaseFsck from client to util
|
||||||
|
HBASE-3219 Split parents are reassigned on restart and on disable/enable
|
||||||
|
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
|
|
|
@ -149,6 +149,28 @@ public class MetaReader {
|
||||||
*/
|
*/
|
||||||
public static Map<HRegionInfo,HServerAddress> fullScan(
|
public static Map<HRegionInfo,HServerAddress> fullScan(
|
||||||
CatalogTracker catalogTracker, final Set<String> disabledTables)
|
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 {
|
throws IOException {
|
||||||
final Map<HRegionInfo,HServerAddress> regions =
|
final Map<HRegionInfo,HServerAddress> regions =
|
||||||
new TreeMap<HRegionInfo,HServerAddress>();
|
new TreeMap<HRegionInfo,HServerAddress>();
|
||||||
|
@ -158,9 +180,12 @@ public class MetaReader {
|
||||||
if (r == null || r.isEmpty()) return true;
|
if (r == null || r.isEmpty()) return true;
|
||||||
Pair<HRegionInfo,HServerAddress> region = metaRowToRegionPair(r);
|
Pair<HRegionInfo,HServerAddress> region = metaRowToRegionPair(r);
|
||||||
if (region == null) return true;
|
if (region == null) return true;
|
||||||
|
HRegionInfo hri = region.getFirst();
|
||||||
if (disabledTables.contains(
|
if (disabledTables.contains(
|
||||||
region.getFirst().getTableDesc().getNameAsString())) return true;
|
hri.getTableDesc().getNameAsString())) return true;
|
||||||
regions.put(region.getFirst(), region.getSecond());
|
// Are we to include split parents in the list?
|
||||||
|
if (excludeOfflinedSplitParents && hri.isSplitParent()) return true;
|
||||||
|
regions.put(hri, region.getSecond());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -415,6 +440,21 @@ public class MetaReader {
|
||||||
*/
|
*/
|
||||||
public static List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker,
|
public static List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker,
|
||||||
byte [] tableName)
|
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 {
|
throws IOException {
|
||||||
if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
|
if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
|
||||||
// If root, do a bit of special handling.
|
// If root, do a bit of special handling.
|
||||||
|
@ -446,6 +486,8 @@ public class MetaReader {
|
||||||
data.getValue(HConstants.CATALOG_FAMILY,
|
data.getValue(HConstants.CATALOG_FAMILY,
|
||||||
HConstants.REGIONINFO_QUALIFIER));
|
HConstants.REGIONINFO_QUALIFIER));
|
||||||
if (info.getTableDesc().getNameAsString().equals(tableString)) {
|
if (info.getTableDesc().getNameAsString().equals(tableString)) {
|
||||||
|
// Are we to include split parents in the list?
|
||||||
|
if (excludeOfflinedSplitParents && info.isSplitParent()) continue;
|
||||||
regions.add(info);
|
regions.add(info);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1105,7 +1105,7 @@ public class AssignmentManager extends ZooKeeperListener {
|
||||||
|
|
||||||
// Scan META for all user regions, skipping any disabled tables
|
// Scan META for all user regions, skipping any disabled tables
|
||||||
Map<HRegionInfo,HServerAddress> allRegions =
|
Map<HRegionInfo,HServerAddress> allRegions =
|
||||||
MetaReader.fullScan(catalogTracker, this.zkTable.getDisabledTables());
|
MetaReader.fullScan(catalogTracker, this.zkTable.getDisabledTables(), true);
|
||||||
if (allRegions == null || allRegions.isEmpty()) return;
|
if (allRegions == null || allRegions.isEmpty()) return;
|
||||||
|
|
||||||
// Determine what type of assignment to do on startup
|
// Determine what type of assignment to do on startup
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class EnableTableHandler extends EventHandler {
|
||||||
// Get the regions of this table. We're done when all listed
|
// Get the regions of this table. We're done when all listed
|
||||||
// tables are onlined.
|
// tables are onlined.
|
||||||
List<HRegionInfo> regionsInMeta =
|
List<HRegionInfo> regionsInMeta =
|
||||||
MetaReader.getTableRegions(this.ct, tableName);
|
MetaReader.getTableRegions(this.ct, tableName, true);
|
||||||
int countOfRegionsInTable = regionsInMeta.size();
|
int countOfRegionsInTable = regionsInMeta.size();
|
||||||
List<HRegionInfo> regions = regionsToAssign(regionsInMeta);
|
List<HRegionInfo> regions = regionsToAssign(regionsInMeta);
|
||||||
if (regions.size() == 0) {
|
if (regions.size() == 0) {
|
||||||
|
|
Loading…
Reference in New Issue