You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ne...@apache.org on 2021/03/01 12:20:31 UTC

[iotdb] branch optimize_get_failstatus_and_reduce_debug_log created (now 5268724)

This is an automated email from the ASF dual-hosted git repository.

neuyilan pushed a change to branch optimize_get_failstatus_and_reduce_debug_log
in repository https://gitbox.apache.org/repos/asf/iotdb.git.


      at 5268724  optimize the get fail status codes & reduce the output of the debug log

This branch includes the following new commits:

     new 5268724  optimize the get fail status codes & reduce the output of the debug log

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: optimize the get fail status codes & reduce the output of the debug log

Posted by ne...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

neuyilan pushed a commit to branch optimize_get_failstatus_and_reduce_debug_log
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 52687241bee29f58dc4e1ac0cfdb2c33ad845ee0
Author: HouliangQi <ne...@163.com>
AuthorDate: Mon Mar 1 20:19:48 2021 +0800

    optimize the get fail status codes & reduce the output of the debug log
---
 .../apache/iotdb/db/qp/executor/PlanExecutor.java  |  9 ++---
 .../iotdb/db/qp/physical/crud/InsertRowsPlan.java  | 13 ++++---
 .../qp/physical/sys/CreateMultiTimeSeriesPlan.java | 13 ++-----
 .../db/qp/physical/sys/DeleteTimeSeriesPlan.java   | 13 ++-----
 .../org/apache/iotdb/db/service/TSServiceImpl.java | 19 +++++-----
 .../org/apache/iotdb/db/utils/StatusUtils.java     | 40 ++++++++++++++++++++++
 6 files changed, 65 insertions(+), 42 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
index 89f77cf..f0a28a5 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
@@ -122,7 +122,6 @@ import org.apache.iotdb.db.utils.FileLoaderUtils;
 import org.apache.iotdb.db.utils.UpgradeUtils;
 import org.apache.iotdb.rpc.RpcUtils;
 import org.apache.iotdb.rpc.TSStatusCode;
-import org.apache.iotdb.service.rpc.thrift.TSStatus;
 import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
 import org.apache.iotdb.tsfile.exception.filter.QueryFilterOptimizationException;
 import org.apache.iotdb.tsfile.file.metadata.ChunkGroupMetadata;
@@ -1181,21 +1180,17 @@ public class PlanExecutor implements IPlanExecutor {
 
   @Override
   public void insert(InsertRowsPlan plan) throws QueryProcessException {
-    boolean allSuccess = true;
     for (int i = 0; i < plan.getInsertRowPlanList().size(); i++) {
       if (plan.getResults().containsKey(i)) {
-        allSuccess = false;
         continue;
       }
       try {
         insert(plan.getInsertRowPlanList().get(i));
-        plan.getResults().put(i, RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
       } catch (QueryProcessException e) {
         plan.getResults().put(i, RpcUtils.getStatus(e.getErrorCode(), e.getMessage()));
-        allSuccess = false;
       }
-      if (!allSuccess) {
-        throw new BatchProcessException(plan.getResults().values().toArray(new TSStatus[0]));
+      if (!plan.getResults().isEmpty()) {
+        throw new BatchProcessException(plan.getFailingStatus());
       }
     }
   }
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertRowsPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertRowsPlan.java
index 5e2f484..cdd35ab 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertRowsPlan.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertRowsPlan.java
@@ -22,6 +22,7 @@ import org.apache.iotdb.db.exception.metadata.IllegalPathException;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.metadata.PartialPath;
 import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
+import org.apache.iotdb.db.utils.StatusUtils;
 import org.apache.iotdb.service.rpc.thrift.TSStatus;
 
 import java.io.DataOutputStream;
@@ -208,12 +209,16 @@ public class InsertRowsPlan extends InsertPlan {
   @Override
   public String toString() {
     return "InsertRowsPlan{"
-        + " insertRowPlanIndexList="
-        + insertRowPlanIndexList
-        + ", insertRowPlanList="
-        + insertRowPlanList
+        + " insertRowPlanIndexList's size="
+        + insertRowPlanIndexList.size()
+        + ", insertRowPlanList's size="
+        + insertRowPlanList.size()
         + ", results="
         + results
         + "}";
   }
+
+  public TSStatus[] getFailingStatus() {
+    return StatusUtils.getFailingStatus(results, insertRowPlanList.size());
+  }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/CreateMultiTimeSeriesPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/CreateMultiTimeSeriesPlan.java
index f3f354d..9ebc54b 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/CreateMultiTimeSeriesPlan.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/CreateMultiTimeSeriesPlan.java
@@ -22,7 +22,7 @@ import org.apache.iotdb.db.exception.metadata.IllegalPathException;
 import org.apache.iotdb.db.metadata.PartialPath;
 import org.apache.iotdb.db.qp.logical.Operator;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.rpc.RpcUtils;
+import org.apache.iotdb.db.utils.StatusUtils;
 import org.apache.iotdb.service.rpc.thrift.TSStatus;
 import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
@@ -33,7 +33,6 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -141,15 +140,7 @@ public class CreateMultiTimeSeriesPlan extends PhysicalPlan {
   }
 
   public TSStatus[] getFailingStatus() {
-    if (results.isEmpty()) {
-      return new TSStatus[0];
-    }
-    TSStatus[] failingStatus = new TSStatus[paths.size()];
-    Arrays.fill(failingStatus, RpcUtils.SUCCESS_STATUS);
-    for (Map.Entry<Integer, TSStatus> status : results.entrySet()) {
-      failingStatus[status.getKey()] = status.getValue();
-    }
-    return failingStatus;
+    return StatusUtils.getFailingStatus(results, paths.size());
   }
 
   public void setResults(Map<Integer, TSStatus> results) {
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/DeleteTimeSeriesPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/DeleteTimeSeriesPlan.java
index 20af1ea..d0b1677 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/DeleteTimeSeriesPlan.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/DeleteTimeSeriesPlan.java
@@ -22,14 +22,13 @@ import org.apache.iotdb.db.exception.metadata.IllegalPathException;
 import org.apache.iotdb.db.metadata.PartialPath;
 import org.apache.iotdb.db.qp.logical.Operator;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.rpc.RpcUtils;
+import org.apache.iotdb.db.utils.StatusUtils;
 import org.apache.iotdb.service.rpc.thrift.TSStatus;
 
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
@@ -102,14 +101,6 @@ public class DeleteTimeSeriesPlan extends PhysicalPlan {
   }
 
   public TSStatus[] getFailingStatus() {
-    if (results.isEmpty()) {
-      return new TSStatus[0];
-    }
-    TSStatus[] failingStatus = new TSStatus[deletePathList.size()];
-    Arrays.fill(failingStatus, RpcUtils.SUCCESS_STATUS);
-    for (Map.Entry<Integer, TSStatus> status : results.entrySet()) {
-      failingStatus[status.getKey()] = status.getValue();
-    }
-    return failingStatus;
+    return StatusUtils.getFailingStatus(results, deletePathList.size());
   }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index 60feccf..d2757af 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -1143,7 +1143,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
           req.deviceIds.get(0),
           req.getTimestamps().get(0));
     }
-    boolean allSuccess = true;
+    boolean checkAllSuccess = true;
     InsertRowsPlan insertRowsPlan = new InsertRowsPlan();
     for (int i = 0; i < req.deviceIds.size(); i++) {
       try {
@@ -1156,11 +1156,11 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         TSStatus status = checkAuthority(plan, req.getSessionId());
         if (status != null) {
           insertRowsPlan.getResults().put(i, status);
-          allSuccess = false;
+          checkAllSuccess = false;
         }
         insertRowsPlan.addOneInsertRowPlan(plan, i);
       } catch (Exception e) {
-        allSuccess = false;
+        checkAllSuccess = false;
         insertRowsPlan
             .getResults()
             .put(
@@ -1172,16 +1172,16 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
     TSStatus tsStatus = executeNonQueryPlan(insertRowsPlan);
 
     return judgeFinalTsStatus(
-        allSuccess, tsStatus, insertRowsPlan.getResults(), req.deviceIds.size());
+        checkAllSuccess, tsStatus, insertRowsPlan.getResults(), req.deviceIds.size());
   }
 
   private TSStatus judgeFinalTsStatus(
-      boolean allSuccess,
+      boolean checkAllSuccess,
       TSStatus executeTsStatus,
       Map<Integer, TSStatus> checkTsStatus,
       int totalRowCount) {
 
-    if (allSuccess) {
+    if (checkAllSuccess) {
       return executeTsStatus;
     }
 
@@ -1252,7 +1252,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
           req.getTimestamps().get(0));
     }
 
-    boolean allSuccess = true;
+    boolean allCheckSuccess = true;
     InsertRowsPlan insertRowsPlan = new InsertRowsPlan();
     for (int i = 0; i < req.deviceIds.size(); i++) {
       InsertRowPlan plan = new InsertRowPlan();
@@ -1266,6 +1266,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         TSStatus status = checkAuthority(plan, req.getSessionId());
         if (status != null) {
           insertRowsPlan.getResults().put(i, status);
+          allCheckSuccess = false;
         }
         insertRowsPlan.addOneInsertRowPlan(plan, i);
       } catch (Exception e) {
@@ -1275,13 +1276,13 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
                 i,
                 onNPEOrUnexpectedException(
                     e, "inserting string records", TSStatusCode.INTERNAL_SERVER_ERROR));
-        allSuccess = false;
+        allCheckSuccess = false;
       }
     }
     TSStatus tsStatus = executeNonQueryPlan(insertRowsPlan);
 
     return judgeFinalTsStatus(
-        allSuccess, tsStatus, insertRowsPlan.getResults(), req.deviceIds.size());
+        allCheckSuccess, tsStatus, insertRowsPlan.getResults(), req.deviceIds.size());
   }
 
   @Override
diff --git a/server/src/main/java/org/apache/iotdb/db/utils/StatusUtils.java b/server/src/main/java/org/apache/iotdb/db/utils/StatusUtils.java
new file mode 100644
index 0000000..f292b35
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/utils/StatusUtils.java
@@ -0,0 +1,40 @@
+/*
+ * 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.db.utils;
+
+import org.apache.iotdb.rpc.RpcUtils;
+import org.apache.iotdb.service.rpc.thrift.TSStatus;
+
+import java.util.Arrays;
+import java.util.Map;
+
+public class StatusUtils {
+  public static TSStatus[] getFailingStatus(Map<Integer, TSStatus> statusMap, int size) {
+    if (statusMap == null || statusMap.isEmpty()) {
+      return new TSStatus[0];
+    }
+    TSStatus[] failingStatus = new TSStatus[size];
+    Arrays.fill(failingStatus, RpcUtils.SUCCESS_STATUS);
+    for (Map.Entry<Integer, TSStatus> status : statusMap.entrySet()) {
+      failingStatus[status.getKey()] = status.getValue();
+    }
+    return failingStatus;
+  }
+}