@InterfaceAudience.Private public class AssignmentManager extends Object
RegionStates.RegionStateStore.| Modifier and Type | Class and Description |
|---|---|
static class |
AssignmentManager.RegionInTransitionStat |
| Modifier and Type | Field and Description |
|---|---|
static String |
ASSIGN_DISPATCH_WAIT_MSEC_CONF_KEY |
static String |
ASSIGN_DISPATCH_WAITQ_MAX_CONF_KEY |
static String |
ASSIGN_MAX_ATTEMPTS |
static String |
ASSIGN_RETRY_IMMEDIATELY_MAX_ATTEMPTS |
static String |
BOOTSTRAP_THREAD_POOL_SIZE_CONF_KEY |
static String |
DEAD_REGION_METRIC_CHORE_INTERVAL_MSEC_CONF_KEY |
static String |
METRICS_RIT_STUCK_WARNING_THRESHOLD
Region in Transition metrics threshold time
|
static String |
RIT_CHORE_INTERVAL_MSEC_CONF_KEY |
static String |
UNEXPECTED_STATE_REGION |
| Constructor and Description |
|---|
AssignmentManager(MasterServices master,
MasterRegion masterRegion) |
| Modifier and Type | Method and Description |
|---|---|
long |
assign(RegionInfo regionInfo) |
long |
assign(RegionInfo regionInfo,
ServerName sn) |
Future<byte[]> |
assignAsync(RegionInfo regionInfo)
Submits a procedure that assigns a region without waiting for it to finish
|
Future<byte[]> |
assignAsync(RegionInfo regionInfo,
ServerName sn)
Submits a procedure that assigns a region to a target server without waiting for it to finish
|
Future<byte[]> |
balance(RegionPlan regionPlan) |
void |
checkIfShouldMoveSystemRegionAsync()
Start a new thread to check if there are region servers whose versions are higher than others.
|
AssignmentManager.RegionInTransitionStat |
computeRegionInTransitionStat() |
TransitRegionStateProcedure[] |
createAssignProcedures(List<RegionInfo> hris)
Create an array of TransitRegionStateProcedure w/o specifying a target server.
|
MergeTableRegionsProcedure |
createMergeProcedure(RegionInfo... ris) |
TransitRegionStateProcedure |
createMoveRegionProcedure(RegionInfo regionInfo,
ServerName targetServer) |
TransitRegionStateProcedure |
createOneAssignProcedure(RegionInfo ri,
boolean override)
Create one TransitRegionStateProcedure to assign a region w/o specifying a target server.
|
TransitRegionStateProcedure |
createOneUnassignProcedure(RegionInfo ri,
boolean override)
Create one TransitRegionStateProcedure to unassign a region.
|
TransitRegionStateProcedure[] |
createRoundRobinAssignProcedures(List<RegionInfo> hris)
Create round-robin assigns.
|
TransitRegionStateProcedure[] |
createRoundRobinAssignProcedures(List<RegionInfo> hris,
List<ServerName> serversToExclude)
Create round-robin assigns.
|
SplitTableRegionProcedure |
createSplitProcedure(RegionInfo regionToSplit,
byte[] splitKey) |
TransitRegionStateProcedure[] |
createUnassignProceduresForClosingExcessRegionReplicas(TableName tableName,
int newReplicaCount)
Called by ModifyTableProcedures to unassign all the excess region replicas for a table.
|
TransitRegionStateProcedure[] |
createUnassignProceduresForDisabling(TableName tableName)
Called by DisableTableProcedure to unassign all the regions for a table.
|
void |
deleteTable(TableName tableName)
Delete the region states.
|
List<RegionInfo> |
getAssignedRegions() |
MetricsAssignmentManager |
getAssignmentManagerMetrics() |
org.apache.hadoop.conf.Configuration |
getConfiguration() |
List<ServerName> |
getExcludedServersForSystemTable()
For a given cluster with mixed versions of servers, get a list of servers with lower versions,
where system table regions should not be assigned to.
|
List<ServerName> |
getFavoredNodes(RegionInfo regionInfo) |
RegionInfo |
getMetaRegionFromName(byte[] regionName) |
Set<RegionInfo> |
getMetaRegionSet() |
int |
getNumRegionsOpened() |
RegionInfo |
getRegionInfo(byte[] regionName)
Resolve a cached
RegionInfo from the region name as a byte[]. |
RegionInfo |
getRegionInfo(String encodedRegionName)
Resolve a cached
RegionInfo from the encoded region name as a String. |
List<RegionStateNode> |
getRegionsInTransition() |
List<RegionInfo> |
getRegionsOnServer(ServerName serverName)
Returns the regions hosted by the specified server.
|
RegionStates |
getRegionStates() |
RegionStatesCount |
getRegionStatesCount(TableName tableName)
Provide regions state count for given table.
|
RegionStateStore |
getRegionStateStore() |
Pair<Integer,Integer> |
getReopenStatus(TableName tableName)
Used by the client (via master) to identify if all regions have the schema updates
|
Map<ServerName,Set<byte[]>> |
getRSReports()
Returns a snapshot of rsReports
|
Map<ServerName,List<RegionInfo>> |
getSnapShotOfAssignment(Collection<RegionInfo> regions) |
List<RegionInfo> |
getTableRegions(TableName tableName,
boolean excludeOfflinedSplitParents) |
List<Pair<RegionInfo,ServerName>> |
getTableRegionsAndLocations(TableName tableName,
boolean excludeOfflinedSplitParents) |
boolean |
hasRegionsInTransition() |
boolean |
isCarryingMeta(ServerName serverName) |
boolean |
isMetaAssigned()
Notice that, this only means the meta region is available on a RS, but the AM may still be
loading the region states from meta, so usually you need to check
isMetaLoaded() first
before checking this method, unless you can make sure that your piece of code can only be
executed after AM builds the region states. |
boolean |
isMetaLoaded()
Return whether AM finishes the meta loading, i.e, the region states rebuilding.
|
boolean |
isMetaRegion(byte[] regionName) |
boolean |
isMetaRegionInTransition() |
boolean |
isRunning() |
void |
joinCluster() |
void |
markRegionAsMerged(RegionInfo child,
ServerName serverName,
RegionInfo[] mergeParents)
When called here, the merge has happened.
|
void |
markRegionAsSplit(RegionInfo parent,
ServerName serverName,
RegionInfo daughterA,
RegionInfo daughterB) |
void |
move(RegionInfo regionInfo) |
Future<byte[]> |
moveAsync(RegionPlan regionPlan) |
void |
offlineRegion(RegionInfo regionInfo) |
void |
onlineRegion(RegionInfo regionInfo,
ServerName serverName) |
void |
populateRegionStatesFromMeta(RegionInfo regionInfo)
Attempt to load
regionInfo from META, adding any results to the
regionStateStore Is NOT aware of replica regions. |
void |
populateRegionStatesFromMeta(String regionEncodedName)
Attempt to load
regionEncodedName from META, adding any results to the
regionStateStore Is NOT aware of replica regions. |
void |
processOfflineRegions()
Create assign procedure for offline regions.
|
protected void |
queueAssign(RegionStateNode regionNode)
Add the assign operation to the assignment queue.
|
void |
regionClosedAbnormally(RegionStateNode regionNode) |
void |
reportOnlineRegions(ServerName serverName,
Set<byte[]> regionNames)
The master will call this method when the RS send the regionServerReport().
|
org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse |
reportRegionStateTransition(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest req) |
void |
setupRIT(List<TransitRegionStateProcedure> procs)
Create RegionStateNode based on the TRSP list, and attach the TRSP to the RegionStateNode.
|
void |
start() |
void |
stop() |
long |
submitServerCrash(ServerName serverName,
boolean shouldSplitWal,
boolean force)
Usually run by the Master in reaction to server crash during normal processing.
|
long |
unassign(RegionInfo regionInfo) |
boolean |
waitMetaAssigned(Procedure<?> proc,
RegionInfo regionInfo)
Notice that this event does not mean the AM has already finished region state rebuilding.
|
boolean |
waitMetaLoaded(Procedure<?> proc)
Wait until AM finishes the meta loading, i.e, the region states rebuilding.
|
void |
wakeMetaLoadedEvent()
This method will be called in master initialization method after calling
processOfflineRegions(), as in processOfflineRegions we will generate assign
procedures for offline regions, which may be conflict with creating table. |
public static final String BOOTSTRAP_THREAD_POOL_SIZE_CONF_KEY
public static final String ASSIGN_DISPATCH_WAIT_MSEC_CONF_KEY
public static final String ASSIGN_DISPATCH_WAITQ_MAX_CONF_KEY
public static final String RIT_CHORE_INTERVAL_MSEC_CONF_KEY
public static final String DEAD_REGION_METRIC_CHORE_INTERVAL_MSEC_CONF_KEY
public static final String ASSIGN_MAX_ATTEMPTS
public static final String ASSIGN_RETRY_IMMEDIATELY_MAX_ATTEMPTS
public static final String METRICS_RIT_STUCK_WARNING_THRESHOLD
public static final String UNEXPECTED_STATE_REGION
public AssignmentManager(MasterServices master, MasterRegion masterRegion)
public void start()
throws IOException,
org.apache.zookeeper.KeeperException
IOExceptionorg.apache.zookeeper.KeeperExceptionpublic void setupRIT(List<TransitRegionStateProcedure> procs)
This is used to restore the RIT region list, so we do not need to restore it in the loadingMeta method below. And it is also very important as now before submitting a TRSP, we need to attach it to the RegionStateNode, which acts like a guard, so we need to restore this information at the very beginning, before we start processing any procedures.
public void stop()
public boolean isRunning()
public org.apache.hadoop.conf.Configuration getConfiguration()
public MetricsAssignmentManager getAssignmentManagerMetrics()
public RegionStates getRegionStates()
public List<RegionInfo> getRegionsOnServer(ServerName serverName)
public List<RegionInfo> getTableRegions(TableName tableName, boolean excludeOfflinedSplitParents)
public List<Pair<RegionInfo,ServerName>> getTableRegionsAndLocations(TableName tableName, boolean excludeOfflinedSplitParents)
public RegionStateStore getRegionStateStore()
public List<ServerName> getFavoredNodes(RegionInfo regionInfo)
public boolean isMetaRegion(byte[] regionName)
public RegionInfo getMetaRegionFromName(byte[] regionName)
public boolean isCarryingMeta(ServerName serverName)
public Set<RegionInfo> getMetaRegionSet()
public boolean isMetaAssigned()
isMetaLoaded() first
before checking this method, unless you can make sure that your piece of code can only be
executed after AM builds the region states.isMetaLoaded()public boolean isMetaRegionInTransition()
public boolean waitMetaAssigned(Procedure<?> proc, RegionInfo regionInfo)
isMetaAssigned() for more details.isMetaAssigned()public boolean waitMetaLoaded(Procedure<?> proc)
public void wakeMetaLoadedEvent()
processOfflineRegions(), as in processOfflineRegions we will generate assign
procedures for offline regions, which may be conflict with creating table.
This is a bit dirty, should be reconsidered after we decide whether to keep the
processOfflineRegions() method.public boolean isMetaLoaded()
isMetaAssigned(),
waitMetaLoaded(Procedure)public void checkIfShouldMoveSystemRegionAsync()
This method is called when a new RegionServer is added to cluster only.
public long assign(RegionInfo regionInfo, ServerName sn) throws IOException
IOExceptionpublic long assign(RegionInfo regionInfo) throws IOException
IOExceptionpublic Future<byte[]> assignAsync(RegionInfo regionInfo, ServerName sn) throws IOException
regionInfo - the region we would like to assignsn - target server nameIOExceptionpublic Future<byte[]> assignAsync(RegionInfo regionInfo) throws IOException
regionInfo - the region we would like to assignIOExceptionpublic long unassign(RegionInfo regionInfo) throws IOException
IOExceptionpublic TransitRegionStateProcedure createMoveRegionProcedure(RegionInfo regionInfo, ServerName targetServer) throws HBaseIOException
HBaseIOExceptionpublic void move(RegionInfo regionInfo) throws IOException
IOExceptionpublic Future<byte[]> moveAsync(RegionPlan regionPlan) throws HBaseIOException
HBaseIOExceptionpublic Future<byte[]> balance(RegionPlan regionPlan) throws HBaseIOException
HBaseIOExceptionpublic TransitRegionStateProcedure[] createRoundRobinAssignProcedures(List<RegionInfo> hris, List<ServerName> serversToExclude)
hris and a call to the balancer
to populate the assigns with targets chosen using round-robin (default balancer
scheme). If at assign-time, the target chosen is no longer up, thats fine, the
AssignProcedure will ask the balancer for a new target, and so on.public TransitRegionStateProcedure[] createRoundRobinAssignProcedures(List<RegionInfo> hris)
hris and a call to the balancer
to populate the assigns with targets chosen using round-robin (default balancer
scheme). If at assign-time, the target chosen is no longer up, thats fine, the
AssignProcedure will ask the balancer for a new target, and so on.public TransitRegionStateProcedure createOneAssignProcedure(RegionInfo ri, boolean override)
public TransitRegionStateProcedure createOneUnassignProcedure(RegionInfo ri, boolean override)
public TransitRegionStateProcedure[] createAssignProcedures(List<RegionInfo> hris)
createAssignProcedures(Map).
If no target server, at assign time, we will try to use the former location of the region if
one exists. This is how we 'retain' the old location across a server restart.
Should only be called when you can make sure that no one can touch these regions other than
you. For example, when you are creating or enabling table. Presumes all Regions are in
appropriate state ripe for assign; no checking of Region state is done in here.createAssignProcedures(Map)public TransitRegionStateProcedure[] createUnassignProceduresForDisabling(TableName tableName)
public TransitRegionStateProcedure[] createUnassignProceduresForClosingExcessRegionReplicas(TableName tableName, int newReplicaCount)
public SplitTableRegionProcedure createSplitProcedure(RegionInfo regionToSplit, byte[] splitKey) throws IOException
IOExceptionpublic MergeTableRegionsProcedure createMergeProcedure(RegionInfo... ris) throws IOException
IOExceptionpublic void deleteTable(TableName tableName) throws IOException
IOExceptionpublic org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse reportRegionStateTransition(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest req) throws PleaseHoldException
PleaseHoldExceptionpublic void reportOnlineRegions(ServerName serverName, Set<byte[]> regionNames)
public AssignmentManager.RegionInTransitionStat computeRegionInTransitionStat()
public void joinCluster()
throws IOException
IOExceptionpublic void processOfflineRegions()
public void populateRegionStatesFromMeta(@NonNull
RegionInfo regionInfo)
throws IOException
regionInfo from META, adding any results to the
regionStateStore Is NOT aware of replica regions.regionInfo - the region to be loaded from META.IOException - If some error occurs while querying META or parsing results.public void populateRegionStatesFromMeta(@NonNull
String regionEncodedName)
throws IOException
regionEncodedName from META, adding any results to the
regionStateStore Is NOT aware of replica regions.regionEncodedName - encoded name for the region to be loaded from META.IOException - If some error occurs while querying META or parsing results.public int getNumRegionsOpened()
public long submitServerCrash(ServerName serverName, boolean shouldSplitWal, boolean force)
force - Set if the request came in externally over RPC (via hbck2). Force means run the
SCP even if it seems as though there might be an outstanding SCP running.Procedure.NO_PROC_ID if none scheduled.public void offlineRegion(RegionInfo regionInfo)
public void onlineRegion(RegionInfo regionInfo, ServerName serverName)
public Map<ServerName,List<RegionInfo>> getSnapShotOfAssignment(Collection<RegionInfo> regions)
public Pair<Integer,Integer> getReopenStatus(TableName tableName)
public boolean hasRegionsInTransition()
public List<RegionStateNode> getRegionsInTransition()
public List<RegionInfo> getAssignedRegions()
public RegionInfo getRegionInfo(byte[] regionName)
RegionInfo from the region name as a byte[].public RegionInfo getRegionInfo(String encodedRegionName)
RegionInfo from the encoded region name as a String.public void regionClosedAbnormally(RegionStateNode regionNode) throws IOException
IOExceptionpublic void markRegionAsSplit(RegionInfo parent, ServerName serverName, RegionInfo daughterA, RegionInfo daughterB) throws IOException
IOExceptionpublic void markRegionAsMerged(RegionInfo child, ServerName serverName, RegionInfo[] mergeParents) throws IOException
IOExceptionprotected void queueAssign(RegionStateNode regionNode)
public List<ServerName> getExcludedServersForSystemTable()
public Map<ServerName,Set<byte[]>> getRSReports()
public RegionStatesCount getRegionStatesCount(TableName tableName)
tableName - TableNameCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.