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/02 06:15:15 UTC

[GitHub] [iotdb] wangchao316 commented on a change in pull request #5403: [IOTDB-2803] Implement create timeseries metadata operation through consensus layer in MPP framework

wangchao316 commented on a change in pull request #5403:
URL: https://github.com/apache/iotdb/pull/5403#discussion_r841008478



##########
File path: node-commons/src/main/java/org/apache/iotdb/commons/partition/RegionReplicaSet.java
##########
@@ -0,0 +1,68 @@
+package org.apache.iotdb.commons.partition;
+
+import org.apache.iotdb.consensus.common.ConsensusGroupId;
+import org.apache.iotdb.consensus.common.Endpoint;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+public class RegionReplicaSet {

Review comment:
       This class already exists in another pr.

##########
File path: server/src/main/java/org/apache/iotdb/db/consensus/statemachine/SchemaRegionStateMachine.java
##########
@@ -40,7 +62,26 @@ public void stop() {}
   @Override
   protected TSStatus write(FragmentInstance fragmentInstance) {
     logger.info("Execute write plan in SchemaRegionStateMachine : {}", fragmentInstance);
-    return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
+    // Take create Timeseries as an example
+    PlanNode planNode = fragmentInstance.getFragment().getRoot();
+    // TODO transfer to physicalplan as a tentative plan
+    PhysicalPlan physicalPlan = planNode.transferToPhysicalPlan();
+    return write(physicalPlan);
+  }
+
+  protected TSStatus write(PhysicalPlan plan) {
+    boolean isSuccessful;
+    try {
+      isSuccessful = executor.processNonQuery(plan);
+    } catch (QueryProcessException e) {
+      return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());

Review comment:
       add log.error

##########
File path: node-commons/pom.xml
##########
@@ -51,6 +51,12 @@
             <artifactId>guava</artifactId>
             <version>[${guava.version},)</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.iotdb</groupId>
+            <artifactId>iotdb-consensus</artifactId>
+            <version>0.14.0-SNAPSHOT</version>

Review comment:
       The node does not depend on the Consensus.

##########
File path: server/src/main/java/org/apache/iotdb/db/consensus/statemachine/SchemaRegionStateMachine.java
##########
@@ -31,6 +39,20 @@
 
   private static final Logger logger = LoggerFactory.getLogger(SchemaRegionStateMachine.class);
 
+  private PlanExecutor executor;
+
+  public SchemaRegionStateMachine() {
+    try {
+      executor = new PlanExecutor();
+    } catch (QueryProcessException e) {
+      if (e.getErrorCode() != TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()) {
+        logger.debug("Meet error while processing non-query.", e);
+      } else {
+        logger.warn("Meet error while processing non-query. ", e);

Review comment:
       why ?

##########
File path: consensus/src/main/java/org/apache/iotdb/consensus/common/ConsensusGroupId.java
##########
@@ -61,4 +62,13 @@ public int hashCode() {
   public String toString() {
     return "ConsensusGroupId{" + "type=" + type + ", id=" + id + '}';
   }
+
+  public void serialize(ByteBuffer byteBuffer) {
+    byteBuffer.putInt(type.ordinal());
+    byteBuffer.putLong(id);
+  }
+
+  public static ConsensusGroupId deserialize(ByteBuffer byteBuffer) {
+    return new ConsensusGroupId(GroupType.values()[byteBuffer.getInt()], byteBuffer.getLong());

Review comment:
       this class moved to commons




-- 
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