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 2020/06/23 02:09:46 UTC

[GitHub] [incubator-iotdb] jt2594838 commented on a change in pull request #1387: [IOTDB-709] Create schema automatically

jt2594838 commented on a change in pull request #1387:
URL: https://github.com/apache/incubator-iotdb/pull/1387#discussion_r443916570



##########
File path: cluster/src/main/java/org/apache/iotdb/cluster/server/member/DataGroupMember.java
##########
@@ -1073,7 +1072,12 @@ public void pullTimeSeriesSchema(PullSchemaRequest request,
 
   /**
    * Create an IPointReader of "path" with “timeFilter” and "valueFilter". A synchronization with
+<<<<<<< HEAD
+   * the leader will be performed first to preserve strong consistency. TODO-Cluster: also support
+   * weak consistency
+=======
    * the leader will be performed according to consistency level
+>>>>>>> origin/cluster_new

Review comment:
       Please resolve the conflicts.

##########
File path: cluster/src/main/java/org/apache/iotdb/cluster/server/member/DataGroupMember.java
##########
@@ -1610,6 +1623,34 @@ public void getAggrResult(GetAggrResultRequest request,
     resultHandler.onComplete(resultBuffers);
   }
 
+  /**
+   * Check if the given measurements are registered or not
+   * @param header
+   * @param timeseriesList
+   * @param resultHandler
+   * @throws TException
+   */
+  @Override
+  public void getUnregisteredTimeseries(Node header, List<String> timeseriesList,
+      AsyncMethodCallback<List<String>> resultHandler) throws TException {
+    if (!syncLeader()) {

Review comment:
       I think there is a method `syncLeaderWithConsistencyCheck` now, and that one should be used.

##########
File path: cluster/src/main/java/org/apache/iotdb/cluster/server/member/MetaGroupMember.java
##########
@@ -1530,9 +1544,29 @@ private TSStatus processPartitionedPlan(PhysicalPlan plan) throws UnsupportedPla
     } catch (MetadataException e) {
       logger.error("Cannot route plan {}", plan, e);
     }
-    // the storage group is not found locally, forward it to the leader
+    // the storage group is not found locally
     if (planGroupMap == null || planGroupMap.isEmpty()) {
-      logger.debug("{}: Cannot found storage groups for {}", name, plan);
+      if (plan instanceof InsertPlan && ClusterDescriptor.getInstance().getConfig()
+          .isEnableAutoCreateSchema()) {
+        // try to set storage group
+        String deviceId = ((InsertPlan) plan).getDeviceId();
+        try {
+          String storageGroupName = MetaUtils
+              .getStorageGroupNameByLevel(deviceId, IoTDBDescriptor.getInstance()
+                  .getConfig().getDefaultStorageGroupLevel());
+          SetStorageGroupPlan setStorageGroupPlan = new SetStorageGroupPlan(
+              new Path(storageGroupName));
+          TSStatus setStorageGroupResult = executeNonQuery(setStorageGroupPlan);
+          if (setStorageGroupResult.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+            throw new MetadataException("Failed to set storage group " + storageGroupName);

Review comment:
       Report the status code and its message in the exception.

##########
File path: cluster/src/main/java/org/apache/iotdb/cluster/server/member/DataGroupMember.java
##########
@@ -1610,6 +1623,34 @@ public void getAggrResult(GetAggrResultRequest request,
     resultHandler.onComplete(resultBuffers);
   }
 
+  /**
+   * Check if the given measurements are registered or not
+   * @param header
+   * @param timeseriesList
+   * @param resultHandler
+   * @throws TException
+   */
+  @Override
+  public void getUnregisteredTimeseries(Node header, List<String> timeseriesList,
+      AsyncMethodCallback<List<String>> resultHandler) throws TException {
+    if (!syncLeader()) {
+      resultHandler.onError(new LeaderUnknownException(getAllNodes()));
+      return;
+    }
+    List<String> result = new ArrayList<>();
+    for (String seriesPath : timeseriesList) {
+      try {
+        List<String> path = MManager.getInstance().getAllTimeseriesName(seriesPath);
+        if (path.size() != 1) {
+          throw new MetadataException("Size of the path is not 1.");

Review comment:
       Better add the seriesPath which triggers the exception into the message.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org