Class ClusterSchemaManager

java.lang.Object
org.apache.iotdb.confignode.manager.schema.ClusterSchemaManager

public class ClusterSchemaManager extends Object
The ClusterSchemaManager Manages cluster schemaengine read and write requests.
  • Constructor Details

  • Method Details

    • setDatabase

      public TSStatus setDatabase(DatabaseSchemaPlan databaseSchemaPlan, boolean isGeneratedByPipe)
      Set Database
    • alterDatabase

      public TSStatus alterDatabase(DatabaseSchemaPlan databaseSchemaPlan, boolean isGeneratedByPipe)
      Alter Database
    • deleteDatabase

      public TSStatus deleteDatabase(DeleteDatabasePlan deleteDatabasePlan, boolean isGeneratedByPipe)
      Delete DatabaseSchema.
    • countMatchedDatabases

      public CountDatabaseResp countMatchedDatabases(CountDatabasePlan countDatabasePlan)
      Count Databases by specified path pattern. Notice: including pre-deleted Database.

      Notice: Only invoke this interface in ConfigManager

      Returns:
      CountDatabaseResp
    • getMatchedDatabaseSchema

      public DatabaseSchemaResp getMatchedDatabaseSchema(GetDatabasePlan getDatabasePlan)
      Get DatabaseSchemas by specified path pattern. Notice: including pre-deleted Database

      Notice: Only invoke this interface in ConfigManager

      Returns:
      DatabaseSchemaResp
    • showDatabase

      public TShowDatabaseResp showDatabase(GetDatabasePlan getDatabasePlan)
      Only used in cluster tool show Databases.
    • getTTLInfoForUpgrading

      public Map<String,Long> getTTLInfoForUpgrading()
    • setSchemaReplicationFactor

      public TSStatus setSchemaReplicationFactor(SetSchemaReplicationFactorPlan setSchemaReplicationFactorPlan)
    • setDataReplicationFactor

      public TSStatus setDataReplicationFactor(SetDataReplicationFactorPlan setDataReplicationFactorPlan)
    • setTimePartitionInterval

      public TSStatus setTimePartitionInterval(SetTimePartitionIntervalPlan setTimePartitionIntervalPlan)
    • adjustMaxRegionGroupNum

      public void adjustMaxRegionGroupNum()
      Only leader use this interface. Adjust the maxSchemaRegionGroupNum and maxDataRegionGroupNum of each Database based on existing cluster resources
    • calcMaxRegionGroupNum

      public static int calcMaxRegionGroupNum(int minRegionGroupNum, double resourceWeight, int resource, int databaseNum, int replicationFactor, int allocatedRegionGroupCount)
    • isDatabaseExist

      public boolean isDatabaseExist(String database)
      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
    • getDatabaseNames

      public List<String> getDatabaseNames()
      Only leader use this interface. Get all Databases name
      Returns:
      List, all Databases' name
    • getDatabaseSchemaByName

      public TDatabaseSchema getDatabaseSchemaByName(String database) throws DatabaseNotExistsException
      Only leader use this interface. Get the specified Database's schemaengine
      Parameters:
      database - DatabaseName
      Returns:
      The specific DatabaseSchema
      Throws:
      DatabaseNotExistsException - When the specific Database doesn't exist
    • getDatabaseNameByDevice

      public String getDatabaseNameByDevice(String devicePath)
      Only leader use this interface.
      Returns:
      The DatabaseName of the specified Device. Empty String if not exists.
    • getMatchedDatabaseSchemasByName

      public Map<String,TDatabaseSchema> getMatchedDatabaseSchemasByName(List<String> rawPathList)
      Only leader use this interface. Get the specified Databases' schemaengine
      Parameters:
      rawPathList - List
      Returns:
      the matched DatabaseSchemas
    • getMatchedDatabaseSchemasByPrefix

      public Map<String,TDatabaseSchema> getMatchedDatabaseSchemasByPrefix(PartialPath prefix)
      Only leader use this interface. Get the specified Databases' schemaengine
      Parameters:
      prefix - prefix full path
      Returns:
      the matched DatabaseSchemas
    • getReplicationFactor

      public int getReplicationFactor(String database, TConsensusGroupType consensusGroupType) throws DatabaseNotExistsException
      Only leader use this interface. Get the replication factor of specified Database
      Parameters:
      database - DatabaseName
      consensusGroupType - SchemaRegion or DataRegion
      Returns:
      SchemaReplicationFactor or DataReplicationFactor
      Throws:
      DatabaseNotExistsException - When the specific Database doesn't exist
    • getMinRegionGroupNum

      public int getMinRegionGroupNum(String database, TConsensusGroupType consensusGroupType)
      Only leader use this interface. Get the maxRegionGroupNum of specified Database.
      Parameters:
      database - DatabaseName
      consensusGroupType - SchemaRegion or DataRegion
      Returns:
      minSchemaRegionGroupNum or minDataRegionGroupNum
    • getMaxRegionGroupNum

      public int getMaxRegionGroupNum(String database, TConsensusGroupType consensusGroupType)
      Only leader use this interface. Get the maxRegionGroupNum of specified Database.
      Parameters:
      database - DatabaseName
      consensusGroupType - SchemaRegion or DataRegion
      Returns:
      maxSchemaRegionGroupNum or maxDataRegionGroupNum
    • createTemplate

      public TSStatus createTemplate(CreateSchemaTemplatePlan createSchemaTemplatePlan)
      create schemaengine template
      Parameters:
      createSchemaTemplatePlan - CreateSchemaTemplatePlan
      Returns:
      TSStatus
    • getAllTemplates

      public TGetAllTemplatesResp getAllTemplates()
      show schemaengine template
      Returns:
      TGetAllTemplatesResp
    • getTemplate

      public TGetTemplateResp getTemplate(String req)
      show nodes in schemaengine template
    • getTemplate

      public Template getTemplate(int id) throws MetadataException
      Get template by id. Only leader uses this interface.
      Throws:
      MetadataException
    • getPathsSetTemplate

      public TGetPathsSetTemplatesResp getPathsSetTemplate(String templateName, PathPatternTree scope)
      show path set template xx
    • getAllTemplateSetInfo

      public byte[] getAllTemplateSetInfo()
      get all template set and pre-set info to sync to a registering dataNodes, the pre unset template info won't be taken
    • getTemplateSetInfo

      public TemplateSetInfoResp getTemplateSetInfo(List<PartialPath> patternList)
    • checkIsTemplateSetOnPath

      public org.apache.tsfile.utils.Pair<TSStatus,Template> checkIsTemplateSetOnPath(String templateName, String path)
    • preUnsetSchemaTemplate

      public TSStatus preUnsetSchemaTemplate(int templateId, PartialPath path)
    • rollbackPreUnsetSchemaTemplate

      public TSStatus rollbackPreUnsetSchemaTemplate(int templateId, PartialPath path)
    • unsetSchemaTemplateInBlackList

      public TSStatus unsetSchemaTemplateInBlackList(int templateId, PartialPath path, boolean isGeneratedByPipe)
    • dropSchemaTemplate

      public TSStatus dropSchemaTemplate(String templateName)
    • extendSchemaTemplate

      public TSStatus extendSchemaTemplate(TemplateExtendInfo templateExtendInfo, boolean isGeneratedByPipe)
    • getSchemaQuotaRemain

      public org.apache.tsfile.utils.Pair<Long,Long> getSchemaQuotaRemain()
      Only leader use this interface. Get the remain schema quota of specified schema region.
      Returns:
      pair of <series quota, device quota>, -1 means no limit
    • updateTimeSeriesUsage

      public void updateTimeSeriesUsage(Map<Integer,Long> seriesUsage)
    • updateDeviceUsage

      public void updateDeviceUsage(Map<Integer,Long> deviceUsage)
    • updateSchemaQuotaConfiguration

      public void updateSchemaQuotaConfiguration(long seriesThreshold, long deviceThreshold)
    • clearSchemaQuotaCache

      public void clearSchemaQuotaCache()