Class RegionStateNode
java.lang.Object
org.apache.hadoop.hbase.master.assignment.RegionStateNode
- All Implemented Interfaces:
Comparable<RegionStateNode>
Current Region State. Most fields are synchronized with meta region, i.e, we will update meta
immediately after we modify this RegionStateNode, and usually under the lock. The only exception
is
lastHost
, which should not be used for critical condition.
Typically, the only way to modify this class is through TransitRegionStateProcedure
, and
we will record the TRSP along with this RegionStateNode to make sure that there could at most one
TRSP. For other operations, such as SCP, we will first get the lock, and then try to schedule a
TRSP. If there is already one, then the solution will be different:
- For SCP, we will update the region state in meta to tell the TRSP to retry.
- For DisableTableProcedure, as we have the xlock, we can make sure that the TRSP has not been executed yet, so just unset it and attach a new one. The original one will quit immediately when executing.
- For split/merge, we will fail immediately as there is no actual operations yet so no harm.
- For EnableTableProcedure/TruncateTableProcedure, we can make sure that there will be no TRSP attached with the RSNs.
- For other procedures, you'd better use ReopenTableRegionsProcedure. The RTRP will take care of lots of corner cases when reopening regions.
volatile
, which means you are free to get it without
lock, but usually you should not use these fields without locking for critical condition, as it
will be easily to introduce inconsistency. For example, you are free to dump the status and show
it on web without locking, but if you want to change the state of the RegionStateNode by checking
the current state, you'd better have the lock...-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static final class
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ProcedureEvent<?>
private ServerName
private long
Updated whenever a call tosetRegionLocation(ServerName)
orsetState(RegionState.State, RegionState.State...)
.private final RegionStateNodeLock
private static final org.slf4j.Logger
private long
private TransitRegionStateProcedure
private final RegionInfo
private ServerName
private final ConcurrentMap<RegionInfo,
RegionStateNode> private RegionState.State
A Region-in-Transition (RIT) moves through states. -
Constructor Summary
ConstructorDescriptionRegionStateNode
(RegionInfo regionInfo, ConcurrentMap<RegionInfo, RegionStateNode> ritMap) -
Method Summary
Modifier and TypeMethodDescriptionvoid
int
compareTo
(RegionStateNode other) boolean
int
long
long
getState()
getTable()
int
hashCode()
boolean
isInState
(RegionState.State... expected) Notice that, we will return true ifexpected
is empty.boolean
(package private) boolean
isLocked()
boolean
isLockedBy
(Procedure<?> proc) boolean
isSplit()
Return whether the region has been split and not online.boolean
isStuck()
boolean
void
lock()
void
offline()
Put region into OFFLINE mode (set state and clear location).void
setLastHost
(ServerName serverName) void
setOpenSeqNum
(long seqId) setRegionLocation
(ServerName serverName) boolean
setState
(RegionState.State update, RegionState.State... expected) toString()
void
transitionState
(RegionState.State update, RegionState.State... expected) Set newRegionState.State
but only if currently inexpected
State (if not, throwUnexpectedStateException
.boolean
tryLock()
boolean
void
unlock()
void
void
-
Field Details
-
LOG
-
lock
-
regionInfo
-
event
-
ritMap
-
procedure
-
regionLocation
-
lastHost
-
state
A Region-in-Transition (RIT) moves through states. SeeRegionState.State
for complete list. A Region that is opened moves from OFFLINE => OPENING => OPENED. -
lastUpdate
Updated whenever a call tosetRegionLocation(ServerName)
orsetState(RegionState.State, RegionState.State...)
. -
openSeqNum
-
-
Constructor Details
-
RegionStateNode
RegionStateNode(RegionInfo regionInfo, ConcurrentMap<RegionInfo, RegionStateNode> ritMap)
-
-
Method Details
-
setState
- Parameters:
update
- new region state this node should be assigned.expected
- current state should be in this given list of expected states- Returns:
- true, if current state is in expected list; otherwise false.
-
offline
Put region into OFFLINE mode (set state and clear location).- Returns:
- Last recorded server deploy
-
transitionState
public void transitionState(RegionState.State update, RegionState.State... expected) throws UnexpectedStateException Set newRegionState.State
but only if currently inexpected
State (if not, throwUnexpectedStateException
.- Throws:
UnexpectedStateException
-
isInState
Notice that, we will return true ifexpected
is empty. This is a bit strange but we need this logic, for example, we can change the state to OPENING from any state, as in SCP we will not change the state to CLOSED before opening the region. -
isStuck
-
isInTransition
-
isSplit
Return whether the region has been split and not online. In this method we will test both region info and state, and will return true if either of the test returns true. Please see the comments inAssignmentManager.markRegionAsSplit(RegionInfo, ServerName, RegionInfo, RegionInfo)
for more details on why we need to test two conditions. -
getLastUpdate
-
setLastHost
-
setOpenSeqNum
-
setRegionLocation
-
setProcedure
-
unsetProcedure
-
getProcedure
-
getProcedureEvent
-
getRegionInfo
-
getTable
-
isSystemTable
-
getLastHost
-
getRegionLocation
-
getState
-
getOpenSeqNum
-
getFormatVersion
-
toRegionState
-
compareTo
- Specified by:
compareTo
in interfaceComparable<RegionStateNode>
-
hashCode
-
equals
-
toString
-
toShortString
-
toDescriptiveString
-
checkOnline
- Throws:
DoNotRetryRegionException
-
lock
- See Also:
-
tryLock
- See Also:
-
unlock
- See Also:
-
lock
- Throws:
ProcedureSuspendedException
- See Also:
-
tryLock
- See Also:
-
unlock
- See Also:
-
isLocked
boolean isLocked()- See Also:
-
isLockedBy
- See Also:
-