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 SummaryNested ClassesModifier and TypeClassDescriptionprivate static final class
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate final ProcedureEvent<?>private ServerNameprivate longUpdated whenever a call tosetRegionLocation(ServerName)orsetState(RegionState.State, RegionState.State...).(package private) final Lockprivate static final org.slf4j.Loggerprivate longprivate TransitRegionStateProcedureprivate final RegionInfoprivate ServerNameprivate final ConcurrentMap<RegionInfo,RegionStateNode> private RegionState.StateA Region-in-Transition (RIT) moves through states.
- 
Constructor SummaryConstructorsConstructorDescriptionRegionStateNode(RegionInfo regionInfo, ConcurrentMap<RegionInfo, RegionStateNode> ritMap) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidintcompareTo(RegionStateNode other) booleanintlonglonggetState()getTable()inthashCode()booleanisInState(RegionState.State... expected) Notice that, we will return true ifexpectedis empty.booleanbooleanisSplit()Return whether the region has been split and not online.booleanisStuck()booleanvoidlock()offline()Put region into OFFLINE mode (set state and clear location).voidsetLastHost(ServerName serverName) voidsetOpenSeqNum(long seqId) setRegionLocation(ServerName serverName) booleansetState(RegionState.State update, RegionState.State... expected) toString()voidtransitionState(RegionState.State update, RegionState.State... expected) Set newRegionState.Statebut only if currently inexpectedState (if not, throwUnexpectedStateException.booleantryLock()voidunlock()void
- 
Field Details- 
LOG
- 
lock
- 
regionInfo
- 
event
- 
ritMap
- 
procedure
- 
regionLocation
- 
lastHost
- 
stateA Region-in-Transition (RIT) moves through states. SeeRegionState.Statefor complete list. A Region that is opened moves from OFFLINE => OPENING => OPENED.
- 
lastUpdateUpdated whenever a call tosetRegionLocation(ServerName)orsetState(RegionState.State, RegionState.State...).
- 
openSeqNum
 
- 
- 
Constructor Details- 
RegionStateNodeRegionStateNode(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.
 
- 
offlinePut region into OFFLINE mode (set state and clear location).- Returns:
- Last recorded server deploy
 
- 
transitionStatepublic void transitionState(RegionState.State update, RegionState.State... expected) throws UnexpectedStateException Set newRegionState.Statebut only if currently inexpectedState (if not, throwUnexpectedStateException.- Throws:
- UnexpectedStateException
 
- 
isInStateNotice that, we will return true ifexpectedis 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
- 
isSplitReturn 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:
- compareToin interface- Comparable<RegionStateNode>
 
- 
hashCode
- 
equals
- 
toString
- 
toShortString
- 
toDescriptiveString
- 
checkOnline- Throws:
- DoNotRetryRegionException
 
- 
lock
- 
tryLock
- 
unlock
 
-