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 03:33:03 UTC

[iotdb] branch add_missing_message created (now bfd1d62)

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

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


      at bfd1d62  code refinement

This branch includes the following new commits:

     new 555467f  add missing error message
     new bfd1d62  code refinement

The 2 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] 02/02: code refinement

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

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

commit bfd1d62a1e943811d9e3dcdbc532ddcff80443cd
Author: jt <jt...@163.com>
AuthorDate: Fri Nov 13 11:31:49 2020 +0800

    code refinement
---
 .../org/apache/iotdb/db/service/TSServiceImpl.java | 67 ++++++++++------------
 1 file changed, 29 insertions(+), 38 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 b1c76b1..983d284 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
@@ -156,6 +156,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       IoTDBDescriptor.getInstance().getConfig().getQueryCacheSizeInMetric();
   private static final int DELETE_SIZE = 20;
   private static final int DEFAULT_FETCH_SIZE = 10000;
+  private static final String ERROR_EXECUTING_SQL =
+      "meet error while executing physical plan: {}";
   private static final String ERROR_PARSING_SQL =
       "meet error while parsing SQL to physical plan: {}";
   private static final String SERVER_INTERNAL_ERROR = "{}: server Internal Error: ";
@@ -201,7 +203,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         .newSingleThreadScheduledExecutor(r -> new Thread(r, "timedQuerySqlCountThread"));
     timedQuerySqlCountThread.scheduleAtFixedRate(() -> {
           if (queryCount.get() != 0) {
-            QUERY_FREQUENCY_LOGGER.info("Query count in current 1 minute: " + queryCount.getAndSet(0));
+            QUERY_FREQUENCY_LOGGER.info("Query count in current 1 minute: {}",
+                queryCount.getAndSet(0));
           }
         },
         config.getFrequencyIntervalInMinute(), config.getFrequencyIntervalInMinute(),
@@ -541,15 +544,9 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       }
 
       String statement = req.getStatement();
-      PhysicalPlan physicalPlan;
-      try {
-        physicalPlan = processor
-            .parseSQLToPhysicalPlan(statement, sessionIdZoneIdMap.get(req.getSessionId()),
-                req.fetchSize);
-      } catch (QueryProcessException | SQLParserException e) {
-        logger.info(ERROR_PARSING_SQL, req.getStatement() + " " + e.getMessage());
-        return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR, e.getMessage());
-      }
+      PhysicalPlan  physicalPlan = processor
+          .parseSQLToPhysicalPlan(statement, sessionIdZoneIdMap.get(req.getSessionId()),
+              req.fetchSize);
 
       if (!physicalPlan.isQuery()) {
         return RpcUtils.getTSExecuteStatementResp(
@@ -564,9 +561,11 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR,
           ERROR_PARSING_SQL + e.getMessage());
     } catch (SQLParserException e) {
-      logger.error(CHECK_METADATA_ERROR, e);
-      return RpcUtils.getTSExecuteStatementResp(
-          TSStatusCode.METADATA_ERROR, CHECK_METADATA_ERROR + e.getMessage());
+      logger.info(ERROR_PARSING_SQL, req.getStatement() + " " + e.getMessage());
+      return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR, e.getMessage());
+    } catch (QueryProcessException e) {
+      logger.info(ERROR_EXECUTING_SQL, e.getMessage());
+      return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR, e.getMessage());
     } catch (Exception e) {
       logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils.getTSExecuteStatementResp(
@@ -582,14 +581,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         return RpcUtils.getTSExecuteStatementResp(TSStatusCode.NOT_LOGIN_ERROR);
       }
 
-      PhysicalPlan physicalPlan;
-      try {
-        physicalPlan =
-            processor.rawDataQueryReqToPhysicalPlan(req);
-      } catch (QueryProcessException | SQLParserException e) {
-        logger.info(ERROR_PARSING_SQL, e.getMessage());
-        return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR, e.getMessage());
-      }
+      PhysicalPlan physicalPlan =
+          processor.rawDataQueryReqToPhysicalPlan(req);
 
       if (!physicalPlan.isQuery()) {
         return RpcUtils.getTSExecuteStatementResp(
@@ -602,11 +595,13 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
     } catch (ParseCancellationException e) {
       logger.warn(ERROR_PARSING_SQL, e.getMessage());
       return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR,
-          ERROR_PARSING_SQL + e.getMessage());
+          e.getMessage());
     } catch (SQLParserException e) {
-      logger.error(CHECK_METADATA_ERROR, e);
-      return RpcUtils.getTSExecuteStatementResp(
-          TSStatusCode.METADATA_ERROR, CHECK_METADATA_ERROR + e.getMessage());
+      logger.info(ERROR_PARSING_SQL, e.getMessage());
+      return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR, e.getMessage());
+    } catch (QueryProcessException e) {
+      logger.info(ERROR_EXECUTING_SQL, e.getMessage());
+      return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR, e.getMessage());
     } catch (Exception e) {
       logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils.getTSExecuteStatementResp(
@@ -620,7 +615,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
    */
   @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning
   private TSExecuteStatementResp internalExecuteQueryStatement(String statement,
-      long statementId, PhysicalPlan plan, int fetchSize, String username) throws IOException {
+      long statementId, PhysicalPlan plan, int fetchSize, String username) {
     queryCount.incrementAndGet();
     auditLogger.debug("Session {} execute Query: {}", currSessionId.get(), statement);
     long startTime = System.currentTimeMillis();
@@ -738,9 +733,6 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       return resp;
     } catch (Exception e) {
       logger.error("{}: Internal server error: ", IoTDBConstant.GLOBAL_DB_NAME, e);
-      if (e instanceof NullPointerException) {
-        e.printStackTrace();
-      }
       if (queryId != -1) {
         try {
           releaseQueryResource(queryId);
@@ -955,7 +947,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
           break;
         case NonExist:
         case Constant:
-          type = TSDataType.TEXT;
+          break;
       }
       respColumns.add(measurementAliasMap.getOrDefault(measurement, measurement));
       columnTypes.add(type.toString());
@@ -1288,7 +1280,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
   }
 
   @Override
-  public TSStatus insertStringRecords(TSInsertStringRecordsReq req) throws TException {
+  public TSStatus insertStringRecords(TSInsertStringRecordsReq req) {
     if (auditLogger.isDebugEnabled()) {
       auditLogger
           .debug("Session {} insertRecords, first device {}, first time {}", currSessionId.get(),
@@ -1308,8 +1300,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         plan.setTime(req.getTimestamps().get(i));
         plan.setMeasurements(req.getMeasurementsList().get(i).toArray(new String[0]));
         plan.setDataTypes(new TSDataType[plan.getMeasurements().length]);
-        plan.setValues(
-            req.getValuesList().get(i).toArray(new Object[req.getValuesList().get(i).size()]));
+        plan.setValues(req.getValuesList().get(i).toArray(new Object[0]));
         plan.setNeedInferType(true);
         TSStatus status = checkAuthority(plan, req.getSessionId());
         if (status == null) {
@@ -1352,7 +1343,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
   }
 
   @Override
-  public TSStatus testInsertStringRecord(TSInsertStringRecordReq req) throws TException {
+  public TSStatus testInsertStringRecord(TSInsertStringRecordReq req) {
     logger.debug("Test insert string record request receive.");
     return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
   }
@@ -1364,7 +1355,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
   }
 
   @Override
-  public TSStatus testInsertStringRecords(TSInsertStringRecordsReq req) throws TException {
+  public TSStatus testInsertStringRecords(TSInsertStringRecordsReq req) {
     logger.debug("Test insert string records request receive.");
     return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
   }
@@ -1401,7 +1392,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
   }
 
   @Override
-  public TSStatus insertStringRecord(TSInsertStringRecordReq req) throws TException {
+  public TSStatus insertStringRecord(TSInsertStringRecordReq req) {
     try {
       auditLogger
           .debug("Session {} insertRecord, device {}, time {}", currSessionId.get(),
@@ -1416,7 +1407,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       plan.setTime(req.getTimestamp());
       plan.setMeasurements(req.getMeasurements().toArray(new String[0]));
       plan.setDataTypes(new TSDataType[plan.getMeasurements().length]);
-      plan.setValues(req.getValues().toArray(new Object[req.getValues().size()]));
+      plan.setValues(req.getValues().toArray(new Object[0]));
       plan.setNeedInferType(true);
 
       TSStatus status = checkAuthority(plan, req.getSessionId());
@@ -1692,7 +1683,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
 
       boolean isAllSuccessful = true;
 
-      if (createMultiTimeSeriesPlan.getResults().entrySet().size() > 0) {
+      if (!createMultiTimeSeriesPlan.getResults().entrySet().isEmpty()) {
         isAllSuccessful = false;
         for (Map.Entry<Integer, Exception> entry : createMultiTimeSeriesPlan.getResults()
             .entrySet()) {


[iotdb] 01/02: add missing error message

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

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

commit 555467fb111a4e5cbf9212db6b5dd88dc319250e
Author: jt <jt...@163.com>
AuthorDate: Fri Nov 13 11:17:37 2020 +0800

    add missing error message
---
 .../org/apache/iotdb/db/service/TSServiceImpl.java   | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 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 9a55444..b1c76b1 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
@@ -1322,7 +1322,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       } catch (Exception e) {
         logger.error("meet error when insert in batch", e);
         isAllSuccessful = false;
-        statusList.add(RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR));
+        statusList.add(RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage()));
       }
     }
 
@@ -1396,8 +1396,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       return executeNonQueryPlan(plan);
     } catch (Exception e) {
       logger.error("meet error when insert", e);
+      return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
     }
-    return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
 
   @Override
@@ -1426,12 +1426,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       return executeNonQueryPlan(plan);
     } catch (Exception e) {
       logger.error("meet error when insert", e);
+      return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
     }
-    return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
 
   @Override
-  public TSStatus deleteData(TSDeleteDataReq req) throws TException {
+  public TSStatus deleteData(TSDeleteDataReq req) {
     try {
       if (!checkLogin(req.getSessionId())) {
         logger.info(INFO_NOT_LOGIN, IoTDBConstant.GLOBAL_DB_NAME);
@@ -1454,8 +1454,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       return new TSStatus(executeNonQueryPlan(plan));
     } catch (Exception e) {
       logger.error("meet error when delete data", e);
+      return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
     }
-    return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
 
   @Override
@@ -1553,8 +1553,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       return new TSStatus(executeNonQueryPlan(plan));
     } catch (Exception e) {
       logger.error("meet error when set storage group", e);
+      return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
     }
-    return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
 
   @Override
@@ -1576,8 +1576,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       return new TSStatus(executeNonQueryPlan(plan));
     } catch (Exception e) {
       logger.error("meet error when delete storage groups", e);
+      return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
     }
-    return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
 
   @Override
@@ -1603,8 +1603,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       return executeNonQueryPlan(plan);
     } catch (Exception e) {
       logger.error("meet error when create timeseries", e);
+      return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
     }
-    return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
 
   @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning
@@ -1713,8 +1713,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       }
     } catch (Exception e) {
       logger.error("meet error when create multi timeseries", e);
+      return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
     }
-    return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
 
   @Override
@@ -1736,8 +1736,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       return executeNonQueryPlan(plan);
     } catch (Exception e) {
       logger.error("meet error when delete timeseries", e);
+      return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
     }
-    return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
 
   @Override