This is an automated email from the ASF dual-hosted git repository. xingtanzjr pushed a commit to branch xingtanzjr/align-id-2 in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit e1f2199f1df7537ba3d5e9ed586f23d44399b138 Author: Jinrui.Zhang <[email protected]> AuthorDate: Fri Apr 1 21:26:49 2022 +0800 align entity name and properties --- .../org/apache/iotdb/consensus/ratis/Utils.java | 2 +- .../iotdb/consensus/ratis/RatisConsensusTest.java | 2 +- .../apache/iotdb/consensus/ratis/UtilsTest.java | 2 +- .../iotdb/commons/partition/ConsensusGroupId.java | 6 +-- .../{DataPartitionInfo.java => DataPartition.java} | 2 +- .../iotdb/commons/partition/PartitionInfo.java | 10 ++-- .../iotdb/commons/partition/SchemaRegionId.java | 54 ---------------------- .../iotdb/db/metadata/LocalConfigManager.java | 31 +++++++------ .../db/metadata/LocalSchemaPartitionTable.java | 29 ++++++------ .../db/metadata/schemaregion/SchemaEngine.java | 10 ++-- .../db/metadata/schemaregion/SchemaRegion.java | 8 ++-- .../iotdb/db/metadata/template/Template.java | 18 ++++---- .../db/metadata/template/TemplateManager.java | 6 +-- .../apache/iotdb/db/mpp/sql/analyze/Analysis.java | 14 +++--- .../apache/iotdb/db/mpp/sql/analyze/Analyzer.java | 6 +-- .../mpp/sql/analyze/ClusterPartitionFetcher.java | 6 +-- .../mpp/sql/analyze/FakePartitionFetcherImpl.java | 20 ++++---- .../db/mpp/sql/analyze/IPartitionFetcher.java | 6 +-- .../sql/analyze/StandalonePartitionFetcher.java | 6 +-- .../plan/SimpleFragmentParallelPlanner.java | 2 +- .../db/mpp/sql/plan/DistributionPlannerTest.java | 19 ++++---- 21 files changed, 104 insertions(+), 155 deletions(-) diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/ratis/Utils.java b/consensus/src/main/java/org/apache/iotdb/consensus/ratis/Utils.java index e68ef86..5896662 100644 --- a/consensus/src/main/java/org/apache/iotdb/consensus/ratis/Utils.java +++ b/consensus/src/main/java/org/apache/iotdb/consensus/ratis/Utils.java @@ -128,7 +128,7 @@ public class Utils { break; } } - return new ConsensusGroupId(groupType, Long.parseLong(items[1])); + return new ConsensusGroupId(groupType, Integer.parseInt(items[1])); } public static ByteBuffer serializeTSStatus(TSStatus status) throws TException { diff --git a/consensus/src/test/java/org/apache/iotdb/consensus/ratis/RatisConsensusTest.java b/consensus/src/test/java/org/apache/iotdb/consensus/ratis/RatisConsensusTest.java index 8cb52ad..0b9ed33 100644 --- a/consensus/src/test/java/org/apache/iotdb/consensus/ratis/RatisConsensusTest.java +++ b/consensus/src/test/java/org/apache/iotdb/consensus/ratis/RatisConsensusTest.java @@ -115,7 +115,7 @@ public class RatisConsensusTest { @Before public void setUp() throws IOException { - gid = new ConsensusGroupId(GroupType.DataRegion, 1L); + gid = new ConsensusGroupId(GroupType.DataRegion, 1); peers = new ArrayList<>(); peer0 = new Peer(gid, new Endpoint("127.0.0.1", 6000)); peer1 = new Peer(gid, new Endpoint("127.0.0.1", 6001)); diff --git a/consensus/src/test/java/org/apache/iotdb/consensus/ratis/UtilsTest.java b/consensus/src/test/java/org/apache/iotdb/consensus/ratis/UtilsTest.java index b3badf7..0597a1e 100644 --- a/consensus/src/test/java/org/apache/iotdb/consensus/ratis/UtilsTest.java +++ b/consensus/src/test/java/org/apache/iotdb/consensus/ratis/UtilsTest.java @@ -28,7 +28,7 @@ import org.junit.Test; public class UtilsTest { @Test public void testEncryption() { - ConsensusGroupId raw = new ConsensusGroupId(GroupType.PartitionRegion, 100L); + ConsensusGroupId raw = new ConsensusGroupId(GroupType.PartitionRegion, 100); RaftGroupId id = Utils.toRatisGroupId(raw); ConsensusGroupId cgid = Utils.toConsensusGroupId(id); Assert.assertEquals(raw, cgid); diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/partition/ConsensusGroupId.java b/node-commons/src/main/java/org/apache/iotdb/commons/partition/ConsensusGroupId.java index cb30fd3..e45fb91 100644 --- a/node-commons/src/main/java/org/apache/iotdb/commons/partition/ConsensusGroupId.java +++ b/node-commons/src/main/java/org/apache/iotdb/commons/partition/ConsensusGroupId.java @@ -25,9 +25,9 @@ import java.util.Objects; public class ConsensusGroupId { private final GroupType type; - private final long id; + private final int id; - public ConsensusGroupId(GroupType type, long id) { + public ConsensusGroupId(GroupType type, int id) { this.type = type; this.id = id; } @@ -36,7 +36,7 @@ public class ConsensusGroupId { return type; } - public long getId() { + public int getId() { return id; } diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartitionInfo.java b/node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartition.java similarity index 98% rename from node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartitionInfo.java rename to node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartition.java index 908890f..7af4aea 100644 --- a/node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartitionInfo.java +++ b/node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartition.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -public class DataPartitionInfo { +public class DataPartition { // Map<StorageGroup, Map<DeviceGroupID, Map<TimePartitionId, List<DataRegionPlaceInfo>>>> private Map<String, Map<SeriesPartitionSlot, Map<TimePartitionSlot, List<RegionReplicaSet>>>> diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/partition/PartitionInfo.java b/node-commons/src/main/java/org/apache/iotdb/commons/partition/PartitionInfo.java index 8f3b4b2..6e846ad 100644 --- a/node-commons/src/main/java/org/apache/iotdb/commons/partition/PartitionInfo.java +++ b/node-commons/src/main/java/org/apache/iotdb/commons/partition/PartitionInfo.java @@ -20,15 +20,15 @@ package org.apache.iotdb.commons.partition; public class PartitionInfo { - private DataPartitionInfo dataPartitionInfo; + private DataPartition dataPartition; private SchemaPartition schemaPartition; - public DataPartitionInfo getDataPartitionInfo() { - return dataPartitionInfo; + public DataPartition getDataPartitionInfo() { + return dataPartition; } - public void setDataPartitionInfo(DataPartitionInfo dataPartitionInfo) { - this.dataPartitionInfo = dataPartitionInfo; + public void setDataPartitionInfo(DataPartition dataPartition) { + this.dataPartition = dataPartition; } public SchemaPartition getSchemaPartitionInfo() { diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/partition/SchemaRegionId.java b/node-commons/src/main/java/org/apache/iotdb/commons/partition/SchemaRegionId.java deleted file mode 100644 index 55fbf86..0000000 --- a/node-commons/src/main/java/org/apache/iotdb/commons/partition/SchemaRegionId.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.iotdb.commons.partition; - -import java.util.Objects; - -public class SchemaRegionId { - private int schemaRegionId; - - public SchemaRegionId(int schemaRegionId) { - this.schemaRegionId = schemaRegionId; - } - - public int getSchemaRegionId() { - return schemaRegionId; - } - - public void setSchemaRegionId(int schemaRegionId) { - this.schemaRegionId = schemaRegionId; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - SchemaRegionId that = (SchemaRegionId) o; - return schemaRegionId == that.schemaRegionId; - } - - @Override - public int hashCode() { - return Objects.hash(schemaRegionId); - } - - public String toString() { - return String.format("SchemaRegion-%d", schemaRegionId); - } -} diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/LocalConfigManager.java b/server/src/main/java/org/apache/iotdb/db/metadata/LocalConfigManager.java index 313c8df..67bbba3 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/LocalConfigManager.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/LocalConfigManager.java @@ -21,7 +21,8 @@ package org.apache.iotdb.db.metadata; import org.apache.iotdb.commons.concurrent.IoTDBThreadPoolFactory; import org.apache.iotdb.commons.conf.IoTDBConstant; -import org.apache.iotdb.commons.partition.SchemaRegionId; +import org.apache.iotdb.commons.partition.ConsensusGroupId; +import org.apache.iotdb.commons.partition.GroupType; import org.apache.iotdb.db.conf.IoTDBConfig; import org.apache.iotdb.db.conf.IoTDBDescriptor; import org.apache.iotdb.db.engine.fileSystem.SystemFileFactory; @@ -162,8 +163,8 @@ public class LocalConfigManager { } for (File schemaRegionDir : schemaRegionDirs) { - SchemaRegionId schemaRegionId = - new SchemaRegionId(Integer.parseInt(schemaRegionDir.getName())); + ConsensusGroupId schemaRegionId = + new ConsensusGroupId(GroupType.SchemaRegion, Integer.parseInt(schemaRegionDir.getName())); localCreateSchemaRegion(storageGroup, schemaRegionId); partitionTable.putSchemaRegionId(storageGroup, schemaRegionId); } @@ -503,27 +504,27 @@ public class LocalConfigManager { // region Interfaces for SchemaRegion Management - public void createSchemaRegion(PartialPath storageGroup, SchemaRegionId schemaRegionId) + public void createSchemaRegion(PartialPath storageGroup, ConsensusGroupId schemaRegionId) throws MetadataException { ensureStorageGroup(storageGroup, false); localCreateSchemaRegion(storageGroup, schemaRegionId); partitionTable.putSchemaRegionId(storageGroup, schemaRegionId); } - public SchemaRegion getSchemaRegion(PartialPath storageGroup, SchemaRegionId schemaRegionId) + public SchemaRegion getSchemaRegion(PartialPath storageGroup, ConsensusGroupId schemaRegionId) throws MetadataException { return schemaEngine.getSchemaRegion(schemaRegionId); } - public void deleteSchemaRegion(PartialPath storageGroup, SchemaRegionId schemaRegionId) + public void deleteSchemaRegion(PartialPath storageGroup, ConsensusGroupId schemaRegionId) throws MetadataException { partitionTable.removeSchemaRegionId(storageGroup, schemaRegionId); schemaEngine.deleteSchemaRegion(schemaRegionId); } private void deleteSchemaRegionsInStorageGroup( - PartialPath storageGroup, Set<SchemaRegionId> schemaRegionIdSet) throws MetadataException { - for (SchemaRegionId schemaRegionId : schemaRegionIdSet) { + PartialPath storageGroup, Set<ConsensusGroupId> schemaRegionIdSet) throws MetadataException { + for (ConsensusGroupId schemaRegionId : schemaRegionIdSet) { schemaEngine.deleteSchemaRegion(schemaRegionId); } @@ -540,7 +541,7 @@ public class LocalConfigManager { } private SchemaRegion localCreateSchemaRegion( - PartialPath storageGroup, SchemaRegionId schemaRegionId) throws MetadataException { + PartialPath storageGroup, ConsensusGroupId schemaRegionId) throws MetadataException { return schemaEngine.createSchemaRegion( storageGroup, schemaRegionId, @@ -556,7 +557,7 @@ public class LocalConfigManager { */ public SchemaRegion getBelongedSchemaRegion(PartialPath path) throws MetadataException { PartialPath storageGroup = storageGroupSchemaManager.getBelongedStorageGroup(path); - SchemaRegionId schemaRegionId = partitionTable.getSchemaRegionId(storageGroup, path); + ConsensusGroupId schemaRegionId = partitionTable.getSchemaRegionId(storageGroup, path); SchemaRegion schemaRegion = schemaEngine.getSchemaRegion(schemaRegionId); if (schemaRegion == null) { schemaRegion = localCreateSchemaRegion(storageGroup, schemaRegionId); @@ -583,7 +584,7 @@ public class LocalConfigManager { List<SchemaRegion> result = new ArrayList<>(); for (PartialPath storageGroup : storageGroupSchemaManager.getInvolvedStorageGroups(pathPattern, isPrefixMatch)) { - for (SchemaRegionId schemaRegionId : + for (ConsensusGroupId schemaRegionId : partitionTable.getInvolvedSchemaRegionIds(storageGroup, pathPattern, isPrefixMatch)) { result.add(schemaEngine.getSchemaRegion(schemaRegionId)); } @@ -595,7 +596,7 @@ public class LocalConfigManager { public List<SchemaRegion> getSchemaRegionsByStorageGroup(PartialPath storageGroup) throws MetadataException { List<SchemaRegion> result = new ArrayList<>(); - for (SchemaRegionId schemaRegionId : + for (ConsensusGroupId schemaRegionId : partitionTable.getSchemaRegionIdsByStorageGroup(storageGroup)) { result.add(schemaEngine.getSchemaRegion(schemaRegionId)); } @@ -618,7 +619,7 @@ public class LocalConfigManager { Template template = templateManager.getTemplate(plan.getName()); - for (SchemaRegionId schemaRegionId : template.getRelatedSchemaRegion()) { + for (ConsensusGroupId schemaRegionId : template.getRelatedSchemaRegion()) { if (!schemaEngine .getSchemaRegion(schemaRegionId) .isTemplateAppendable(template, plan.getMeasurements())) { @@ -708,7 +709,7 @@ public class LocalConfigManager { result.addAll(schemaRegion.getPathsSetTemplate(IoTDBConstant.ONE_LEVEL_PATH_WILDCARD)); } } else { - for (SchemaRegionId schemaRegionId : + for (ConsensusGroupId schemaRegionId : templateManager.getTemplate(templateName).getRelatedSchemaRegion()) { result.addAll( schemaEngine.getSchemaRegion(schemaRegionId).getPathsSetTemplate(templateName)); @@ -725,7 +726,7 @@ public class LocalConfigManager { result.addAll(schemaRegion.getPathsUsingTemplate(IoTDBConstant.ONE_LEVEL_PATH_WILDCARD)); } } else { - for (SchemaRegionId schemaRegionId : + for (ConsensusGroupId schemaRegionId : templateManager.getTemplate(templateName).getRelatedSchemaRegion()) { result.addAll( schemaEngine.getSchemaRegion(schemaRegionId).getPathsUsingTemplate(templateName)); diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/LocalSchemaPartitionTable.java b/server/src/main/java/org/apache/iotdb/db/metadata/LocalSchemaPartitionTable.java index 9c2b415..e081de8 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/LocalSchemaPartitionTable.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/LocalSchemaPartitionTable.java @@ -19,7 +19,8 @@ package org.apache.iotdb.db.metadata; -import org.apache.iotdb.commons.partition.SchemaRegionId; +import org.apache.iotdb.commons.partition.ConsensusGroupId; +import org.apache.iotdb.commons.partition.GroupType; import org.apache.iotdb.db.exception.metadata.MetadataException; import org.apache.iotdb.db.metadata.path.PartialPath; @@ -38,7 +39,7 @@ public class LocalSchemaPartitionTable { private AtomicInteger schemaRegionIdGenerator; - private Map<PartialPath, Set<SchemaRegionId>> table; + private Map<PartialPath, Set<ConsensusGroupId>> table; private static class LocalSchemaPartitionTableHolder { private static final LocalSchemaPartitionTable INSTANCE = new LocalSchemaPartitionTable(); @@ -68,40 +69,40 @@ public class LocalSchemaPartitionTable { } } - public synchronized SchemaRegionId allocateSchemaRegionId(PartialPath storageGroup) { - SchemaRegionId schemaRegionId = new SchemaRegionId(schemaRegionIdGenerator.getAndIncrement()); + public synchronized ConsensusGroupId allocateSchemaRegionId(PartialPath storageGroup) { + ConsensusGroupId schemaRegionId = new ConsensusGroupId(GroupType.SchemaRegion, schemaRegionIdGenerator.getAndIncrement()); table.get(storageGroup).add(schemaRegionId); return schemaRegionId; } public synchronized void putSchemaRegionId( - PartialPath storageGroup, SchemaRegionId schemaRegionId) { + PartialPath storageGroup, ConsensusGroupId schemaRegionId) { table.get(storageGroup).add(schemaRegionId); - if (schemaRegionId.getSchemaRegionId() >= schemaRegionIdGenerator.get()) { - schemaRegionIdGenerator.set(schemaRegionId.getSchemaRegionId() + 1); + if (schemaRegionId.getId() >= schemaRegionIdGenerator.get()) { + schemaRegionIdGenerator.set(schemaRegionId.getId() + 1); } } public synchronized void removeSchemaRegionId( - PartialPath storageGroup, SchemaRegionId schemaRegionId) { + PartialPath storageGroup, ConsensusGroupId schemaRegionId) { table.get(storageGroup).remove(schemaRegionId); } - public SchemaRegionId getSchemaRegionId(PartialPath storageGroup, PartialPath path) { + public ConsensusGroupId getSchemaRegionId(PartialPath storageGroup, PartialPath path) { return calculateSchemaRegionId(storageGroup, path); } - public List<SchemaRegionId> getInvolvedSchemaRegionIds( + public List<ConsensusGroupId> getInvolvedSchemaRegionIds( PartialPath storageGroup, PartialPath pathPattern, boolean isPrefixMatch) { - List<SchemaRegionId> result = new ArrayList<>(); + List<ConsensusGroupId> result = new ArrayList<>(); if (table.containsKey(storageGroup)) { result.addAll(table.get(storageGroup)); } return result; } - public Set<SchemaRegionId> getSchemaRegionIdsByStorageGroup(PartialPath storageGroup) { + public Set<ConsensusGroupId> getSchemaRegionIdsByStorageGroup(PartialPath storageGroup) { return table.get(storageGroup); } @@ -109,13 +110,13 @@ public class LocalSchemaPartitionTable { table.put(storageGroup, Collections.synchronizedSet(new HashSet<>())); } - public synchronized Set<SchemaRegionId> deleteStorageGroup(PartialPath storageGroup) { + public synchronized Set<ConsensusGroupId> deleteStorageGroup(PartialPath storageGroup) { return table.remove(storageGroup); } // This method may be extended to implement multi schemaRegion for one storageGroup // todo keep consistent with the partition method of config node in new cluster - private SchemaRegionId calculateSchemaRegionId(PartialPath storageGroup, PartialPath path) { + private ConsensusGroupId calculateSchemaRegionId(PartialPath storageGroup, PartialPath path) { return table.get(storageGroup).iterator().next(); } } diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaEngine.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaEngine.java index ff1d1ab..2bd031d 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaEngine.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaEngine.java @@ -19,7 +19,7 @@ package org.apache.iotdb.db.metadata.schemaregion; -import org.apache.iotdb.commons.partition.SchemaRegionId; +import org.apache.iotdb.commons.partition.ConsensusGroupId; import org.apache.iotdb.db.exception.metadata.MetadataException; import org.apache.iotdb.db.metadata.mnode.IStorageGroupMNode; import org.apache.iotdb.db.metadata.path.PartialPath; @@ -31,7 +31,7 @@ import java.util.concurrent.ConcurrentHashMap; // manage all the schemaRegion in this dataNode public class SchemaEngine { - private Map<SchemaRegionId, SchemaRegion> schemaRegionMap; + private Map<ConsensusGroupId, SchemaRegion> schemaRegionMap; private static class SchemaEngineManagerHolder { private static final SchemaEngine INSTANCE = new SchemaEngine(); @@ -56,7 +56,7 @@ public class SchemaEngine { } } - public SchemaRegion getSchemaRegion(SchemaRegionId schemaRegionId) { + public SchemaRegion getSchemaRegion(ConsensusGroupId schemaRegionId) { return schemaRegionMap.get(schemaRegionId); } @@ -65,7 +65,7 @@ public class SchemaEngine { } public synchronized SchemaRegion createSchemaRegion( - PartialPath storageGroup, SchemaRegionId schemaRegionId, IStorageGroupMNode storageGroupMNode) + PartialPath storageGroup, ConsensusGroupId schemaRegionId, IStorageGroupMNode storageGroupMNode) throws MetadataException { SchemaRegion schemaRegion = schemaRegionMap.get(schemaRegionId); if (schemaRegion != null) { @@ -76,7 +76,7 @@ public class SchemaEngine { return schemaRegion; } - public void deleteSchemaRegion(SchemaRegionId schemaRegionId) throws MetadataException { + public void deleteSchemaRegion(ConsensusGroupId schemaRegionId) throws MetadataException { schemaRegionMap.remove(schemaRegionId).deleteSchemaRegion(); } } diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegion.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegion.java index b1407ad..72bb3b9 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegion.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegion.java @@ -18,7 +18,7 @@ */ package org.apache.iotdb.db.metadata.schemaregion; -import org.apache.iotdb.commons.partition.SchemaRegionId; +import org.apache.iotdb.commons.partition.ConsensusGroupId; import org.apache.iotdb.db.conf.IoTDBConfig; import org.apache.iotdb.db.conf.IoTDBDescriptor; import org.apache.iotdb.db.engine.StorageEngine; @@ -153,7 +153,7 @@ public class SchemaRegion { private String schemaRegionDirPath; private String storageGroupFullPath; - private SchemaRegionId schemaRegionId; + private ConsensusGroupId schemaRegionId; // the log file seriesPath private String logFilePath; @@ -168,7 +168,7 @@ public class SchemaRegion { // region Interfaces and Implementation of initialization、snapshot、recover and clear public SchemaRegion( - PartialPath storageGroup, SchemaRegionId schemaRegionId, IStorageGroupMNode storageGroupMNode) + PartialPath storageGroup, ConsensusGroupId schemaRegionId, IStorageGroupMNode storageGroupMNode) throws MetadataException { storageGroupFullPath = storageGroup.getFullPath(); @@ -216,7 +216,7 @@ public class SchemaRegion { + File.separator + storageGroupFullPath + File.separator - + schemaRegionId.getSchemaRegionId(); + + schemaRegionId.getId(); File schemaRegionFolder = SystemFileFactory.INSTANCE.getFile(schemaRegionDirPath); if (!schemaRegionFolder.exists()) { if (schemaRegionFolder.mkdirs()) { diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/template/Template.java b/server/src/main/java/org/apache/iotdb/db/metadata/template/Template.java index a426478..2d455d4 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/template/Template.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/template/Template.java @@ -18,7 +18,7 @@ */ package org.apache.iotdb.db.metadata.template; -import org.apache.iotdb.commons.partition.SchemaRegionId; +import org.apache.iotdb.commons.partition.ConsensusGroupId; import org.apache.iotdb.db.exception.metadata.IllegalPathException; import org.apache.iotdb.db.exception.metadata.MetadataException; import org.apache.iotdb.db.exception.metadata.PathNotExistException; @@ -67,7 +67,7 @@ public class Template { private Map<String, IMeasurementSchema> schemaMap; // accelerate template query and check - private Map<String, Set<SchemaRegionId>> relatedSchemaRegion; + private Map<String, Set<ConsensusGroupId>> relatedSchemaRegion; public Template() {} @@ -411,27 +411,27 @@ public class Template { return directNodes.values(); } - public Set<SchemaRegionId> getRelatedSchemaRegion() { - Set<SchemaRegionId> result = new HashSet<>(); - for (Set<SchemaRegionId> schemaRegionIds : relatedSchemaRegion.values()) { + public Set<ConsensusGroupId> getRelatedSchemaRegion() { + Set<ConsensusGroupId> result = new HashSet<>(); + for (Set<ConsensusGroupId> schemaRegionIds : relatedSchemaRegion.values()) { result.addAll(schemaRegionIds); } return result; } - public Set<SchemaRegionId> getRelatedSchemaRegionInStorageGroup(String storageGroup) { + public Set<ConsensusGroupId> getRelatedSchemaRegionInStorageGroup(String storageGroup) { return relatedSchemaRegion.get(storageGroup); } - public void markSchemaRegion(String storageGroup, SchemaRegionId schemaRegionId) { + public void markSchemaRegion(String storageGroup, ConsensusGroupId schemaRegionId) { if (!relatedSchemaRegion.containsKey(storageGroup)) { relatedSchemaRegion.putIfAbsent(storageGroup, new HashSet<>()); } relatedSchemaRegion.get(storageGroup).add(schemaRegionId); } - public void unmarkSchemaRegion(String storageGroup, SchemaRegionId schemaRegionId) { - Set<SchemaRegionId> schemaRegionIds = relatedSchemaRegion.get(storageGroup); + public void unmarkSchemaRegion(String storageGroup, ConsensusGroupId schemaRegionId) { + Set<ConsensusGroupId> schemaRegionIds = relatedSchemaRegion.get(storageGroup); schemaRegionIds.remove(schemaRegionId); if (schemaRegionIds.isEmpty()) { relatedSchemaRegion.remove(storageGroup); diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/template/TemplateManager.java b/server/src/main/java/org/apache/iotdb/db/metadata/template/TemplateManager.java index a3186e1..bfed348 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/template/TemplateManager.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/template/TemplateManager.java @@ -19,7 +19,7 @@ package org.apache.iotdb.db.metadata.template; import org.apache.iotdb.commons.conf.IoTDBConstant; -import org.apache.iotdb.commons.partition.SchemaRegionId; +import org.apache.iotdb.commons.partition.ConsensusGroupId; import org.apache.iotdb.db.conf.IoTDBDescriptor; import org.apache.iotdb.db.exception.metadata.DuplicatedTemplateException; import org.apache.iotdb.db.exception.metadata.MetadataException; @@ -307,7 +307,7 @@ public class TemplateManager { } public void markSchemaRegion( - Template template, String storageGroup, SchemaRegionId schemaRegionId) { + Template template, String storageGroup, ConsensusGroupId schemaRegionId) { synchronized (templateUsageInStorageGroup) { if (!templateUsageInStorageGroup.containsKey(storageGroup)) { templateUsageInStorageGroup.putIfAbsent( @@ -319,7 +319,7 @@ public class TemplateManager { } public void unmarkSchemaRegion( - Template template, String storageGroup, SchemaRegionId schemaRegionId) { + Template template, String storageGroup, ConsensusGroupId schemaRegionId) { Set<Template> usageInStorageGroup = templateUsageInStorageGroup.get(storageGroup); usageInStorageGroup.remove(template); synchronized (templateUsageInStorageGroup) { diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/Analysis.java b/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/Analysis.java index b28e373..d184b82 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/Analysis.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/Analysis.java @@ -19,7 +19,7 @@ package org.apache.iotdb.db.mpp.sql.analyze; -import org.apache.iotdb.commons.partition.DataPartitionInfo; +import org.apache.iotdb.commons.partition.DataPartition; import org.apache.iotdb.commons.partition.RegionReplicaSet; import org.apache.iotdb.commons.partition.SchemaPartition; import org.apache.iotdb.db.metadata.path.PartialPath; @@ -45,7 +45,7 @@ public class Analysis { // indicate whether this statement is write or read private QueryType queryType; - private DataPartitionInfo dataPartitionInfo; + private DataPartition dataPartition; private SchemaPartition schemaPartition; @@ -55,7 +55,7 @@ public class Analysis { public List<RegionReplicaSet> getPartitionInfo(PartialPath seriesPath, Filter timefilter) { // TODO: (xingtanzjr) implement the calculation of timePartitionIdList - return dataPartitionInfo.getDataRegionReplicaSet(seriesPath.getDevice(), null); + return dataPartition.getDataRegionReplicaSet(seriesPath.getDevice(), null); } public Statement getStatement() { @@ -66,12 +66,12 @@ public class Analysis { this.statement = statement; } - public DataPartitionInfo getDataPartitionInfo() { - return dataPartitionInfo; + public DataPartition getDataPartitionInfo() { + return dataPartition; } - public void setDataPartitionInfo(DataPartitionInfo dataPartitionInfo) { - this.dataPartitionInfo = dataPartitionInfo; + public void setDataPartitionInfo(DataPartition dataPartition) { + this.dataPartition = dataPartition; } public SchemaPartition getSchemaPartitionInfo() { diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/Analyzer.java b/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/Analyzer.java index 92d1270..500676b 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/Analyzer.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/Analyzer.java @@ -19,7 +19,7 @@ package org.apache.iotdb.db.mpp.sql.analyze; -import org.apache.iotdb.commons.partition.DataPartitionInfo; +import org.apache.iotdb.commons.partition.DataPartition; import org.apache.iotdb.commons.partition.DataPartitionQueryParam; import org.apache.iotdb.commons.partition.PartitionInfo; import org.apache.iotdb.db.exception.query.PathNumOverLimitException; @@ -110,7 +110,7 @@ public class Analyzer { dataPartitionQueryParam.setDevicePath(deviceId); dataPartitionQueryParams.add(dataPartitionQueryParam); } - DataPartitionInfo dataPartitionInfo = + DataPartition dataPartition = partitionFetcher.fetchDataPartitionInfos(dataPartitionQueryParams); // optimize expressions in whereCondition @@ -125,7 +125,7 @@ public class Analyzer { analysis.setStatement(rewrittenStatement); analysis.setSchemaTree(schemaTree); analysis.setDeviceIdToPathsMap(deviceIdToPathsMap); - analysis.setDataPartitionInfo(dataPartitionInfo); + analysis.setDataPartitionInfo(dataPartition); } catch (StatementAnalyzeException | PathNumOverLimitException e) { e.printStackTrace(); } diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/ClusterPartitionFetcher.java b/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/ClusterPartitionFetcher.java index 9c929fe..c142b22 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/ClusterPartitionFetcher.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/ClusterPartitionFetcher.java @@ -18,7 +18,7 @@ */ package org.apache.iotdb.db.mpp.sql.analyze; -import org.apache.iotdb.commons.partition.DataPartitionInfo; +import org.apache.iotdb.commons.partition.DataPartition; import org.apache.iotdb.commons.partition.DataPartitionQueryParam; import org.apache.iotdb.commons.partition.PartitionInfo; import org.apache.iotdb.commons.partition.SchemaPartition; @@ -28,12 +28,12 @@ import java.util.List; public class ClusterPartitionFetcher implements IPartitionFetcher { @Override - public DataPartitionInfo fetchDataPartitionInfo(DataPartitionQueryParam parameter) { + public DataPartition fetchDataPartitionInfo(DataPartitionQueryParam parameter) { return null; } @Override - public DataPartitionInfo fetchDataPartitionInfos(List<DataPartitionQueryParam> parameterList) { + public DataPartition fetchDataPartitionInfos(List<DataPartitionQueryParam> parameterList) { return null; } diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/FakePartitionFetcherImpl.java b/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/FakePartitionFetcherImpl.java index 9b912a3..a2f5fb8 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/FakePartitionFetcherImpl.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/FakePartitionFetcherImpl.java @@ -25,17 +25,17 @@ import java.util.*; public class FakePartitionFetcherImpl implements IPartitionFetcher { @Override - public DataPartitionInfo fetchDataPartitionInfo(DataPartitionQueryParam parameter) { + public DataPartition fetchDataPartitionInfo(DataPartitionQueryParam parameter) { return null; } @Override - public DataPartitionInfo fetchDataPartitionInfos(List<DataPartitionQueryParam> parameterList) { + public DataPartition fetchDataPartitionInfos(List<DataPartitionQueryParam> parameterList) { String device1 = "root.sg.d1"; String device2 = "root.sg.d22"; String device3 = "root.sg.d333"; - DataPartitionInfo dataPartitionInfo = new DataPartitionInfo(); + DataPartition dataPartition = new DataPartition(); Map<String, Map<SeriesPartitionSlot, Map<TimePartitionSlot, List<RegionReplicaSet>>>> dataPartitionMap = new HashMap<>(); Map<SeriesPartitionSlot, Map<TimePartitionSlot, List<RegionReplicaSet>>> sgPartitionMap = @@ -45,11 +45,11 @@ public class FakePartitionFetcherImpl implements IPartitionFetcher { d1DataRegions.add( new RegionReplicaSet( new ConsensusGroupId(GroupType.DataRegion, 1), - Arrays.asList(new Endpoint("192.0.1.1", 9000), new Endpoint("192.0.1.2", 9000)))); + Arrays.asList(new DataNodeLocation(11, new Endpoint("192.0.1.1", 9000)), new DataNodeLocation(12, new Endpoint("192.0.1.2", 9000))))); d1DataRegions.add( new RegionReplicaSet( new ConsensusGroupId(GroupType.DataRegion, 2), - Arrays.asList(new Endpoint("192.0.2.1", 9000), new Endpoint("192.0.2.2", 9000)))); + Arrays.asList(new DataNodeLocation(21, new Endpoint("192.0.2.1", 9000)), new DataNodeLocation(22, new Endpoint("192.0.2.2", 9000))))); Map<TimePartitionSlot, List<RegionReplicaSet>> d1DataRegionMap = new HashMap<>(); d1DataRegionMap.put(new TimePartitionSlot(), d1DataRegions); @@ -57,7 +57,7 @@ public class FakePartitionFetcherImpl implements IPartitionFetcher { d2DataRegions.add( new RegionReplicaSet( new ConsensusGroupId(GroupType.DataRegion, 3), - Arrays.asList(new Endpoint("192.0.3.1", 9000), new Endpoint("192.0.3.2", 9000)))); + Arrays.asList(new DataNodeLocation(31, new Endpoint("192.0.3.1", 9000)), new DataNodeLocation(32, new Endpoint("192.0.3.2", 9000))))); Map<TimePartitionSlot, List<RegionReplicaSet>> d2DataRegionMap = new HashMap<>(); d2DataRegionMap.put(new TimePartitionSlot(), d2DataRegions); @@ -65,11 +65,11 @@ public class FakePartitionFetcherImpl implements IPartitionFetcher { d3DataRegions.add( new RegionReplicaSet( new ConsensusGroupId(GroupType.DataRegion, 1), - Arrays.asList(new Endpoint("192.0.1.1", 9000), new Endpoint("192.0.1.2", 9000)))); + Arrays.asList(new DataNodeLocation(11, new Endpoint("192.0.1.1", 9000)), new DataNodeLocation(12, new Endpoint("192.0.1.2", 9000))))); d3DataRegions.add( new RegionReplicaSet( new ConsensusGroupId(GroupType.DataRegion, 4), - Arrays.asList(new Endpoint("192.0.4.1", 9000), new Endpoint("192.0.4.2", 9000)))); + Arrays.asList(new DataNodeLocation(41, new Endpoint("192.0.4.1", 9000)), new DataNodeLocation(42, new Endpoint("192.0.4.2", 9000))))); Map<TimePartitionSlot, List<RegionReplicaSet>> d3DataRegionMap = new HashMap<>(); d3DataRegionMap.put(new TimePartitionSlot(), d3DataRegions); @@ -79,9 +79,9 @@ public class FakePartitionFetcherImpl implements IPartitionFetcher { dataPartitionMap.put("root.sg", sgPartitionMap); - dataPartitionInfo.setDataPartitionMap(dataPartitionMap); + dataPartition.setDataPartitionMap(dataPartitionMap); - return dataPartitionInfo; + return dataPartition; } @Override diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/IPartitionFetcher.java b/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/IPartitionFetcher.java index 376b4cb..ad747f6 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/IPartitionFetcher.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/IPartitionFetcher.java @@ -18,7 +18,7 @@ */ package org.apache.iotdb.db.mpp.sql.analyze; -import org.apache.iotdb.commons.partition.DataPartitionInfo; +import org.apache.iotdb.commons.partition.DataPartition; import org.apache.iotdb.commons.partition.DataPartitionQueryParam; import org.apache.iotdb.commons.partition.PartitionInfo; import org.apache.iotdb.commons.partition.SchemaPartition; @@ -27,9 +27,9 @@ import java.util.List; public interface IPartitionFetcher { - DataPartitionInfo fetchDataPartitionInfo(DataPartitionQueryParam parameter); + DataPartition fetchDataPartitionInfo(DataPartitionQueryParam parameter); - DataPartitionInfo fetchDataPartitionInfos(List<DataPartitionQueryParam> parameterList); + DataPartition fetchDataPartitionInfos(List<DataPartitionQueryParam> parameterList); SchemaPartition fetchSchemaPartitionInfo(String devicePath); diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/StandalonePartitionFetcher.java b/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/StandalonePartitionFetcher.java index 56c898f..934a95b 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/StandalonePartitionFetcher.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/StandalonePartitionFetcher.java @@ -18,7 +18,7 @@ */ package org.apache.iotdb.db.mpp.sql.analyze; -import org.apache.iotdb.commons.partition.DataPartitionInfo; +import org.apache.iotdb.commons.partition.DataPartition; import org.apache.iotdb.commons.partition.DataPartitionQueryParam; import org.apache.iotdb.commons.partition.PartitionInfo; import org.apache.iotdb.commons.partition.SchemaPartition; @@ -35,12 +35,12 @@ public class StandalonePartitionFetcher implements IPartitionFetcher { } @Override - public DataPartitionInfo fetchDataPartitionInfo(DataPartitionQueryParam parameter) { + public DataPartition fetchDataPartitionInfo(DataPartitionQueryParam parameter) { return null; } @Override - public DataPartitionInfo fetchDataPartitionInfos(List<DataPartitionQueryParam> parameterList) { + public DataPartition fetchDataPartitionInfos(List<DataPartitionQueryParam> parameterList) { return null; } diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/SimpleFragmentParallelPlanner.java b/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/SimpleFragmentParallelPlanner.java index 08c9897..8e8b26b 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/SimpleFragmentParallelPlanner.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/SimpleFragmentParallelPlanner.java @@ -87,7 +87,7 @@ public class SimpleFragmentParallelPlanner implements IFragmentParallelPlaner { // TODO: (xingtanzjr) We select the first Endpoint as the default target host for current // instance - fragmentInstance.setHostEndpoint(dataRegion.getDataNodeList().get(0)); + fragmentInstance.setHostEndpoint(dataRegion.getDataNodeList().get(0).getEndPoint()); instanceMap.putIfAbsent(fragment.getId(), fragmentInstance); fragmentInstanceList.add(fragmentInstance); } diff --git a/server/src/test/java/org/apache/iotdb/db/mpp/sql/plan/DistributionPlannerTest.java b/server/src/test/java/org/apache/iotdb/db/mpp/sql/plan/DistributionPlannerTest.java index 5bbefb5..05dda1a 100644 --- a/server/src/test/java/org/apache/iotdb/db/mpp/sql/plan/DistributionPlannerTest.java +++ b/server/src/test/java/org/apache/iotdb/db/mpp/sql/plan/DistributionPlannerTest.java @@ -20,7 +20,8 @@ package org.apache.iotdb.db.mpp.sql.plan; import org.apache.iotdb.commons.partition.ConsensusGroupId; -import org.apache.iotdb.commons.partition.DataPartitionInfo; +import org.apache.iotdb.commons.partition.DataNodeLocation; +import org.apache.iotdb.commons.partition.DataPartition; import org.apache.iotdb.commons.partition.SeriesPartitionSlot; import org.apache.iotdb.commons.partition.Endpoint; import org.apache.iotdb.commons.partition.GroupType; @@ -161,7 +162,7 @@ public class DistributionPlannerTest { String device2 = "root.sg.d22"; String device3 = "root.sg.d333"; - DataPartitionInfo dataPartitionInfo = new DataPartitionInfo(); + DataPartition dataPartition = new DataPartition(); Map<String, Map<SeriesPartitionSlot, Map<TimePartitionSlot, List<RegionReplicaSet>>>> dataPartitionMap = new HashMap<>(); Map<SeriesPartitionSlot, Map<TimePartitionSlot, List<RegionReplicaSet>>> sgPartitionMap = @@ -171,11 +172,11 @@ public class DistributionPlannerTest { d1DataRegions.add( new RegionReplicaSet( new ConsensusGroupId(GroupType.DataRegion, 1), - Arrays.asList(new Endpoint("192.0.1.1", 9000), new Endpoint("192.0.1.2", 9000)))); + Arrays.asList(new DataNodeLocation(11, new Endpoint("192.0.1.1", 9000)), new DataNodeLocation(12, new Endpoint("192.0.1.2", 9000))))); d1DataRegions.add( new RegionReplicaSet( new ConsensusGroupId(GroupType.DataRegion, 2), - Arrays.asList(new Endpoint("192.0.2.1", 9000), new Endpoint("192.0.2.2", 9000)))); + Arrays.asList(new DataNodeLocation(21, new Endpoint("192.0.2.1", 9000)), new DataNodeLocation(22, new Endpoint("192.0.2.2", 9000))))); Map<TimePartitionSlot, List<RegionReplicaSet>> d1DataRegionMap = new HashMap<>(); d1DataRegionMap.put(new TimePartitionSlot(), d1DataRegions); @@ -183,7 +184,7 @@ public class DistributionPlannerTest { d2DataRegions.add( new RegionReplicaSet( new ConsensusGroupId(GroupType.DataRegion, 3), - Arrays.asList(new Endpoint("192.0.3.1", 9000), new Endpoint("192.0.3.2", 9000)))); + Arrays.asList(new DataNodeLocation(31, new Endpoint("192.0.3.1", 9000)), new DataNodeLocation(32, new Endpoint("192.0.3.2", 9000))))); Map<TimePartitionSlot, List<RegionReplicaSet>> d2DataRegionMap = new HashMap<>(); d2DataRegionMap.put(new TimePartitionSlot(), d2DataRegions); @@ -191,11 +192,11 @@ public class DistributionPlannerTest { d3DataRegions.add( new RegionReplicaSet( new ConsensusGroupId(GroupType.DataRegion, 1), - Arrays.asList(new Endpoint("192.0.1.1", 9000), new Endpoint("192.0.1.2", 9000)))); + Arrays.asList(new DataNodeLocation(11, new Endpoint("192.0.1.1", 9000)), new DataNodeLocation(12, new Endpoint("192.0.1.2", 9000))))); d3DataRegions.add( new RegionReplicaSet( new ConsensusGroupId(GroupType.DataRegion, 4), - Arrays.asList(new Endpoint("192.0.4.1", 9000), new Endpoint("192.0.4.2", 9000)))); + Arrays.asList(new DataNodeLocation(41, new Endpoint("192.0.4.1", 9000)), new DataNodeLocation(42, new Endpoint("192.0.4.2", 9000))))); Map<TimePartitionSlot, List<RegionReplicaSet>> d3DataRegionMap = new HashMap<>(); d3DataRegionMap.put(new TimePartitionSlot(), d3DataRegions); @@ -205,9 +206,9 @@ public class DistributionPlannerTest { dataPartitionMap.put("root.sg", sgPartitionMap); - dataPartitionInfo.setDataPartitionMap(dataPartitionMap); + dataPartition.setDataPartitionMap(dataPartitionMap); - analysis.setDataPartitionInfo(dataPartitionInfo); + analysis.setDataPartitionInfo(dataPartition); return analysis; } }
