Class RegionStates
java.lang.Object
org.apache.hadoop.hbase.master.assignment.RegionStates
RegionStates contains a set of Maps that describes the in-memory state of the AM, with the
regions available in the system, the region in transition, the offline regions and the servers
holding regions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentSkipListMap<String,RegionStateNode> this map is a hack to lookup of region in master by encoded region name is O(n).private static final org.slf4j.Loggerstatic final RegionStates.RegionStateStampComparatorprivate final ConcurrentSkipListMap<byte[],RegionStates.RegionFailedOpen> private final ConcurrentSkipListMap<RegionInfo,RegionStateNode> private final ConcurrentSkipListMap<RegionInfo,RegionStateNode> Regions marked as offline on a read of hbase:meta.private final ConcurrentSkipListMap<byte[],RegionStateNode> A Map fromRegionInfo.getRegionName()toRegionStateNodeprivate final Objectprivate final ConcurrentHashMap<ServerName,ServerStateNode> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRegionToServer(RegionStateNode regionNode) addToFailedOpen(RegionStateNode regionNode) voidaddToOfflineRegions(RegionStateNode regionNode) checkReopened(HRegionLocation oldLoc) Check whether the region has been reopened.voidclear()Called on stop of AssignmentManager.private HRegionLocation(package private) RegionStateNodecreateRegionStateNode(RegionInfo regionInfo) voidcreateServer(ServerName serverName) Create the ServerStateNode when registering a new region serverprivate voidcreateSnapshot(RegionStateNode node, Map<ServerName, List<RegionInfo>> result) voiddeleteRegion(RegionInfo regionInfo) voiddeleteRegions(List<RegionInfo> regionInfos) getAssignmentsForBalancer(TableStateManager tableStateManager, List<ServerName> onlineServers) This is an EXPENSIVE clone.doublegetFailedOpen(RegionInfo regionInfo) getOrCreateRegionStateNode(RegionInfo regionInfo) getRegionByStateOfTable(TableName tableName) getRegionServerOfRegion(RegionInfo regionInfo) intGet the number of regions in transition.getRegionsOfTable(TableName table) Returns Return online regions of table; does not include OFFLINE or SPLITTING regions.private List<RegionInfo>getRegionsOfTable(TableName table, Predicate<RegionStateNode> filter) Returns Return the regions of the table and filter them.Get the regions for deleting a table.Get the regions for enabling a table.getRegionsOfTableForReopen(TableName tableName) Get the regions to be reopened when modifying a table.getRegionState(String encodedRegionName) getRegionState(RegionInfo regionInfo) getRegionStateNode(RegionInfo regionInfo) getRegionStateNodeFromEncodedRegionName(String encodedRegionName) getRegionStateNodeFromName(byte[] regionName) Returns A view of region state nodes for all the regions.Returns A snapshot of region state nodes for all the regions.getServerNode(ServerName serverName) Returns Pertinent ServerStateNode or NULL if none found (Do not make modifications).getSnapShotOfAssignment(Collection<RegionInfo> regions) (package private) ArrayList<RegionInfo>getTableRegionsInfo(TableName tableName) (package private) List<RegionStateNode>getTableRegionStateNodes(TableName tableName) (package private) ArrayList<RegionState>getTableRegionStates(TableName tableName) booleanbooleanhasTableRegionStates(TableName tableName) private booleaninclude(RegionStateNode node, boolean offline) Utility.booleanbooleanisRegionInState(RegionInfo regionInfo, RegionState.State... state) booleanisRegionInTransition(RegionInfo regionInfo) booleanisRegionOffline(RegionInfo regionInfo) Returns True if region is offline (In OFFLINE or CLOSED state).booleanisRegionOnline(RegionInfo regionInfo) private booleanisTableDisabled(TableStateManager tableStateManager, TableName tableName) voidlogSplit(ServerName serverName) Called after we've split all logs on a crashed Server.voidlogSplitting(ServerName serverName) Call this when we start log splitting for a crashed Server.voidmetaLogSplit(ServerName serverName) Called after we've split the meta logs on a crashed Server.voidmetaLogSplitting(ServerName serverName) Call this when we start meta log splitting a crashed Server.static StringregionNamesToString(Collection<byte[]> regions) voidremoveFromFailedOpen(RegionInfo regionInfo) voidremoveRegionFromServer(ServerName serverName, RegionStateNode regionNode) voidremoveServer(ServerName serverName) Called by SCP at end of successful processing.private voidsetServerState(ServerName serverName, ServerState state) voidupdateRegionState(RegionInfo regionInfo, RegionState.State state)
-
Field Details
-
LOG
-
REGION_STATE_STAMP_COMPARATOR
-
regionsMapLock
-
regionsMap
A Map fromRegionInfo.getRegionName()toRegionStateNode -
encodedRegionsMap
this map is a hack to lookup of region in master by encoded region name is O(n). must put and remove with regionsMap. -
regionInTransition
-
regionOffline
Regions marked as offline on a read of hbase:meta. Unused or at least, once offlined, regions have no means of coming on line again. TODO. -
regionFailedOpen
-
serverMap
-
-
Constructor Details
-
RegionStates
public RegionStates()
-
-
Method Details
-
clear
Called on stop of AssignmentManager. -
isRegionInRegionStates
-
createRegionStateNode
-
getOrCreateRegionStateNode
-
getRegionStateNodeFromName
-
getRegionStateNodeFromEncodedRegionName
-
getRegionStateNode
-
deleteRegion
-
deleteRegions
-
getTableRegionStateNodes
-
getTableRegionStates
-
getTableRegionsInfo
-
getRegionStateNodes
Returns A view of region state nodes for all the regions. -
getRegionStates
Returns A snapshot of region state nodes for all the regions. -
getRegionState
-
getRegionState
-
hasTableRegionStates
-
getRegionsOfTable
Returns Return online regions of table; does not include OFFLINE or SPLITTING regions. -
createRegionForReopen
-
getRegionsOfTableForReopen
Get the regions to be reopened when modifying a table. Notice that theopenSeqNumin the returned HRegionLocation is also used to indicate the state of this region, positive means the region is inRegionState.State.OPEN, -1 meansRegionState.State.OPENING. And for regions in other states we do not need reopen them. -
checkReopened
Check whether the region has been reopened. The meaning of theHRegionLocationis the same withgetRegionsOfTableForReopen(TableName). For a region which is inRegionState.State.OPENbefore, if the region state is changed or the open seq num is changed, we can confirm that it has been reopened. For a region which is inRegionState.State.OPENINGbefore, usually it will be inRegionState.State.OPENnow and we will schedule a MRP to reopen it. But there are several exceptions:- The region is in state other than
RegionState.State.OPENorRegionState.State.OPENING. - The location of the region has been changed
RegionState.State.OPENINGstate and still on the same server, then here we will still return aHRegionLocationfor it, just likegetRegionsOfTableForReopen(TableName).- Parameters:
oldLoc- the previous state/location of this region- Returns:
- null if the region has been reopened, otherwise a new
HRegionLocationwhich means we still need to reopen the region. - See Also:
- The region is in state other than
-
getRegionsOfTableForEnabling
Get the regions for enabling a table. Here we want the EnableTableProcedure to be more robust and can be used to fix some nasty states, so the checks in this method will be a bit strange. In general, a region can only be offline when it is split, for merging we will just delete the parent regions, but with HBCK we may force update the state of a region to fix some nasty bugs, so in this method we will try to bring the offline regions back if it is not split. That's why we only check for split state here. -
getRegionsOfTableForDeleting
Get the regions for deleting a table. Here we need to return all the regions irrespective of the states in order to archive them all. This is because if we don't archive OFFLINE/SPLIT regions and if a snapshot or a cloned table references to the regions, we will lose the data of the regions. -
getRegionsOfTable
Returns Return the regions of the table and filter them. -
include
Utility. Whether to include region in list of regions. Default is to weed out split and offline regions.- Returns:
- True if we should include the
node(do not include if split or offline unlessofflineis set to true.
-
setServerState
-
metaLogSplitting
Call this when we start meta log splitting a crashed Server.- See Also:
-
metaLogSplit
Called after we've split the meta logs on a crashed Server.- See Also:
-
logSplitting
Call this when we start log splitting for a crashed Server.- See Also:
-
logSplit
Called after we've split all logs on a crashed Server.- See Also:
-
updateRegionState
-
getAssignedRegions
-
isRegionInState
-
isRegionOnline
-
isRegionOffline
Returns True if region is offline (In OFFLINE or CLOSED state). -
getSnapShotOfAssignment
-
createSnapshot
-
getRegionAssignments
-
getRegionByStateOfTable
-
getRegionServerOfRegion
-
getAssignmentsForBalancer
public Map<TableName,Map<ServerName, getAssignmentsForBalancerList<RegionInfo>>> (TableStateManager tableStateManager, List<ServerName> onlineServers) This is an EXPENSIVE clone. Cloning though is the safest thing to do. Can't let out original since it can change and at least the load balancer wants to iterate this exported list. We need to synchronize on regions since all access to this.servers is under a lock on this.regions.- Returns:
- A clone of current open or opening assignments.
-
isTableDisabled
-
hasRegionsInTransition
-
isRegionInTransition
-
getRegionTransitionState
-
getRegionsInTransition
-
getRegionsInTransitionCount
Get the number of regions in transition. -
getRegionsStateInTransition
-
getRegionsInTransitionOrderedByTimestamp
-
addToOfflineRegions
-
addToFailedOpen
-
getFailedOpen
-
removeFromFailedOpen
-
getRegionFailedOpen
-
createServer
Create the ServerStateNode when registering a new region server -
removeServer
Called by SCP at end of successful processing. -
getServerNode
Returns Pertinent ServerStateNode or NULL if none found (Do not make modifications). -
getAverageLoad
-
addRegionToServer
-
removeRegionFromServer
-
regionNamesToString
-