You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2020/11/13 01:40:16 UTC

[iotdb] branch master updated: fix

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 3dd4dc6  fix
     new a5af774  Merge pull request #2021 from LebronAl/fix_tsServiceImpl_response
3dd4dc6 is described below

commit 3dd4dc6540a9cab67cec9fc0d82213cdbd27ee21
Author: LebronAl <TX...@gmail.com>
AuthorDate: Wed Nov 11 18:00:43 2020 +0800

    fix
---
 .../org/apache/iotdb/db/service/TSServiceImpl.java | 67 +++++++++++++++-------
 1 file changed, 45 insertions(+), 22 deletions(-)

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 34f0588..9a55444 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
@@ -753,14 +753,16 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       Measurement.INSTANCE.addOperationLatency(Operation.EXECUTE_QUERY, startTime);
       long costTime = System.currentTimeMillis() - startTime;
       if (costTime >= config.getSlowQueryThreshold()) {
-        SLOW_SQL_LOGGER.info("Cost: " + costTime + " ms, sql is " + statement);
+        SLOW_SQL_LOGGER.info("Cost: {} ms, sql is {}", costTime, statement);
       }
       if (config.isDebugOn()) {
-        SLOW_SQL_LOGGER.info("ChunkCache used memory proportion: " + ChunkCache.getInstance()
-            .getUsedMemoryProportion() + "\nChunkMetadataCache used memory proportion: "
-            + ChunkMetadataCache.getInstance().getUsedMemoryProportion()
-            + "\nTimeSeriesMetadataCache used memory proportion: " + TimeSeriesMetadataCache
-            .getInstance().getUsedMemoryProportion());
+        SLOW_SQL_LOGGER.info(
+            "ChunkCache used memory proportion: {}\nChunkMetadataCache used memory proportion: {}\n"
+                + "TimeSeriesMetadataCache used memory proportion: {}",
+            ChunkCache.getInstance()
+                .getUsedMemoryProportion(),
+            ChunkMetadataCache.getInstance().getUsedMemoryProportion(), TimeSeriesMetadataCache
+                .getInstance().getUsedMemoryProportion());
       }
     }
   }
@@ -1253,6 +1255,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
 
     List<TSStatus> statusList = new ArrayList<>();
     InsertRowPlan plan = new InsertRowPlan();
+    boolean isAllSuccessful = true;
     for (int i = 0; i < req.deviceIds.size(); i++) {
       try {
         plan.setDeviceId(new PartialPath(req.getDeviceIds().get(i)));
@@ -1263,18 +1266,25 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         plan.fillValues(req.valuesList.get(i));
         plan.setNeedInferType(false);
         TSStatus status = checkAuthority(plan, req.getSessionId());
-        if (status != null) {
-          statusList.add(status);
-        } else {
-          statusList.add(executeNonQueryPlan(plan));
+        if (status == null) {
+          status = executeNonQueryPlan(plan);
+          isAllSuccessful =
+              ((status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode())
+                  && isAllSuccessful);
         }
+        statusList.add(status);
       } catch (Exception e) {
         logger.error("meet error when insert in batch", e);
+        isAllSuccessful = false;
         statusList.add(RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR));
       }
     }
 
-    return RpcUtils.getStatus(statusList);
+    if (!isAllSuccessful) {
+      return RpcUtils.getStatus(statusList);
+    }
+
+    return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
   }
 
   @Override
@@ -1291,6 +1301,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
 
     List<TSStatus> statusList = new ArrayList<>();
     InsertRowPlan plan = new InsertRowPlan();
+    boolean isAllSuccessful = true;
     for (int i = 0; i < req.deviceIds.size(); i++) {
       try {
         plan.setDeviceId(new PartialPath(req.getDeviceIds().get(i)));
@@ -1301,18 +1312,25 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
             req.getValuesList().get(i).toArray(new Object[req.getValuesList().get(i).size()]));
         plan.setNeedInferType(true);
         TSStatus status = checkAuthority(plan, req.getSessionId());
-        if (status != null) {
-          statusList.add(status);
-        } else {
-          statusList.add(executeNonQueryPlan(plan));
+        if (status == null) {
+          status = executeNonQueryPlan(plan);
+          isAllSuccessful =
+              ((status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode())
+                  && isAllSuccessful);
         }
+        statusList.add(status);
       } catch (Exception e) {
         logger.error("meet error when insert in batch", e);
+        isAllSuccessful = false;
         statusList.add(RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR));
       }
     }
 
-    return RpcUtils.getStatus(statusList);
+    if (!isAllSuccessful) {
+      return RpcUtils.getStatus(statusList);
+    }
+
+    return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
   }
 
   @Override
@@ -1483,6 +1501,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       }
 
       List<TSStatus> statusList = new ArrayList<>();
+      boolean isAllSuccessful = true;
       for (int i = 0; i < req.deviceIds.size(); i++) {
         InsertTabletPlan insertTabletPlan = new InsertTabletPlan(
             new PartialPath(req.deviceIds.get(i)),
@@ -1497,14 +1516,18 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         insertTabletPlan.setDataTypes(req.typesList.get(i));
 
         TSStatus status = checkAuthority(insertTabletPlan, req.getSessionId());
-        if (status != null) {
-          statusList.add(status);
-          continue;
+        if (status == null) {
+          status = executeNonQueryPlan(insertTabletPlan);
+          isAllSuccessful =
+              ((status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode())
+                  && isAllSuccessful);
         }
-
-        statusList.add(executeNonQueryPlan(insertTabletPlan));
+        statusList.add(status);
       }
-      return RpcUtils.getStatus(statusList);
+      if (!isAllSuccessful) {
+        return RpcUtils.getStatus(statusList);
+      }
+      return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
     } catch (Exception e) {
       logger.error("{}: error occurs when insertTablets", IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils