提交 dd879eb8 编写于 作者: Q qiaojialin

fix IT test, IoTDBRPCException -> IoTDBSQLException, default user/password

上级 6320a45b
......@@ -38,11 +38,11 @@ public class Config {
*/
public static final String DEFAULT_SERIES_NAME = "default";
public static final String AUTH_USER = "root";
public static final String DEFAULT_USER = "root";
public static final String AUTH_USER = "user";
public static final String DEFAULT_USER = "user";
public static final String AUTH_PASSWORD = "root";
public static final String DEFALUT_PASSWORD = "root";
public static final String AUTH_PASSWORD = "password";
public static final String DEFALUT_PASSWORD = "password";
public static final int RETRY_NUM = 3;
public static final long RETRY_INTERVAL = 1000;
......
......@@ -424,7 +424,7 @@ public class IoTDBConnection implements Connection {
} catch (IoTDBRPCException e) {
// failed to connect, disconnect from the server
transport.close();
throw new SQLException(e);
throw new IoTDBSQLException(e);
}
if (protocolVersion.getValue() != openResp.getServerProtocolVersion().getValue()) {
throw new TException(String
......
......@@ -84,9 +84,13 @@ public class IoTDBDatabaseMetadata implements DatabaseMetaData {
req.setColumnPath(schemaPattern);
try {
TSFetchMetadataResp resp = client.fetchMetadata(req);
RpcUtils.verifySuccess(resp.getStatus());
try {
RpcUtils.verifySuccess(resp.getStatus());
} catch (IoTDBRPCException e) {
throw new IoTDBSQLException(e);
}
return new IoTDBMetadataResultSet(resp.getColumnsList(), null, null);
} catch (TException | IoTDBRPCException e) {
} catch (TException e) {
throw new TException("Conncetion error when fetching column metadata", e);
}
case Constant.CATALOG_DEVICE:
......@@ -94,19 +98,27 @@ public class IoTDBDatabaseMetadata implements DatabaseMetaData {
req.setColumnPath(schemaPattern);
try {
TSFetchMetadataResp resp = client.fetchMetadata(req);
RpcUtils.verifySuccess(resp.getStatus());
try {
RpcUtils.verifySuccess(resp.getStatus());
} catch (IoTDBRPCException e) {
throw new IoTDBSQLException(e);
}
return new IoTDBMetadataResultSet(resp.getColumnsList(), null, null);
} catch (TException | IoTDBRPCException e) {
} catch (TException e) {
throw new TException("Conncetion error when fetching delta object metadata", e);
}
case Constant.CATALOG_STORAGE_GROUP:
req = new TSFetchMetadataReq(Constant.GLOBAL_SHOW_STORAGE_GROUP_REQ);
try {
TSFetchMetadataResp resp = client.fetchMetadata(req);
RpcUtils.verifySuccess(resp.getStatus());
try {
RpcUtils.verifySuccess(resp.getStatus());
} catch (IoTDBRPCException e) {
throw new IoTDBSQLException(e);
}
Set<String> showStorageGroup = resp.getShowStorageGroups();
return new IoTDBMetadataResultSet(null, showStorageGroup, null);
} catch (TException | IoTDBRPCException e) {
} catch (TException e) {
throw new TException("Conncetion error when fetching storage group metadata", e);
}
case Constant.CATALOG_TIMESERIES:
......@@ -114,10 +126,14 @@ public class IoTDBDatabaseMetadata implements DatabaseMetaData {
req.setColumnPath(schemaPattern);
try {
TSFetchMetadataResp resp = client.fetchMetadata(req);
RpcUtils.verifySuccess(resp.getStatus());
try {
RpcUtils.verifySuccess(resp.getStatus());
} catch (IoTDBRPCException e) {
throw new IoTDBSQLException(e);
}
List<List<String>> showTimeseriesList = resp.getShowTimeseriesList();
return new IoTDBMetadataResultSet(null, null, showTimeseriesList);
} catch (TException | IoTDBRPCException e) {
} catch (TException e) {
throw new TException("Conncetion error when fetching timeseries metadata", e);
}
default:
......
......@@ -710,7 +710,11 @@ public class IoTDBQueryResultSet implements ResultSet {
try {
TSFetchResultsResp resp = client.fetchResults(req);
RpcUtils.verifySuccess(resp.getStatus());
try {
RpcUtils.verifySuccess(resp.getStatus());
} catch (IoTDBRPCException e) {
throw new IoTDBSQLException(e);
}
if (!resp.hasResultSet) {
emptyResultSet = true;
} else {
......@@ -718,7 +722,7 @@ public class IoTDBQueryResultSet implements ResultSet {
List<RowRecord> records = Utils.convertRowRecords(tsQueryDataSet);
recordItr = records.iterator();
}
} catch (TException | IoTDBRPCException e) {
} catch (TException e) {
throw new SQLException(
"Cannot fetch result from server, because of network connection: {} ", e);
}
......
......@@ -251,7 +251,7 @@ public class IoTDBStatement implements Statement {
try {
RpcUtils.verifySuccess(execResp.getStatus());
} catch (IoTDBRPCException e) {
throw new SQLException(e);
throw new IoTDBSQLException(e);
}
if (execResp.getOperationHandle().hasResultSet) {
IoTDBQueryResultSet resSet = new IoTDBQueryResultSet(this,
......@@ -355,7 +355,7 @@ public class IoTDBStatement implements Statement {
try {
RpcUtils.verifySuccess(execResp.getStatus());
} catch (IoTDBRPCException e) {
throw new SQLException(e);
throw new IoTDBSQLException(e);
}
IoTDBQueryResultSet resSet = new IoTDBQueryResultSet(this, execResp.getColumns(), client,
operationHandle, sql, execResp.getOperationType(), execResp.getDataTypeList(),
......
......@@ -381,6 +381,7 @@
<module>tsfile</module>
<module>service-rpc</module>
<module>jdbc</module>
<module>session</module>
<module>client</module>
<module>server</module>
<module>example</module>
......@@ -388,7 +389,6 @@
<module>spark-tsfile</module>
<!-- <module>hadoop</module> -->
<module>distribution</module>
<module>session</module>
</modules>
<build>
<pluginManagement>
......
......@@ -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("org.apache.iotdb.rpc.IoTDBRPCException: 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("org.apache.iotdb.rpc.IoTDBRPCException: 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("org.apache.iotdb.rpc.IoTDBRPCException: 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("org.apache.iotdb.rpc.IoTDBRPCException: Unsupported data type in aggregation SUM : BOOLEAN", e.getMessage());
}
statement.close();
} catch (Exception e) {
......
......@@ -19,49 +19,42 @@
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>iotdb-parent</artifactId>
<groupId>org.apache.iotdb</groupId>
<version>0.9.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>iotdb-session</artifactId>
<name>IoTDB Session</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>service-rpc</artifactId>
<version>0.9.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>tsfile</artifactId>
<version>0.9.0-SNAPSHOT</version>
</dependency>
</dependencies>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>iotdb-parent</artifactId>
<groupId>org.apache.iotdb</groupId>
<version>0.9.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>iotdb-session</artifactId>
<name>IoTDB Session</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>service-rpc</artifactId>
<version>0.9.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>tsfile</artifactId>
<version>0.9.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
......@@ -20,8 +20,7 @@ package org.apache.iotdb.session;
public class Config {
public static final String DEFAULT_USER = "root";
public static final String DEFALUT_PASSWORD = "root";
public static final String DEFAULT_USER = "user";
public static final String DEFALUT_PASSWORD = "password";
}
......@@ -18,7 +18,7 @@
*/
package org.apache.iotdb.session;
public class IoTDBSessionException extends RuntimeException {
public class IoTDBSessionException extends Exception {
private static final long serialVersionUID = 2405104784097667293L;
......
......@@ -32,7 +32,6 @@ import org.apache.iotdb.service.rpc.thrift.TSProtocolVersion;
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_StatusCode;
import org.apache.iotdb.tsfile.write.record.RowBatch;
import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
import org.apache.thrift.TException;
......@@ -72,11 +71,12 @@ public class Session {
this.password = password;
}
public void open() {
public void open() throws IoTDBSessionException {
open(false, 0);
}
public void open(boolean enableRPCCompression, int connectionTimeoutInMs) {
public void open(boolean enableRPCCompression, int connectionTimeoutInMs)
throws IoTDBSessionException {
transport = new TSocket(host, port, connectionTimeoutInMs);
if (!transport.isOpen()) {
try {
......@@ -128,7 +128,7 @@ public class Session {
}
public void close() {
public void close() throws IoTDBSessionException {
if (isClosed) {
return;
}
......@@ -145,7 +145,7 @@ public class Session {
}
}
public TSExecuteBatchStatementResp insertBatch(RowBatch rowBatch) {
public TSExecuteBatchStatementResp insertBatch(RowBatch rowBatch) throws IoTDBSessionException {
TSBatchInsertionReq request = new TSBatchInsertionReq();
request.deviceId = rowBatch.deviceId;
for (MeasurementSchema measurementSchema: rowBatch.measurements) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册