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
Modifier and TypeClassDescriptionstatic final class
private static class
-
Field Summary
Modifier 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.Logger
static final RegionStates.RegionStateStampComparator
private 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()
toRegionStateNode
private final Object
private final ConcurrentHashMap<ServerName,
ServerStateNode> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addRegionToServer
(RegionStateNode regionNode) addToFailedOpen
(RegionStateNode regionNode) void
addToOfflineRegions
(RegionStateNode regionNode) checkReopened
(HRegionLocation oldLoc) Check whether the region has been reopened.void
clear()
Called on stop of AssignmentManager.private HRegionLocation
(package private) RegionStateNode
createRegionStateNode
(RegionInfo regionInfo) void
createServer
(ServerName serverName) Create the ServerStateNode when registering a new region serverprivate void
createSnapshot
(RegionStateNode node, Map<ServerName, List<RegionInfo>> result) void
deleteRegion
(RegionInfo regionInfo) void
deleteRegions
(List<RegionInfo> regionInfos) getAssignmentsForBalancer
(TableStateManager tableStateManager, List<ServerName> onlineServers) This is an EXPENSIVE clone.double
getFailedOpen
(RegionInfo regionInfo) getOrCreateRegionStateNode
(RegionInfo regionInfo) getRegionByStateOfTable
(TableName tableName) getRegionServerOfRegion
(RegionInfo regionInfo) int
Get 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) boolean
boolean
hasTableRegionStates
(TableName tableName) private boolean
include
(RegionStateNode node, boolean offline) Utility.boolean
boolean
isRegionInState
(RegionInfo regionInfo, RegionState.State... state) boolean
isRegionInTransition
(RegionInfo regionInfo) boolean
isRegionOffline
(RegionInfo regionInfo) Returns True if region is offline (In OFFLINE or CLOSED state).boolean
isRegionOnline
(RegionInfo regionInfo) private boolean
isTableDisabled
(TableStateManager tableStateManager, TableName tableName) void
logSplit
(ServerName serverName) Called after we've split all logs on a crashed Server.void
logSplitting
(ServerName serverName) Call this when we start log splitting for a crashed Server.void
metaLogSplit
(ServerName serverName) Called after we've split the meta logs on a crashed Server.void
metaLogSplitting
(ServerName serverName) Call this when we start meta log splitting a crashed Server.static String
regionNamesToString
(Collection<byte[]> regions) void
removeFromFailedOpen
(RegionInfo regionInfo) void
removeRegionFromServer
(ServerName serverName, RegionStateNode regionNode) void
removeServer
(ServerName serverName) Called by SCP at end of successful processing.private void
setServerState
(ServerName serverName, ServerState state) void
updateRegionState
(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 theopenSeqNum
in 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 theHRegionLocation
is the same withgetRegionsOfTableForReopen(TableName)
. For a region which is inRegionState.State.OPEN
before, 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.OPENING
before, usually it will be inRegionState.State.OPEN
now and we will schedule a MRP to reopen it. But there are several exceptions:- The region is in state other than
RegionState.State.OPEN
orRegionState.State.OPENING
. - The location of the region has been changed
RegionState.State.OPENING
state and still on the same server, then here we will still return aHRegionLocation
for it, just likegetRegionsOfTableForReopen(TableName)
.- Parameters:
oldLoc
- the previous state/location of this region- Returns:
- null if the region has been reopened, otherwise a new
HRegionLocation
which 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 unlessoffline
is 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
-