public int getMaxRegionGroupNum(
      final String database, final TConsensusGroupType consensusGroupType) {
    databaseReadWriteLock.readLock().lock();
    try {
      final TDatabaseSchema storageGroupSchema =
          (PathUtils.isTableModelDatabase(database) ? tableModelMTree : treeModelMTree)
              .getDatabaseNodeByDatabasePath(getQualifiedDatabasePartialPath(database))
              .getAsMNode()
              .getDatabaseSchema();
      switch (consensusGroupType) {
        case SchemaRegion:
          return storageGroupSchema.getMaxSchemaRegionGroupNum();
        case DataRegion:
        default:
          return storageGroupSchema.getMaxDataRegionGroupNum();
      }
    } catch (final MetadataException e) {
      LOGGER.warn(ERROR_NAME, e);
      return -1;
    } finally {
      databaseReadWriteLock.readLock().unlock();
    }
  }
Only leader use this interface. Get the maxRegionGroupNum of specified Database.

@param database DatabaseName
@param consensusGroupType SchemaRegion or DataRegion
@return maxSchemaRegionGroupNum or maxDataRegionGroupNum
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java