Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public TDatabaseSchema getSchema() {
@Override
protected void serializeImpl(DataOutputStream stream) throws IOException {
stream.writeShort(getType().getPlanType());
ThriftConfigNodeSerDeUtils.serializeTStorageGroupSchema(schema, stream);
ThriftConfigNodeSerDeUtils.serializeTDatabaseSchema(schema, stream);
}

@Override
protected void deserializeImpl(ByteBuffer buffer) throws IOException {
schema = ThriftConfigNodeSerDeUtils.deserializeTStorageGroupSchema(buffer);
schema = ThriftConfigNodeSerDeUtils.deserializeTDatabaseSchema(buffer);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.iotdb.common.rpc.thrift.TSchemaNode;
import org.apache.iotdb.commons.auth.AuthException;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.schema.node.MNodeType;
import org.apache.iotdb.commons.snapshot.SnapshotProcessor;
import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan;
import org.apache.iotdb.confignode.consensus.request.auth.AuthorPlan;
Expand Down Expand Up @@ -115,7 +116,6 @@
import org.apache.iotdb.confignode.rpc.thrift.TDatabaseSchema;
import org.apache.iotdb.confignode.rpc.thrift.TShowRegionReq;
import org.apache.iotdb.consensus.common.DataSet;
import org.apache.iotdb.db.metadata.mnode.MNodeType;
import org.apache.iotdb.rpc.TSStatusCode;
import org.apache.iotdb.tsfile.utils.Pair;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ public TSStatus createDatabase(DatabaseSchemaPlan plan) {
mTree.setStorageGroup(partialPathName);

// Set DatabaseSchema
mTree.getDatabaseNodeByDatabasePath(partialPathName).setStorageGroupSchema(databaseSchema);
mTree
.getDatabaseNodeByDatabasePath(partialPathName)
.getAsMNode()
.setDatabaseSchema(databaseSchema);

result.setCode(TSStatusCode.SUCCESS_STATUS.getStatusCode());
} catch (MetadataException e) {
Expand All @@ -159,7 +162,7 @@ public TSStatus alterDatabase(DatabaseSchemaPlan plan) {
PartialPath partialPathName = new PartialPath(alterSchema.getName());

TDatabaseSchema currentSchema =
mTree.getDatabaseNodeByDatabasePath(partialPathName).getStorageGroupSchema();
mTree.getDatabaseNodeByDatabasePath(partialPathName).getAsMNode().getDatabaseSchema();
// TODO: Support alter other fields
if (alterSchema.isSetMinSchemaRegionGroupNum()) {
currentSchema.setMinSchemaRegionGroupNum(alterSchema.getMinSchemaRegionGroupNum());
Expand Down Expand Up @@ -192,7 +195,10 @@ public TSStatus alterDatabase(DatabaseSchemaPlan plan) {
currentSchema.getMaxDataRegionGroupNum());
}

mTree.getDatabaseNodeByDatabasePath(partialPathName).setStorageGroupSchema(currentSchema);
mTree
.getDatabaseNodeByDatabasePath(partialPathName)
.getAsMNode()
.setDatabaseSchema(currentSchema);
result.setCode(TSStatusCode.SUCCESS_STATUS.getStatusCode());
} catch (MetadataException e) {
LOGGER.error(ERROR_NAME, e);
Expand Down Expand Up @@ -259,7 +265,8 @@ public DatabaseSchemaResp getMatchedDatabaseSchemas(GetDatabasePlan plan) {
List<PartialPath> matchedPaths = mTree.getMatchedDatabases(patternPath, false);
for (PartialPath path : matchedPaths) {
schemaMap.put(
path.getFullPath(), mTree.getDatabaseNodeByDatabasePath(path).getStorageGroupSchema());
path.getFullPath(),
mTree.getDatabaseNodeByDatabasePath(path).getAsMNode().getDatabaseSchema());
}
result.setSchemaMap(schemaMap);
result.setStatus(new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()));
Expand All @@ -282,7 +289,7 @@ public TSStatus setTTL(SetTTLPlan plan) {
List<PartialPath> matchedPaths = mTree.getBelongedDatabases(patternPath);
if (!matchedPaths.isEmpty()) {
for (PartialPath path : matchedPaths) {
mTree.getDatabaseNodeByDatabasePath(path).getStorageGroupSchema().setTTL(plan.getTTL());
mTree.getDatabaseNodeByDatabasePath(path).setDataTTL(plan.getTTL());
}
result.setCode(TSStatusCode.SUCCESS_STATUS.getStatusCode());
} else {
Expand All @@ -306,7 +313,8 @@ public TSStatus setSchemaReplicationFactor(SetSchemaReplicationFactorPlan plan)
if (mTree.isDatabaseAlreadySet(path)) {
mTree
.getDatabaseNodeByDatabasePath(path)
.getStorageGroupSchema()
.getAsMNode()
.getDatabaseSchema()
.setSchemaReplicationFactor(plan.getSchemaReplicationFactor());
result.setCode(TSStatusCode.SUCCESS_STATUS.getStatusCode());
} else {
Expand All @@ -329,7 +337,8 @@ public TSStatus setDataReplicationFactor(SetDataReplicationFactorPlan plan) {
if (mTree.isDatabaseAlreadySet(path)) {
mTree
.getDatabaseNodeByDatabasePath(path)
.getStorageGroupSchema()
.getAsMNode()
.getDatabaseSchema()
.setDataReplicationFactor(plan.getDataReplicationFactor());
result.setCode(TSStatusCode.SUCCESS_STATUS.getStatusCode());
} else {
Expand All @@ -352,7 +361,8 @@ public TSStatus setTimePartitionInterval(SetTimePartitionIntervalPlan plan) {
if (mTree.isDatabaseAlreadySet(path)) {
mTree
.getDatabaseNodeByDatabasePath(path)
.getStorageGroupSchema()
.getAsMNode()
.getDatabaseSchema()
.setTimePartitionInterval(plan.getTimePartitionInterval());
result.setCode(TSStatusCode.SUCCESS_STATUS.getStatusCode());
} else {
Expand Down Expand Up @@ -381,7 +391,7 @@ public TSStatus adjustMaxRegionGroupCount(AdjustMaxRegionGroupNumPlan plan) {
plan.getMaxRegionGroupNumMap().entrySet()) {
PartialPath path = new PartialPath(entry.getKey());
TDatabaseSchema databaseSchema =
mTree.getDatabaseNodeByDatabasePath(path).getStorageGroupSchema();
mTree.getDatabaseNodeByDatabasePath(path).getAsMNode().getDatabaseSchema();
databaseSchema.setMaxSchemaRegionGroupNum(entry.getValue().getLeft());
databaseSchema.setMaxDataRegionGroupNum(entry.getValue().getRight());
}
Expand Down Expand Up @@ -445,7 +455,10 @@ public TDatabaseSchema getMatchedDatabaseSchemaByName(String database)
throws DatabaseNotExistsException {
databaseReadWriteLock.readLock().lock();
try {
return mTree.getDatabaseNodeByDatabasePath(new PartialPath(database)).getStorageGroupSchema();
return mTree
.getDatabaseNodeByDatabasePath(new PartialPath(database))
.getAsMNode()
.getDatabaseSchema();
} catch (MetadataException e) {
throw new DatabaseNotExistsException(database);
} finally {
Expand All @@ -468,7 +481,8 @@ public Map<String, TDatabaseSchema> getMatchedDatabaseSchemasByName(List<String>
List<PartialPath> matchedPaths = mTree.getMatchedDatabases(patternPath, false);
for (PartialPath path : matchedPaths) {
schemaMap.put(
path.getFullPath(), mTree.getDatabaseNodeByPath(path).getStorageGroupSchema());
path.getFullPath(),
mTree.getDatabaseNodeByPath(path).getAsMNode().getDatabaseSchema());
}
}
} catch (MetadataException e) {
Expand All @@ -491,7 +505,7 @@ public int getMinRegionGroupNum(String database, TConsensusGroupType consensusGr
try {
PartialPath path = new PartialPath(database);
TDatabaseSchema storageGroupSchema =
mTree.getDatabaseNodeByDatabasePath(path).getStorageGroupSchema();
mTree.getDatabaseNodeByDatabasePath(path).getAsMNode().getDatabaseSchema();
switch (consensusGroupType) {
case SchemaRegion:
return storageGroupSchema.getMinSchemaRegionGroupNum();
Expand Down Expand Up @@ -519,7 +533,7 @@ public int getMaxRegionGroupNum(String database, TConsensusGroupType consensusGr
try {
PartialPath path = new PartialPath(database);
TDatabaseSchema storageGroupSchema =
mTree.getDatabaseNodeByDatabasePath(path).getStorageGroupSchema();
mTree.getDatabaseNodeByDatabasePath(path).getAsMNode().getDatabaseSchema();
switch (consensusGroupType) {
case SchemaRegion:
return storageGroupSchema.getMaxSchemaRegionGroupNum();
Expand Down Expand Up @@ -853,7 +867,7 @@ public Map<String, TDatabaseSchema> getMatchedDatabaseSchemasByOneName(
List<PartialPath> matchedPaths = mTree.getBelongedDatabases(patternPath);
for (PartialPath path : matchedPaths) {
schemaMap.put(
path.getFullPath(), mTree.getDatabaseNodeByPath(path).getStorageGroupSchema());
path.getFullPath(), mTree.getDatabaseNodeByPath(path).getAsMNode().getDatabaseSchema());
}
} catch (MetadataException e) {
LOGGER.warn(ERROR_NAME, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,14 @@ protected DeleteStorageGroupState getInitialState() {
public void serialize(DataOutputStream stream) throws IOException {
stream.writeShort(ProcedureType.DELETE_STORAGE_GROUP_PROCEDURE.getTypeCode());
super.serialize(stream);
ThriftConfigNodeSerDeUtils.serializeTStorageGroupSchema(deleteDatabaseSchema, stream);
ThriftConfigNodeSerDeUtils.serializeTDatabaseSchema(deleteDatabaseSchema, stream);
}

@Override
public void deserialize(ByteBuffer byteBuffer) {
super.deserialize(byteBuffer);
try {
deleteDatabaseSchema = ThriftConfigNodeSerDeUtils.deserializeTStorageGroupSchema(byteBuffer);
deleteDatabaseSchema = ThriftConfigNodeSerDeUtils.deserializeTDatabaseSchema(byteBuffer);
} catch (ThriftSerDeException e) {
LOG.error("Error in deserialize DeleteStorageGroupProcedure", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void setUp() throws Exception {
break;
case SchemaFile:
EnvFactory.getEnv().getConfig().getCommonConfig().setSchemaEngineMode("Schema_File");
allocateMemoryForSchemaRegion(3600);
allocateMemoryForSchemaRegion(4000);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public IoTDBSortedShowTimeseriesIT(SchemaTestMode schemaTestMode) {
public void setUp() throws Exception {
super.setUp();
if (schemaTestMode.equals(SchemaTestMode.SchemaFile)) {
allocateMemoryForSchemaRegion(5500);
allocateMemoryForSchemaRegion(10000);
}
EnvFactory.getEnv().initClusterEnvironment();
createSchema();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public IoTDBTagIT(SchemaTestMode schemaTestMode) {
public void setUp() throws Exception {
super.setUp();
if (schemaTestMode.equals(SchemaTestMode.SchemaFile)) {
allocateMemoryForSchemaRegion(5500);
allocateMemoryForSchemaRegion(10000);
}
EnvFactory.getEnv().initClusterEnvironment();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,26 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.iotdb.db.metadata.mnode;
package org.apache.iotdb.commons.schema.node;

import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.schema.node.role.IDatabaseMNode;
import org.apache.iotdb.commons.schema.node.role.IDeviceMNode;
import org.apache.iotdb.commons.schema.node.role.IMeasurementMNode;
import org.apache.iotdb.commons.schema.node.utils.IMNodeContainer;
import org.apache.iotdb.commons.schema.node.visitor.MNodeVisitor;
import org.apache.iotdb.commons.schema.tree.ITreeNode;
import org.apache.iotdb.db.metadata.mnode.container.IMNodeContainer;
import org.apache.iotdb.db.metadata.mnode.visitor.MNodeVisitor;
import org.apache.iotdb.db.metadata.mtree.store.disk.cache.CacheEntry;

/** This interface defines a MNode's operation interfaces. */
public interface IMNode extends ITreeNode {
public interface IMNode<N extends IMNode<N>> extends ITreeNode {

String getName();

void setName(String name);

IMNode getParent();
N getParent();

void setParent(IMNode parent);
void setParent(N parent);

String getFullPath();

Expand All @@ -43,64 +45,44 @@ public interface IMNode extends ITreeNode {

boolean hasChild(String name);

IMNode getChild(String name);
N getChild(String name);

IMNode addChild(String name, IMNode child);
N addChild(String name, N child);

IMNode addChild(IMNode child);
N addChild(N child);

IMNode deleteChild(String name);
N deleteChild(String name);

// this method will replace the oldChild with the newChild, the data of oldChild will be moved to
// newChild
void replaceChild(String oldChildName, IMNode newChildNode);
void replaceChild(String oldChildName, N newChildNode);

// this method will move all the reference or value of current node's attributes to newMNode
void moveDataToNewMNode(IMNode newMNode);
void moveDataToNewMNode(N newMNode);

IMNodeContainer getChildren();
IMNodeContainer<N> getChildren();

void setChildren(IMNodeContainer children);

boolean isUseTemplate();

void setUseTemplate(boolean useTemplate);

/** @return the logic id of template set or activated on this node, id>=-1 */
int getSchemaTemplateId();

/** @return the template id with current state, may be negative since unset or deactivation */
int getSchemaTemplateIdWithState();

void setSchemaTemplateId(int schemaTemplateId);

void preUnsetSchemaTemplate();

void rollbackUnsetSchemaTemplate();

boolean isSchemaTemplatePreUnset();

void unsetSchemaTemplate();
void setChildren(IMNodeContainer<N> children);

boolean isAboveDatabase();

boolean isStorageGroup();
boolean isDatabase();

boolean isEntity();
boolean isDevice();

boolean isMeasurement();

MNodeType getMNodeType(Boolean isConfig);

IStorageGroupMNode getAsStorageGroupMNode();
IDatabaseMNode<N> getAsDatabaseMNode();

IEntityMNode getAsEntityMNode();
IDeviceMNode<N> getAsDeviceMNode();

IMeasurementMNode getAsMeasurementMNode();
IMeasurementMNode<N> getAsMeasurementMNode();

CacheEntry getCacheEntry();
<R, C> R accept(MNodeVisitor<R, C> visitor, C context);

void setCacheEntry(CacheEntry cacheEntry);
int estimateSize();

<R, C> R accept(MNodeVisitor<R, C> visitor, C context);
N getAsMNode();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iotdb.db.metadata.mnode;
package org.apache.iotdb.commons.schema.node;

import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;

Expand Down
Loading