You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/04/01 05:55:57 UTC
[GitHub] [iotdb] qiaojialin commented on a change in pull request #5374: [IOTDB-2684] refactoring confignode architecture and schema partition assign
qiaojialin commented on a change in pull request #5374:
URL: https://github.com/apache/iotdb/pull/5374#discussion_r840220832
##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/manager/Manager.java
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.confignode.manager;
+
+import org.apache.iotdb.confignode.physical.PhysicalPlan;
+import org.apache.iotdb.confignode.rpc.thrift.DeviceGroupHashInfo;
+import org.apache.iotdb.consensus.common.DataSet;
+import org.apache.iotdb.service.rpc.thrift.TSStatus;
+
+/**
+ * a subset of services provided by {@ConfigNodeManager}. For use internally only, pased to
Review comment:
```suggestion
* a subset of services provided by {@ConfigManager}. For use internally only, passed to
```
##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/manager/AssignRegionManager.java
##########
@@ -0,0 +1,152 @@
+/*
+ * 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.confignode.manager;
+
+import org.apache.iotdb.confignode.conf.ConfigNodeConf;
+import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
+import org.apache.iotdb.confignode.consensus.response.StorageGroupSchemaDataSet;
+import org.apache.iotdb.confignode.partition.DataRegionInfo;
+import org.apache.iotdb.confignode.partition.SchemaRegionInfo;
+import org.apache.iotdb.confignode.partition.StorageGroupSchema;
+import org.apache.iotdb.confignode.persistence.RegionInfoPersistence;
+import org.apache.iotdb.confignode.physical.sys.QueryStorageGroupSchemaPlan;
+import org.apache.iotdb.confignode.physical.sys.SetStorageGroupPlan;
+import org.apache.iotdb.consensus.common.response.ConsensusReadResponse;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.service.rpc.thrift.TSStatus;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/** manage data partition and schema partition */
+public class AssignRegionManager {
Review comment:
```suggestion
public class RegionManager {
```
Please keep consistent with our docs
##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/persistence/RegionInfoPersistence.java
##########
@@ -0,0 +1,188 @@
+/*
+ * 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.confignode.persistence;
+
+import org.apache.iotdb.commons.utils.TestOnly;
+import org.apache.iotdb.confignode.consensus.response.StorageGroupSchemaDataSet;
+import org.apache.iotdb.confignode.partition.DataRegionInfo;
+import org.apache.iotdb.confignode.partition.SchemaRegionInfo;
+import org.apache.iotdb.confignode.partition.SchemaRegionReplicaSet;
+import org.apache.iotdb.confignode.partition.StorageGroupSchema;
+import org.apache.iotdb.confignode.physical.sys.SetStorageGroupPlan;
+import org.apache.iotdb.consensus.common.Endpoint;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.service.rpc.thrift.TSStatus;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/** manage data partition and schema partition */
+public class RegionInfoPersistence {
+
+ /** partition read write lock */
+ private final ReentrantReadWriteLock partitionReadWriteLock;
+
+ // TODO: Serialize and Deserialize
+ private final Map<String, StorageGroupSchema> storageGroupsMap;
Review comment:
add javadoc
storage group -> StorageGroupSchema
##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/persistence/DataNodeInfoPersistence.java
##########
@@ -0,0 +1,186 @@
+/*
+ * 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.confignode.persistence;
+
+import org.apache.iotdb.commons.utils.TestOnly;
+import org.apache.iotdb.confignode.consensus.response.DataNodesInfoDataSet;
+import org.apache.iotdb.confignode.partition.DataNodeInfo;
+import org.apache.iotdb.confignode.physical.sys.QueryDataNodeInfoPlan;
+import org.apache.iotdb.confignode.physical.sys.RegisterDataNodePlan;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.service.rpc.thrift.TSStatus;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentNavigableMap;
+import java.util.concurrent.ConcurrentSkipListMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class DataNodeInfoPersistence {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DataNodeInfoPersistence.class);
+
+ /** online data nodes */
+ private final ConcurrentNavigableMap<Integer, DataNodeInfo> onlineDataNodes =
+ new ConcurrentSkipListMap();
+
+ /** For remove node or draining node */
+ private Set<DataNodeInfo> drainingDataNodes = new HashSet<>();
Review comment:
nodes that can not connect or be removed?
##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/partition/SchemaRegionInfo.java
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.confignode.partition;
+
+import org.apache.iotdb.confignode.util.SerializeDeserializeUtil;
+
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class SchemaRegionInfo {
Review comment:
could this be used in SchemaPartitionInfo?
##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/partition/SchemaRegionInfo.java
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.confignode.partition;
+
+import org.apache.iotdb.confignode.util.SerializeDeserializeUtil;
+
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class SchemaRegionInfo {
+
+ // TODO: Serialize and Deserialize
+ // Map<SchemaRegionID, List<DataNodeID>>
+ private Map<Integer, List<Integer>> schemaRegionDataNodesMap;
+
+ public SchemaRegionInfo() {
+ this.schemaRegionDataNodesMap = new HashMap<>();
+ }
+
+ public void createSchemaRegion(int schemaRegion, List<Integer> dataNode) {
Review comment:
addSchemaRegion
##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/partition/SchemaRegionInfo.java
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.confignode.partition;
+
+import org.apache.iotdb.confignode.util.SerializeDeserializeUtil;
+
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class SchemaRegionInfo {
Review comment:
Besides, this class is duplicated with SchemaRegionReplicaSet?
##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/persistence/RegionInfoPersistence.java
##########
@@ -0,0 +1,188 @@
+/*
+ * 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.confignode.persistence;
+
+import org.apache.iotdb.commons.utils.TestOnly;
+import org.apache.iotdb.confignode.consensus.response.StorageGroupSchemaDataSet;
+import org.apache.iotdb.confignode.partition.DataRegionInfo;
+import org.apache.iotdb.confignode.partition.SchemaRegionInfo;
+import org.apache.iotdb.confignode.partition.SchemaRegionReplicaSet;
+import org.apache.iotdb.confignode.partition.StorageGroupSchema;
+import org.apache.iotdb.confignode.physical.sys.SetStorageGroupPlan;
+import org.apache.iotdb.consensus.common.Endpoint;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.service.rpc.thrift.TSStatus;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/** manage data partition and schema partition */
+public class RegionInfoPersistence {
+
+ /** partition read write lock */
+ private final ReentrantReadWriteLock partitionReadWriteLock;
+
+ // TODO: Serialize and Deserialize
+ private final Map<String, StorageGroupSchema> storageGroupsMap;
+
+ // TODO: Serialize and Deserialize
+ private int nextSchemaRegionGroup = 0;
+ // TODO: Serialize and Deserialize
+ private int nextDataRegionGroup = 0;
+
+ // TODO: Serialize and Deserialize
+ private final SchemaRegionInfo schemaRegion;
+
+ // TODO: Serialize and Deserialize
+ private final DataRegionInfo dataRegion;
+
+ public RegionInfoPersistence() {
+ this.partitionReadWriteLock = new ReentrantReadWriteLock();
+ this.storageGroupsMap = new HashMap<>();
+ this.schemaRegion = new SchemaRegionInfo();
+ this.dataRegion = new DataRegionInfo();
+ }
+
+ /**
+ * 1. region allocation 2. add to storage group map
+ *
+ * @param plan SetStorageGroupPlan
+ * @return TSStatusCode.SUCCESS_STATUS if region allocate
+ */
+ public TSStatus setStorageGroup(SetStorageGroupPlan plan) {
+ TSStatus result;
+ partitionReadWriteLock.writeLock().lock();
+ try {
+ if (storageGroupsMap.containsKey(plan.getSchema().getName())) {
+ result = new TSStatus(TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode());
+ result.setMessage(
+ String.format("StorageGroup %s is already set.", plan.getSchema().getName()));
+ } else {
+ StorageGroupSchema schema = new StorageGroupSchema(plan.getSchema().getName());
+ storageGroupsMap.put(schema.getName(), schema);
+
+ plan.getSchemaRegionInfo()
+ .getSchemaRegionDataNodesMap()
+ .entrySet()
+ .forEach(
+ entity -> {
+ schemaRegion.createSchemaRegion(entity.getKey(), entity.getValue());
+ entity
+ .getValue()
+ .forEach(
+ dataNodeId -> {
+ DataNodeInfoPersistence.getInstance()
+ .addSchemaRegionGroup(dataNodeId, entity.getKey());
+ });
+ });
+
+ plan.getDataRegionInfo()
+ .getDataRegionDataNodesMap()
+ .entrySet()
+ .forEach(
+ entity -> {
+ dataRegion.createDataRegion(entity.getKey(), entity.getValue());
+ entity
+ .getValue()
+ .forEach(
+ dataNodeId -> {
+ DataNodeInfoPersistence.getInstance()
+ .addDataRegionGroup(dataNodeId, entity.getKey());
+ });
+ });
+
+ result = new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
+ }
+ } finally {
+ partitionReadWriteLock.writeLock().unlock();
+ }
+ return result;
+ }
+
+ public StorageGroupSchemaDataSet getStorageGroupSchema() {
+ StorageGroupSchemaDataSet result = new StorageGroupSchemaDataSet();
+ partitionReadWriteLock.readLock().lock();
+ try {
+ result.setSchemaList(new ArrayList<>(storageGroupsMap.values()));
+ } finally {
+ partitionReadWriteLock.readLock().unlock();
+ }
+ return result;
+ }
+
+ /** @return key is schema region id, value is endpoint list */
+ public List<SchemaRegionReplicaSet> getSchemaRegionEndPoint() {
+ List<SchemaRegionReplicaSet> schemaRegionEndPoints = new ArrayList<>();
+
+ schemaRegion
+ .getSchemaRegionDataNodesMap()
+ .entrySet()
+ .forEach(
+ entity -> {
+ SchemaRegionReplicaSet schemaRegionReplicaSet = new SchemaRegionReplicaSet();
+ List<Endpoint> endPoints = new ArrayList<>();
+ entity
+ .getValue()
+ .forEach(
+ dataNodeId -> {
+ if (DataNodeInfoPersistence.getInstance()
+ .getOnlineDataNodes()
+ .containsKey(dataNodeId)) {
+ endPoints.add(
+ DataNodeInfoPersistence.getInstance()
+ .getOnlineDataNodes()
+ .get(dataNodeId)
+ .getEndPoint());
+ }
+ });
+ schemaRegionReplicaSet.setSchemaRegionId(entity.getKey());
+ schemaRegionReplicaSet.setEndPointList(endPoints);
+ schemaRegionEndPoints.add(schemaRegionReplicaSet);
+ });
+ return schemaRegionEndPoints;
+ }
+
+ public boolean containsKey(String storageName) {
Review comment:
```suggestion
public boolean containsStorageGroup(String storageName) {
```
##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/partition/SchemaRegionReplicaSet.java
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.confignode.partition;
+
+import org.apache.iotdb.consensus.common.Endpoint;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+public class SchemaRegionReplicaSet {
Review comment:
This is dueplicated with SchemaRegionReplicaSet in iotdb-commons
##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/physical/sys/SetStorageGroupPlan.java
##########
@@ -28,6 +30,10 @@
private StorageGroupSchema schema;
+ private SchemaRegionInfo schemaRegionInfo;
+
+ private DataRegionInfo dataRegionInfo;
Review comment:
These two Infos seem not belong to this plan...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org