Class RegionMaintainHandler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRegionLocation(TConsensusGroupId regionId, TDataNodeLocation newLocation) createNewRegionPeer(TConsensusGroupId regionId, TDataNodeLocation destDataNode) Create a new RegionReplica and build the ConsensusGroup on the destined DataNodefilterDataNodeWithOtherRegionReplica(TConsensusGroupId regionId, List<TDataNodeLocation> filterLocations) filterDataNodeWithOtherRegionReplica(TConsensusGroupId regionId, List<TDataNodeLocation> excludeLocations, NodeStatus... allowingStatus) filterDataNodeWithOtherRegionReplica(TConsensusGroupId regionId, TDataNodeLocation filterLocation) Filter a DataNode who contains other RegionReplica excepts the given one.filterDataNodeWithOtherRegionReplica(TConsensusGroupId regionId, TDataNodeLocation filterLocation, NodeStatus... allowingStatus) findDestDataNode(TConsensusGroupId regionId) Find dest data node.findRegionLocations(TConsensusGroupId regionId) Find all DataNodes which contains the given regionIdvoidforceUpdateRegionCache(TConsensusGroupId regionId, TDataNodeLocation newLocation, RegionStatus regionStatus) static StringgetIdWithRpcEndpoint(TDataNodeLocation location) getRegionReplicaSet(TConsensusGroupId regionId) getRegionReplicaSetString(TConsensusGroupId regionId) booleanbooleanvoidremoveRegionLocation(TConsensusGroupId regionId, TDataNodeLocation deprecatedLocation) resetPeerList(TConsensusGroupId regionId, List<TDataNodeLocation> correctDataNodeLocations, Map<Integer, TDataNodeLocation> dataNodeLocationMap) static StringsimplifiedLocation(TDataNodeLocation dataNodeLocation) submitAddRegionPeerTask(long procedureId, TDataNodeLocation destDataNode, TConsensusGroupId regionId, TDataNodeLocation coordinator) Order the specific ConsensusGroup to add peer for the new RegionReplica.submitDeleteOldRegionPeerTask(long procedureId, TDataNodeLocation originalDataNode, TConsensusGroupId regionId) Delete a Region peer in the given ConsensusGroup and all of its data on the specified DataNodesubmitRemoveRegionPeerTask(long procedureId, TDataNodeLocation originalDataNode, TConsensusGroupId regionId, TDataNodeLocation coordinator) Order the specific ConsensusGroup to remove peer for the old RegionReplica.voidtransferRegionLeader(TConsensusGroupId regionId, TDataNodeLocation originalDataNode, TDataNodeLocation coodinator) Change the leader of given Region.waitTaskFinish(long taskId, TDataNodeLocation dataNodeLocation)
-
Constructor Details
-
RegionMaintainHandler
-
-
Method Details
-
getIdWithRpcEndpoint
-
simplifiedLocation
-
findDestDataNode
Find dest data node.- Parameters:
regionId- region id- Returns:
- dest data node location
-
createNewRegionPeer
Create a new RegionReplica and build the ConsensusGroup on the destined DataNodecreateNewRegionPeer should be invoked on a DataNode that doesn't contain any peer of the specific ConsensusGroup, in order to avoid there exists one DataNode who has more than one RegionReplica.
- Parameters:
regionId- The given ConsensusGroupdestDataNode- The destined DataNode where the new peer will be created- Returns:
- status
-
submitAddRegionPeerTask
public TSStatus submitAddRegionPeerTask(long procedureId, TDataNodeLocation destDataNode, TConsensusGroupId regionId, TDataNodeLocation coordinator) Order the specific ConsensusGroup to add peer for the new RegionReplica.The add peer interface could be invoked at any DataNode who contains one of the RegionReplica of the specified ConsensusGroup except the new one
- Parameters:
destDataNode- The DataNodeLocation where the new RegionReplica is createdregionId- region id- Returns:
- TSStatus
-
submitRemoveRegionPeerTask
public TSStatus submitRemoveRegionPeerTask(long procedureId, TDataNodeLocation originalDataNode, TConsensusGroupId regionId, TDataNodeLocation coordinator) Order the specific ConsensusGroup to remove peer for the old RegionReplica.The remove peer interface could be invoked at any DataNode who contains one of the RegionReplica of the specified ConsensusGroup except the origin one
- Parameters:
originalDataNode- The DataNodeLocation who contains the original RegionReplicaregionId- region id- Returns:
- TSStatus
-
submitDeleteOldRegionPeerTask
public TSStatus submitDeleteOldRegionPeerTask(long procedureId, TDataNodeLocation originalDataNode, TConsensusGroupId regionId) Delete a Region peer in the given ConsensusGroup and all of its data on the specified DataNodeIf the originalDataNode is down, we should delete local data and do other cleanup works manually.
- Parameters:
originalDataNode- The DataNodeLocation who contains the original RegionReplicaregionId- region id- Returns:
- TSStatus
-
resetPeerList
public Map<Integer,TSStatus> resetPeerList(TConsensusGroupId regionId, List<TDataNodeLocation> correctDataNodeLocations, Map<Integer, TDataNodeLocation> dataNodeLocationMap) -
waitTaskFinish
-
addRegionLocation
-
forceUpdateRegionCache
public void forceUpdateRegionCache(TConsensusGroupId regionId, TDataNodeLocation newLocation, RegionStatus regionStatus) -
removeRegionLocation
-
findRegionLocations
Find all DataNodes which contains the given regionId- Parameters:
regionId- region id- Returns:
- DataNode locations
-
getRegionReplicaSet
-
getRegionReplicaSetString
-
isSucceed
-
isFailed
-
transferRegionLeader
public void transferRegionLeader(TConsensusGroupId regionId, TDataNodeLocation originalDataNode, TDataNodeLocation coodinator) throws ProcedureException, InterruptedException Change the leader of given Region.For IOT_CONSENSUS, using `changeLeaderForIoTConsensus` method to change the regionLeaderMap maintained in ConfigNode.
For RATIS_CONSENSUS, invoking `changeRegionLeader` DataNode RPC method to change the leader.
- Parameters:
regionId- The region to be migratedoriginalDataNode- The DataNode where the region locates- Throws:
ProcedureExceptionInterruptedException
-
filterDataNodeWithOtherRegionReplica
public Optional<TDataNodeLocation> filterDataNodeWithOtherRegionReplica(TConsensusGroupId regionId, TDataNodeLocation filterLocation) Filter a DataNode who contains other RegionReplica excepts the given one.Choose the RUNNING status datanode firstly, if no RUNNING status datanode match the condition, then we choose the REMOVING status datanode.
`addRegionPeer`, `removeRegionPeer` and `changeRegionLeader` invoke this method.
- Parameters:
regionId- The specific RegionIdfilterLocation- The DataNodeLocation that should be filtered- Returns:
- A DataNodeLocation that contains other RegionReplica and different from the filterLocation
-
filterDataNodeWithOtherRegionReplica
public Optional<TDataNodeLocation> filterDataNodeWithOtherRegionReplica(TConsensusGroupId regionId, List<TDataNodeLocation> filterLocations) -
filterDataNodeWithOtherRegionReplica
public Optional<TDataNodeLocation> filterDataNodeWithOtherRegionReplica(TConsensusGroupId regionId, TDataNodeLocation filterLocation, NodeStatus... allowingStatus) -
filterDataNodeWithOtherRegionReplica
public Optional<TDataNodeLocation> filterDataNodeWithOtherRegionReplica(TConsensusGroupId regionId, List<TDataNodeLocation> excludeLocations, NodeStatus... allowingStatus)
-