Class PartitionManager
java.lang.Object
org.apache.iotdb.confignode.manager.partition.PartitionManager
The
PartitionManager manages cluster PartitionTable read and write requests.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcountDataNodeScatterWidth(int dataNodeId, TConsensusGroupType type) Only leader use this interface.filterRegionGroupThroughStatus(String database, RegionGroupStatus... status) Filter the RegionGroups in the specified Database through the RegionGroupStatus.filterUnExistDatabases(List<PartialPath> databases) Filter the un-exist Databases.intOnly leader use this interface.generateTConsensusGroupIdByRegionId(int regionId) Only leader use this interface.getAllRegionGroupIds(String database, TConsensusGroupType type) Only leader use this interface.Only leader use this interface.getAllReplicaSets(int dataNodeId) Get all RegionGroups currently owned by the specified Database.getAllReplicaSets(String database) Only leader use this interface.getAllReplicaSets(String database, TConsensusGroupType type) Only leader use this interface.Only leader use this interface.Only leader use this interface.Only leader use this interface.intgetAssignedSeriesPartitionSlotsCount(String database) Only leader use this interface.longgetAssignedTimePartitionSlotsCount(String database) Only leader use this interface.getDatabaseRelatedDataNodes(String database, TConsensusGroupType type) Get the DataNodes who contain the specified Database's Schema or Data.Thread-safely get DataPartitionvoidgetLastDataAllotTable(String database) Get the last DataAllotTable of the specified Database.getNodePathsPartition(GetNodePathsPartitionPlan physicalPlan) GetNodePathsPartition.Get DataPartition and create a new one if it does not exist.Get SchemaPartition and create a new one if it does not exist.getPredecessorDataPartition(String database, TSeriesPartitionSlot seriesPartitionSlot, TTimePartitionSlot timePartitionSlot) Only leader use this interface.intgetRegionCount(int dataNodeId, TConsensusGroupType type) Only leader use this interface.getRegionDatabase(TConsensusGroupId regionId) Get database for region.intgetRegionGroupCount(String database, TConsensusGroupType type) Only leader use this interface.getRegionType(int regionId) Get theTConsensusGroupTypeof the given integer regionId.getReplicaSets(String database, List<TConsensusGroupId> regionGroupIds) Only leader use this interface.Thread-safely get SchemaPartition.voidgetSeriesPartitionSlot(String devicePath) Get TSeriesPartitionSlot.List<org.apache.tsfile.utils.Pair<Long,TConsensusGroupId>> getSortedRegionGroupSlotsCounter(String database, TConsensusGroupType type) Only leader use this interface.getSuccessorDataPartition(String database, TSeriesPartitionSlot seriesPartitionSlot, TTimePartitionSlot timePartitionSlot) Only leader use this interface.booleanisDatabaseExist(String database) Check if the specified Database exists.booleanisDatabasePreDeleted(String database) booleanisDataNodeContainsRegion(int dataNodeId, TConsensusGroupId regionId) booleanisRegionGroupExists(TConsensusGroupId regionGroupId) Check if the specified RegionGroup exists.voidCalled byregionMaintainer.voidpreDeleteDatabase(String database, PreDeleteDatabasePlan.PreDeleteType preDeleteType) voidvoid
-
Field Details
-
CONSENSUS_WRITE_ERROR
- See Also:
-
-
Constructor Details
-
PartitionManager
-
-
Method Details
-
getSchemaPartition
Thread-safely get SchemaPartition.- Parameters:
req- SchemaPartitionPlan with partitionSlotsMap- Returns:
- SchemaPartitionDataSet that contains only existing SchemaPartition
-
getDataPartition
Thread-safely get DataPartition- Parameters:
req- DataPartitionPlan with Map<StorageGroupName, Map<SeriesPartitionSlot, TTimeSlotList>>- Returns:
- DataPartitionDataSet that contains only existing DataPartition
-
getOrCreateSchemaPartition
Get SchemaPartition and create a new one if it does not exist.- Parameters:
req- SchemaPartitionPlan with partitionSlotsMap- Returns:
- SchemaPartitionResp with DataPartition and TSStatus. SUCCESS_STATUS if all process finish. NOT_ENOUGH_DATA_NODE if the DataNodes is not enough to create new Regions. STORAGE_GROUP_NOT_EXIST if some StorageGroup don't exist.
-
getOrCreateDataPartition
Get DataPartition and create a new one if it does not exist.- Parameters:
req- DataPartitionPlan with Map<StorageGroupName, Map <SeriesPartitionSlot, List<TimePartitionSlot>> >- Returns:
- DataPartitionResp with DataPartition and
TSStatus.TSStatusCode.SUCCESS_STATUSif all process finish.TSStatusCode.NO_ENOUGH_DATANODEif the DataNodes is not enough to create new Regions.TSStatusCode.DATABASE_NOT_EXISTif some database does not exist.
-
getSuccessorDataPartition
public TConsensusGroupId getSuccessorDataPartition(String database, TSeriesPartitionSlot seriesPartitionSlot, TTimePartitionSlot timePartitionSlot) Only leader use this interface. Checks whether the specified DataPartition has a successor and returns if it does.- Parameters:
database- DatabaseNameseriesPartitionSlot- Corresponding SeriesPartitionSlottimePartitionSlot- Corresponding TimePartitionSlot- Returns:
- The specific DataPartition's successor if exists, null otherwise
-
getPredecessorDataPartition
public TConsensusGroupId getPredecessorDataPartition(String database, TSeriesPartitionSlot seriesPartitionSlot, TTimePartitionSlot timePartitionSlot) Only leader use this interface. Checks whether the specified DataPartition has a predecessor and returns if it does.- Parameters:
database- DatabaseNameseriesPartitionSlot- Corresponding SeriesPartitionSlottimePartitionSlot- Corresponding TimePartitionSlot- Returns:
- The specific DataPartition's predecessor if exists, null otherwise
-
getDatabaseRelatedDataNodes
public Set<TDataNodeLocation> getDatabaseRelatedDataNodes(String database, TConsensusGroupType type) Get the DataNodes who contain the specified Database's Schema or Data.- Parameters:
database- The specific Database's nametype- SchemaRegion or DataRegion- Returns:
- Set <TDataNodeLocation>, the related DataNodes
-
getAllReplicaSetsMap
Only leader use this interface.- Parameters:
type- The specified TConsensusGroupType- Returns:
- Deep copy of all Regions' RegionReplicaSet and organized to Map
-
getAllReplicaSets
Only leader use this interface.- Returns:
- Deep copy of all Regions' RegionReplicaSet
-
getAllReplicaSets
Only leader use this interface.- Parameters:
type- The specified TConsensusGroupType- Returns:
- Deep copy of all Regions' RegionReplicaSet with the specified TConsensusGroupType
-
getAllReplicaSets
Only leader use this interface.- Parameters:
database- The specified Database- Returns:
- All Regions' RegionReplicaSet of the specified Database
-
getAllReplicaSets
Only leader use this interface.- Parameters:
database- The specified Databasetype- SchemaRegion or DataRegion- Returns:
- Deep copy of all Regions' RegionReplicaSet with the specified Database and TConsensusGroupType
-
getAllReplicaSets
Get all RegionGroups currently owned by the specified Database.- Parameters:
dataNodeId- The specified dataNodeId- Returns:
- Deep copy of all RegionGroups' RegionReplicaSet with the specified dataNodeId
-
getReplicaSets
public List<TRegionReplicaSet> getReplicaSets(String database, List<TConsensusGroupId> regionGroupIds) Only leader use this interface.- Parameters:
database- The specified DatabaseregionGroupIds- The specified RegionGroupIds- Returns:
- All Regions' RegionReplicaSet of the specified Database
-
isDataNodeContainsRegion
-
getRegionCount
Only leader use this interface.Get the number of Regions currently owned by the specified DataNode
- Parameters:
dataNodeId- The specified DataNodetype- SchemaRegion or DataRegion- Returns:
- The number of Regions currently owned by the specified DataNode
-
countDataNodeScatterWidth
Only leader use this interface.Count the scatter width of the specified DataNode
- Parameters:
dataNodeId- The specified DataNodetype- SchemaRegion or DataRegion- Returns:
- The schema/data scatter width of the specified DataNode. The scatter width refers to the number of other DataNodes in the cluster which have at least one identical schema/data replica as the specified DataNode.
-
getRegionGroupCount
public int getRegionGroupCount(String database, TConsensusGroupType type) throws DatabaseNotExistsException Only leader use this interface.Get the number of RegionGroups currently owned by the specified Database
- Parameters:
database- DatabaseNametype- SchemaRegion or DataRegion- Returns:
- Number of Regions currently owned by the specified Database
- Throws:
DatabaseNotExistsException- When the specified Database doesn't exist
-
getAllRegionGroupIdMap
Only leader use this interface.Get the all RegionGroups currently in the cluster
- Parameters:
type- SchemaRegion or DataRegion- Returns:
- Map<Database, List
>
-
getAllRegionGroupIds
public List<TConsensusGroupId> getAllRegionGroupIds(String database, TConsensusGroupType type) throws DatabaseNotExistsException Only leader use this interface.Get all the RegionGroups currently owned by the specified Database
- Parameters:
database- DatabaseNametype- SchemaRegion or DataRegion- Returns:
- List of TConsensusGroupId
- Throws:
DatabaseNotExistsException- When the specified Database doesn't exist
-
isDatabaseExist
Check if the specified Database exists.- Parameters:
database- The specified Database- Returns:
- True if the DatabaseSchema is exists and the Database is not pre-deleted
-
filterUnExistDatabases
Filter the un-exist Databases.- Parameters:
databases- the Databases to check- Returns:
- List of PartialPath the Databases that not exist
-
getAssignedSeriesPartitionSlotsCount
Only leader use this interface.Get the assigned SeriesPartitionSlots count in the specified Database
- Parameters:
database- The specified Database- Returns:
- The assigned SeriesPartitionSlots count
-
getAssignedTimePartitionSlotsCount
Only leader use this interface.Get the assigned TimePartitionSlots count in the specified Database
- Parameters:
database- The specified Database- Returns:
- The assigned TimePartitionSlots count
-
getSortedRegionGroupSlotsCounter
public List<org.apache.tsfile.utils.Pair<Long,TConsensusGroupId>> getSortedRegionGroupSlotsCounter(String database, TConsensusGroupType type) throws NoAvailableRegionGroupException Only leader use this interface.- Parameters:
database- DatabaseNametype- SchemaRegion or DataRegion- Returns:
- The specific StorageGroup's Regions that sorted by the number of allocated slots
- Throws:
NoAvailableRegionGroupException- When all RegionGroups within the specified StorageGroup are unavailable currently
-
getAllSchemaPartition
Only leader use this interface.- Returns:
- Integer set of all schemaengine region id
-
generateNextRegionGroupId
public int generateNextRegionGroupId()Only leader use this interface.- Returns:
- the next RegionGroupId
-
generateTConsensusGroupIdByRegionId
-
getNodePathsPartition
GetNodePathsPartition.- Parameters:
physicalPlan- GetNodesPathsPartitionReq- Returns:
- SchemaNodeManagementPartitionDataSet that contains only existing matched SchemaPartition and matched child paths aboveMTree
-
preDeleteDatabase
-
isDatabasePreDeleted
-
getSeriesPartitionSlot
Get TSeriesPartitionSlot.- Parameters:
devicePath- Full path ending with device name- Returns:
- SeriesPartitionSlot
-
getRegionInfoList
-
isRegionGroupExists
Check if the specified RegionGroup exists.- Parameters:
regionGroupId- The specified RegionGroup
-
addRegionLocation
-
removeRegionLocation
-
getRegionId
-
getTimeSlotList
-
countTimeSlotList
-
getSeriesSlotList
-
getRegionDatabase
Get database for region.- Parameters:
regionId- regionId- Returns:
- database name
-
maintainRegionReplicas
public void maintainRegionReplicas()Called byregionMaintainer.Periodically maintain the RegionReplicas to be created or deleted
-
startRegionCleaner
public void startRegionCleaner() -
stopRegionCleaner
public void stopRegionCleaner() -
filterRegionGroupThroughStatus
public List<TRegionReplicaSet> filterRegionGroupThroughStatus(String database, RegionGroupStatus... status) Filter the RegionGroups in the specified Database through the RegionGroupStatus.- Parameters:
database- The specified Databasestatus- The specified RegionGroupStatus- Returns:
- Filtered RegionGroups with the specified RegionGroupStatus
-
getSchemaRegionIds
-
getDataRegionIds
-
getRegionType
Get theTConsensusGroupTypeof the given integer regionId.- Parameters:
regionId- The specified integer regionId- Returns:
Optional.of(Object tConsensusGroupType)of the given integer regionId, orOptional.empty()if the integer regionId does not match any of the regionGroups.
-
getLastDataAllotTable
Get the last DataAllotTable of the specified Database.- Parameters:
database- The specified Database- Returns:
- The last DataAllotTable
-
getRegionMaintainer
-