@InterfaceAudience.Private public class RegionStates extends Object
Modifier and Type | Method and Description |
---|---|
void |
clearLastAssignment(HRegionInfo region) |
RegionState |
createRegionState(HRegionInfo hri)
Add a region to RegionStates.
|
RegionState |
createRegionState(HRegionInfo hri,
RegionState.State newState,
ServerName serverName,
ServerName lastHost)
Add a region to RegionStates with the specified state.
|
void |
createRegionStates(List<HRegionInfo> hris)
Add a list of regions to RegionStates.
|
void |
deleteRegion(HRegionInfo hri)
Remove a region from all state maps.
|
protected Map<TableName,Map<ServerName,List<HRegionInfo>>> |
getAssignmentsByTable()
This is an EXPENSIVE clone.
|
protected double |
getAverageLoad()
Compute the average load across all region servers.
|
Map<HRegionInfo,ServerName> |
getRegionAssignments() |
protected Map<ServerName,List<HRegionInfo>> |
getRegionAssignmentsByServer()
Returns a clone of region assignments per server
|
Map<RegionState.State,List<HRegionInfo>> |
getRegionByStateOfTable(TableName tableName)
Gets current state of all regions of the table.
|
protected HRegionInfo |
getRegionInfo(byte[] regionName)
Get the HRegionInfo from cache, if not there, from the hbase:meta table
|
ServerName |
getRegionServerOfRegion(HRegionInfo hri) |
Map<String,RegionState> |
getRegionsInTransition()
Get regions in transition and their states
|
List<HRegionInfo> |
getRegionsOfTable(TableName tableName)
Gets the online regions of the specified table.
|
protected RegionState |
getRegionState(HRegionInfo hri) |
protected RegionState |
getRegionState(String encodedName) |
RegionState |
getRegionTransitionState(HRegionInfo hri)
Get region transition state
|
RegionState |
getRegionTransitionState(String encodedName)
Get region transition state
|
Set<HRegionInfo> |
getServerRegions(ServerName serverName)
Get a copy of all regions assigned to a server
|
boolean |
isMetaRegionInTransition() |
boolean |
isRegionInState(HRegionInfo hri,
RegionState.State... states) |
boolean |
isRegionInState(String encodedName,
RegionState.State... states) |
boolean |
isRegionInTransition(HRegionInfo hri) |
boolean |
isRegionInTransition(String encodedName) |
boolean |
isRegionOffline(HRegionInfo hri) |
boolean |
isRegionOnline(HRegionInfo hri) |
boolean |
isRegionsInTransition() |
void |
logSplit(HRegionInfo region)
Log split is done for a given region, so it is assignable now.
|
void |
logSplit(ServerName serverName)
A dead server's wals have been split so that all the regions
used to be open on it can be safely assigned now.
|
void |
regionOffline(HRegionInfo hri)
A region is offline, won't be in transition any more.
|
void |
regionOffline(HRegionInfo hri,
RegionState.State expectedState)
A region is offline, won't be in transition any more.
|
void |
regionOnline(HRegionInfo hri,
ServerName serverName) |
void |
regionOnline(HRegionInfo hri,
ServerName serverName,
long openSeqNum)
A region is online, won't be in transition any more.
|
List<HRegionInfo> |
serverOffline(ZooKeeperWatcher watcher,
ServerName sn)
A server is offline, all regions on it are dead.
|
void |
tableDeleted(TableName tableName)
A table is deleted.
|
RegionState |
transitionOpenFromPendingOpenOrOpeningOnServer(RegionTransition transition,
RegionState fromState,
ServerName sn)
Transition a region state to OPEN from OPENING/PENDING_OPEN
|
RegionState |
updateRegionState(HRegionInfo hri,
RegionState.State state)
Update a region state.
|
RegionState |
updateRegionState(HRegionInfo hri,
RegionState.State state,
ServerName serverName)
Update a region state.
|
RegionState |
updateRegionState(RegionTransition transition,
RegionState.State state)
Update a region state.
|
void |
waitForUpdate(long timeout)
Wait for the state map to be updated by assignment manager.
|
void |
waitOnRegionToClearRegionsInTransition(HRegionInfo hri)
Wait on region to clear regions-in-transition.
|
public Map<HRegionInfo,ServerName> getRegionAssignments()
public ServerName getRegionServerOfRegion(HRegionInfo hri)
public Map<String,RegionState> getRegionsInTransition()
public boolean isRegionInTransition(HRegionInfo hri)
public boolean isRegionInTransition(String encodedName)
public boolean isRegionsInTransition()
public boolean isMetaRegionInTransition()
public boolean isRegionOnline(HRegionInfo hri)
public boolean isRegionOffline(HRegionInfo hri)
public boolean isRegionInState(HRegionInfo hri, RegionState.State... states)
public boolean isRegionInState(String encodedName, RegionState.State... states)
public void waitForUpdate(long timeout) throws InterruptedException
InterruptedException
public RegionState getRegionTransitionState(HRegionInfo hri)
public RegionState getRegionTransitionState(String encodedName)
public void createRegionStates(List<HRegionInfo> hris)
public RegionState createRegionState(HRegionInfo hri)
public RegionState createRegionState(HRegionInfo hri, RegionState.State newState, ServerName serverName, ServerName lastHost)
hri
- the region info to create a state fornewState
- the state to the region in set toserverName
- the server the region is transitioning onlastHost
- the last server that hosts the regionpublic RegionState updateRegionState(HRegionInfo hri, RegionState.State state)
public RegionState updateRegionState(RegionTransition transition, RegionState.State state)
public RegionState transitionOpenFromPendingOpenOrOpeningOnServer(RegionTransition transition, RegionState fromState, ServerName sn)
public RegionState updateRegionState(HRegionInfo hri, RegionState.State state, ServerName serverName)
public void regionOnline(HRegionInfo hri, ServerName serverName)
public void regionOnline(HRegionInfo hri, ServerName serverName, long openSeqNum)
public void logSplit(ServerName serverName)
public void logSplit(HRegionInfo region)
public void clearLastAssignment(HRegionInfo region)
public void regionOffline(HRegionInfo hri)
public void regionOffline(HRegionInfo hri, RegionState.State expectedState)
public List<HRegionInfo> serverOffline(ZooKeeperWatcher watcher, ServerName sn)
public List<HRegionInfo> getRegionsOfTable(TableName tableName)
hbase:meta
.
Only returns online regions. If a region on this table has been
closed during a disable, etc., it will be included in the returned list.
So, the returned list may not necessarily be ALL regions in this table, its
all the ONLINE regions in the table.tableName
- tableName
public Map<RegionState.State,List<HRegionInfo>> getRegionByStateOfTable(TableName tableName)
hbase:meta
.
Method guaranteed to return keys for all states
in RegionState.State
tableName
- tableName
public void waitOnRegionToClearRegionsInTransition(HRegionInfo hri) throws InterruptedException
If the region isn't in transition, returns immediately. Otherwise, method blocks until the region is out of transition.
InterruptedException
public void tableDeleted(TableName tableName)
public Set<HRegionInfo> getServerRegions(ServerName serverName)
public void deleteRegion(HRegionInfo hri)
protected double getAverageLoad()
protected Map<TableName,Map<ServerName,List<HRegionInfo>>> getAssignmentsByTable()
protected RegionState getRegionState(HRegionInfo hri)
protected Map<ServerName,List<HRegionInfo>> getRegionAssignmentsByServer()
protected RegionState getRegionState(String encodedName)
protected HRegionInfo getRegionInfo(byte[] regionName)
regionName
-