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

haonan 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 ee5e23dbb94 Rest service code optimization and fixed insertRecords 
error prompt returning null issue (#11678)
ee5e23dbb94 is described below

commit ee5e23dbb944243e6dc0b99467d1e32f1ef14905
Author: CloudWise-Lukemiao 
<[email protected]>
AuthorDate: Fri Dec 8 18:55:16 2023 +0800

    Rest service code optimization and fixed insertRecords error prompt 
returning null issue (#11678)
---
 .../resources/conf/iotdb-datanode.properties       |   6 +-
 .../iotdb/db/conf/rest/IoTDBRestServiceConfig.java |   1 +
 .../db/conf/rest/IoTDBRestServiceDescriptor.java   | 119 +++++++++++----------
 .../rest/v1/handler/RequestValidationHandler.java  |  12 ---
 .../v1/handler/StatementConstructionHandler.java   |  59 ----------
 .../protocol/rest/v1/impl/RestApiServiceImpl.java  |  47 --------
 .../protocol/rest/v2/impl/RestApiServiceImpl.java  |  36 +++++--
 .../openapi/src/main/openapi3/iotdb_rest_v1.yaml   |  52 ---------
 8 files changed, 92 insertions(+), 240 deletions(-)

diff --git 
a/iotdb-core/datanode/src/assembly/resources/conf/iotdb-datanode.properties 
b/iotdb-core/datanode/src/assembly/resources/conf/iotdb-datanode.properties
index 84969f014ec..f51b56e8b83 100644
--- a/iotdb-core/datanode/src/assembly/resources/conf/iotdb-datanode.properties
+++ b/iotdb-core/datanode/src/assembly/resources/conf/iotdb-datanode.properties
@@ -67,6 +67,9 @@ dn_data_region_consensus_port=10760
 # Does dn_rpc_port enable SSL
 # enable_thrift_ssl=false
 
+# Rest Service enabled SSL
+# enable_https=false
+
 # SSL key store path
 # linux e.g. /home/iotdb/server.keystore (absolute path) or server.keystore 
(relative path)
 # windows e.g. C:\\iotdb\\server.keystore (absolute path) or server.keystore 
(relative path)
@@ -303,9 +306,6 @@ dn_seed_config_node=127.0.0.1:10710
 # init capacity of users can be stored in the user login cache.
 # cache_init_num=10
 
-# is SSL enabled
-# enable_https=false
-
 # Is client authentication required
 # client_auth=false
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceConfig.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceConfig.java
index dd984815e76..4639ce4cbb8 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceConfig.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceConfig.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.db.conf.rest;
 
 public class IoTDBRestServiceConfig {
   static final String CONFIG_NAME = "iotdb-datanode.properties";
+  static final String OLD_CONFIG_NAME = "iotdb-common.properties";
   /** If the enableRestService is true, we will start REST Service. */
   private boolean enableRestService = false;
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceDescriptor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceDescriptor.java
index 6d485ab51e1..aada9813035 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceDescriptor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceDescriptor.java
@@ -38,7 +38,15 @@ public class IoTDBRestServiceDescriptor {
   private final IoTDBRestServiceConfig conf = new IoTDBRestServiceConfig();
 
   protected IoTDBRestServiceDescriptor() {
-    loadProps();
+    Properties properties = loadProps(IoTDBRestServiceConfig.CONFIG_NAME);
+    if (properties != null) {
+      if (!properties.containsKey("enable_rest_service")) {
+        properties = loadProps(IoTDBRestServiceConfig.OLD_CONFIG_NAME);
+      }
+      if (properties != null) {
+        loadProps(properties);
+      }
+    }
   }
 
   public static IoTDBRestServiceDescriptor getInstance() {
@@ -47,58 +55,17 @@ public class IoTDBRestServiceDescriptor {
 
   /** load an property file. */
   @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity 
warning
-  private void loadProps() {
-    URL url = getPropsUrl();
+  private Properties loadProps(String configName) {
+    URL url = getPropsUrl(configName);
     if (url == null) {
       logger.warn("Couldn't load the REST Service configuration from any of 
the known sources.");
-      return;
+      return null;
     }
     try (InputStream inputStream = url.openStream()) {
       logger.info("Start to read config file {}", url);
       Properties properties = new Properties();
       properties.load(inputStream);
-      conf.setEnableRestService(
-          Boolean.parseBoolean(
-              properties.getProperty(
-                  "enable_rest_service", 
Boolean.toString(conf.isEnableRestService()))));
-      conf.setRestServicePort(
-          Integer.parseInt(
-              properties.getProperty(
-                  "rest_service_port", 
Integer.toString(conf.getRestServicePort()))));
-      conf.setRestQueryDefaultRowSizeLimit(
-          Integer.parseInt(
-              properties.getProperty(
-                  "rest_query_default_row_size_limit",
-                  Integer.toString(conf.getRestQueryDefaultRowSizeLimit()))));
-      conf.setEnableSwagger(
-          Boolean.parseBoolean(
-              properties.getProperty("enable_swagger", 
Boolean.toString(conf.isEnableSwagger()))));
-
-      conf.setEnableHttps(
-          Boolean.parseBoolean(
-              properties.getProperty("enable_https", 
Boolean.toString(conf.isEnableHttps()))));
-      conf.setClientAuth(
-          Boolean.parseBoolean(
-              properties.getProperty("client_auth", 
Boolean.toString(conf.isClientAuth()))));
-      conf.setKeyStorePath(properties.getProperty("key_store_path", 
conf.getKeyStorePath()));
-      conf.setKeyStorePwd(properties.getProperty("key_store_pwd", 
conf.getKeyStorePwd()));
-      conf.setTrustStorePath(properties.getProperty("trust_store_path", 
conf.getTrustStorePath()));
-      conf.setTrustStorePwd(properties.getProperty("trust_store_pwd", 
conf.getTrustStorePwd()));
-      conf.setIdleTimeoutInSeconds(
-          Integer.parseInt(
-              properties.getProperty(
-                  "idle_timeout_in_seconds", 
Integer.toString(conf.getIdleTimeoutInSeconds()))));
-      conf.setCacheExpireInSeconds(
-          Integer.parseInt(
-              properties.getProperty(
-                  "cache_expire_in_seconds", 
Integer.toString(conf.getCacheExpireInSeconds()))));
-      conf.setCacheInitNum(
-          Integer.parseInt(
-              properties.getProperty("cache_init_num", 
Integer.toString(conf.getCacheInitNum()))));
-      conf.setCacheMaxNum(
-          Integer.parseInt(
-              properties.getProperty("cache_max_num", 
Integer.toString(conf.getCacheMaxNum()))));
-
+      return properties;
     } catch (FileNotFoundException e) {
       logger.warn("REST service fail to find config file {}", url, e);
     } catch (IOException e) {
@@ -106,6 +73,51 @@ public class IoTDBRestServiceDescriptor {
     } catch (Exception e) {
       logger.warn("REST service Incorrect format in config file, use default 
configuration", e);
     }
+    return null;
+  }
+
+  private void loadProps(Properties properties) {
+    conf.setEnableRestService(
+        Boolean.parseBoolean(
+            properties.getProperty(
+                "enable_rest_service", 
Boolean.toString(conf.isEnableRestService()))));
+    conf.setRestServicePort(
+        Integer.parseInt(
+            properties.getProperty(
+                "rest_service_port", 
Integer.toString(conf.getRestServicePort()))));
+    conf.setRestQueryDefaultRowSizeLimit(
+        Integer.parseInt(
+            properties.getProperty(
+                "rest_query_default_row_size_limit",
+                Integer.toString(conf.getRestQueryDefaultRowSizeLimit()))));
+    conf.setEnableSwagger(
+        Boolean.parseBoolean(
+            properties.getProperty("enable_swagger", 
Boolean.toString(conf.isEnableSwagger()))));
+
+    conf.setEnableHttps(
+        Boolean.parseBoolean(
+            properties.getProperty("enable_https", 
Boolean.toString(conf.isEnableHttps()))));
+    conf.setClientAuth(
+        Boolean.parseBoolean(
+            properties.getProperty("client_auth", 
Boolean.toString(conf.isClientAuth()))));
+    conf.setKeyStorePath(properties.getProperty("key_store_path", 
conf.getKeyStorePath()));
+    conf.setKeyStorePwd(properties.getProperty("key_store_pwd", 
conf.getKeyStorePwd()));
+    conf.setTrustStorePath(properties.getProperty("trust_store_path", 
conf.getTrustStorePath()));
+    conf.setTrustStorePwd(properties.getProperty("trust_store_pwd", 
conf.getTrustStorePwd()));
+    conf.setIdleTimeoutInSeconds(
+        Integer.parseInt(
+            properties.getProperty(
+                "idle_timeout_in_seconds", 
Integer.toString(conf.getIdleTimeoutInSeconds()))));
+    conf.setCacheExpireInSeconds(
+        Integer.parseInt(
+            properties.getProperty(
+                "cache_expire_in_seconds", 
Integer.toString(conf.getCacheExpireInSeconds()))));
+    conf.setCacheInitNum(
+        Integer.parseInt(
+            properties.getProperty("cache_init_num", 
Integer.toString(conf.getCacheInitNum()))));
+    conf.setCacheMaxNum(
+        Integer.parseInt(
+            properties.getProperty("cache_max_num", 
Integer.toString(conf.getCacheMaxNum()))));
   }
 
   /**
@@ -113,29 +125,24 @@ public class IoTDBRestServiceDescriptor {
    *
    * @return url object if location exit, otherwise null.
    */
-  public URL getPropsUrl() {
+  public URL getPropsUrl(String configName) {
     // Check if a config-directory was specified first.
     String urlString = System.getProperty(IoTDBConstant.IOTDB_CONF, null);
     // If it wasn't, check if a home directory was provided (This usually 
contains a config)
     if (urlString == null) {
       urlString = System.getProperty(IoTDBConstant.IOTDB_HOME, null);
       if (urlString != null) {
-        urlString =
-            urlString
-                + File.separatorChar
-                + "conf"
-                + File.separatorChar
-                + IoTDBRestServiceConfig.CONFIG_NAME;
+        urlString = urlString + File.separatorChar + "conf" + 
File.separatorChar + configName;
       } else {
         // If this too wasn't provided, try to find a default config in the 
root of the classpath.
-        URL uri = IoTDBConfig.class.getResource("/" + 
IoTDBRestServiceConfig.CONFIG_NAME);
+        URL uri = IoTDBConfig.class.getResource("/" + configName);
         if (uri != null) {
           return uri;
         }
         logger.warn(
             "Cannot find IOTDB_HOME or IOTDB_CONF environment variable when 
loading "
                 + "config file {}, use default configuration",
-            IoTDBRestServiceConfig.CONFIG_NAME);
+            configName);
         // update all data seriesPath
         return null;
       }
@@ -143,7 +150,7 @@ public class IoTDBRestServiceDescriptor {
     // If a config location was provided, but it doesn't end with a properties 
file,
     // append the default location.
     else if (!urlString.endsWith(".properties")) {
-      urlString += (File.separatorChar + IoTDBRestServiceConfig.CONFIG_NAME);
+      urlString += (File.separatorChar + configName);
     }
 
     // If the url doesn't start with "file:" or "classpath:", it's provided as 
a no path.
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/RequestValidationHandler.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/RequestValidationHandler.java
index dc9dafbf0e3..32e97d36fec 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/RequestValidationHandler.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/RequestValidationHandler.java
@@ -18,7 +18,6 @@
 package org.apache.iotdb.db.protocol.rest.v1.handler;
 
 import org.apache.iotdb.db.protocol.rest.v1.model.ExpressionRequest;
-import org.apache.iotdb.db.protocol.rest.v1.model.InsertRecordsRequest;
 import org.apache.iotdb.db.protocol.rest.v1.model.InsertTabletRequest;
 import org.apache.iotdb.db.protocol.rest.v1.model.SQL;
 
@@ -45,17 +44,6 @@ public class RequestValidationHandler {
     Objects.requireNonNull(insertTabletRequest.getValues(), "values should not 
be null");
   }
 
-  public static void validateInsertRecordsRequest(InsertRecordsRequest 
insertRecordsRequest) {
-    Objects.requireNonNull(insertRecordsRequest.getTimestamps(), "timestamps 
should not be null");
-    Objects.requireNonNull(insertRecordsRequest.getIsAligned(), "isAligned 
should not be null");
-    Objects.requireNonNull(insertRecordsRequest.getDeviceIds(), "deviceIds 
should not be null");
-    Objects.requireNonNull(
-        insertRecordsRequest.getDataTypesList(), "dataTypesList should not be 
null");
-    Objects.requireNonNull(insertRecordsRequest.getValuesList(), "valuesList 
should not be null");
-    Objects.requireNonNull(
-        insertRecordsRequest.getMeasurementsList(), "measurementsList should 
not be null");
-  }
-
   public static void validateExpressionRequest(ExpressionRequest 
expressionRequest) {
     Objects.requireNonNull(expressionRequest.getExpression(), "expression 
should not be null");
     Objects.requireNonNull(expressionRequest.getPrefixPath(), "prefixPath 
should not be null");
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/StatementConstructionHandler.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/StatementConstructionHandler.java
index 56846959556..eb2d32df72e 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/StatementConstructionHandler.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/StatementConstructionHandler.java
@@ -20,21 +20,15 @@ package org.apache.iotdb.db.protocol.rest.v1.handler;
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.utils.PathUtils;
 import org.apache.iotdb.db.exception.WriteProcessRejectException;
-import org.apache.iotdb.db.protocol.rest.utils.InsertRowDataUtils;
-import org.apache.iotdb.db.protocol.rest.v1.model.InsertRecordsRequest;
 import org.apache.iotdb.db.protocol.rest.v1.model.InsertTabletRequest;
 import 
org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.DataNodeDevicePathCache;
-import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertRowStatement;
-import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertRowsStatement;
 import 
org.apache.iotdb.db.queryengine.plan.statement.crud.InsertTabletStatement;
 import org.apache.iotdb.db.utils.TimestampPrecisionUtils;
-import org.apache.iotdb.rpc.IoTDBConnectionException;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.utils.Binary;
 import org.apache.iotdb.tsfile.utils.BitMap;
 
 import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 
@@ -176,57 +170,4 @@ public class StatementConstructionHandler {
     insertStatement.setAligned(insertTabletRequest.getIsAligned());
     return insertStatement;
   }
-
-  public static InsertRowsStatement createInsertRowsStatement(
-      InsertRecordsRequest insertRecordsRequest)
-      throws MetadataException, IoTDBConnectionException {
-
-    // construct insert statement
-    InsertRowsStatement insertStatement = new InsertRowsStatement();
-    List<InsertRowStatement> insertRowStatementList = new ArrayList<>();
-    List<List<TSDataType>> dataTypesList = new ArrayList<>();
-
-    for (int i = 0; i < insertRecordsRequest.getDataTypesList().size(); i++) {
-      List<TSDataType> dataTypes = new ArrayList<>();
-      for (int c = 0; c < 
insertRecordsRequest.getDataTypesList().get(i).size(); c++) {
-        dataTypes.add(
-            TSDataType.valueOf(
-                
insertRecordsRequest.getDataTypesList().get(i).get(c).toUpperCase(Locale.ROOT)));
-      }
-      dataTypesList.add(dataTypes);
-    }
-
-    InsertRowDataUtils.filterNullValueAndMeasurement(
-        insertRecordsRequest.getDeviceIds(),
-        insertRecordsRequest.getTimestamps(),
-        insertRecordsRequest.getMeasurementsList(),
-        insertRecordsRequest.getValuesList(),
-        dataTypesList);
-
-    for (int i = 0; i < insertRecordsRequest.getDeviceIds().size(); i++) {
-      InsertRowStatement statement = new InsertRowStatement();
-      statement.setDevicePath(
-          DataNodeDevicePathCache.getInstance()
-              .getPartialPath(insertRecordsRequest.getDeviceIds().get(i)));
-      statement.setMeasurements(
-          PathUtils.checkIsLegalSingleMeasurementsAndUpdate(
-                  insertRecordsRequest.getMeasurementsList().get(i))
-              .toArray(new String[0]));
-      
TimestampPrecisionUtils.checkTimestampPrecision(insertRecordsRequest.getTimestamps().get(i));
-      statement.setTime(insertRecordsRequest.getTimestamps().get(i));
-      statement.setDataTypes(dataTypesList.get(i).toArray(new TSDataType[0]));
-      List<Object> values =
-          InsertRowDataUtils.reGenValues(
-              dataTypesList.get(i), 
insertRecordsRequest.getValuesList().get(i));
-      statement.setValues(values.toArray());
-      statement.setAligned(insertRecordsRequest.getIsAligned());
-      if (statement.isEmpty()) {
-        continue;
-      }
-      insertRowStatementList.add(statement);
-    }
-    insertStatement.setInsertRowStatementList(insertRowStatementList);
-
-    return insertStatement;
-  }
 }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/impl/RestApiServiceImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/impl/RestApiServiceImpl.java
index 7563a1c1d5e..47433bb5a68 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/impl/RestApiServiceImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/impl/RestApiServiceImpl.java
@@ -29,7 +29,6 @@ import 
org.apache.iotdb.db.protocol.rest.v1.handler.QueryDataSetHandler;
 import org.apache.iotdb.db.protocol.rest.v1.handler.RequestValidationHandler;
 import 
org.apache.iotdb.db.protocol.rest.v1.handler.StatementConstructionHandler;
 import org.apache.iotdb.db.protocol.rest.v1.model.ExecutionStatus;
-import org.apache.iotdb.db.protocol.rest.v1.model.InsertRecordsRequest;
 import org.apache.iotdb.db.protocol.rest.v1.model.InsertTabletRequest;
 import org.apache.iotdb.db.protocol.rest.v1.model.SQL;
 import org.apache.iotdb.db.protocol.session.SessionManager;
@@ -42,7 +41,6 @@ import 
org.apache.iotdb.db.queryengine.plan.execution.ExecutionResult;
 import org.apache.iotdb.db.queryengine.plan.execution.IQueryExecution;
 import org.apache.iotdb.db.queryengine.plan.parser.StatementGenerator;
 import org.apache.iotdb.db.queryengine.plan.statement.Statement;
-import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertRowsStatement;
 import 
org.apache.iotdb.db.queryengine.plan.statement.crud.InsertTabletStatement;
 import org.apache.iotdb.db.utils.SetThreadName;
 import org.apache.iotdb.rpc.TSStatusCode;
@@ -186,51 +184,6 @@ public class RestApiServiceImpl extends RestApiService {
     }
   }
 
-  @Override
-  public Response insertRecords(
-      InsertRecordsRequest insertRecordsRequest, SecurityContext 
securityContext) {
-    Long queryId = null;
-    try {
-      
RequestValidationHandler.validateInsertRecordsRequest(insertRecordsRequest);
-
-      InsertRowsStatement insertRowsStatement =
-          
StatementConstructionHandler.createInsertRowsStatement(insertRecordsRequest);
-
-      Response response = authorizationHandler.checkAuthority(securityContext, 
insertRowsStatement);
-      if (response != null) {
-        return response;
-      }
-      queryId = SESSION_MANAGER.requestQueryId();
-      ExecutionResult result =
-          COORDINATOR.execute(
-              insertRowsStatement,
-              SESSION_MANAGER.requestQueryId(),
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
-              "",
-              partitionFetcher,
-              schemaFetcher,
-              config.getQueryTimeoutThreshold());
-
-      return Response.ok()
-          .entity(
-              (result.status.code == 
TSStatusCode.SUCCESS_STATUS.getStatusCode()
-                      || result.status.code == 
TSStatusCode.REDIRECTION_RECOMMEND.getStatusCode())
-                  ? new ExecutionStatus()
-                      .code(TSStatusCode.SUCCESS_STATUS.getStatusCode())
-                      .message(TSStatusCode.SUCCESS_STATUS.name())
-                  : new ExecutionStatus()
-                      .code(result.status.getCode())
-                      .message(result.status.getMessage()))
-          .build();
-    } catch (Exception e) {
-      return 
Response.ok().entity(ExceptionHandler.tryCatchException(e)).build();
-    } finally {
-      if (queryId != null) {
-        COORDINATOR.cleanupQueryExecution(queryId);
-      }
-    }
-  }
-
   @Override
   public Response insertTablet(
       InsertTabletRequest insertTabletRequest, SecurityContext 
securityContext) {
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/impl/RestApiServiceImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/impl/RestApiServiceImpl.java
index ff34db35324..5cace589391 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/impl/RestApiServiceImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/impl/RestApiServiceImpl.java
@@ -211,18 +211,32 @@ public class RestApiServiceImpl extends RestApiService {
               partitionFetcher,
               schemaFetcher,
               config.getQueryTimeoutThreshold());
+      if (result.status.code == TSStatusCode.SUCCESS_STATUS.getStatusCode()
+          || result.status.code == 
TSStatusCode.REDIRECTION_RECOMMEND.getStatusCode()) {
+        return Response.ok()
+            .entity(
+                new ExecutionStatus()
+                    .code(TSStatusCode.SUCCESS_STATUS.getStatusCode())
+                    .message(TSStatusCode.SUCCESS_STATUS.name()))
+            .build();
+      } else if (result.status.message == null
+          && result.status.subStatus != null
+          && result.status.subStatus.size() > 0) {
+        return Response.ok()
+            .entity(
+                new ExecutionStatus()
+                    .code(result.status.getCode())
+                    .message(result.status.subStatus.get(0).message))
+            .build();
+      } else {
+        return Response.ok()
+            .entity(
+                new ExecutionStatus()
+                    .code(result.status.getCode())
+                    .message(result.status.getMessage()))
+            .build();
+      }
 
-      return Response.ok()
-          .entity(
-              (result.status.code == 
TSStatusCode.SUCCESS_STATUS.getStatusCode()
-                      || result.status.code == 
TSStatusCode.REDIRECTION_RECOMMEND.getStatusCode())
-                  ? new ExecutionStatus()
-                      .code(TSStatusCode.SUCCESS_STATUS.getStatusCode())
-                      .message(TSStatusCode.SUCCESS_STATUS.name())
-                  : new ExecutionStatus()
-                      .code(result.status.getCode())
-                      .message(result.status.getMessage()))
-          .build();
     } catch (Exception e) {
       return 
Response.ok().entity(ExceptionHandler.tryCatchException(e)).build();
     } finally {
diff --git a/iotdb-protocol/openapi/src/main/openapi3/iotdb_rest_v1.yaml 
b/iotdb-protocol/openapi/src/main/openapi3/iotdb_rest_v1.yaml
index f2e439d4400..18080c693ab 100644
--- a/iotdb-protocol/openapi/src/main/openapi3/iotdb_rest_v1.yaml
+++ b/iotdb-protocol/openapi/src/main/openapi3/iotdb_rest_v1.yaml
@@ -49,24 +49,6 @@ paths:
               schema:
                 $ref: '#/components/schemas/ExecutionStatus'
 
-  /rest/v1/insertRecords:
-    post:
-      summary: insertRecords
-      description: insertRecords
-      operationId: insertRecords
-      requestBody:
-        content:
-          application/json:
-            schema:
-              $ref: '#/components/schemas/InsertRecordsRequest'
-      responses:
-        "200":
-          description: ExecutionStatus
-          content:
-            application/json:
-              schema:
-                $ref: '#/components/schemas/ExecutionStatus'
-
   /rest/v1/nonQuery:
     post:
       summary: executeNonQueryStatement
@@ -213,40 +195,6 @@ components:
         deviceId:
           type: string
 
-    InsertRecordsRequest:
-      title: InsertRecordsRequest
-      type: object
-      properties:
-        timestamps:
-          type: array
-          items:
-            type: integer
-            format: int64
-        measurementsList:
-          type: array
-          items:
-            type: array
-            items:
-              type: string
-        dataTypesList:
-          type: array
-          items:
-            type: array
-            items:
-              type: string
-        valuesList:
-          type: array
-          items:
-            type: array
-            items:
-              type: object
-        isAligned:
-          type: boolean
-        deviceIds:
-          type: array
-          items:
-            type: string
-
     ExecutionStatus:
       type: object
       properties:

Reply via email to