You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2019/08/27 06:24:15 UTC
[incubator-iotdb] branch master updated: [IOTDB-161] Add ErrorCode
of different response errors (#350)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 8827bdf [IOTDB-161] Add ErrorCode of different response errors (#350)
8827bdf is described below
commit 8827bdf98e60d8e8cc8d2c9d618f029e031e96c2
Author: Zesong Sun <24...@qq.com>
AuthorDate: Tue Aug 27 14:24:10 2019 +0800
[IOTDB-161] Add ErrorCode of different response errors (#350)
* Add ErrorCode of different response errors
---
.../UserGuide/6-JDBC API/2-Status Code.md | 64 +++++
docs/Documentation/UserGuide/0-Content.md | 7 +-
.../UserGuide/6-JDBC API/2-Status Code.md | 64 +++++
.../jdbc/IoTDBPreparedInsertionStatement.java | 5 +-
.../java/org/apache/iotdb/jdbc/IoTDBStatement.java | 22 +-
.../src/main/java/org/apache/iotdb/jdbc/Utils.java | 3 -
.../test/java/org/apache/iotdb/jdbc/BatchTest.java | 15 +-
.../org/apache/iotdb/jdbc/IoTDBConnectionTest.java | 13 +-
.../iotdb/jdbc/IoTDBDatabaseMetadataTest.java | 11 +-
.../iotdb/jdbc/IoTDBPreparedStatementTest.java | 13 +-
.../apache/iotdb/jdbc/IoTDBQueryResultSetTest.java | 20 +-
.../org/apache/iotdb/jdbc/IoTDBStatementTest.java | 11 +-
.../test/java/org/apache/iotdb/jdbc/UtilsTest.java | 11 +-
pom.xml | 2 -
.../engine/storagegroup/StorageGroupProcessor.java | 6 +-
.../db/engine/storagegroup/TsFileProcessor.java | 4 +-
.../org/apache/iotdb/db/service/TSServiceImpl.java | 277 +++++++++------------
.../iotdb/db/integration/IoTDBAggregationIT.java | 8 +-
.../main/java/org/apache/iotdb/rpc/RpcUtils.java | 5 +-
.../java/org/apache/iotdb/rpc/TSStatusType.java | 55 ++++
service-rpc/src/main/thrift/rpc.thrift | 21 +-
21 files changed, 373 insertions(+), 264 deletions(-)
diff --git a/docs/Documentation-CHN/UserGuide/6-JDBC API/2-Status Code.md b/docs/Documentation-CHN/UserGuide/6-JDBC API/2-Status Code.md
new file mode 100644
index 0000000..15f77d9
--- /dev/null
+++ b/docs/Documentation-CHN/UserGuide/6-JDBC API/2-Status Code.md
@@ -0,0 +1,64 @@
+<!--
+
+ 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.
+
+-->
+
+# Chapter6: JDBC API
+
+## Status Code
+
+在最新版本中引入了**状态码**这一概念。例如,因为IoTDB需要在写入数据之前首先注册时间序列,一种可能的解决方案是:
+
+```
+try {
+ writeData();
+} catch (SQLException e) {
+ // the most case is that the time series does not exist
+ if (e.getMessage().contains("exist")) {
+ //However, using the content of the error message is not so efficient
+ registerTimeSeries();
+ //write data once again
+ writeData();
+ }
+}
+
+```
+
+利用状态码,我们就可以不必写诸如`if (e.getErrorMessage().contains("exist"))`的代码,只需要使用`e.getStatusType().getCode() == TSStatusType.TIME_SERIES_NOT_EXIST_ERROR.getStatusCode()`。
+
+这里是状态码和相对应信息的列表:
+
+|状态码|状态类型|状态信息|
+|:---|:---|:---|
+|200|SUCCESS_STATUS||
+|201|STILL_EXECUTING_STATUS||
+|202|INVALID_HANDLE_STATUS||
+|301|TIMESERIES_NOT_EXIST_ERROR|时间序列不存在|
+|302|UNSUPPORTED_FETCH_METADATA_OPERATION_ERROR|不支持的获取元数据操作|
+|303|FETCH_METADATA_ERROR|获取元数据失败|
+|304|CHECK_FILE_LEVEL_ERROR|检查文件层级错误|
+|400|EXECUTE_STATEMENT_ERROR|执行语句错误|
+|401|SQL_PARSE_ERROR|SQL语句分析错误|
+|402|GENERATE_TIME_ZONE_ERROR|生成时区错误|
+|403|SET_TIME_ZONE_ERROR|设置时区错误|
+|500|INTERNAL_SERVER_ERROR|服务器内部错误|
+|600|WRONG_LOGIN_PASSWORD_ERROR|用户名或密码错误|
+|601|NOT_LOGIN_ERROR|没有登录|
+|602|NO_PERMISSION_ERROR|没有操作权限|
+|603|UNINITIALIZED_AUTH_ERROR|授权人未初始化|
diff --git a/docs/Documentation/UserGuide/0-Content.md b/docs/Documentation/UserGuide/0-Content.md
index 1b245d2..07aa1cf 100644
--- a/docs/Documentation/UserGuide/0-Content.md
+++ b/docs/Documentation/UserGuide/0-Content.md
@@ -49,10 +49,13 @@
* 2-Reference
# Chapter 6: JDBC API
* 1-JDBC API
-# Chapter 7: TsFile
+* 2-Status Code
+# Chapter 7: Session API
+* 1-Session API
+# Chapter 8: TsFile
* 1-Installation
* 2-Usage
* 3-Hierarchy
-# Chapter 8: System Tools
+# Chapter 9: System Tools
* 1-Sync
* 2-Memory Estimation Tool
diff --git a/docs/Documentation/UserGuide/6-JDBC API/2-Status Code.md b/docs/Documentation/UserGuide/6-JDBC API/2-Status Code.md
new file mode 100644
index 0000000..ea62c35
--- /dev/null
+++ b/docs/Documentation/UserGuide/6-JDBC API/2-Status Code.md
@@ -0,0 +1,64 @@
+<!--
+
+ 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.
+
+-->
+
+# Chapter6: JDBC API
+
+## Status Code
+
+**Status Code** is introduced in the latest version. For example, as IoTDB requires registering the time series first before writing data, a kind of solution is:
+
+```
+try {
+ writeData();
+} catch (SQLException e) {
+ // the most case is that the time series does not exist
+ if (e.getMessage().contains("exist")) {
+ //However, using the content of the error message is not so efficient
+ registerTimeSeries();
+ //write data once again
+ writeData();
+ }
+}
+
+```
+
+With Status Code, instead of writing codes like `if (e.getErrorMessage().contains("exist"))`, we can simply use `e.getStatusType().getCode() == TSStatusType.TIME_SERIES_NOT_EXIST_ERROR.getStatusCode()`.
+
+Here is a list of Status Code and related message:
+
+|Status Code|Status Type|Status Message|
+|:---|:---|:---|
+|200|SUCCESS_STATUS||
+|201|STILL_EXECUTING_STATUS||
+|202|INVALID_HANDLE_STATUS||
+|301|TIMESERIES_NOT_EXIST_ERROR|Timeseries does not exist|
+|302|UNSUPPORTED_FETCH_METADATA_OPERATION_ERROR|Unsupported fetch metadata operation|
+|303|FETCH_METADATA_ERROR|Failed to fetch metadata|
+|304|CHECK_FILE_LEVEL_ERROR|Meet error while checking file level|
+|400|EXECUTE_STATEMENT_ERROR|Execute statement error|
+|401|SQL_PARSE_ERROR|Meet error while parsing SQL|
+|402|GENERATE_TIME_ZONE_ERROR|Meet error while generating time zone|
+|403|SET_TIME_ZONE_ERROR|Meet error while setting time zone|
+|500|INTERNAL_SERVER_ERROR|Internal server error|
+|600|WRONG_LOGIN_PASSWORD_ERROR|Username or password is wrong|
+|601|NOT_LOGIN_ERROR|Has not logged in|
+|602|NO_PERMISSION_ERROR|No permissions for this operation|
+|603|UNINITIALIZED_AUTH_ERROR|Uninitialized authorizer|
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBPreparedInsertionStatement.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBPreparedInsertionStatement.java
index 3065d8f..2fe0370 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBPreparedInsertionStatement.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBPreparedInsertionStatement.java
@@ -22,11 +22,12 @@ package org.apache.iotdb.jdbc;
import java.sql.SQLException;
import java.time.ZoneId;
import java.util.List;
+
+import org.apache.iotdb.rpc.TSStatusType;
import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementResp;
import org.apache.iotdb.service.rpc.thrift.TSIService.Iface;
import org.apache.iotdb.service.rpc.thrift.TSInsertionReq;
import org.apache.iotdb.service.rpc.thrift.TS_SessionHandle;
-import org.apache.iotdb.service.rpc.thrift.TS_StatusCode;
import org.apache.thrift.TException;
public class IoTDBPreparedInsertionStatement extends IoTDBPreparedStatement {
@@ -49,7 +50,7 @@ public class IoTDBPreparedInsertionStatement extends IoTDBPreparedStatement {
req.unsetMeasurements();
req.unsetTimestamp();
req.unsetValues();
- return resp.getStatus().getStatusCode() == TS_StatusCode.SUCCESS_STATUS;
+ return resp.getStatus().getStatusType().getCode() == TSStatusType.SUCCESS_STATUS.getStatusCode();
} catch (TException e) {
throw new SQLException(e);
}
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
index 14e6c2c..680a0a3 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
@@ -30,20 +30,11 @@ import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
+
import org.apache.iotdb.rpc.IoTDBRPCException;
import org.apache.iotdb.rpc.RpcUtils;
-import org.apache.iotdb.service.rpc.thrift.TSCancelOperationReq;
-import org.apache.iotdb.service.rpc.thrift.TSCancelOperationResp;
-import org.apache.iotdb.service.rpc.thrift.TSCloseOperationReq;
-import org.apache.iotdb.service.rpc.thrift.TSCloseOperationResp;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteBatchStatementReq;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteBatchStatementResp;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementReq;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementResp;
-import org.apache.iotdb.service.rpc.thrift.TSIService;
-import org.apache.iotdb.service.rpc.thrift.TSOperationHandle;
-import org.apache.iotdb.service.rpc.thrift.TS_SessionHandle;
-import org.apache.iotdb.service.rpc.thrift.TS_StatusCode;
+import org.apache.iotdb.rpc.TSStatusType;
+import org.apache.iotdb.service.rpc.thrift.*;
import org.apache.thrift.TException;
public class IoTDBStatement implements Statement {
@@ -51,6 +42,7 @@ public class IoTDBStatement implements Statement {
private static final String SHOW_TIMESERIES_COMMAND_LOWERCASE = "show timeseries";
private static final String SHOW_STORAGE_GROUP_COMMAND_LOWERCASE = "show storage group";
private static final String METHOD_NOT_SUPPORTED_STRING = "Method not supported";
+
ZoneId zoneId;
private ResultSet resultSet = null;
private IoTDBConnection connection;
@@ -294,7 +286,7 @@ public class IoTDBStatement implements Statement {
TSExecuteBatchStatementReq execReq = new TSExecuteBatchStatementReq(sessionHandle,
batchSQLList);
TSExecuteBatchStatementResp execResp = client.executeBatchStatement(execReq);
- if (execResp.getStatus().statusCode == TS_StatusCode.SUCCESS_STATUS) {
+ if (execResp.getStatus().getStatusType().getCode() == TSStatusType.SUCCESS_STATUS.getStatusCode()) {
if (execResp.getResult() == null) {
return new int[0];
} else {
@@ -309,7 +301,7 @@ public class IoTDBStatement implements Statement {
} else {
BatchUpdateException exception;
if (execResp.getResult() == null) {
- exception = new BatchUpdateException(execResp.getStatus().errorMessage, new int[0]);
+ exception = new BatchUpdateException(execResp.getStatus().getStatusType().getMessage(), new int[0]);
} else {
List<Integer> result = execResp.getResult();
int len = result.size();
@@ -317,7 +309,7 @@ public class IoTDBStatement implements Statement {
for (int i = 0; i < len; i++) {
updateArray[i] = result.get(i);
}
- exception = new BatchUpdateException(execResp.getStatus().errorMessage, updateArray);
+ exception = new BatchUpdateException(execResp.getStatus().getStatusType().getMessage(), updateArray);
}
throw exception;
}
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/Utils.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/Utils.java
index 7cf52de..9ca73b2 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/Utils.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/Utils.java
@@ -18,7 +18,6 @@
*/
package org.apache.iotdb.jdbc;
-import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -32,8 +31,6 @@ import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.read.common.Field;
import org.apache.iotdb.tsfile.read.common.RowRecord;
import org.apache.iotdb.tsfile.utils.Binary;
-import org.apache.iotdb.tsfile.utils.BytesUtils;
-import org.apache.iotdb.tsfile.write.record.RowBatch;
/**
* Utils to convert between thrift format and TsFile format.
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/BatchTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/BatchTest.java
index 912019d..09505f4 100644
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/BatchTest.java
+++ b/jdbc/src/test/java/org/apache/iotdb/jdbc/BatchTest.java
@@ -29,12 +29,9 @@ import java.sql.Statement;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteBatchStatementReq;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteBatchStatementResp;
-import org.apache.iotdb.service.rpc.thrift.TSIService;
-import org.apache.iotdb.service.rpc.thrift.TS_SessionHandle;
-import org.apache.iotdb.service.rpc.thrift.TS_Status;
-import org.apache.iotdb.service.rpc.thrift.TS_StatusCode;
+
+import org.apache.iotdb.rpc.TSStatusType;
+import org.apache.iotdb.service.rpc.thrift.*;
import org.apache.thrift.TException;
import org.junit.After;
import org.junit.Before;
@@ -50,8 +47,10 @@ public class BatchTest {
private TSIService.Iface client;
@Mock
private TS_SessionHandle sessHandle;
- private TS_Status Status_SUCCESS = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
- private TS_Status Status_ERROR = new TS_Status(TS_StatusCode.ERROR_STATUS);
+ private TS_StatusType successStatus = new TS_StatusType(TSStatusType.SUCCESS_STATUS.getStatusCode(), "");
+ private TS_StatusType errorStatus = new TS_StatusType(TSStatusType.INTERNAL_SERVER_ERROR.getStatusCode(), "");
+ private TS_Status Status_SUCCESS = new TS_Status(successStatus);
+ private TS_Status Status_ERROR = new TS_Status(errorStatus);
private TSExecuteBatchStatementResp resp;
private ZoneId zoneID = ZoneId.systemDefault();
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBConnectionTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBConnectionTest.java
index e374064..36bc42b 100644
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBConnectionTest.java
+++ b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBConnectionTest.java
@@ -24,13 +24,9 @@ import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
-import org.apache.iotdb.service.rpc.thrift.ServerProperties;
-import org.apache.iotdb.service.rpc.thrift.TSGetTimeZoneResp;
-import org.apache.iotdb.service.rpc.thrift.TSIService;
-import org.apache.iotdb.service.rpc.thrift.TSSetTimeZoneReq;
-import org.apache.iotdb.service.rpc.thrift.TSSetTimeZoneResp;
-import org.apache.iotdb.service.rpc.thrift.TS_Status;
-import org.apache.iotdb.service.rpc.thrift.TS_StatusCode;
+
+import org.apache.iotdb.rpc.TSStatusType;
+import org.apache.iotdb.service.rpc.thrift.*;
import org.apache.thrift.TException;
import org.junit.After;
import org.junit.Before;
@@ -44,7 +40,8 @@ public class IoTDBConnectionTest {
private TSIService.Iface client;
private IoTDBConnection connection = new IoTDBConnection();
- private TS_Status Status_SUCCESS = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ private TS_StatusType successStatus = new TS_StatusType(TSStatusType.SUCCESS_STATUS.getStatusCode(), "");
+ private TS_Status Status_SUCCESS = new TS_Status(successStatus);
@Before
public void setUp() throws Exception {
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBDatabaseMetadataTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBDatabaseMetadataTest.java
index 1f5ac25..1fdb324 100644
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBDatabaseMetadataTest.java
+++ b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBDatabaseMetadataTest.java
@@ -30,11 +30,9 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataReq;
-import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataResp;
-import org.apache.iotdb.service.rpc.thrift.TSIService;
-import org.apache.iotdb.service.rpc.thrift.TS_Status;
-import org.apache.iotdb.service.rpc.thrift.TS_StatusCode;
+
+import org.apache.iotdb.rpc.TSStatusType;
+import org.apache.iotdb.service.rpc.thrift.*;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -66,7 +64,8 @@ public class IoTDBDatabaseMetadataTest {
@Mock
private TSFetchMetadataResp fetchMetadataResp;
- private TS_Status Status_SUCCESS = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ private TS_StatusType successStatus = new TS_StatusType(TSStatusType.SUCCESS_STATUS.getStatusCode(), "");
+ private TS_Status Status_SUCCESS = new TS_Status(successStatus);
private DatabaseMetaData databaseMetaData;
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBPreparedStatementTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBPreparedStatementTest.java
index ca9928e..f690de2 100644
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBPreparedStatementTest.java
+++ b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBPreparedStatementTest.java
@@ -26,14 +26,10 @@ import static org.mockito.Mockito.when;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.time.ZoneId;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementReq;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementResp;
-import org.apache.iotdb.service.rpc.thrift.TSGetOperationStatusResp;
+
+import org.apache.iotdb.rpc.TSStatusType;
+import org.apache.iotdb.service.rpc.thrift.*;
import org.apache.iotdb.service.rpc.thrift.TSIService.Iface;
-import org.apache.iotdb.service.rpc.thrift.TSOperationHandle;
-import org.apache.iotdb.service.rpc.thrift.TS_SessionHandle;
-import org.apache.iotdb.service.rpc.thrift.TS_Status;
-import org.apache.iotdb.service.rpc.thrift.TS_StatusCode;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -53,7 +49,8 @@ public class IoTDBPreparedStatementTest {
private Iface client;
@Mock
private TS_SessionHandle sessHandle;
- private TS_Status Status_SUCCESS = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ private TS_StatusType successStatus = new TS_StatusType(TSStatusType.SUCCESS_STATUS.getStatusCode(), "");
+ private TS_Status Status_SUCCESS = new TS_Status(successStatus);
@Mock
private TSOperationHandle tOperationHandle;
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBQueryResultSetTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBQueryResultSetTest.java
index bffc5f0..a2ce904 100644
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBQueryResultSetTest.java
+++ b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBQueryResultSetTest.java
@@ -31,20 +31,9 @@ import java.sql.Types;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
-import org.apache.iotdb.service.rpc.thrift.TSDataValue;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementReq;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementResp;
-import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataReq;
-import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataResp;
-import org.apache.iotdb.service.rpc.thrift.TSFetchResultsReq;
-import org.apache.iotdb.service.rpc.thrift.TSFetchResultsResp;
-import org.apache.iotdb.service.rpc.thrift.TSIService;
-import org.apache.iotdb.service.rpc.thrift.TSOperationHandle;
-import org.apache.iotdb.service.rpc.thrift.TSQueryDataSet;
-import org.apache.iotdb.service.rpc.thrift.TSRowRecord;
-import org.apache.iotdb.service.rpc.thrift.TS_SessionHandle;
-import org.apache.iotdb.service.rpc.thrift.TS_Status;
-import org.apache.iotdb.service.rpc.thrift.TS_StatusCode;
+
+import org.apache.iotdb.rpc.TSStatusType;
+import org.apache.iotdb.service.rpc.thrift.*;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.junit.Assert;
import org.junit.Before;
@@ -117,7 +106,8 @@ public class IoTDBQueryResultSetTest {
@Mock
private TSFetchResultsResp fetchResultsResp;
- private TS_Status Status_SUCCESS = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ private TS_StatusType successStatus = new TS_StatusType(TSStatusType.SUCCESS_STATUS.getStatusCode(), "");
+ private TS_Status Status_SUCCESS = new TS_Status(successStatus);
private ZoneId zoneID = ZoneId.systemDefault();
@Before
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBStatementTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBStatementTest.java
index d8632fc..ff5ece7 100644
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBStatementTest.java
+++ b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBStatementTest.java
@@ -30,12 +30,10 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataReq;
-import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataResp;
+
+import org.apache.iotdb.rpc.TSStatusType;
+import org.apache.iotdb.service.rpc.thrift.*;
import org.apache.iotdb.service.rpc.thrift.TSIService.Iface;
-import org.apache.iotdb.service.rpc.thrift.TS_SessionHandle;
-import org.apache.iotdb.service.rpc.thrift.TS_Status;
-import org.apache.iotdb.service.rpc.thrift.TS_StatusCode;
import org.apache.thrift.TException;
import org.junit.After;
import org.junit.Assert;
@@ -58,7 +56,8 @@ public class IoTDBStatementTest {
@Mock
private TSFetchMetadataResp fetchMetadataResp;
- private TS_Status Status_SUCCESS = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ private TS_StatusType successStatus = new TS_StatusType(TSStatusType.SUCCESS_STATUS.getStatusCode(), "");
+ private TS_Status Status_SUCCESS = new TS_Status(successStatus);
private ZoneId zoneID = ZoneId.systemDefault();
@Before
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/UtilsTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/UtilsTest.java
index 123d2e3..bc3a766 100644
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/UtilsTest.java
+++ b/jdbc/src/test/java/org/apache/iotdb/jdbc/UtilsTest.java
@@ -27,11 +27,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.apache.iotdb.rpc.RpcUtils;
+import org.apache.iotdb.rpc.TSStatusType;
import org.apache.iotdb.service.rpc.thrift.TSDataValue;
import org.apache.iotdb.service.rpc.thrift.TSQueryDataSet;
import org.apache.iotdb.service.rpc.thrift.TSRowRecord;
import org.apache.iotdb.service.rpc.thrift.TS_Status;
-import org.apache.iotdb.service.rpc.thrift.TS_StatusCode;
+
+import org.apache.iotdb.rpc.RpcUtils;
+import org.apache.iotdb.service.rpc.thrift.*;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.read.common.Field;
import org.apache.iotdb.tsfile.read.common.RowRecord;
@@ -70,13 +73,15 @@ public class UtilsTest {
@Test
public void testVerifySuccess() {
try {
- RpcUtils.verifySuccess(new TS_Status(TS_StatusCode.SUCCESS_STATUS));
+ TS_StatusType successStatus = new TS_StatusType(TSStatusType.SUCCESS_STATUS.getStatusCode(), "");
+ RpcUtils.verifySuccess(new TS_Status(successStatus));
} catch (Exception e) {
fail();
}
try {
- RpcUtils.verifySuccess(new TS_Status(TS_StatusCode.ERROR_STATUS));
+ TS_StatusType errorStatus = new TS_StatusType(TSStatusType.INTERNAL_SERVER_ERROR.getStatusCode(), "");
+ RpcUtils.verifySuccess(new TS_Status(errorStatus));
} catch (Exception e) {
return;
}
diff --git a/pom.xml b/pom.xml
index 746f838..77a2219 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,7 +44,6 @@
<url>https://github.com/apache/incubator-iotdb</url>
<tag>rel/0.8</tag>
</scm>
-
<modules>
<module>tsfile</module>
<module>service-rpc</module>
@@ -58,7 +57,6 @@
<!-- <module>hadoop</module> -->
<module>distribution</module>
</modules>
-
<!-- Properties Management -->
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
index c6324eb..513da9d 100755
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
@@ -54,9 +54,9 @@ import org.apache.iotdb.db.qp.physical.crud.BatchInsertPlan;
import org.apache.iotdb.db.qp.physical.crud.DeletePlan;
import org.apache.iotdb.db.qp.physical.crud.InsertPlan;
import org.apache.iotdb.db.query.context.QueryContext;
+import org.apache.iotdb.rpc.TSStatusType;
import org.apache.iotdb.db.utils.CopyOnReadLinkedList;
import org.apache.iotdb.db.writelog.recover.TsFileRecoverPerformer;
-import org.apache.iotdb.service.rpc.thrift.TS_StatusCode;
import org.apache.iotdb.tsfile.file.metadata.ChunkMetaData;
import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
@@ -302,7 +302,7 @@ public class StorageGroupProcessor {
List<Integer> unsequenceIndexes = new ArrayList<>();
for (int i = 0; i < batchInsertPlan.getRowCount(); i++) {
- results[i] = TS_StatusCode.SUCCESS_STATUS.getValue();
+ results[i] = TSStatusType.SUCCESS_STATUS.getStatusCode();
if (batchInsertPlan.getTimes()[i] > latestFlushedTimeForEachDevice
.get(batchInsertPlan.getDeviceId())) {
sequenceIndexes.add(i);
@@ -330,7 +330,7 @@ public class StorageGroupProcessor {
TsFileProcessor tsFileProcessor = getOrCreateTsFileProcessor(sequence);
if (tsFileProcessor == null) {
for (int index : indexes) {
- results[index] = TS_StatusCode.ERROR_STATUS.getValue();
+ results[index] = TSStatusType.INTERNAL_SERVER_ERROR.getStatusCode();
}
return;
}
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
index b46f058..5d237d1 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
@@ -48,10 +48,10 @@ import org.apache.iotdb.db.qp.physical.crud.BatchInsertPlan;
import org.apache.iotdb.db.qp.physical.crud.InsertPlan;
import org.apache.iotdb.db.query.context.QueryContext;
import org.apache.iotdb.db.rescon.MemTablePool;
+import org.apache.iotdb.rpc.TSStatusType;
import org.apache.iotdb.db.utils.QueryUtils;
import org.apache.iotdb.db.writelog.manager.MultiFileLogNodeManager;
import org.apache.iotdb.db.writelog.node.WriteLogNode;
-import org.apache.iotdb.service.rpc.thrift.TS_StatusCode;
import org.apache.iotdb.tsfile.file.metadata.ChunkMetaData;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.utils.Pair;
@@ -173,7 +173,7 @@ public class TsFileProcessor {
} catch (IOException e) {
logger.error("write WAL failed", e);
for (int index: indexes) {
- results[index] = TS_StatusCode.ERROR_STATUS.getValue();
+ results[index] = TSStatusType.INTERNAL_SERVER_ERROR.getStatusCode();
}
return false;
}
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 7ba97e7..6d54f26 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
@@ -18,24 +18,6 @@
*/
package org.apache.iotdb.db.service;
-import static org.apache.iotdb.db.conf.IoTDBConstant.PRIVILEGE;
-import static org.apache.iotdb.db.conf.IoTDBConstant.ROLE;
-import static org.apache.iotdb.db.conf.IoTDBConstant.USER;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.regex.Pattern;
import org.apache.iotdb.db.auth.AuthException;
import org.apache.iotdb.db.auth.AuthorityChecker;
import org.apache.iotdb.db.auth.authorizer.IAuthorizer;
@@ -49,12 +31,7 @@ import org.apache.iotdb.db.cost.statistic.Measurement;
import org.apache.iotdb.db.cost.statistic.Operation;
import org.apache.iotdb.db.engine.StorageEngine;
import org.apache.iotdb.db.engine.flush.pool.FlushTaskPoolManager;
-import org.apache.iotdb.db.exception.ArgsErrorException;
-import org.apache.iotdb.db.exception.MetadataErrorException;
-import org.apache.iotdb.db.exception.PathErrorException;
-import org.apache.iotdb.db.exception.ProcessorException;
-import org.apache.iotdb.db.exception.QueryInBatchStmtException;
-import org.apache.iotdb.db.exception.StorageEngineException;
+import org.apache.iotdb.db.exception.*;
import org.apache.iotdb.db.exception.qp.IllegalASTFormatException;
import org.apache.iotdb.db.exception.qp.QueryProcessorException;
import org.apache.iotdb.db.metadata.MManager;
@@ -68,36 +45,8 @@ import org.apache.iotdb.db.qp.physical.sys.AuthorPlan;
import org.apache.iotdb.db.query.context.QueryContext;
import org.apache.iotdb.db.query.control.QueryResourceManager;
import org.apache.iotdb.db.utils.QueryDataSetUtils;
-import org.apache.iotdb.service.rpc.thrift.ServerProperties;
-import org.apache.iotdb.service.rpc.thrift.TSBatchInsertionReq;
-import org.apache.iotdb.service.rpc.thrift.TSCancelOperationReq;
-import org.apache.iotdb.service.rpc.thrift.TSCancelOperationResp;
-import org.apache.iotdb.service.rpc.thrift.TSCloseOperationReq;
-import org.apache.iotdb.service.rpc.thrift.TSCloseOperationResp;
-import org.apache.iotdb.service.rpc.thrift.TSCloseSessionReq;
-import org.apache.iotdb.service.rpc.thrift.TSCloseSessionResp;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteBatchStatementReq;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteBatchStatementResp;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementReq;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementResp;
-import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataReq;
-import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataResp;
-import org.apache.iotdb.service.rpc.thrift.TSFetchResultsReq;
-import org.apache.iotdb.service.rpc.thrift.TSFetchResultsResp;
-import org.apache.iotdb.service.rpc.thrift.TSGetTimeZoneResp;
-import org.apache.iotdb.service.rpc.thrift.TSHandleIdentifier;
-import org.apache.iotdb.service.rpc.thrift.TSIService;
-import org.apache.iotdb.service.rpc.thrift.TSInsertionReq;
-import org.apache.iotdb.service.rpc.thrift.TSOpenSessionReq;
-import org.apache.iotdb.service.rpc.thrift.TSOpenSessionResp;
-import org.apache.iotdb.service.rpc.thrift.TSOperationHandle;
-import org.apache.iotdb.service.rpc.thrift.TSProtocolVersion;
-import org.apache.iotdb.service.rpc.thrift.TSQueryDataSet;
-import org.apache.iotdb.service.rpc.thrift.TSSetTimeZoneReq;
-import org.apache.iotdb.service.rpc.thrift.TSSetTimeZoneResp;
-import org.apache.iotdb.service.rpc.thrift.TS_SessionHandle;
-import org.apache.iotdb.service.rpc.thrift.TS_Status;
-import org.apache.iotdb.service.rpc.thrift.TS_StatusCode;
+import org.apache.iotdb.rpc.TSStatusType;
+import org.apache.iotdb.service.rpc.thrift.*;
import org.apache.iotdb.tsfile.common.constant.StatisticConstant;
import org.apache.iotdb.tsfile.exception.filter.QueryFilterOptimizationException;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
@@ -108,6 +57,18 @@ import org.apache.thrift.server.ServerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.ZoneId;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.regex.Pattern;
+
+import static org.apache.iotdb.db.conf.IoTDBConstant.*;
+
/**
* Thrift RPC implementation at server side.
*/
@@ -116,7 +77,6 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
private static final Logger logger = LoggerFactory.getLogger(TSServiceImpl.class);
private static final String INFO_NOT_LOGIN = "{}: Not login.";
- private static final String ERROR_NOT_LOGIN = "Not login";
protected QueryProcessor processor;
// Record the username for every rpc connection. Username.get() is null if
@@ -157,14 +117,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
}
TS_Status tsStatus;
if (status) {
- tsStatus = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
- tsStatus.setErrorMessage("login successfully.");
+ tsStatus = new TS_Status(getStatus(TSStatusType.SUCCESS_STATUS, "Login successfully"));
username.set(req.getUsername());
zoneIds.set(config.getZoneID());
initForOneSession();
} else {
- tsStatus = new TS_Status(TS_StatusCode.ERROR_STATUS);
- tsStatus.setErrorMessage("login failed. Username or password is wrong.");
+ tsStatus = getStatus(TSStatusType.WRONG_LOGIN_PASSWORD_ERROR);
}
TSOpenSessionResp resp = new TSOpenSessionResp(tsStatus,
TSProtocolVersion.IOTDB_SERVICE_PROTOCOL_V1);
@@ -172,8 +130,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
new TS_SessionHandle(new TSHandleIdentifier(ByteBuffer.wrap(req.getUsername().getBytes()),
ByteBuffer.wrap(req.getPassword().getBytes()))));
logger.info("{}: Login status: {}. User : {}", IoTDBConstant.GLOBAL_DB_NAME,
- tsStatus.getErrorMessage(),
- req.getUsername());
+ tsStatus.getStatusType().getMessage(), req.getUsername());
return resp;
}
@@ -188,13 +145,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
logger.info("{}: receive close session", IoTDBConstant.GLOBAL_DB_NAME);
TS_Status tsStatus;
if (username.get() == null) {
- tsStatus = new TS_Status(TS_StatusCode.ERROR_STATUS);
- tsStatus.setErrorMessage("Has not logged in");
+ tsStatus = getStatus(TSStatusType.NOT_LOGIN_ERROR);
if (zoneIds.get() != null) {
zoneIds.remove();
}
} else {
- tsStatus = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ tsStatus = new TS_Status(getStatus(TSStatusType.SUCCESS_STATUS));
username.remove();
if (zoneIds.get() != null) {
zoneIds.remove();
@@ -205,7 +161,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
@Override
public TSCancelOperationResp cancelOperation(TSCancelOperationReq req) {
- return new TSCancelOperationResp(new TS_Status(TS_StatusCode.SUCCESS_STATUS));
+ return new TSCancelOperationResp(getStatus(TSStatusType.SUCCESS_STATUS));
}
@Override
@@ -224,7 +180,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
} catch (Exception e) {
logger.error("Error in closeOperation : ", e);
}
- return new TSCloseOperationResp(new TS_Status(TS_StatusCode.SUCCESS_STATUS));
+ return new TSCloseOperationResp(getStatus(TSStatusType.SUCCESS_STATUS));
}
private void releaseQueryResource(TSCloseOperationReq req) throws StorageEngineException {
@@ -253,9 +209,29 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
}
}
- private TS_Status getErrorStatus(String message) {
- TS_Status status = new TS_Status(TS_StatusCode.ERROR_STATUS);
- status.setErrorMessage(message);
+ /**
+ * convert from TSStatusType to TS_Status according to status code and status message
+ *
+ * @param statusType status type
+ * @return
+ */
+ private TS_Status getStatus(TSStatusType statusType) {
+ TS_StatusType statusCodeAndMessage = new TS_StatusType(statusType.getStatusCode(), statusType.getStatusMessage());
+ TS_Status status = new TS_Status(statusCodeAndMessage);
+ return status;
+ }
+
+ /**
+ * convert from TSStatusType to TS_Status, which has message appending with existed status message
+ *
+ * @param statusType status type
+ * @param appendMessage appending message
+ * @return
+ */
+ private TS_Status getStatus(TSStatusType statusType, String appendMessage) {
+ TS_StatusType statusCodeAndMessage = new TS_StatusType(statusType.getStatusCode(),
+ statusType.getStatusMessage() + ": " + appendMessage);
+ TS_Status status = new TS_Status(statusCodeAndMessage);
return status;
}
@@ -264,7 +240,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
TS_Status status;
if (!checkLogin()) {
logger.info(INFO_NOT_LOGIN, IoTDBConstant.GLOBAL_DB_NAME);
- status = getErrorStatus(ERROR_NOT_LOGIN);
+ status = getStatus(TSStatusType.NOT_LOGIN_ERROR);
return new TSFetchMetadataResp(status);
}
TSFetchMetadataResp resp = new TSFetchMetadataResp();
@@ -274,17 +250,17 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
String path = req.getColumnPath();
List<List<String>> showTimeseriesList = getTimeSeriesForPath(path);
resp.setShowTimeseriesList(showTimeseriesList);
- status = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ status = new TS_Status(getStatus(TSStatusType.SUCCESS_STATUS));
break;
case "SHOW_STORAGE_GROUP":
Set<String> storageGroups = getAllStorageGroups();
resp.setShowStorageGroups(storageGroups);
- status = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ status = new TS_Status(getStatus(TSStatusType.SUCCESS_STATUS));
break;
case "METADATA_IN_JSON":
String metadataInJson = getMetadataInString();
resp.setMetadataInJson(metadataInJson);
- status = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ status = new TS_Status(getStatus(TSStatusType.SUCCESS_STATUS));
break;
case "DELTA_OBEJECT":
Metadata metadata = getMetadata();
@@ -295,21 +271,18 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
} else {
resp.setColumnsList(deviceMap.get(column));
}
- status = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ status = new TS_Status(getStatus(TSStatusType.SUCCESS_STATUS));
break;
case "COLUMN":
resp.setDataType(getSeriesType(req.getColumnPath()).toString());
- status = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ status = new TS_Status(getStatus(TSStatusType.SUCCESS_STATUS));
break;
case "ALL_COLUMNS":
resp.setColumnsList(getPaths(req.getColumnPath()));
- status = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ status = new TS_Status(getStatus(TSStatusType.SUCCESS_STATUS));
break;
default:
- status = new TS_Status(TS_StatusCode.ERROR_STATUS);
- status
- .setErrorMessage(
- String.format("Unsupported fetch metadata operation %s", req.getType()));
+ status = getStatus(TSStatusType.FETCH_METADATA_ERROR, req.getType());
break;
}
} catch (PathErrorException | MetadataErrorException | OutOfMemoryError e) {
@@ -317,8 +290,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
.error(String.format("Failed to fetch timeseries %s's metadata", req.getColumnPath()),
e);
Thread.currentThread().interrupt();
- status = getErrorStatus(
- String.format("Failed to fetch metadata because: %s", e));
+ status = getStatus(TSStatusType.FETCH_METADATA_ERROR, e.getMessage());
resp.setStatus(status);
return resp;
}
@@ -421,7 +393,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
try {
if (!checkLogin()) {
logger.info(INFO_NOT_LOGIN, IoTDBConstant.GLOBAL_DB_NAME);
- return getTSBathExecuteStatementResp(TS_StatusCode.ERROR_STATUS, ERROR_NOT_LOGIN, null);
+ return getTSBatchExecuteStatementResp(getStatus(TSStatusType.NOT_LOGIN_ERROR), null);
}
List<String> statements = req.getStatements();
@@ -436,16 +408,15 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
}
if (isAllSuccessful) {
- return getTSBathExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS,
- "Execute batch statements successfully", result);
+ return getTSBatchExecuteStatementResp(getStatus(TSStatusType.SUCCESS_STATUS,
+ "Execute batch statements successfully"), result);
} else {
- return getTSBathExecuteStatementResp(TS_StatusCode.ERROR_STATUS,
- batchErrorMessage.toString(),
- result);
+ return getTSBatchExecuteStatementResp(getStatus(TSStatusType.EXECUTE_STATEMENT_ERROR,
+ batchErrorMessage.toString()), result);
}
} catch (Exception e) {
logger.error("{}: error occurs when executing statements", IoTDBConstant.GLOBAL_DB_NAME, e);
- return getTSBathExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage(), null);
+ return getTSBatchExecuteStatementResp(getStatus(TSStatusType.EXECUTE_STATEMENT_ERROR, e.getMessage()), null);
} finally {
Measurement.INSTANCE.addOperationLatency(Operation.EXECUTE_JDBC_BATCH, t1);
}
@@ -461,11 +432,11 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
throw new QueryInBatchStmtException("Query statement not allowed in batch: " + statement);
}
TSExecuteStatementResp resp = executeUpdateStatement(physicalPlan);
- if (resp.getStatus().getStatusCode().equals(TS_StatusCode.SUCCESS_STATUS)) {
+ if (resp.getStatus().getStatusType().getCode() == TSStatusType.SUCCESS_STATUS.getStatusCode()) {
result.add(Statement.SUCCESS_NO_INFO);
} else {
result.add(Statement.EXECUTE_FAILED);
- batchErrorMessage.append(resp.getStatus().getErrorMessage()).append("\n");
+ batchErrorMessage.append(resp.getStatus().getStatusType().getCode()).append("\n");
return false;
}
} catch (Exception e) {
@@ -487,12 +458,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
try {
if (!checkLogin()) {
logger.info(INFO_NOT_LOGIN, IoTDBConstant.GLOBAL_DB_NAME);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, ERROR_NOT_LOGIN);
+ return getTSExecuteStatementResp(getStatus(TSStatusType.NOT_LOGIN_ERROR));
}
String statement = req.getStatement();
if (execAdminCommand(statement)) {
- return getTSExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, "ADMIN_COMMAND_SUCCESS");
+ return getTSExecuteStatementResp(getStatus(TSStatusType.SUCCESS_STATUS, "ADMIN_COMMAND_SUCCESS"));
}
if (execShowFlushInfo(statement)) {
@@ -501,7 +472,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
FlushTaskPoolManager.getInstance().getTotalTasks(),
FlushTaskPoolManager.getInstance().getWorkingTasksNumber(),
FlushTaskPoolManager.getInstance().getWaitingTasksNumber());
- return getTSExecuteStatementResp(TS_StatusCode.SUCCESS_WITH_INFO_STATUS, msg);
+ return getTSExecuteStatementResp(getStatus(TSStatusType.SUCCESS_STATUS, msg));
}
if (execShowDynamicParameters(statement)) {
@@ -515,12 +486,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
MManager.getInstance().getAllStorageGroup().size(),
IoTDBConfigDynamicAdapter.getInstance().getTotalTimeseries(),
MManager.getInstance().getMaximalSeriesNumberAmongStorageGroups());
- return getTSExecuteStatementResp(TS_StatusCode.SUCCESS_WITH_INFO_STATUS, msg);
+ return getTSExecuteStatementResp(getStatus(TSStatusType.SUCCESS_STATUS, msg));
}
if (execSetConsistencyLevel(statement)) {
- return getTSExecuteStatementResp(TS_StatusCode.SUCCESS_WITH_INFO_STATUS,
- "Execute set consistency level successfully");
+ return getTSExecuteStatementResp(getStatus(TSStatusType.SUCCESS_STATUS,
+ "Execute set consistency level successfully"));
}
PhysicalPlan physicalPlan;
@@ -532,11 +503,11 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
}
} catch (IllegalASTFormatException e) {
logger.debug("meet error while parsing SQL to physical plan: ", e);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS,
- "Statement format is not right:" + e.getMessage());
+ return getTSExecuteStatementResp(getStatus(TSStatusType.SQL_PARSE_ERROR,
+ "Statement format is not right: " + e.getMessage()));
} catch (Exception e) {
logger.info("meet error while executing statement: {}", req.getStatement(), e);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
+ return getTSExecuteStatementResp(getStatus(TSStatusType.EXECUTE_STATEMENT_ERROR, e.getMessage()));
}
}
@@ -608,7 +579,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
return resp;
} catch (Exception e) {
logger.error("{}: Internal server error: ", IoTDBConstant.GLOBAL_DB_NAME, e);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
+ return getTSExecuteStatementResp(getStatus(TSStatusType.INTERNAL_SERVER_ERROR, e.getMessage()));
} finally {
Measurement.INSTANCE.addOperationLatency(Operation.EXECUTE_QUERY, t1);
}
@@ -618,7 +589,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
public TSExecuteStatementResp executeQueryStatement(TSExecuteStatementReq req) {
if (!checkLogin()) {
logger.info(INFO_NOT_LOGIN, IoTDBConstant.GLOBAL_DB_NAME);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, ERROR_NOT_LOGIN);
+ return getTSExecuteStatementResp(getStatus(TSStatusType.NOT_LOGIN_ERROR));
}
String statement = req.getStatement();
@@ -627,12 +598,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
physicalPlan = processor.parseSQLToPhysicalPlan(statement, zoneIds.get());
} catch (QueryProcessorException | ArgsErrorException | MetadataErrorException e) {
logger.error("meet error while parsing SQL to physical plan!", e);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
+ return getTSExecuteStatementResp(getStatus(TSStatusType.SQL_PARSE_ERROR, e.getMessage()));
}
if (!physicalPlan.isQuery()) {
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS,
- "Statement is not a query statement.");
+ return getTSExecuteStatementResp(getStatus(TSStatusType.EXECUTE_STATEMENT_ERROR,
+ "Statement is not a query statement."));
}
return executeQueryStatement(statement, physicalPlan);
}
@@ -646,7 +617,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
}
private TSExecuteStatementResp executeAuthQuery(PhysicalPlan plan, List<String> columns) {
- TSExecuteStatementResp resp = getTSExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, "");
+ TSExecuteStatementResp resp = getTSExecuteStatementResp(getStatus(TSStatusType.SUCCESS_STATUS));
resp.setIgnoreTimeStamp(true);
AuthorPlan authorPlan = (AuthorPlan) plan;
switch (authorPlan.getAuthorType()) {
@@ -670,8 +641,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
columns.add(PRIVILEGE);
break;
default:
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, String.format("%s is not an "
- + "auth query", authorPlan.getAuthorType()));
+ return getTSExecuteStatementResp(getStatus(TSStatusType.SQL_PARSE_ERROR,
+ String.format("%s is not an auth query", authorPlan.getAuthorType())));
}
return resp;
}
@@ -682,7 +653,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
// check seriesPath exists
if (paths.isEmpty()) {
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Timeseries does not exist.");
+ return getTSExecuteStatementResp(getStatus(TSStatusType.TIMESERIES_NOT_EXIST_ERROR));
}
// check file level set
@@ -690,16 +661,15 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
checkFileLevelSet(paths);
} catch (PathErrorException e) {
logger.error("meet error while checking file level.", e);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
+ return getTSExecuteStatementResp(getStatus(TSStatusType.CHECK_FILE_LEVEL_ERROR, e.getMessage()));
}
// check permissions
if (!checkAuthorization(paths, plan)) {
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS,
- "No permissions for this query.");
+ return getTSExecuteStatementResp(getStatus(TSStatusType.NO_PERMISSION_ERROR));
}
- TSExecuteStatementResp resp = getTSExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, "");
+ TSExecuteStatementResp resp = getTSExecuteStatementResp(getStatus(TSStatusType.SUCCESS_STATUS));
// Restore column header of aggregate to func(column_name), only
// support single aggregate function for now
switch (plan.getOperatorType()) {
@@ -735,12 +705,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
public TSFetchResultsResp fetchResults(TSFetchResultsReq req) {
try {
if (!checkLogin()) {
- return getTSFetchResultsResp(TS_StatusCode.ERROR_STATUS, "Not login.");
+ return getTSFetchResultsResp(getStatus(TSStatusType.NOT_LOGIN_ERROR));
}
String statement = req.getStatement();
if (!queryStatus.get().containsKey(statement)) {
- return getTSFetchResultsResp(TS_StatusCode.ERROR_STATUS, "Has not executed statement");
+ return getTSFetchResultsResp(getStatus(TSStatusType.EXECUTE_STATEMENT_ERROR, "Has not executed statement"));
}
QueryDataSet queryDataSet;
@@ -759,14 +729,14 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
queryRet.get().remove(statement);
}
- TSFetchResultsResp resp = getTSFetchResultsResp(TS_StatusCode.SUCCESS_STATUS,
- "FetchResult successfully. Has more result: " + hasResultSet);
+ TSFetchResultsResp resp = getTSFetchResultsResp(getStatus(TSStatusType.SUCCESS_STATUS,
+ "FetchResult successfully. Has more result: " + hasResultSet));
resp.setHasResultSet(hasResultSet);
resp.setQueryDataSet(result);
return resp;
} catch (Exception e) {
logger.error("{}: Internal server error: ", IoTDBConstant.GLOBAL_DB_NAME, e);
- return getTSFetchResultsResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
+ return getTSFetchResultsResp(getStatus(TSStatusType.INTERNAL_SERVER_ERROR, e.getMessage()));
}
}
@@ -801,13 +771,13 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
try {
if (!checkLogin()) {
logger.info(INFO_NOT_LOGIN, IoTDBConstant.GLOBAL_DB_NAME);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, ERROR_NOT_LOGIN);
+ return getTSExecuteStatementResp(getStatus(TSStatusType.NOT_LOGIN_ERROR));
}
String statement = req.getStatement();
return executeUpdateStatement(statement);
} catch (Exception e) {
logger.error("{}: server Internal Error: ", IoTDBConstant.GLOBAL_DB_NAME, e);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
+ return getTSExecuteStatementResp(getStatus(TSStatusType.INTERNAL_SERVER_ERROR, e.getMessage()));
}
}
@@ -815,13 +785,11 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
List<Path> paths = plan.getPaths();
try {
if (!checkAuthorization(paths, plan)) {
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS,
- "No permissions for this operation " + plan.getOperatorType());
+ return getTSExecuteStatementResp(getStatus(TSStatusType.NO_PERMISSION_ERROR, plan.getOperatorType().toString()));
}
} catch (AuthException e) {
logger.error("meet error while checking authorization.", e);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS,
- "Uninitialized authorizer " + e.getMessage());
+ return getTSExecuteStatementResp(getStatus(TSStatusType.UNINITIALIZED_AUTH_ERROR, e.getMessage()));
}
// TODO
// In current version, we only return OK/ERROR
@@ -831,12 +799,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
execRet = executeNonQuery(plan);
} catch (ProcessorException e) {
logger.debug("meet error while processing non-query. ", e);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
+ return getTSExecuteStatementResp(getStatus(TSStatusType.EXECUTE_STATEMENT_ERROR, e.getMessage()));
}
- TS_StatusCode statusCode = execRet ? TS_StatusCode.SUCCESS_STATUS : TS_StatusCode.ERROR_STATUS;
+ TSStatusType statusType = execRet ? TSStatusType.SUCCESS_STATUS : TSStatusType.EXECUTE_STATEMENT_ERROR;
String msg = execRet ? "Execute successfully" : "Execute statement error.";
- TSExecuteStatementResp resp = getTSExecuteStatementResp(statusCode, msg);
+ TSExecuteStatementResp resp = getTSExecuteStatementResp(getStatus(statusType, msg));
TSHandleIdentifier operationId = new TSHandleIdentifier(
ByteBuffer.wrap(username.get().getBytes()),
ByteBuffer.wrap("PASS".getBytes()));
@@ -861,12 +829,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
physicalPlan = processor.parseSQLToPhysicalPlan(statement, zoneIds.get());
} catch (QueryProcessorException | ArgsErrorException | MetadataErrorException e) {
logger.error("meet error while parsing SQL to physical plan!", e);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
+ return getTSExecuteStatementResp(getStatus(TSStatusType.SQL_PARSE_ERROR, e.getMessage()));
}
if (physicalPlan.isQuery()) {
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS,
- "Statement is a query statement.");
+ return getTSExecuteStatementResp(getStatus(TSStatusType.EXECUTE_STATEMENT_ERROR,
+ "Statement is a query statement."));
}
return executeUpdateStatement(physicalPlan);
@@ -895,10 +863,9 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
return AuthorityChecker.check(username.get(), paths, plan.getOperatorType(), targetUser);
}
- private TSExecuteStatementResp getTSExecuteStatementResp(TS_StatusCode code, String msg) {
+ private TSExecuteStatementResp getTSExecuteStatementResp(TS_Status status) {
TSExecuteStatementResp resp = new TSExecuteStatementResp();
- TS_Status tsStatus = new TS_Status(code);
- tsStatus.setErrorMessage(msg);
+ TS_Status tsStatus = new TS_Status(status);
resp.setStatus(tsStatus);
TSHandleIdentifier operationId = new TSHandleIdentifier(
ByteBuffer.wrap(username.get().getBytes()),
@@ -908,21 +875,17 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
return resp;
}
- private TSExecuteBatchStatementResp getTSBathExecuteStatementResp(TS_StatusCode code,
- String msg,
- List<Integer> result) {
+ private TSExecuteBatchStatementResp getTSBatchExecuteStatementResp(TS_Status status, List<Integer> result) {
TSExecuteBatchStatementResp resp = new TSExecuteBatchStatementResp();
- TS_Status tsStatus = new TS_Status(code);
- tsStatus.setErrorMessage(msg);
+ TS_Status tsStatus = new TS_Status(status);
resp.setStatus(tsStatus);
resp.setResult(result);
return resp;
}
- private TSFetchResultsResp getTSFetchResultsResp(TS_StatusCode code, String msg) {
+ private TSFetchResultsResp getTSFetchResultsResp(TS_Status status) {
TSFetchResultsResp resp = new TSFetchResultsResp();
- TS_Status tsStatus = new TS_Status(code);
- tsStatus.setErrorMessage(msg);
+ TS_Status tsStatus = new TS_Status(status);
resp.setStatus(tsStatus);
return resp;
}
@@ -937,12 +900,11 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
TS_Status tsStatus;
TSGetTimeZoneResp resp;
try {
- tsStatus = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ tsStatus = new TS_Status(getStatus(TSStatusType.SUCCESS_STATUS));
resp = new TSGetTimeZoneResp(tsStatus, zoneIds.get().toString());
} catch (Exception e) {
logger.error("meet error while generating time zone.", e);
- tsStatus = new TS_Status(TS_StatusCode.ERROR_STATUS);
- tsStatus.setErrorMessage(e.getMessage());
+ tsStatus = getStatus(TSStatusType.GENERATE_TIME_ZONE_ERROR);
resp = new TSGetTimeZoneResp(tsStatus, "Unknown time zone");
}
return resp;
@@ -954,11 +916,10 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
try {
String timeZoneID = req.getTimeZone();
zoneIds.set(ZoneId.of(timeZoneID));
- tsStatus = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
+ tsStatus = new TS_Status(getStatus(TSStatusType.SUCCESS_STATUS));
} catch (Exception e) {
logger.error("meet error while setting time zone.", e);
- tsStatus = new TS_Status(TS_StatusCode.ERROR_STATUS);
- tsStatus.setErrorMessage(e.getMessage());
+ tsStatus = getStatus(TSStatusType.SET_TIME_ZONE_ERROR);
}
return new TSSetTimeZoneResp(tsStatus);
}
@@ -979,7 +940,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
public TSExecuteStatementResp insert(TSInsertionReq req) {
if (!checkLogin()) {
logger.info(INFO_NOT_LOGIN, IoTDBConstant.GLOBAL_DB_NAME);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, ERROR_NOT_LOGIN);
+ return getTSExecuteStatementResp(getStatus(TSStatusType.NOT_LOGIN_ERROR));
}
long stmtId = req.getStmtId();
@@ -1003,7 +964,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
return executeUpdateStatement(plan);
} catch (Exception e) {
logger.info("meet error while executing an insertion into {}", req.getDeviceId(), e);
- return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
+ return getTSExecuteStatementResp(getStatus(TSStatusType.EXECUTE_STATEMENT_ERROR, e.getMessage()));
}
}
@@ -1013,7 +974,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
try {
if (!checkLogin()) {
logger.info(INFO_NOT_LOGIN, IoTDBConstant.GLOBAL_DB_NAME);
- return getTSBathExecuteStatementResp(TS_StatusCode.ERROR_STATUS, ERROR_NOT_LOGIN, null);
+ return getTSBatchExecuteStatementResp(getStatus(TSStatusType.NOT_LOGIN_ERROR), null);
}
BatchInsertPlan batchInsertPlan = new BatchInsertPlan(req.deviceId, req.measurements);
@@ -1030,19 +991,19 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
List<Path> paths = batchInsertPlan.getPaths();
try {
if (!checkAuthorization(paths, batchInsertPlan)) {
- return getTSBathExecuteStatementResp(TS_StatusCode.ERROR_STATUS,
- "No permissions for this operation " + batchInsertPlan.getOperatorType(), null);
+ return getTSBatchExecuteStatementResp(getStatus(TSStatusType.NO_PERMISSION_ERROR,
+ "No permissions for this operation " + batchInsertPlan.getOperatorType()), null);
}
} catch (AuthException e) {
logger.error("meet error while checking authorization.", e);
- return getTSBathExecuteStatementResp(TS_StatusCode.ERROR_STATUS,
- "Uninitialized authorizer " + e.getMessage(), null);
+ return getTSBatchExecuteStatementResp(getStatus(TSStatusType.UNINITIALIZED_AUTH_ERROR,
+ "Uninitialized authorizer " + e.getMessage()), null);
}
Integer[] results = processor.getExecutor().insertBatch(batchInsertPlan);
for (Integer result : results) {
- if (result != TS_StatusCode.SUCCESS_STATUS.getValue()) {
+ if (result != TSStatusType.SUCCESS_STATUS.getStatusCode()) {
isAllSuccessful = false;
break;
}
@@ -1050,14 +1011,14 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
if (isAllSuccessful) {
logger.debug("Insert one RowBatch successfully");
- return getTSBathExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, "", Arrays.asList(results));
+ return getTSBatchExecuteStatementResp(getStatus(TSStatusType.SUCCESS_STATUS), Arrays.asList(results));
} else {
logger.debug("Insert one RowBatch failed!");
- return getTSBathExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "", Arrays.asList(results));
+ return getTSBatchExecuteStatementResp(getStatus(TSStatusType.INTERNAL_SERVER_ERROR), Arrays.asList(results));
}
} catch (Exception e) {
logger.error("{}: error occurs when executing statements", IoTDBConstant.GLOBAL_DB_NAME, e);
- return getTSBathExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage(), null);
+ return getTSBatchExecuteStatementResp(getStatus(TSStatusType.EXECUTE_STATEMENT_ERROR, e.getMessage()), null);
} finally {
Measurement.INSTANCE.addOperationLatency(Operation.EXECUTE_RPC_BATCH_INSERT, t1);
}
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationIT.java
index be1eee8..7529f49 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationIT.java
@@ -510,7 +510,7 @@ public class IoTDBAggregationIT {
resultSet.next();
fail();
} catch (Exception e) {
- Assert.assertEquals("Unsupported data type in aggregation MEAN : TEXT", e.getMessage());
+ Assert.assertEquals("Internal server error: Unsupported data type in aggregation MEAN : TEXT", e.getMessage());
}
statement.close();
@@ -523,7 +523,7 @@ public class IoTDBAggregationIT {
resultSet.next();
fail();
} catch (Exception e) {
- Assert.assertEquals("Unsupported data type in aggregation SUM : TEXT", e.getMessage());
+ Assert.assertEquals("Internal server error: Unsupported data type in aggregation SUM : TEXT", e.getMessage());
}
statement.close();
@@ -536,7 +536,7 @@ public class IoTDBAggregationIT {
resultSet.next();
fail();
} catch (Exception e) {
- Assert.assertEquals("Unsupported data type in aggregation MEAN : BOOLEAN", e.getMessage());
+ Assert.assertEquals("Internal server error: Unsupported data type in aggregation MEAN : BOOLEAN", e.getMessage());
}
statement.close();
@@ -549,7 +549,7 @@ public class IoTDBAggregationIT {
resultSet.next();
fail();
} catch (Exception e) {
- Assert.assertEquals("Unsupported data type in aggregation SUM : BOOLEAN", e.getMessage());
+ Assert.assertEquals("Internal server error: Unsupported data type in aggregation SUM : BOOLEAN", e.getMessage());
}
statement.close();
} catch (Exception e) {
diff --git a/service-rpc/src/main/java/org/apache/iotdb/rpc/RpcUtils.java b/service-rpc/src/main/java/org/apache/iotdb/rpc/RpcUtils.java
index 908812c..74df2bc 100644
--- a/service-rpc/src/main/java/org/apache/iotdb/rpc/RpcUtils.java
+++ b/service-rpc/src/main/java/org/apache/iotdb/rpc/RpcUtils.java
@@ -21,7 +21,6 @@ package org.apache.iotdb.rpc;
import java.lang.reflect.Proxy;
import org.apache.iotdb.service.rpc.thrift.TSIService;
import org.apache.iotdb.service.rpc.thrift.TS_Status;
-import org.apache.iotdb.service.rpc.thrift.TS_StatusCode;
public class RpcUtils {
@@ -36,8 +35,8 @@ public class RpcUtils {
* @param status -status
*/
public static void verifySuccess(TS_Status status) throws IoTDBRPCException {
- if (status.getStatusCode() != TS_StatusCode.SUCCESS_STATUS) {
- throw new IoTDBRPCException(status.errorMessage);
+ if (status.getStatusType().getCode() != TSStatusType.SUCCESS_STATUS.getStatusCode()) {
+ throw new IoTDBRPCException(status.getStatusType().getMessage());
}
}
diff --git a/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusType.java b/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusType.java
new file mode 100644
index 0000000..5a4acf6
--- /dev/null
+++ b/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusType.java
@@ -0,0 +1,55 @@
+/**
+ * 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.rpc;
+
+public enum TSStatusType {
+ SUCCESS_STATUS(200, ""),
+ STILL_EXECUTING_STATUS(201, ""),
+ INVALID_HANDLE_STATUS(202, ""),
+ TIMESERIES_NOT_EXIST_ERROR(301, "Timeseries does not exist"),
+ UNSUPPORTED_FETCH_METADATA_OPERATION_ERROR(302, "Unsupported fetch metadata operation"),
+ FETCH_METADATA_ERROR(303, "Failed to fetch metadata"),
+ CHECK_FILE_LEVEL_ERROR(304, "Meet error while checking file level"),
+ EXECUTE_STATEMENT_ERROR(400, "Execute statement error"),
+ SQL_PARSE_ERROR(401, "Meet error while parsing SQL"),
+ GENERATE_TIME_ZONE_ERROR(402, "Meet error while generating time zone"),
+ SET_TIME_ZONE_ERROR(403, "Meet error while setting time zone"),
+ INTERNAL_SERVER_ERROR(500, "Internal server error"),
+ WRONG_LOGIN_PASSWORD_ERROR(600, "Username or password is wrong"),
+ NOT_LOGIN_ERROR(601, "Has not logged in"),
+ NO_PERMISSION_ERROR(602, "No permissions for this operation"),
+ UNINITIALIZED_AUTH_ERROR(603, "Uninitialized authorizer");
+
+ private int statusCode;
+ private String statusMessage;
+
+ private TSStatusType(int statusCode, String statusMessage) {
+ this.statusCode = statusCode;
+ this.statusMessage = statusMessage;
+ }
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ public String getStatusMessage() {
+ return statusMessage;
+ }
+}
diff --git a/service-rpc/src/main/thrift/rpc.thrift b/service-rpc/src/main/thrift/rpc.thrift
index a96284b..13aae09 100644
--- a/service-rpc/src/main/thrift/rpc.thrift
+++ b/service-rpc/src/main/thrift/rpc.thrift
@@ -18,28 +18,17 @@
*/
namespace java org.apache.iotdb.service.rpc.thrift
-
-// The return status code contained in each response.
-enum TS_StatusCode {
- SUCCESS_STATUS,
- SUCCESS_WITH_INFO_STATUS,
- STILL_EXECUTING_STATUS,
- ERROR_STATUS,
- INVALID_HANDLE_STATUS
+// The return status code and message in each response.
+struct TS_StatusType {
+ 1: required i32 code
+ 2: required string message
}
// The return status of a remote request
struct TS_Status {
- 1: required TS_StatusCode statusCode
-
- // If status is SUCCESS_WITH_INFO, info_msgs may be populated with
- // additional diagnostic information.
+ 1: required TS_StatusType statusType
2: optional list<string> infoMessages
-
- // If status is ERROR, then the following fields may be set
3: optional string sqlState // as defined in the ISO/IEF CLIENT specification
- 4: optional i32 errorCode // internal error code
- 5: optional string errorMessage
}
struct TSHandleIdentifier {