Class LoadCache
java.lang.Object
org.apache.iotdb.confignode.manager.load.cache.LoadCache
Maintain all kinds of heartbeat samples and statistics.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcacheAINodeHeartbeatSample(int nodeId, NodeHeartbeatSample sample) Cache the latest heartbeat sample of a AINode.voidcacheConfigNodeHeartbeatSample(int nodeId, NodeHeartbeatSample sample) Cache the latest heartbeat sample of a ConfigNode.voidcacheConsensusSample(TConsensusGroupId regionGroupId, ConsensusGroupHeartbeatSample sample) Cache the latest leader of a RegionGroup.voidcacheDataNodeHeartbeatSample(int nodeId, NodeHeartbeatSample sample) Cache the latest heartbeat sample of a DataNode.voidcacheRegionHeartbeatSample(TConsensusGroupId regionGroupId, int nodeId, RegionHeartbeatSample sample, boolean overwrite) Cache the latest heartbeat sample of a RegionGroup.booleancheckAndSetHeartbeatProcessing(int nodeId) Check if the specified Node is processing heartbeat.voidintcountRegionWithSpecifiedStatus(TConsensusGroupType type, RegionStatus... status) Count the number of cluster Regions with specified RegionStatus.voidcreateNodeHeartbeatCache(NodeType nodeType, int nodeId) Create a new NodeHeartbeatCache for the specified Node.voidcreateRegionCache(TConsensusGroupId regionGroupId, int dataNodeId) Create a new RegionCache for the specified Region in the specified RegionGroup.voidcreateRegionGroupHeartbeatCache(String database, TConsensusGroupId regionGroupId, Set<Integer> dataNodeIds) Create a new RegionGroupCache and a new ConsensusGroupCache for the specified RegionGroup.filterConfigNodeThroughStatus(NodeStatus... status) Filter ConfigNodes through the specified NodeStatus.filterDataNodeThroughStatus(NodeStatus... status) Filter DataNodes through the specified NodeStatus.filterRegionGroupThroughStatus(RegionGroupStatus... status) Filter the RegionGroups through the RegionGroupStatus.getConfirmedConfigNodeEndPoints(int dataNodeId) Get the ConsensusGroupStatistics of all RegionGroups.Get a map of cached RegionGroups of all Databases.Get the NodeStatistics of all DataNodes.Get the NodeStatistics of all Nodes.Get the RegionGroupStatistics of all RegionGroups.Get a map of cached RegionGroupsGet the RegionStatistics of all Regions.doublegetFreeDiskSpace(int dataNodeId) Get the free disk space of the specified DataNode.intGet the lowest loadScore DataNode.intgetLowestLoadDataNode(List<Integer> dataNodeIds) Get the lowest loadScore DataNode from the specified DataNodes.getNodeStatus(int nodeId) Safely get NodeStatus by NodeId.Get all Node's current status with reason.getNodeStatusWithReason(int nodeId) Safely get the specified Node's current status with reason.getRegionCacheLastSampleStatus(TConsensusGroupId regionGroupId, int nodeId) getRegionGroupStatus(List<TConsensusGroupId> consensusGroupIds) Safely get RegionGroupStatus.getRegionGroupStatus(TConsensusGroupId consensusGroupId) Safely get RegionGroupStatus.Safely get the latest RegionLeaderMap.getRegionLeaderMap(TConsensusGroupType consensusGroupType) Safely get the latest RegionLeaderMap.getRegionStatus(TConsensusGroupId consensusGroupId, int dataNodeId) Safely get RegionStatus.voidinitHeartbeatCache(IManager configManager) voidremoveNodeCache(int nodeId) Remove the NodeHeartbeatCache of the specified Node.voidremoveRegionCache(TConsensusGroupId regionGroupId, int dataNodeId) Remove the cache of the specified Region in the specified RegionGroup.voidremoveRegionGroupCache(TConsensusGroupId consensusGroupId) Remove the specified RegionGroup's cache.voidresetHeartbeatProcessing(int nodeId) voidupdateConfirmedConfigNodeEndPoints(int dataNodeId, Set<TEndPoint> configNodeEndPoints) voidUpdate the ConsensusGroupStatistics of all RegionGroups.voidupdateNodeStatistics(boolean forceUpdate) Update the NodeStatistics of all Nodes.voidUpdate the RegionGroupStatistics of all RegionGroups.voidupdateRegionSizeMap(int dataNodeId, Map<Integer, Long> regionSizeMap) voidwaitForLeaderElection(List<TConsensusGroupId> regionGroupIds) Wait for the specified RegionGroups to finish leader election.
-
Constructor Details
-
LoadCache
public LoadCache()
-
-
Method Details
-
initHeartbeatCache
-
clearHeartbeatCache
public void clearHeartbeatCache() -
checkAndSetHeartbeatProcessing
public boolean checkAndSetHeartbeatProcessing(int nodeId) Check if the specified Node is processing heartbeat. And set the processing flag to true.- Parameters:
nodeId- The specified NodeId.- Returns:
- False if the previous heartbeat is completed, true otherwise.
-
createNodeHeartbeatCache
Create a new NodeHeartbeatCache for the specified Node.- Parameters:
nodeType- The specified NodeTypenodeId- The specified NodeId
-
cacheConfigNodeHeartbeatSample
Cache the latest heartbeat sample of a ConfigNode.- Parameters:
nodeId- the id of the ConfigNodesample- the latest heartbeat sample
-
cacheDataNodeHeartbeatSample
Cache the latest heartbeat sample of a DataNode.- Parameters:
nodeId- the id of the DataNodesample- the latest heartbeat sample
-
cacheAINodeHeartbeatSample
Cache the latest heartbeat sample of a AINode.- Parameters:
nodeId- the id of the AINodesample- the latest heartbeat sample
-
resetHeartbeatProcessing
public void resetHeartbeatProcessing(int nodeId) -
removeNodeCache
public void removeNodeCache(int nodeId) Remove the NodeHeartbeatCache of the specified Node.- Parameters:
nodeId- the index of the specified Node
-
createRegionGroupHeartbeatCache
public void createRegionGroupHeartbeatCache(String database, TConsensusGroupId regionGroupId, Set<Integer> dataNodeIds) Create a new RegionGroupCache and a new ConsensusGroupCache for the specified RegionGroup.- Parameters:
database- the Database where the RegionGroup belongedregionGroupId- the index of the RegionGroupdataNodeIds- the index of the DataNodes where the Regions resided
-
createRegionCache
Create a new RegionCache for the specified Region in the specified RegionGroup.- Parameters:
regionGroupId- the index of the RegionGroupdataNodeId- the index of the DataNode where the Region resides
-
cacheRegionHeartbeatSample
public void cacheRegionHeartbeatSample(TConsensusGroupId regionGroupId, int nodeId, RegionHeartbeatSample sample, boolean overwrite) Cache the latest heartbeat sample of a RegionGroup.- Parameters:
regionGroupId- the id of the RegionGroupnodeId- the id of the DataNode where specified Region residessample- the latest heartbeat sample
-
getRegionCacheLastSampleStatus
-
removeRegionCache
Remove the cache of the specified Region in the specified RegionGroup.- Parameters:
regionGroupId- the specified RegionGroupdataNodeId- the specified DataNode
-
cacheConsensusSample
public void cacheConsensusSample(TConsensusGroupId regionGroupId, ConsensusGroupHeartbeatSample sample) Cache the latest leader of a RegionGroup.- Parameters:
regionGroupId- the id of the RegionGroupsample- the latest heartbeat sample
-
updateNodeStatistics
public void updateNodeStatistics(boolean forceUpdate) Update the NodeStatistics of all Nodes. -
updateRegionGroupStatistics
public void updateRegionGroupStatistics()Update the RegionGroupStatistics of all RegionGroups. -
updateConsensusGroupStatistics
public void updateConsensusGroupStatistics()Update the ConsensusGroupStatistics of all RegionGroups. -
getCurrentNodeStatisticsMap
Get the NodeStatistics of all Nodes.- Returns:
- a map of NodeStatistics
-
getCurrentDataNodeStatisticsMap
Get the NodeStatistics of all DataNodes.- Returns:
- a map of all DataNodes' NodeStatistics
-
getCurrentDatabaseRegionGroupMap
public Map<String,List<TConsensusGroupId>> getCurrentDatabaseRegionGroupMap(TConsensusGroupType type) Get a map of cached RegionGroups of all Databases.- Parameters:
type- SchemaRegion or DataRegion- Returns:
- Map<Database, List
>
-
getCurrentRegionLocationMap
Get a map of cached RegionGroups- Parameters:
type- SchemaRegion or DataRegion- Returns:
- Map<RegionGroupId, Set
>
-
getCurrentRegionGroupStatisticsMap
Get the RegionGroupStatistics of all RegionGroups.- Returns:
- a map of RegionGroupStatistics
-
getCurrentRegionStatisticsMap
public Map<TConsensusGroupId,Map<Integer, getCurrentRegionStatisticsMapRegionStatistics>> (TConsensusGroupType type) Get the RegionStatistics of all Regions.- Parameters:
type- DataRegion or SchemaRegion- Returns:
- a map of RegionStatistics
-
getCurrentConsensusGroupStatisticsMap
Get the ConsensusGroupStatistics of all RegionGroups.- Returns:
- a map of ConsensusGroupStatistics
-
getNodeStatus
Safely get NodeStatus by NodeId.- Parameters:
nodeId- The specified NodeId- Returns:
- NodeStatus of the specified Node. Unknown if cache doesn't exist.
-
getNodeStatusWithReason
Safely get the specified Node's current status with reason.- Parameters:
nodeId- The specified NodeId- Returns:
- The specified Node's current status if the nodeCache contains it, Unknown otherwise
-
getNodeStatusWithReason
Get all Node's current status with reason.- Returns:
- Map<NodeId, NodeStatus with reason>
-
filterConfigNodeThroughStatus
Filter ConfigNodes through the specified NodeStatus.- Parameters:
status- The specified NodeStatus- Returns:
- Filtered ConfigNodes with the specified NodeStatus
-
filterDataNodeThroughStatus
Filter DataNodes through the specified NodeStatus.- Parameters:
status- The specified NodeStatus- Returns:
- Filtered DataNodes with the specified NodeStatus
-
getFreeDiskSpace
public double getFreeDiskSpace(int dataNodeId) Get the free disk space of the specified DataNode.- Parameters:
dataNodeId- The index of the specified DataNode- Returns:
- The free disk space that sample through heartbeat, 0 if no heartbeat received
-
getLowestLoadDataNode
public int getLowestLoadDataNode()Get the lowest loadScore DataNode.- Returns:
- The index of the lowest loadScore DataNode. -1 if no DataNode heartbeat received.
-
getLowestLoadDataNode
Get the lowest loadScore DataNode from the specified DataNodes.- Parameters:
dataNodeIds- The specified DataNodes- Returns:
- The index of the lowest loadScore DataNode. -1 if no DataNode heartbeat received.
-
getRegionStatus
Safely get RegionStatus.- Parameters:
consensusGroupId- Specified RegionGroupIddataNodeId- Specified RegionReplicaId- Returns:
- Corresponding RegionStatus if cache exists, Unknown otherwise
-
getRegionGroupStatus
Safely get RegionGroupStatus.- Parameters:
consensusGroupId- Specified RegionGroupId- Returns:
- Corresponding RegionGroupStatus if cache exists, Disabled otherwise
-
getRegionGroupStatus
public Map<TConsensusGroupId,RegionGroupStatus> getRegionGroupStatus(List<TConsensusGroupId> consensusGroupIds) Safely get RegionGroupStatus.- Parameters:
consensusGroupIds- Specified RegionGroupIds- Returns:
- Corresponding RegionGroupStatus if cache exists, Disabled otherwise
-
filterRegionGroupThroughStatus
Filter the RegionGroups through the RegionGroupStatus.- Parameters:
status- The specified RegionGroupStatus- Returns:
- Filtered RegionGroups with the specified RegionGroupStatus
-
countRegionWithSpecifiedStatus
Count the number of cluster Regions with specified RegionStatus.- Parameters:
type- The specified RegionGroupTypestatus- The specified statues- Returns:
- The number of cluster Regions with specified RegionStatus
-
removeRegionGroupCache
Remove the specified RegionGroup's cache. -
getRegionLeaderMap
Safely get the latest RegionLeaderMap.- Returns:
- Map<RegionGroupId, leaderId>, leaderId will be -1 if the RegionGroup has no leader yet.
-
getRegionLeaderMap
Safely get the latest RegionLeaderMap.- Parameters:
consensusGroupType- DataRegion or SchemaRegion- Returns:
- Map<RegionGroupId, leaderId>, leaderId will be -1 if the RegionGroup has no leader yet.
-
waitForLeaderElection
Wait for the specified RegionGroups to finish leader election.- Parameters:
regionGroupIds- Specified RegionGroupIds
-
updateConfirmedConfigNodeEndPoints
-
getConfirmedConfigNodeEndPoints
-
updateRegionSizeMap
-
getRegionSizeMap
-