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/09/17 09:43:14 UTC
[incubator-iotdb] branch session_log created (now f60efd6)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a change to branch session_log
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.
at f60efd6 add log for session
This branch includes the following new commits:
new f60efd6 add log for session
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[incubator-iotdb] 01/01: add log for session
Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch session_log
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit f60efd6bc2feff727b289b83c20cb8f8dc38e3c9
Author: qiaojialin <64...@qq.com>
AuthorDate: Tue Sep 17 17:42:52 2019 +0800
add log for session
---
.../main/java/org/apache/iotdb/SessionExample.java | 6 ++---
.../org/apache/iotdb/db/service/TSServiceImpl.java | 6 ++---
service-rpc/src/main/thrift/rpc.thrift | 8 ++----
.../java/org/apache/iotdb/session/Session.java | 31 ++++++++++++++++------
4 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/example/session/src/main/java/org/apache/iotdb/SessionExample.java b/example/session/src/main/java/org/apache/iotdb/SessionExample.java
index dd1989d..e938017 100644
--- a/example/session/src/main/java/org/apache/iotdb/SessionExample.java
+++ b/example/session/src/main/java/org/apache/iotdb/SessionExample.java
@@ -55,7 +55,7 @@ public class SessionExample {
measurements.add("s1");
measurements.add("s2");
measurements.add("s3");
- for (long time = 0; time < 30000; time++) {
+ for (long time = 0; time < 100; time++) {
List<String> values = new ArrayList<>();
values.add("1");
values.add("2");
@@ -66,7 +66,7 @@ public class SessionExample {
private static void delete() throws IoTDBSessionException {
String path = "root.sg1.d1.s1";
- long deleteTime = 29999;
+ long deleteTime = 99;
session.delete(path, deleteTime);
}
@@ -81,7 +81,7 @@ public class SessionExample {
long[] timestamps = rowBatch.timestamps;
Object[] values = rowBatch.values;
- for (long time = 0; time < 30000; time++) {
+ for (long time = 0; time < 100; time++) {
int row = rowBatch.batchSize++;
timestamps[row] = time;
for (int i = 0; i < 3; i++) {
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 2d913bd..130362e 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
@@ -1023,7 +1023,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
}
@Override
- public TSRPCResp deleteRow(TSDeleteReq req) throws TException {
+ public TSRPCResp deleteData(TSDeleteReq req) throws TException {
if (!checkLogin()) {
logger.info(INFO_NOT_LOGIN, IoTDBConstant.GLOBAL_DB_NAME);
return new TSRPCResp(getStatus(TSStatusType.NOT_LOGIN_ERROR));
@@ -1088,13 +1088,13 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
}
@Override
- public TSRPCResp setStorageGroup(TSSetStorageGroupReq req) throws TException {
+ public TSRPCResp setStorageGroup(String storageGroup) throws TException {
if (!checkLogin()) {
logger.info(INFO_NOT_LOGIN, IoTDBConstant.GLOBAL_DB_NAME);
return new TSRPCResp(getStatus(TSStatusType.NOT_LOGIN_ERROR));
}
- MetadataPlan plan = new MetadataPlan(MetadataOperator.NamespaceType.SET_STORAGE_GROUP, new Path(req.getStorageGroupId()));
+ MetadataPlan plan = new MetadataPlan(MetadataOperator.NamespaceType.SET_STORAGE_GROUP, new Path(storageGroup));
TS_Status status = checkAuthority(plan);
if (status != null) {
return new TSRPCResp(status);
diff --git a/service-rpc/src/main/thrift/rpc.thrift b/service-rpc/src/main/thrift/rpc.thrift
index 6eb33b7..2d41ef7 100644
--- a/service-rpc/src/main/thrift/rpc.thrift
+++ b/service-rpc/src/main/thrift/rpc.thrift
@@ -251,10 +251,6 @@ struct TSDeleteReq {
2: required i64 timestamp
}
-struct TSSetStorageGroupReq {
- 1: required string storageGroupId
-}
-
struct TSRPCResp {
1: required TS_Status status
}
@@ -303,13 +299,13 @@ service TSIService {
TSExecuteBatchStatementResp insertBatch(1:TSBatchInsertionReq req);
- TSRPCResp setStorageGroup(1:TSSetStorageGroupReq req);
+ TSRPCResp setStorageGroup(1:string storageGroup);
TSRPCResp createTimeseries(1:TSCreateTimeseriesReq req);
TSRPCResp insertRow(1:TSInsertReq req);
- TSRPCResp deleteRow(1:TSDeleteReq req);
+ TSRPCResp deleteData(1:TSDeleteReq req);
i64 requestStatementId();
}
diff --git a/session/src/main/java/org/apache/iotdb/session/Session.java b/session/src/main/java/org/apache/iotdb/session/Session.java
index 2ee79e9..0e3118b 100644
--- a/session/src/main/java/org/apache/iotdb/session/Session.java
+++ b/session/src/main/java/org/apache/iotdb/session/Session.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.session;
import java.util.List;
import org.apache.iotdb.rpc.IoTDBRPCException;
import org.apache.iotdb.rpc.RpcUtils;
+import org.apache.iotdb.rpc.TSStatusType;
import org.apache.iotdb.service.rpc.thrift.*;
import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
@@ -34,9 +35,12 @@ import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransportException;
import java.time.ZoneId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Session {
+ private static final Logger logger = LoggerFactory.getLogger(Session.class);
private String host;
private int port;
private String username;
@@ -151,7 +155,7 @@ public class Session {
request.setSize(rowBatch.batchSize);
try {
- return client.insertBatch(request);
+ return checkAndReturn(client.insertBatch(request));
} catch (TException e) {
throw new IoTDBSessionException(e);
}
@@ -166,7 +170,7 @@ public class Session {
request.setValues(values);
try {
- return client.insertRow(request);
+ return checkAndReturn(client.insertRow(request));
} catch (TException e) {
throw new IoTDBSessionException(e);
}
@@ -178,18 +182,15 @@ public class Session {
request.setTimestamp(time);
try {
- return client.deleteRow(request);
+ return checkAndReturn(client.deleteData(request));
} catch (TException e) {
throw new IoTDBSessionException(e);
}
}
public synchronized TSRPCResp setStorageGroup(String storageGroupId) throws IoTDBSessionException {
- TSSetStorageGroupReq request = new TSSetStorageGroupReq();
- request.setStorageGroupId(storageGroupId);
-
try {
- return client.setStorageGroup(request);
+ return checkAndReturn(client.setStorageGroup(storageGroupId));
} catch (TException e) {
throw new IoTDBSessionException(e);
}
@@ -203,12 +204,26 @@ public class Session {
request.setCompressor(compressor.ordinal());
try {
- return client.createTimeseries(request);
+ return checkAndReturn(client.createTimeseries(request));
} catch (TException e) {
throw new IoTDBSessionException(e);
}
}
+ private TSRPCResp checkAndReturn(TSRPCResp resp) {
+ if (resp.status.statusType.getCode() != TSStatusType.SUCCESS_STATUS.getStatusCode()) {
+ logger.error(resp.status.statusType.getMessage());
+ }
+ return resp;
+ }
+
+ private TSExecuteBatchStatementResp checkAndReturn(TSExecuteBatchStatementResp resp) {
+ if (resp.status.statusType.getCode() != TSStatusType.SUCCESS_STATUS.getStatusCode()) {
+ logger.error(resp.status.statusType.getMessage());
+ }
+ return resp;
+ }
+
public synchronized String getTimeZone() throws TException, IoTDBRPCException {
if (zoneId != null) {
return zoneId.toString();