Class PartitionInfo
java.lang.Object
org.apache.iotdb.confignode.persistence.partition.PartitionInfo
- All Implemented Interfaces:
SnapshotProcessor
The
PartitionInfo stores cluster PartitionTable.
The PartitionTable includes:
1. regionMap: location of Region member
2. schemaPartition: location of schemaEngine
3. dataPartition: location of data
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe region has expanded to a new DataNode, now update the databasePartitionTable.Remove PartitionTable where the TimeSlot is expired.voidclear()intcountDataNodeScatterWidth(int dataNodeId, TConsensusGroupType type, int clusterNodeCount) Only leader use this interface.Thread-safely create new DatabasePartitionTable.Create DataPartition.Thread-safely cache allocation result of new RegionGroups.Create SchemaPartition.voidThread-safely delete database.booleanfilterUnassignedDataPartitionSlots(Map<String, Map<TSeriesPartitionSlot, TTimeSlotList>> partitionSlotsMap) Only Leader use this interface.filterUnassignedSchemaPartitionSlots(Map<String, List<TSeriesPartitionSlot>> partitionSlotsMap) Only Leader use this interface.intOnly 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.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 specific database's Schema or Data.Thread-safely get DataPartition.voidgetLastDataAllotTable(String database) Get the last DataAllotTable of the specified Database.getPredecessorDataPartition(String database, TSeriesPartitionSlot seriesPartitionSlot, TTimePartitionSlot timePartitionSlot) Checks whether the specified DataPartition has a predecessor and returns if it does.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.List<org.apache.tsfile.utils.Pair<Long,TConsensusGroupId>> getRegionGroupSlotsCounter(String database, TConsensusGroupType type) Only leader use this interface.getRegionId(GetRegionIdPlan plan) Get the RegionId of the specific Database or seriesSlotId(device).getRegionInfoList(GetRegionInfoListPlan regionsInfoPlan) Get Region information.Get a deep copy of RegionCleanList for RegionCleaner to maintain cluster RegionReplicas.getRegionType(int regionId) getReplicaSets(String database, List<TConsensusGroupId> regionGroupIds) Only leader use this interface.getSchemaNodeManagementPartition(List<String> matchedDatabases) Get SchemaNodeManagementPartition through matched Database.Thread-safely get SchemaPartition.voidgetSuccessorDataPartition(String database, TSeriesPartitionSlot seriesPartitionSlot, TTimePartitionSlot timePartitionSlot) Checks whether the specified DataPartition has a successor and returns if it does.Get the timePartition of the specific Database or seriesSlotId(device) or regionId.inthashCode()booleanisDatabaseExisted(String database) Check if the specified Database exists.booleanisDatabasePreDeleted(String database) booleanisRegionGroupExisted(TConsensusGroupId regionGroupId) Check if the specified RegionGroup exists.offerRegionMaintainTasks(OfferRegionMaintainTasksPlan offerRegionMaintainTasksPlan) Offer a batch of RegionMaintainTasks for the RegionMaintainer.Poll the head of RegionMaintainTasks from the regionMaintainTaskList after it's executed successfully.Poll the head of RegionMaintainTasks of target regions from regionMaintainTaskList after they are executed successfully.preDeleteDatabase(PreDeleteDatabasePlan preDeleteDatabasePlan) Thread-safely pre-delete the specific database.voidprocessLoadSnapshot(File snapshotDir) booleanprocessTakeSnapshot(File snapshotDir) The region is no longer located on a DataNode, now update the databasePartitionTable.updateDataNode(UpdateDataNodePlan updateDataNodePlan) Thread-safely update DataNodeLocation in RegionGroup.
-
Constructor Details
-
PartitionInfo
public PartitionInfo()
-
-
Method Details
-
generateNextRegionGroupId
public int generateNextRegionGroupId() -
updateDataNode
Thread-safely update DataNodeLocation in RegionGroup.- Parameters:
updateDataNodePlan- UpdateDataNodePlan- Returns:
TSStatusCode.SUCCESS_STATUSif the DataNodeLocations are updated successfully.
-
createDatabase
Thread-safely create new DatabasePartitionTable.- Parameters:
plan- DatabaseSchemaPlan- Returns:
TSStatusCode.SUCCESS_STATUSif the new DatabasePartitionTable is created successfully.
-
createRegionGroups
Thread-safely cache allocation result of new RegionGroups.- Parameters:
plan- CreateRegionGroupsPlan- Returns:
TSStatusCode.SUCCESS_STATUS
-
offerRegionMaintainTasks
Offer a batch of RegionMaintainTasks for the RegionMaintainer.- Returns:
TSStatusCode.SUCCESS_STATUS
-
pollRegionMaintainTask
Poll the head of RegionMaintainTasks from the regionMaintainTaskList after it's executed successfully.- Returns:
TSStatusCode.SUCCESS_STATUS
-
pollSpecificRegionMaintainTask
Poll the head of RegionMaintainTasks of target regions from regionMaintainTaskList after they are executed successfully. Tasks of each region group are treated as single independent queue.- Parameters:
plan- provides target region ids- Returns:
TSStatusCode.SUCCESS_STATUS
-
getRegionMaintainEntryList
Get a deep copy of RegionCleanList for RegionCleaner to maintain cluster RegionReplicas.- Returns:
- A deep copy of RegionCleanList
-
preDeleteDatabase
Thread-safely pre-delete the specific database.- Parameters:
preDeleteDatabasePlan- PreDeleteStorageGroupPlan- Returns:
TSStatusCode.SUCCESS_STATUS
-
isDatabasePreDeleted
-
deleteDatabase
Thread-safely delete database.- Parameters:
plan- DeleteDatabasePlan
-
getSchemaPartition
Thread-safely get SchemaPartition.- Parameters:
plan- SchemaPartitionPlan with partitionSlotsMap- Returns:
- SchemaPartitionDataSet that contains only existing SchemaPartition
-
getDataPartition
Thread-safely get DataPartition.- Parameters:
plan- DataPartitionPlan with partitionSlotsMap- Returns:
- DataPartitionDataSet that contains only existing DataPartition
-
getSuccessorDataPartition
public TConsensusGroupId getSuccessorDataPartition(String database, TSeriesPartitionSlot seriesPartitionSlot, TTimePartitionSlot timePartitionSlot) 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) 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
-
isDatabaseExisted
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
-
createSchemaPartition
Create SchemaPartition.- Parameters:
plan- CreateSchemaPartitionPlan with SchemaPartition assigned result- Returns:
TSStatusCode.SUCCESS_STATUS
-
createDataPartition
Create DataPartition.- Parameters:
plan- CreateDataPartitionPlan with DataPartition assigned result- Returns:
TSStatusCode.SUCCESS_STATUS
-
autoCleanPartitionTable
Remove PartitionTable where the TimeSlot is expired.- Parameters:
plan- Including TTL and current TimeSlot
-
getSchemaNodeManagementPartition
Get SchemaNodeManagementPartition through matched Database. -
getRegionInfoList
Get Region information. -
isRegionGroupExisted
Check if the specified RegionGroup exists.- Parameters:
regionGroupId- The specified RegionGroup
-
updateRegionLocation
-
addRegionLocation
The region has expanded to a new DataNode, now update the databasePartitionTable. -
removeRegionLocation
The region is no longer located on a DataNode, now update the databasePartitionTable. -
getRegionDatabase
Get database for region.- Parameters:
regionId- regionId- Returns:
- database name
-
filterUnassignedSchemaPartitionSlots
public Map<String,List<TSeriesPartitionSlot>> filterUnassignedSchemaPartitionSlots(Map<String, List<TSeriesPartitionSlot>> partitionSlotsMap) Only Leader use this interface. Filter unassigned SchemaPartitionSlots.- Parameters:
partitionSlotsMap- Map<database, List> - Returns:
- Map<database, List
>, SchemaPartitionSlots that is not assigned in partitionSlotsMap
-
filterUnassignedDataPartitionSlots
public Map<String,Map<TSeriesPartitionSlot, filterUnassignedDataPartitionSlotsTTimeSlotList>> (Map<String, Map<TSeriesPartitionSlot, TTimeSlotList>> partitionSlotsMap) Only Leader use this interface. Filter unassigned SchemaPartitionSlots- Parameters:
partitionSlotsMap- Map<database, Map<TSeriesPartitionSlot, TTimeSlotList>>- Returns:
- Map<database, Map<TSeriesPartitionSlot, TTimeSlotList>>, DataPartitionSlots that is not assigned in partitionSlotsMap
-
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
-
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
public int countDataNodeScatterWidth(int dataNodeId, TConsensusGroupType type, int clusterNodeCount) Only leader use this interface.Count the scatter width of the specified DataNode
- Parameters:
dataNodeId- The specified DataNodetype- SchemaRegion or DataRegionclusterNodeCount- The number of registeredNodes- 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 specific database
- Throws:
DatabaseNotExistsException- When the specific 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
-
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
-
getDatabaseRelatedDataNodes
public Set<TDataNodeLocation> getDatabaseRelatedDataNodes(String database, TConsensusGroupType type) Get the DataNodes who contain the specific database's Schema or Data.- Parameters:
database- The specific database's nametype- SchemaRegion or DataRegion- Returns:
- Set <TDataNodeLocation>, the related DataNodes
-
getRegionGroupSlotsCounter
public List<org.apache.tsfile.utils.Pair<Long,TConsensusGroupId>> getRegionGroupSlotsCounter(String database, TConsensusGroupType type) Only leader use this interface.- Parameters:
database- DatabaseNametype- SchemaRegion or DataRegion- Returns:
- The database's Running or Available Regions that sorted by the number of allocated slots
-
getAllSchemaPartition
Only leader use this interface.- Returns:
- Integer set of all schemaEngine region id
-
getLastDataAllotTable
Get the last DataAllotTable of the specified Database.- Parameters:
database- The specified Database- Returns:
- The last DataAllotTable
-
processTakeSnapshot
public boolean processTakeSnapshot(File snapshotDir) throws org.apache.thrift.TException, IOException - Specified by:
processTakeSnapshotin interfaceSnapshotProcessor- Throws:
org.apache.thrift.TExceptionIOException
-
processLoadSnapshot
- Specified by:
processLoadSnapshotin interfaceSnapshotProcessor- Throws:
org.apache.thrift.TExceptionIOException
-
getRegionId
Get the RegionId of the specific Database or seriesSlotId(device).- Parameters:
plan- GetRegionIdPlan with the specific Database ,seriesSlotId(device) , timeSlotId.- Returns:
- GetRegionIdResp with
TSStatusand List<TConsensusGroupId >.
-
getTimeSlotList
Get the timePartition of the specific Database or seriesSlotId(device) or regionId.- Parameters:
plan- GetRegionIdPlan with the specific Database ,seriesSlotId(device) , regionId.- Returns:
- GetRegionIdResp with STATUS and List<TTimePartitionSlot>.
-
countTimeSlotList
-
getSeriesSlotList
-
getSchemaRegionIds
-
getDataRegionIds
-
getRegionType
-
clear
public void clear() -
equals
-
hashCode
public int hashCode()
-