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 2020/05/22 05:14:30 UTC
[incubator-iotdb] branch revert-1194-add_retry_in_session created
(now e7b0891)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a change to branch revert-1194-add_retry_in_session
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.
at e7b0891 Revert "[IOTDB-667] add retry in session and jdbc.execute (#1194)"
This branch includes the following new commits:
new e7b0891 Revert "[IOTDB-667] add retry in session and jdbc.execute (#1194)"
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: Revert "[IOTDB-667] add retry in session
and jdbc.execute (#1194)"
Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch revert-1194-add_retry_in_session
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit e7b0891190f2e04785fb262117a45a458a18926f
Author: Jialin Qiao <qj...@mails.tsinghua.edu.cn>
AuthorDate: Fri May 22 13:14:18 2020 +0800
Revert "[IOTDB-667] add retry in session and jdbc.execute (#1194)"
This reverts commit 4d27c9364e752e63af4b269ba89c477399eb5468.
---
.../org/apache/iotdb/jdbc/IoTDBConnection.java | 1 -
.../java/org/apache/iotdb/jdbc/IoTDBStatement.java | 14 +-
.../java/org/apache/iotdb/session/Session.java | 165 ++-------------------
3 files changed, 19 insertions(+), 161 deletions(-)
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
index e634674..0f5982c 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
@@ -479,7 +479,6 @@ public class IoTDBConnection implements Connection {
try {
Thread.sleep(Config.RETRY_INTERVAL);
} catch (InterruptedException e1) {
- Thread.currentThread().interrupt();
logger.error("reconnect is interrupted.", e1);
}
}
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 0096cdb..fdd81bc 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
@@ -174,17 +174,11 @@ public class IoTDBStatement implements Statement {
return executeSQL(sql);
} catch (TException e) {
if (reConnect()) {
- try {
- return executeSQL(sql);
- } catch (TException e2) {
- throw new SQLException(
- "Fail to execute sql " + sql + "after reconnecting. please check server status",
- e2);
- }
+ throw new SQLException(String.format("Fail to execute %s", sql), e);
} else {
- throw new SQLException(
- "Fail to reconnect to server when execute sql " + sql
- + ". please check server status", e);
+ throw new SQLException(String
+ .format("Fail to reconnect to server when executing %s. please check server status",
+ sql), e);
}
}
}
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 89f32b6..dad90cd 100644
--- a/session/src/main/java/org/apache/iotdb/session/Session.java
+++ b/session/src/main/java/org/apache/iotdb/session/Session.java
@@ -75,10 +75,6 @@ public class Session {
private ZoneId zoneId;
private long statementId;
private int fetchSize;
- private int connectionTimeoutInMs = Config.DEFAULT_TIMEOUT_MS;
- private boolean enableRPCCompression = false;
- private final int RETRY_NUM = 2;
- private final int RETRY_INTERVAL = 1000;
public Session(String host, int port) {
this(host, port, Config.DEFAULT_USER, Config.DEFAULT_PASSWORD);
@@ -117,8 +113,6 @@ public class Session {
if (!isClosed) {
return;
}
- this.enableRPCCompression = enableRPCCompression;
- this.connectionTimeoutInMs = connectionTimeoutInMs;
transport = new TSocket(host, port, connectionTimeoutInMs);
if (!transport.isOpen()) {
try {
@@ -191,29 +185,6 @@ public class Session {
}
}
- private boolean reconnect() {
- boolean flag = false;
- for (int i = 1; i <= RETRY_NUM; i++) {
- try {
- if (transport != null) {
- transport.close();
- }
- isClosed = true;
- open(enableRPCCompression, connectionTimeoutInMs);
- flag = true;
- break;
- } catch (Exception e) {
- try {
- Thread.sleep(RETRY_INTERVAL);
- } catch (InterruptedException e1) {
- Thread.currentThread().interrupt();
- logger.error("reconnection is interrupted.", e1);
- }
- }
- }
- return flag;
- }
-
/**
* insert data in one row, if you want to improve your performance, please use insertRecords method
* or insertTablet method
@@ -250,16 +221,7 @@ public class Session {
try {
RpcUtils.verifySuccess(client.insertRecord(request));
} catch (TException e) {
- if (reconnect()) {
- try {
- RpcUtils.verifySuccess(client.insertRecord(request));
- } catch (TException e1) {
- throw new IoTDBConnectionException(e1);
- }
- } else {
- throw new IoTDBConnectionException("Fail to reconnect to server,"
- + " please check server status", e);
- }
+ throw new IoTDBConnectionException(e);
}
}
@@ -314,16 +276,7 @@ public class Session {
try {
RpcUtils.verifySuccess(client.insertTablet(request).statusList);
} catch (TException e) {
- if (reconnect()) {
- try {
- RpcUtils.verifySuccess(client.insertTablet(request).statusList);
- } catch (TException e1) {
- throw new IoTDBConnectionException(e1);
- }
- } else {
- throw new IoTDBConnectionException("Fail to reconnect to server,"
- + " please check server status", e);
- }
+ throw new IoTDBConnectionException(e);
}
}
@@ -378,16 +331,7 @@ public class Session {
try {
RpcUtils.verifySuccess(client.insertTablets(request).statusList);
} catch (TException e) {
- if (reconnect()) {
- try {
- RpcUtils.verifySuccess(client.insertTablets(request).statusList);
- } catch (TException e1) {
- throw new IoTDBConnectionException(e1);
- }
- } else {
- throw new IoTDBConnectionException("Fail to reconnect to server,"
- + " please check server status", e);
- }
+ throw new IoTDBConnectionException(e);
}
}
}
@@ -421,16 +365,7 @@ public class Session {
try {
RpcUtils.verifySuccess(client.insertRecords(request).statusList);
} catch (TException e) {
- if (reconnect()) {
- try {
- RpcUtils.verifySuccess(client.insertRecords(request).statusList);
- } catch (TException e1) {
- throw new IoTDBConnectionException(e1);
- }
- } else {
- throw new IoTDBConnectionException("Fail to reconnect to server,"
- + " please check server status", e);
- }
+ throw new IoTDBConnectionException(e);
}
}
@@ -528,16 +463,7 @@ public class Session {
try {
RpcUtils.verifySuccess(client.deleteTimeseries(sessionId, paths));
} catch (TException e) {
- if (reconnect()) {
- try {
- RpcUtils.verifySuccess(client.deleteTimeseries(sessionId, paths));
- } catch (TException e1) {
- throw new IoTDBConnectionException(e1);
- }
- } else {
- throw new IoTDBConnectionException("Fail to reconnect to server,"
- + " please check server status", e);
- }
+ throw new IoTDBConnectionException(e);
}
}
@@ -570,16 +496,7 @@ public class Session {
try {
RpcUtils.verifySuccess(client.deleteData(request));
} catch (TException e) {
- if (reconnect()) {
- try {
- RpcUtils.verifySuccess(client.deleteData(request));
- } catch (TException e1) {
- throw new IoTDBConnectionException(e1);
- }
- } else {
- throw new IoTDBConnectionException("Fail to reconnect to server,"
- + " please check server status", e);
- }
+ throw new IoTDBConnectionException(e);
}
}
@@ -588,16 +505,7 @@ public class Session {
try {
RpcUtils.verifySuccess(client.setStorageGroup(sessionId, storageGroupId));
} catch (TException e) {
- if (reconnect()) {
- try {
- RpcUtils.verifySuccess(client.setStorageGroup(sessionId, storageGroupId));
- } catch (TException e1) {
- throw new IoTDBConnectionException(e1);
- }
- } else {
- throw new IoTDBConnectionException("Fail to reconnect to server,"
- + " please check server status", e);
- }
+ throw new IoTDBConnectionException(e);
}
}
@@ -614,16 +522,7 @@ public class Session {
try {
RpcUtils.verifySuccess(client.deleteStorageGroups(sessionId, storageGroup));
} catch (TException e) {
- if (reconnect()) {
- try {
- RpcUtils.verifySuccess(client.deleteStorageGroups(sessionId, storageGroup));
- } catch (TException e1) {
- throw new IoTDBConnectionException(e1);
- }
- } else {
- throw new IoTDBConnectionException("Fail to reconnect to server,"
- + " please check server status", e);
- }
+ throw new IoTDBConnectionException(e);
}
}
@@ -651,16 +550,7 @@ public class Session {
try {
RpcUtils.verifySuccess(client.createTimeseries(request));
} catch (TException e) {
- if (reconnect()) {
- try {
- RpcUtils.verifySuccess(client.createTimeseries(request));
- } catch (TException e1) {
- throw new IoTDBConnectionException(e1);
- }
- } else {
- throw new IoTDBConnectionException("Fail to reconnect to server,"
- + " please check server status", e);
- }
+ throw new IoTDBConnectionException(e);
}
}
@@ -700,16 +590,7 @@ public class Session {
try {
RpcUtils.verifySuccess(client.createMultiTimeseries(request).statusList);
} catch (TException e) {
- if (reconnect()) {
- try {
- RpcUtils.verifySuccess(client.createMultiTimeseries(request).statusList);
- } catch (TException e1) {
- throw new IoTDBConnectionException(e1);
- }
- } else {
- throw new IoTDBConnectionException("Fail to reconnect to server,"
- + " please check server status", e);
- }
+ throw new IoTDBConnectionException(e);
}
}
@@ -766,17 +647,9 @@ public class Session {
try {
execResp = client.executeQueryStatement(execReq);
} catch (TException e) {
- if (reconnect()) {
- try {
- execResp = client.executeQueryStatement(execReq);
- } catch (TException e1) {
- throw new IoTDBConnectionException(e1);
- }
- } else {
- throw new IoTDBConnectionException("Fail to reconnect to server,"
- + " please check server status", e);
- }
+ throw new IoTDBConnectionException(e);
}
+
RpcUtils.verifySuccess(execResp.getStatus());
return new SessionDataSet(sql, execResp.getColumns(), execResp.getDataTypeList(), execResp.columnNameIndexMap,
execResp.getQueryId(), client, sessionId, execResp.queryDataSet, execResp.isIgnoreTimeStamp());
@@ -791,18 +664,10 @@ public class Session {
throws IoTDBConnectionException, StatementExecutionException {
TSExecuteStatementReq execReq = new TSExecuteStatementReq(sessionId, sql, statementId);
try {
- RpcUtils.verifySuccess(client.executeUpdateStatement(execReq).getStatus());
+ TSExecuteStatementResp execResp = client.executeUpdateStatement(execReq);
+ RpcUtils.verifySuccess(execResp.getStatus());
} catch (TException e) {
- if (reconnect()) {
- try {
- RpcUtils.verifySuccess(client.executeUpdateStatement(execReq).getStatus());
- } catch (TException e1) {
- throw new IoTDBConnectionException(e1);
- }
- } else {
- throw new IoTDBConnectionException("Fail to reconnect to server,"
- + " please check server status", e);
- }
+ throw new IoTDBConnectionException(e);
}
}