You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2020/05/22 07:40:34 UTC
[incubator-iotdb] branch IOTDB-693 created (now 8245dc1)
This is an automated email from the ASF dual-hosted git repository.
hxd pushed a change to branch IOTDB-693
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.
at 8245dc1 print more info if the sessionPool retry and fails more than RETRY times
This branch includes the following new commits:
new 8245dc1 print more info if the sessionPool retry and fails more than RETRY times
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: print more info if the sessionPool retry
and fails more than RETRY times
Posted by hx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch IOTDB-693
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 8245dc15ac675fab977f38851e7d1d0670df68bd
Author: xiangdong huang <sa...@gmail.com>
AuthorDate: Fri May 22 15:40:13 2020 +0800
print more info if the sessionPool retry and fails more than RETRY times
---
.../org/apache/iotdb/session/pool/SessionPool.java | 115 +++++++--------------
1 file changed, 35 insertions(+), 80 deletions(-)
diff --git a/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java b/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
index 7ad90ce..77c3eb0 100644
--- a/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
+++ b/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
@@ -76,6 +76,7 @@ public class SessionPool {
private long timeout; //ms
private static int RETRY = 3;
+ private static int FINAL_RETRY = RETRY - 1;
private boolean enableCompression = false;
public SessionPool(String ip, int port, String user, String password, int maxSize) {
@@ -221,6 +222,16 @@ public class SessionPool {
}
}
+ private void mayThrowConnectionException(Session session, int times, IoTDBConnectionException e) throws IoTDBConnectionException {
+ closeSession(session);
+ removeSession();
+ if (times == FINAL_RETRY) {
+ throw new IoTDBConnectionException(
+ String.format("retry to execute statement on %s:%s failed %d times: %s", ip, port,
+ RETRY, e.getMessage()), e);
+ }
+ }
+
/**
* insert the data of a device. For each timestamp, the number of measurements is the same.
*
@@ -267,15 +278,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (BatchExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
@@ -304,15 +312,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (BatchExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
/**
@@ -333,15 +338,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (BatchExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
/**
@@ -361,15 +363,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (StatementExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
/**
@@ -386,15 +385,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (BatchExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
/**
@@ -412,15 +408,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (BatchExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
/**
@@ -437,15 +430,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (StatementExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
/**
@@ -463,15 +453,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (StatementExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
/**
@@ -489,15 +476,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (StatementExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
/**
@@ -516,15 +500,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (StatementExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
/**
@@ -543,15 +524,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (StatementExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
public void setStorageGroup(String storageGroupId)
@@ -564,15 +542,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (StatementExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
public void deleteStorageGroup(String storageGroup)
@@ -585,15 +560,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (StatementExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
public void deleteStorageGroups(List<String> storageGroup)
@@ -606,15 +578,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (StatementExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
public void createTimeseries(String path, TSDataType dataType, TSEncoding encoding,
@@ -627,15 +596,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (StatementExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
public void createTimeseries(String path, TSDataType dataType, TSEncoding encoding,
@@ -651,15 +617,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (StatementExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
public void createMultiTimeseries(List<String> paths, List<TSDataType> dataTypes,
@@ -676,15 +639,12 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (BatchExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
public boolean checkTimeseriesExists(String path) throws IoTDBConnectionException {
@@ -696,12 +656,11 @@ public class SessionPool {
return resp;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
+ //never go here.
+ return false;
}
/**
@@ -724,15 +683,14 @@ public class SessionPool {
return wrapper;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (StatementExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
+ // never go here
+ return null;
}
/**
@@ -750,14 +708,11 @@ public class SessionPool {
return;
} catch (IoTDBConnectionException e) {
// TException means the connection is broken, remove it and get a new one.
- closeSession(session);
- removeSession();
+ mayThrowConnectionException(session, i, e);
} catch (StatementExecutionException e) {
putBack(session);
throw e;
}
}
- throw new IoTDBConnectionException(
- String.format("retry to execute statement on %s:%s failed %d times", ip, port, RETRY));
}
}