@InterfaceAudience.Private public class RegionStateNode extends Object implements Comparable<RegionStateNode>
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:
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...Modifier and Type | Class and Description |
---|---|
private static class |
RegionStateNode.AssignmentProcedureEvent |
Modifier and Type | Field and Description |
---|---|
private ProcedureEvent<?> |
event |
private ServerName |
lastHost |
private long |
lastUpdate
Updated whenever a call to
setRegionLocation(ServerName) or
setState(RegionState.State, RegionState.State...) . |
(package private) Lock |
lock |
private static org.slf4j.Logger |
LOG |
private long |
openSeqNum |
private TransitRegionStateProcedure |
procedure |
private RegionInfo |
regionInfo |
private ServerName |
regionLocation |
private ConcurrentMap<RegionInfo,RegionStateNode> |
ritMap |
private RegionState.State |
state
A Region-in-Transition (RIT) moves through states.
|
Constructor and Description |
---|
RegionStateNode(RegionInfo regionInfo,
ConcurrentMap<RegionInfo,RegionStateNode> ritMap) |
private static final org.slf4j.Logger LOG
private final RegionInfo regionInfo
private final ProcedureEvent<?> event
private final ConcurrentMap<RegionInfo,RegionStateNode> ritMap
private volatile TransitRegionStateProcedure procedure
private volatile ServerName regionLocation
private volatile ServerName lastHost
private volatile RegionState.State state
RegionState.State
for complete list. A
Region that is opened moves from OFFLINE => OPENING => OPENED.private volatile long lastUpdate
setRegionLocation(ServerName)
or
setState(RegionState.State, RegionState.State...)
.private volatile long openSeqNum
RegionStateNode(RegionInfo regionInfo, ConcurrentMap<RegionInfo,RegionStateNode> ritMap)
public boolean setState(RegionState.State update, RegionState.State... expected)
update
- new region state this node should be assigned.expected
- current state should be in this given list of expected statespublic ServerName offline()
public void transitionState(RegionState.State update, RegionState.State... expected) throws UnexpectedStateException
RegionState.State
but only if currently in expected
State (if not, throw
UnexpectedStateException
.UnexpectedStateException
public boolean isInState(RegionState.State... expected)
expected
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.public boolean isStuck()
public boolean isInTransition()
public long getLastUpdate()
public void setLastHost(ServerName serverName)
public void setOpenSeqNum(long seqId)
public ServerName setRegionLocation(ServerName serverName)
public void setProcedure(TransitRegionStateProcedure proc)
public void unsetProcedure(TransitRegionStateProcedure proc)
public TransitRegionStateProcedure getProcedure()
public ProcedureEvent<?> getProcedureEvent()
public RegionInfo getRegionInfo()
public boolean isSystemTable()
public ServerName getLastHost()
public ServerName getRegionLocation()
public RegionState.State getState()
public long getOpenSeqNum()
public int getFormatVersion()
public RegionState toRegionState()
public int compareTo(RegionStateNode other)
compareTo
in interface Comparable<RegionStateNode>
public String toShortString()
public String toDescriptiveString()
public void checkOnline() throws DoNotRetryRegionException
DoNotRetryRegionException
public void lock()
public void unlock()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.