This is an automated email from the ASF dual-hosted git repository. yongzao pushed a commit to branch Support-cluster-Database-heterogeneous-by-ALTER-SQL in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 1a142ba756eebca8661cbf5d819bc175b9e923ed Author: YongzaoDan <[email protected]> AuthorDate: Thu Feb 2 23:13:58 2023 +0800 Finish ConfigNode part --- .../consensus/request/ConfigPhysicalPlan.java | 9 +- .../consensus/request/ConfigPhysicalPlanType.java | 5 +- ...orageGroupPlan.java => DatabaseSchemaPlan.java} | 12 +-- .../confignode/manager/ClusterSchemaManager.java | 78 +++++++++++++--- .../iotdb/confignode/manager/ConfigManager.java | 16 +++- .../apache/iotdb/confignode/manager/IManager.java | 15 +++- .../persistence/executor/ConfigPlanExecutor.java | 43 ++++----- .../persistence/partition/PartitionInfo.java | 4 +- .../persistence/schema/ClusterSchemaInfo.java | 70 +++++++++++++-- .../thrift/ConfigNodeRPCServiceProcessor.java | 100 +++++++++++++++------ .../request/ConfigPhysicalPlanSerDeTest.java | 33 +++++-- .../persistence/ClusterSchemaInfoTest.java | 21 +++-- .../confignode/persistence/PartitionInfoTest.java | 12 ++- .../src/main/thrift/confignode.thrift | 18 ++-- 14 files changed, 322 insertions(+), 114 deletions(-) diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlan.java b/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlan.java index c09b2f7ade..ae7642709e 100644 --- a/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlan.java +++ b/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlan.java @@ -65,11 +65,11 @@ import org.apache.iotdb.confignode.consensus.request.write.region.CreateRegionGr import org.apache.iotdb.confignode.consensus.request.write.region.OfferRegionMaintainTasksPlan; import org.apache.iotdb.confignode.consensus.request.write.region.PollRegionMaintainTaskPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.AdjustMaxRegionGroupNumPlan; +import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DatabaseSchemaPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DeleteStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.PreDeleteStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetDataReplicationFactorPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetSchemaReplicationFactorPlan; -import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTTLPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTimePartitionIntervalPlan; import org.apache.iotdb.confignode.consensus.request.write.sync.CreatePipeSinkPlan; @@ -163,8 +163,11 @@ public abstract class ConfigPhysicalPlan implements IConsensusRequest { case GetDataNodeConfiguration: plan = new GetDataNodeConfigurationPlan(); break; - case SetStorageGroup: - plan = new SetStorageGroupPlan(); + case CreateDatabase: + plan = new DatabaseSchemaPlan(ConfigPhysicalPlanType.CreateDatabase); + break; + case AlterDatabase: + plan = new DatabaseSchemaPlan(ConfigPhysicalPlanType.AlterDatabase); break; case SetTTL: plan = new SetTTLPlan(); diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanType.java b/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanType.java index 3884beb5c4..5f94a50c32 100644 --- a/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanType.java +++ b/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanType.java @@ -33,8 +33,8 @@ public enum ConfigPhysicalPlanType { RemoveDataNode((short) 102), UpdateDataNodeConfiguration((short) 103), - /** StorageGroup */ - SetStorageGroup((short) 200), + /** Database */ + CreateDatabase((short) 200), SetTTL((short) 201), SetSchemaReplicationFactor((short) 202), SetDataReplicationFactor((short) 203), @@ -44,6 +44,7 @@ public enum ConfigPhysicalPlanType { PreDeleteStorageGroup((short) 207), GetStorageGroup((short) 208), CountStorageGroup((short) 209), + AlterDatabase((short) 210), /** Region */ CreateRegionGroups((short) 300), diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/storagegroup/SetStorageGroupPlan.java b/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/storagegroup/DatabaseSchemaPlan.java similarity index 87% rename from confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/storagegroup/SetStorageGroupPlan.java rename to confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/storagegroup/DatabaseSchemaPlan.java index 608ce06688..af1b8cac26 100644 --- a/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/storagegroup/SetStorageGroupPlan.java +++ b/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/storagegroup/DatabaseSchemaPlan.java @@ -28,17 +28,17 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.util.Objects; -public class SetStorageGroupPlan extends ConfigPhysicalPlan { +public class DatabaseSchemaPlan extends ConfigPhysicalPlan { private TStorageGroupSchema schema; - public SetStorageGroupPlan() { - super(ConfigPhysicalPlanType.SetStorageGroup); + public DatabaseSchemaPlan(ConfigPhysicalPlanType planType) { + super(planType); this.schema = new TStorageGroupSchema(); } - public SetStorageGroupPlan(TStorageGroupSchema schema) { - this(); + public DatabaseSchemaPlan(ConfigPhysicalPlanType planType, TStorageGroupSchema schema) { + this(planType); this.schema = schema; } @@ -61,7 +61,7 @@ public class SetStorageGroupPlan extends ConfigPhysicalPlan { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - SetStorageGroupPlan that = (SetStorageGroupPlan) o; + DatabaseSchemaPlan that = (DatabaseSchemaPlan) o; return schema.equals(that.schema); } diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterSchemaManager.java b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterSchemaManager.java index bd9217acb4..209afa3c9c 100644 --- a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterSchemaManager.java +++ b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterSchemaManager.java @@ -42,10 +42,10 @@ import org.apache.iotdb.confignode.consensus.request.read.template.GetPathsSetTe import org.apache.iotdb.confignode.consensus.request.read.template.GetSchemaTemplatePlan; import org.apache.iotdb.confignode.consensus.request.read.template.GetTemplateSetInfoPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.AdjustMaxRegionGroupNumPlan; +import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DatabaseSchemaPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DeleteStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetDataReplicationFactorPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetSchemaReplicationFactorPlan; -import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTTLPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTimePartitionIntervalPlan; import org.apache.iotdb.confignode.consensus.request.write.template.CreateSchemaTemplatePlan; @@ -115,25 +115,19 @@ public class ClusterSchemaManager { // Consensus read/write interfaces // ====================================================== - /** - * Set StorageGroup - * - * @return SUCCESS_STATUS if the StorageGroup is set successfully. STORAGE_GROUP_ALREADY_EXISTS if - * the StorageGroup is already set. PERSISTENCE_FAILURE if fail to set StorageGroup in - * MTreeAboveSG. - */ - public TSStatus setStorageGroup(SetStorageGroupPlan setStorageGroupPlan) { + /** Set Database */ + public TSStatus setDatabase(DatabaseSchemaPlan databaseSchemaPlan) { TSStatus result; - if (setStorageGroupPlan.getSchema().getName().length() > MAX_DATABASE_NAME_LENGTH) { + if (databaseSchemaPlan.getSchema().getName().length() > MAX_DATABASE_NAME_LENGTH) { IllegalPathException illegalPathException = new IllegalPathException( - setStorageGroupPlan.getSchema().getName(), + databaseSchemaPlan.getSchema().getName(), "the length of database name shall not exceed " + MAX_DATABASE_NAME_LENGTH); return RpcUtils.getStatus( illegalPathException.getErrorCode(), illegalPathException.getMessage()); } try { - clusterSchemaInfo.checkContainsStorageGroup(setStorageGroupPlan.getSchema().getName()); + clusterSchemaInfo.checkContainsStorageGroup(databaseSchemaPlan.getSchema().getName()); } catch (MetadataException metadataException) { // Reject if StorageGroup already set if (metadataException instanceof IllegalPathException) { @@ -146,7 +140,7 @@ public class ClusterSchemaManager { } // Cache StorageGroupSchema - result = getConsensusManager().write(setStorageGroupPlan).getStatus(); + result = getConsensusManager().write(databaseSchemaPlan).getStatus(); // Adjust the maximum RegionGroup number of each StorageGroup adjustMaxRegionGroupNum(); @@ -154,6 +148,64 @@ public class ClusterSchemaManager { return result; } + /** Alter Database */ + public TSStatus alterDatabase(DatabaseSchemaPlan databaseSchemaPlan) { + TSStatus result; + boolean isDatabaseExisted; + TStorageGroupSchema storageGroupSchema = databaseSchemaPlan.getSchema(); + + try { + isDatabaseExisted = clusterSchemaInfo.isDatabaseExisted(storageGroupSchema.getName()); + } catch (IllegalPathException e) { + // Reject if DatabaseName is illegal + result = new TSStatus(TSStatusCode.ILLEGAL_PATH.getStatusCode()); + result.setMessage("Failed to alter database. " + e.getMessage()); + return result; + } + + if (!isDatabaseExisted) { + // Reject if Database doesn't exist + result = new TSStatus(TSStatusCode.DATABASE_NOT_EXIST.getStatusCode()); + result.setMessage( + "Failed to alter database. The Database " + + storageGroupSchema.getName() + + " doesn't exist."); + return result; + } + + if (storageGroupSchema.isSetMinSchemaRegionGroupNum()) { + // Validate alter SchemaRegionGroupNum + int minSchemaRegionGroupNum = + getMinRegionGroupNum(storageGroupSchema.getName(), TConsensusGroupType.SchemaRegion); + if (storageGroupSchema.getMinSchemaRegionGroupNum() <= minSchemaRegionGroupNum) { + result = new TSStatus(TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode()); + result.setMessage( + String.format( + "Failed to alter database. The SchemaRegionGroupNum could only be increased. " + + "Current SchemaRegionGroupNum: %d, Alter SchemaRegionGroupNum: %d", + minSchemaRegionGroupNum, storageGroupSchema.getMinSchemaRegionGroupNum())); + return result; + } + } + if (storageGroupSchema.isSetMinDataRegionGroupNum()) { + // Validate alter DataRegionGroupNum + int minDataRegionGroupNum = + getMinRegionGroupNum(storageGroupSchema.getName(), TConsensusGroupType.DataRegion); + if (storageGroupSchema.getMinDataRegionGroupNum() <= minDataRegionGroupNum) { + result = new TSStatus(TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode()); + result.setMessage( + String.format( + "Failed to alter database. The DataRegionGroupNum could only be increased. " + + "Current DataRegionGroupNum: %d, Alter DataRegionGroupNum: %d", + minDataRegionGroupNum, storageGroupSchema.getMinDataRegionGroupNum())); + return result; + } + } + + // Alter DatabaseSchema + return getConsensusManager().write(databaseSchemaPlan).getStatus(); + } + /** Delete StorageGroup synchronized to protect the safety of adjustMaxRegionGroupNum */ public synchronized TSStatus deleteStorageGroup(DeleteStorageGroupPlan deleteStorageGroupPlan) { TSStatus result = getConsensusManager().write(deleteStorageGroupPlan).getStatus(); diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java index 36371078e8..abd47082e5 100644 --- a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java +++ b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java @@ -59,9 +59,9 @@ import org.apache.iotdb.confignode.consensus.request.write.confignode.RemoveConf import org.apache.iotdb.confignode.consensus.request.write.datanode.RegisterDataNodePlan; import org.apache.iotdb.confignode.consensus.request.write.datanode.RemoveDataNodePlan; import org.apache.iotdb.confignode.consensus.request.write.datanode.UpdateDataNodePlan; +import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DatabaseSchemaPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetDataReplicationFactorPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetSchemaReplicationFactorPlan; -import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTTLPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTimePartitionIntervalPlan; import org.apache.iotdb.confignode.consensus.request.write.sync.CreatePipeSinkPlan; @@ -510,10 +510,20 @@ public class ConfigManager implements IManager { } @Override - public synchronized TSStatus setStorageGroup(SetStorageGroupPlan setStorageGroupPlan) { + public synchronized TSStatus setDatabase(DatabaseSchemaPlan databaseSchemaPlan) { TSStatus status = confirmLeader(); if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - return clusterSchemaManager.setStorageGroup(setStorageGroupPlan); + return clusterSchemaManager.setDatabase(databaseSchemaPlan); + } else { + return status; + } + } + + @Override + public TSStatus alterDatabase(DatabaseSchemaPlan databaseSchemaPlan) { + TSStatus status = confirmLeader(); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + return clusterSchemaManager.alterDatabase(databaseSchemaPlan); } else { return status; } diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java b/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java index 913e7bb105..2004847152 100644 --- a/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java +++ b/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java @@ -36,9 +36,9 @@ import org.apache.iotdb.confignode.consensus.request.read.storagegroup.GetStorag import org.apache.iotdb.confignode.consensus.request.write.confignode.RemoveConfigNodePlan; import org.apache.iotdb.confignode.consensus.request.write.datanode.RemoveDataNodePlan; import org.apache.iotdb.confignode.consensus.request.write.datanode.UpdateDataNodePlan; +import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DatabaseSchemaPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetDataReplicationFactorPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetSchemaReplicationFactorPlan; -import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTTLPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTimePartitionIntervalPlan; import org.apache.iotdb.confignode.consensus.request.write.sync.CreatePipeSinkPlan; @@ -274,11 +274,18 @@ public interface IManager { DataSet getMatchedStorageGroupSchemas(GetStorageGroupPlan getOrCountStorageGroupPlan); /** - * Set StorageGroup + * Set Database * - * @return status + * @return TSStatus + */ + TSStatus setDatabase(DatabaseSchemaPlan databaseSchemaPlan); + + /** + * Alter Database + * + * @return TSStatus */ - TSStatus setStorageGroup(SetStorageGroupPlan setStorageGroupPlan); + TSStatus alterDatabase(DatabaseSchemaPlan databaseSchemaPlan); /** * Delete StorageGroups diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java index 2919db18c7..7fa337f47b 100644 --- a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java +++ b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java @@ -63,11 +63,11 @@ import org.apache.iotdb.confignode.consensus.request.write.procedure.UpdateProce import org.apache.iotdb.confignode.consensus.request.write.region.CreateRegionGroupsPlan; import org.apache.iotdb.confignode.consensus.request.write.region.OfferRegionMaintainTasksPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.AdjustMaxRegionGroupNumPlan; +import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DatabaseSchemaPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DeleteStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.PreDeleteStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetDataReplicationFactorPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetSchemaReplicationFactorPlan; -import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTTLPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTimePartitionIntervalPlan; import org.apache.iotdb.confignode.consensus.request.write.sync.CreatePipeSinkPlan; @@ -263,12 +263,14 @@ public class ConfigPlanExecutor { return nodeInfo.removeDataNode((RemoveDataNodePlan) physicalPlan); case UpdateDataNodeConfiguration: return nodeInfo.updateDataNode((UpdateDataNodePlan) physicalPlan); - case SetStorageGroup: - TSStatus status = clusterSchemaInfo.setStorageGroup((SetStorageGroupPlan) physicalPlan); + case CreateDatabase: + TSStatus status = clusterSchemaInfo.createDatabase((DatabaseSchemaPlan) physicalPlan); if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { return status; } - return partitionInfo.setStorageGroup((SetStorageGroupPlan) physicalPlan); + return partitionInfo.createDatabase((DatabaseSchemaPlan) physicalPlan); + case AlterDatabase: + return clusterSchemaInfo.alterDatabase((DatabaseSchemaPlan) physicalPlan); case AdjustMaxRegionGroupNum: return clusterSchemaInfo.adjustMaxRegionGroupCount( (AdjustMaxRegionGroupNumPlan) physicalPlan); @@ -397,23 +399,22 @@ public class ConfigPlanExecutor { } AtomicBoolean result = new AtomicBoolean(true); - snapshotProcessorList.stream() - .forEach( - x -> { - boolean takeSnapshotResult = true; - try { - takeSnapshotResult = x.processTakeSnapshot(snapshotDir); - } catch (TException | IOException e) { - LOGGER.error("Take snapshot error: {}", e.getMessage()); - takeSnapshotResult = false; - } finally { - // If any snapshot fails, the whole fails - // So this is just going to be false - if (!takeSnapshotResult) { - result.set(false); - } - } - }); + snapshotProcessorList.forEach( + x -> { + boolean takeSnapshotResult = true; + try { + takeSnapshotResult = x.processTakeSnapshot(snapshotDir); + } catch (TException | IOException e) { + LOGGER.error("Take snapshot error: {}", e.getMessage()); + takeSnapshotResult = false; + } finally { + // If any snapshot fails, the whole fails + // So this is just going to be false + if (!takeSnapshotResult) { + result.set(false); + } + } + }); if (result.get()) { LOGGER.info("Task snapshot success, snapshotDir: {}", snapshotDir); } diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java index b8f5a51099..2043b6c087 100644 --- a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java +++ b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java @@ -43,9 +43,9 @@ import org.apache.iotdb.confignode.consensus.request.write.partition.CreateSchem import org.apache.iotdb.confignode.consensus.request.write.partition.UpdateRegionLocationPlan; import org.apache.iotdb.confignode.consensus.request.write.region.CreateRegionGroupsPlan; import org.apache.iotdb.confignode.consensus.request.write.region.OfferRegionMaintainTasksPlan; +import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DatabaseSchemaPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DeleteStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.PreDeleteStorageGroupPlan; -import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetStorageGroupPlan; import org.apache.iotdb.confignode.consensus.response.DataPartitionResp; import org.apache.iotdb.confignode.consensus.response.GetRegionIdResp; import org.apache.iotdb.confignode.consensus.response.GetSeriesSlotListResp; @@ -134,7 +134,7 @@ public class PartitionInfo implements SnapshotProcessor { * @param plan SetStorageGroupPlan * @return SUCCESS_STATUS if the new StorageGroupPartitionInfo is created successfully. */ - public TSStatus setStorageGroup(SetStorageGroupPlan plan) { + public TSStatus createDatabase(DatabaseSchemaPlan plan) { String storageGroupName = plan.getSchema().getName(); StorageGroupPartitionTable storageGroupPartitionTable = new StorageGroupPartitionTable(storageGroupName); diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java index e697d9a15c..e3b5037a8f 100644 --- a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java +++ b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java @@ -34,10 +34,10 @@ import org.apache.iotdb.confignode.consensus.request.read.template.GetPathsSetTe import org.apache.iotdb.confignode.consensus.request.read.template.GetSchemaTemplatePlan; import org.apache.iotdb.confignode.consensus.request.read.template.GetTemplateSetInfoPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.AdjustMaxRegionGroupNumPlan; +import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DatabaseSchemaPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DeleteStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetDataReplicationFactorPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetSchemaReplicationFactorPlan; -import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTTLPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTimePartitionIntervalPlan; import org.apache.iotdb.confignode.consensus.request.write.template.CreateSchemaTemplatePlan; @@ -118,13 +118,12 @@ public class ClusterSchemaInfo implements SnapshotProcessor { // ====================================================== /** - * Cache StorageGroupSchema + * Cache DatabaseSchema * - * @param plan SetStorageGroupPlan - * @return SUCCESS_STATUS if the StorageGroup is set successfully. CACHE_FAILURE if fail to set - * StorageGroup in MTreeAboveSG. + * @param plan DatabaseSchemaPlan + * @return SUCCESS_STATUS if the Database is set successfully. */ - public TSStatus setStorageGroup(SetStorageGroupPlan plan) { + public TSStatus createDatabase(DatabaseSchemaPlan plan) { TSStatus result = new TSStatus(); storageGroupReadWriteLock.writeLock().lock(); try { @@ -148,6 +147,50 @@ public class ClusterSchemaInfo implements SnapshotProcessor { return result; } + /** + * Alter DatabaseSchema + * + * @param plan DatabaseSchemaPlan + * @return SUCCESS_STATUS if the DatabaseSchema is altered successfully. + */ + public TSStatus alterDatabase(DatabaseSchemaPlan plan) { + TSStatus result = new TSStatus(); + storageGroupReadWriteLock.writeLock().lock(); + try { + TStorageGroupSchema alterSchema = plan.getSchema(); + PartialPath partialPathName = new PartialPath(alterSchema.getName()); + + TStorageGroupSchema currentSchema = + mTree.getStorageGroupNodeByStorageGroupPath(partialPathName).getStorageGroupSchema(); + // TODO: Support alter other fields + if (alterSchema.isSetMinSchemaRegionGroupNum()) { + currentSchema.setMinSchemaRegionGroupNum(alterSchema.getMinSchemaRegionGroupNum()); + currentSchema.setMaxSchemaRegionGroupNum( + Math.max( + currentSchema.getMinSchemaRegionGroupNum(), + currentSchema.getMaxSchemaRegionGroupNum())); + } + if (alterSchema.isSetMaxDataRegionGroupNum()) { + currentSchema.setMaxDataRegionGroupNum(alterSchema.getMinDataRegionGroupNum()); + currentSchema.setMaxDataRegionGroupNum( + Math.max( + currentSchema.getMinDataRegionGroupNum(), + currentSchema.getMaxDataRegionGroupNum())); + } + + mTree + .getStorageGroupNodeByStorageGroupPath(partialPathName) + .setStorageGroupSchema(currentSchema); + result.setCode(TSStatusCode.SUCCESS_STATUS.getStatusCode()); + } catch (MetadataException e) { + LOGGER.error(ERROR_NAME, e); + result.setCode(e.getErrorCode()).setMessage(e.getMessage()); + } finally { + storageGroupReadWriteLock.writeLock().unlock(); + } + return result; + } + /** * Delete StorageGroup * @@ -367,6 +410,21 @@ public class ClusterSchemaInfo implements SnapshotProcessor { return storageGroups; } + /** + * Only leader use this interface. Check if the specified Database already exists. + * + * @param databaseName The specified Database's name + * @throws IllegalPathException If the specified Database's name is illegal + */ + public boolean isDatabaseExisted(String databaseName) throws IllegalPathException { + storageGroupReadWriteLock.readLock().lock(); + try { + return mTree.isStorageGroupAlreadySet(new PartialPath(databaseName)); + } finally { + storageGroupReadWriteLock.readLock().unlock(); + } + } + /** * Only leader use this interface. Check if the specific StorageGroup already exists. * diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java b/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java index 08bbfcecca..e3c38dbd90 100644 --- a/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java +++ b/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java @@ -47,9 +47,9 @@ import org.apache.iotdb.confignode.consensus.request.read.storagegroup.GetStorag import org.apache.iotdb.confignode.consensus.request.write.confignode.RemoveConfigNodePlan; import org.apache.iotdb.confignode.consensus.request.write.datanode.RemoveDataNodePlan; import org.apache.iotdb.confignode.consensus.request.write.datanode.UpdateDataNodePlan; +import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DatabaseSchemaPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetDataReplicationFactorPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetSchemaReplicationFactorPlan; -import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTTLPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTimePartitionIntervalPlan; import org.apache.iotdb.confignode.consensus.request.write.sync.CreatePipeSinkPlan; @@ -131,7 +131,6 @@ import org.apache.iotdb.confignode.rpc.thrift.TSetDataNodeStatusReq; import org.apache.iotdb.confignode.rpc.thrift.TSetDataReplicationFactorReq; import org.apache.iotdb.confignode.rpc.thrift.TSetSchemaReplicationFactorReq; import org.apache.iotdb.confignode.rpc.thrift.TSetSchemaTemplateReq; -import org.apache.iotdb.confignode.rpc.thrift.TSetStorageGroupReq; import org.apache.iotdb.confignode.rpc.thrift.TSetTimePartitionIntervalReq; import org.apache.iotdb.confignode.rpc.thrift.TShowCQResp; import org.apache.iotdb.confignode.rpc.thrift.TShowClusterResp; @@ -275,80 +274,123 @@ public class ConfigNodeRPCServiceProcessor implements IConfigNodeRPCService.Ifac } @Override - public TSStatus setStorageGroup(TSetStorageGroupReq req) throws TException { - TStorageGroupSchema storageGroupSchema = req.getStorageGroup(); + public TSStatus setDatabase(TStorageGroupSchema databaseSchema) { TSStatus errorResp = null; // Set default configurations if necessary - if (!storageGroupSchema.isSetTTL()) { - storageGroupSchema.setTTL(CommonDescriptor.getInstance().getConfig().getDefaultTTLInMs()); - } else if (storageGroupSchema.getTTL() <= 0) { + if (!databaseSchema.isSetTTL()) { + databaseSchema.setTTL(CommonDescriptor.getInstance().getConfig().getDefaultTTLInMs()); + } else if (databaseSchema.getTTL() <= 0) { errorResp = new TSStatus(TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode()) .setMessage("Failed to create database. The TTL should be positive."); } - if (!storageGroupSchema.isSetSchemaReplicationFactor()) { - storageGroupSchema.setSchemaReplicationFactor( - CONFIG_NODE_CONFIG.getSchemaReplicationFactor()); - } else if (storageGroupSchema.getSchemaReplicationFactor() <= 0) { + if (!databaseSchema.isSetSchemaReplicationFactor()) { + databaseSchema.setSchemaReplicationFactor(CONFIG_NODE_CONFIG.getSchemaReplicationFactor()); + } else if (databaseSchema.getSchemaReplicationFactor() <= 0) { errorResp = new TSStatus(TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode()) .setMessage( "Failed to create database. The schemaReplicationFactor should be positive."); } - if (!storageGroupSchema.isSetDataReplicationFactor()) { - storageGroupSchema.setDataReplicationFactor(CONFIG_NODE_CONFIG.getDataReplicationFactor()); - } else if (storageGroupSchema.getDataReplicationFactor() <= 0) { + if (!databaseSchema.isSetDataReplicationFactor()) { + databaseSchema.setDataReplicationFactor(CONFIG_NODE_CONFIG.getDataReplicationFactor()); + } else if (databaseSchema.getDataReplicationFactor() <= 0) { errorResp = new TSStatus(TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode()) .setMessage( "Failed to create database. The dataReplicationFactor should be positive."); } - if (!storageGroupSchema.isSetTimePartitionInterval()) { - storageGroupSchema.setTimePartitionInterval(CONFIG_NODE_CONFIG.getTimePartitionInterval()); - } else if (storageGroupSchema.getTimePartitionInterval() <= 0) { + if (!databaseSchema.isSetTimePartitionInterval()) { + databaseSchema.setTimePartitionInterval(CONFIG_NODE_CONFIG.getTimePartitionInterval()); + } else if (databaseSchema.getTimePartitionInterval() <= 0) { errorResp = new TSStatus(TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode()) .setMessage( "Failed to create database. The timePartitionInterval should be positive."); } - if (!storageGroupSchema.isSetMinSchemaRegionGroupNum()) { - storageGroupSchema.setMinSchemaRegionGroupNum( + if (!databaseSchema.isSetMinSchemaRegionGroupNum()) { + databaseSchema.setMinSchemaRegionGroupNum( CONFIG_NODE_CONFIG.getDefaultSchemaRegionGroupNumPerDatabase()); - } else if (storageGroupSchema.getMinSchemaRegionGroupNum() <= 0) { + } else if (databaseSchema.getMinSchemaRegionGroupNum() <= 0) { errorResp = new TSStatus(TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode()) .setMessage( "Failed to create database. The schemaRegionGroupNum should be positive."); } - if (!storageGroupSchema.isSetMinDataRegionGroupNum()) { - storageGroupSchema.setMinDataRegionGroupNum( + if (!databaseSchema.isSetMinDataRegionGroupNum()) { + databaseSchema.setMinDataRegionGroupNum( CONFIG_NODE_CONFIG.getDefaultDataRegionGroupNumPerDatabase()); - } else if (storageGroupSchema.getMinDataRegionGroupNum() <= 0) { + } else if (databaseSchema.getMinDataRegionGroupNum() <= 0) { errorResp = new TSStatus(TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode()) .setMessage("Failed to create database. The dataRegionGroupNum should be positive."); } if (errorResp != null) { - LOGGER.warn("Execute SetStorageGroupRequest {} with result {}", req, errorResp); + LOGGER.warn("Execute SetStorageGroupRequest {} with result {}", databaseSchema, errorResp); return errorResp; } // The maxRegionGroupNum is equal to the minRegionGroupNum when initialize - storageGroupSchema.setMaxSchemaRegionGroupNum(storageGroupSchema.getMinSchemaRegionGroupNum()); - storageGroupSchema.setMaxDataRegionGroupNum(storageGroupSchema.getMinDataRegionGroupNum()); + databaseSchema.setMaxSchemaRegionGroupNum(databaseSchema.getMinSchemaRegionGroupNum()); + databaseSchema.setMaxDataRegionGroupNum(databaseSchema.getMinDataRegionGroupNum()); - SetStorageGroupPlan setReq = new SetStorageGroupPlan(storageGroupSchema); - TSStatus resp = configManager.setStorageGroup(setReq); + DatabaseSchemaPlan setPlan = + new DatabaseSchemaPlan(ConfigPhysicalPlanType.CreateDatabase, databaseSchema); + TSStatus resp = configManager.setDatabase(setPlan); // Print log to record the ConfigNode that performs the set SetStorageGroupRequest - LOGGER.info("Execute SetStorageGroupRequest {} with result {}", req, resp); + LOGGER.info("Execute SetDatabase: {} with result: {}", databaseSchema, resp); + + return resp; + } + + @Override + public TSStatus alterDatabase(TStorageGroupSchema databaseSchema) { + TSStatus errorResp = null; + + // TODO: Support alter the following fields + if (databaseSchema.isSetTTL()) { + errorResp = + new TSStatus(TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode()) + .setMessage("Failed to alter database. Doesn't support ALTER TTL yet."); + } + if (databaseSchema.isSetSchemaReplicationFactor()) { + errorResp = + new TSStatus(TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode()) + .setMessage( + "Failed to alter database. Doesn't support ALTER SchemaReplicationFactor yet."); + } + if (databaseSchema.isSetDataReplicationFactor()) { + errorResp = + new TSStatus(TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode()) + .setMessage( + "Failed to alter database. Doesn't support ALTER DataReplicationFactor yet."); + } + if (databaseSchema.isSetTimePartitionInterval()) { + errorResp = + new TSStatus(TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode()) + .setMessage( + "Failed to alter database. Doesn't support ALTER TimePartitionInterval yet."); + } + + if (errorResp != null) { + LOGGER.warn("Execute SetStorageGroupRequest {} with result {}", databaseSchema, errorResp); + return errorResp; + } + + DatabaseSchemaPlan alterPlan = + new DatabaseSchemaPlan(ConfigPhysicalPlanType.AlterDatabase, databaseSchema); + TSStatus resp = configManager.alterDatabase(alterPlan); + + // Print log to record the ConfigNode that performs the set SetStorageGroupRequest + LOGGER.info("Execute SetDatabase: {} with result: {}", databaseSchema, resp); return resp; } diff --git a/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanSerDeTest.java b/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanSerDeTest.java index 978d81843c..be70040b22 100644 --- a/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanSerDeTest.java +++ b/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanSerDeTest.java @@ -80,10 +80,10 @@ import org.apache.iotdb.confignode.consensus.request.write.region.CreateRegionGr import org.apache.iotdb.confignode.consensus.request.write.region.OfferRegionMaintainTasksPlan; import org.apache.iotdb.confignode.consensus.request.write.region.PollRegionMaintainTaskPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.AdjustMaxRegionGroupNumPlan; +import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DatabaseSchemaPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DeleteStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetDataReplicationFactorPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetSchemaReplicationFactorPlan; -import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTTLPlan; import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetTimePartitionIntervalPlan; import org.apache.iotdb.confignode.consensus.request.write.sync.CreatePipeSinkPlan; @@ -189,17 +189,38 @@ public class ConfigPhysicalPlanSerDeTest { } @Test - public void SetStorageGroupPlanTest() throws IOException { - SetStorageGroupPlan req0 = - new SetStorageGroupPlan( + public void CreateDatabasePlanTest() throws IOException { + DatabaseSchemaPlan req0 = + new DatabaseSchemaPlan( + ConfigPhysicalPlanType.CreateDatabase, new TStorageGroupSchema() .setName("sg") .setTTL(Long.MAX_VALUE) .setSchemaReplicationFactor(3) .setDataReplicationFactor(3) .setTimePartitionInterval(604800)); - SetStorageGroupPlan req1 = - (SetStorageGroupPlan) ConfigPhysicalPlan.Factory.create(req0.serializeToByteBuffer()); + DatabaseSchemaPlan req1 = + (DatabaseSchemaPlan) ConfigPhysicalPlan.Factory.create(req0.serializeToByteBuffer()); + Assert.assertEquals(req0, req1); + } + + @Test + public void AlterDatabasePlanTest() throws IOException { + DatabaseSchemaPlan req0 = + new DatabaseSchemaPlan( + ConfigPhysicalPlanType.AlterDatabase, + new TStorageGroupSchema() + .setName("sg") + .setTTL(Long.MAX_VALUE) + .setSchemaReplicationFactor(3) + .setDataReplicationFactor(3) + .setTimePartitionInterval(604800) + .setMinSchemaRegionGroupNum(2) + .setMaxSchemaRegionGroupNum(5) + .setMinDataRegionGroupNum(3) + .setMaxDataRegionGroupNum(8)); + DatabaseSchemaPlan req1 = + (DatabaseSchemaPlan) ConfigPhysicalPlan.Factory.create(req0.serializeToByteBuffer()); Assert.assertEquals(req0, req1); } diff --git a/confignode/src/test/java/org/apache/iotdb/confignode/persistence/ClusterSchemaInfoTest.java b/confignode/src/test/java/org/apache/iotdb/confignode/persistence/ClusterSchemaInfoTest.java index 5d5b4923a3..bf706ff942 100644 --- a/confignode/src/test/java/org/apache/iotdb/confignode/persistence/ClusterSchemaInfoTest.java +++ b/confignode/src/test/java/org/apache/iotdb/confignode/persistence/ClusterSchemaInfoTest.java @@ -21,9 +21,10 @@ package org.apache.iotdb.confignode.persistence; import org.apache.iotdb.commons.exception.IllegalPathException; import org.apache.iotdb.commons.utils.PathUtils; +import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType; import org.apache.iotdb.confignode.consensus.request.read.storagegroup.GetStorageGroupPlan; import org.apache.iotdb.confignode.consensus.request.read.template.GetPathsSetTemplatePlan; -import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetStorageGroupPlan; +import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DatabaseSchemaPlan; import org.apache.iotdb.confignode.consensus.request.write.template.CreateSchemaTemplatePlan; import org.apache.iotdb.confignode.consensus.request.write.template.SetSchemaTemplatePlan; import org.apache.iotdb.confignode.persistence.schema.ClusterSchemaInfo; @@ -90,7 +91,8 @@ public class ClusterSchemaInfoTest { tStorageGroupSchema.setSchemaReplicationFactor(i); tStorageGroupSchema.setTimePartitionInterval(i); testMap.put(path, tStorageGroupSchema); - clusterSchemaInfo.setStorageGroup(new SetStorageGroupPlan(tStorageGroupSchema)); + clusterSchemaInfo.createDatabase( + new DatabaseSchemaPlan(ConfigPhysicalPlanType.CreateDatabase, tStorageGroupSchema)); i++; } clusterSchemaInfo.processTakeSnapshot(snapshotDir); @@ -114,12 +116,15 @@ public class ClusterSchemaInfoTest { new CreateSchemaTemplatePlan(template.serialize().array()); clusterSchemaInfo.createSchemaTemplate(createSchemaTemplatePlan); - clusterSchemaInfo.setStorageGroup( - new SetStorageGroupPlan(new TStorageGroupSchema("root.test1"))); - clusterSchemaInfo.setStorageGroup( - new SetStorageGroupPlan(new TStorageGroupSchema("root.test2"))); - clusterSchemaInfo.setStorageGroup( - new SetStorageGroupPlan(new TStorageGroupSchema("root.test3"))); + clusterSchemaInfo.createDatabase( + new DatabaseSchemaPlan( + ConfigPhysicalPlanType.CreateDatabase, new TStorageGroupSchema("root.test1"))); + clusterSchemaInfo.createDatabase( + new DatabaseSchemaPlan( + ConfigPhysicalPlanType.CreateDatabase, new TStorageGroupSchema("root.test2"))); + clusterSchemaInfo.createDatabase( + new DatabaseSchemaPlan( + ConfigPhysicalPlanType.CreateDatabase, new TStorageGroupSchema("root.test3"))); clusterSchemaInfo.setSchemaTemplate( new SetSchemaTemplatePlan(templateName, "root.test1.template")); diff --git a/confignode/src/test/java/org/apache/iotdb/confignode/persistence/PartitionInfoTest.java b/confignode/src/test/java/org/apache/iotdb/confignode/persistence/PartitionInfoTest.java index dd504686c9..2ed59e9122 100644 --- a/confignode/src/test/java/org/apache/iotdb/confignode/persistence/PartitionInfoTest.java +++ b/confignode/src/test/java/org/apache/iotdb/confignode/persistence/PartitionInfoTest.java @@ -29,12 +29,13 @@ import org.apache.iotdb.common.rpc.thrift.TTimePartitionSlot; import org.apache.iotdb.commons.partition.DataPartitionTable; import org.apache.iotdb.commons.partition.SchemaPartitionTable; import org.apache.iotdb.commons.partition.SeriesPartitionTable; +import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType; import org.apache.iotdb.confignode.consensus.request.read.region.GetRegionInfoListPlan; import org.apache.iotdb.confignode.consensus.request.write.partition.CreateDataPartitionPlan; import org.apache.iotdb.confignode.consensus.request.write.partition.CreateSchemaPartitionPlan; import org.apache.iotdb.confignode.consensus.request.write.region.CreateRegionGroupsPlan; import org.apache.iotdb.confignode.consensus.request.write.region.OfferRegionMaintainTasksPlan; -import org.apache.iotdb.confignode.consensus.request.write.storagegroup.SetStorageGroupPlan; +import org.apache.iotdb.confignode.consensus.request.write.storagegroup.DatabaseSchemaPlan; import org.apache.iotdb.confignode.consensus.response.RegionInfoListResp; import org.apache.iotdb.confignode.persistence.partition.PartitionInfo; import org.apache.iotdb.confignode.persistence.partition.maintainer.RegionCreateTask; @@ -101,7 +102,9 @@ public class PartitionInfoTest { partitionInfo.generateNextRegionGroupId(); // Set StorageGroup - partitionInfo.setStorageGroup(new SetStorageGroupPlan(new TStorageGroupSchema("root.test"))); + partitionInfo.createDatabase( + new DatabaseSchemaPlan( + ConfigPhysicalPlanType.CreateDatabase, new TStorageGroupSchema("root.test"))); // Create a SchemaRegion CreateRegionGroupsPlan createRegionGroupsReq = new CreateRegionGroupsPlan(); @@ -154,8 +157,9 @@ public class PartitionInfoTest { partitionInfo.generateNextRegionGroupId(); // Set StorageGroup - partitionInfo.setStorageGroup( - new SetStorageGroupPlan(new TStorageGroupSchema("root.test" + i))); + partitionInfo.createDatabase( + new DatabaseSchemaPlan( + ConfigPhysicalPlanType.CreateDatabase, new TStorageGroupSchema("root.test" + i))); // Create a SchemaRegion CreateRegionGroupsPlan createRegionGroupsPlan = new CreateRegionGroupsPlan(); diff --git a/thrift-confignode/src/main/thrift/confignode.thrift b/thrift-confignode/src/main/thrift/confignode.thrift index 124621fe81..de3006fc9a 100644 --- a/thrift-confignode/src/main/thrift/confignode.thrift +++ b/thrift-confignode/src/main/thrift/confignode.thrift @@ -777,24 +777,28 @@ service IConfigNodeRPCService { common.TSStatus reportRegionMigrateResult(TRegionMigrateResultReportReq req) // ====================================================== - // StorageGroup + // Database // ====================================================== /** - * Set a new StorageGroup, all fields in TStorageGroupSchema can be customized + * Set a new Databse, all fields in TStorageGroupSchema can be customized * while the undefined fields will automatically use default values * - * @return SUCCESS_STATUS if the new StorageGroup set successfully - * PATH_ILLEGAL if the new StorageGroup's name is illegal - * STORAGE_GROUP_ALREADY_EXISTS if the StorageGroup already exist + * @return SUCCESS_STATUS if the new Database set successfully + * ILLEGAL_PATH if the new Database name is illegal + * DATABASE_CONFIG_ERROR if some of the DatabaseSchema is illeagal + * DATABASE_ALREADY_EXISTS if the Database already exist */ common.TSStatus setDatabase(TStorageGroupSchema databaseSchema) /** - * Alter a StorageGroup's schema, including + * Alter a Database's schema, including * TTL, ReplicationFactor, timePartitionInterval and RegionGroupNum * - * @return SUCCESS_STATUS if the specified StorageGroupSchema is altered successfully + * @return SUCCESS_STATUS if the specified DatabaseSchema is altered successfully + * ILLEGAL_PATH if the new Database name is illegal + * DATABASE_CONFIG_ERROR if some of the DatabaseSchema is illeagal + * DATABASE_NOT_EXIST if the specified Database doesn't exist */ common.TSStatus alterDatabase(TStorageGroupSchema databaseSchema)
