You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2019/03/29 10:01:38 UTC
[incubator-iotdb] branch fix_70_71 created (now 693841f)
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a change to branch fix_70_71
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.
at 693841f fix jira issue 70 71
This branch includes the following new commits:
new 693841f fix jira issue 70 71
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: fix jira issue 70 71
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch fix_70_71
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 693841f57b8ef5e7dd604ad73108c6f2b9d599f8
Author: 江天 <jt...@163.com>
AuthorDate: Fri Mar 29 18:00:27 2019 +0800
fix jira issue 70 71
---
.../db/engine/overflow/io/OverflowResource.java | 36 ++++++++++++----------
.../org/apache/iotdb/jdbc/IoTDBConnection.java | 8 ++++-
2 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowResource.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowResource.java
index fbaf317..0b45d54 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowResource.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowResource.java
@@ -106,31 +106,35 @@ public class OverflowResource {
modificationFile = new ModificationFile(insertFilePath + ModificationFile.FILE_SUFFIX);
}
- private Pair<Long, Long> readPositionInfo() {
- try(FileInputStream inputStream = new FileInputStream(positionFilePath)) {
- byte[] insertPositionData = new byte[8];
- byte[] updatePositionData = new byte[8];
- int byteRead = inputStream.read(insertPositionData);
- if (byteRead != 8) {
- throw new IOException("Not enough bytes for insertPositionData");
- }
- byteRead = inputStream.read(updatePositionData);
- if (byteRead != 8) {
- throw new IOException("Not enough bytes for updatePositionData");
+ private Pair<Long, Long> readPositionInfo() throws IOException {
+ File positionFile = new File(positionFilePath);
+ if (positionFile.exists()) {
+ try(FileInputStream inputStream = new FileInputStream(positionFile)) {
+ byte[] insertPositionData = new byte[8];
+ byte[] updatePositionData = new byte[8];
+ int byteRead = inputStream.read(insertPositionData);
+ if (byteRead != 8) {
+ throw new IOException("Not enough bytes for insertPositionData");
+ }
+ byteRead = inputStream.read(updatePositionData);
+ if (byteRead != 8) {
+ throw new IOException("Not enough bytes for updatePositionData");
+ }
+ long lastInsertPosition = BytesUtils.bytesToLong(insertPositionData);
+ long lastUpdatePosition = BytesUtils.bytesToLong(updatePositionData);
+ return new Pair<>(lastInsertPosition, lastUpdatePosition);
}
- long lastInsertPosition = BytesUtils.bytesToLong(insertPositionData);
- long lastUpdatePosition = BytesUtils.bytesToLong(updatePositionData);
- return new Pair<>(lastInsertPosition, lastUpdatePosition);
- } catch (IOException e) {
+ } else {
+ LOGGER.debug("No position info, returning a default value");
long left = 0;
long right = 0;
File insertTempFile = new File(insertFilePath);
if (insertTempFile.exists()) {
left = insertTempFile.length();
}
- LOGGER.warn("Cannot read position info, returning a default value", e);
return new Pair<>(left, right);
}
+
}
private void writePositionInfo(long lastInsertPosition, long lastUpdatePosition)
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 871a665..815725a 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
@@ -427,7 +427,13 @@ public class IoTDBConnection implements Connection {
TSOpenSessionResp openResp = client.openSession(openReq);
// validate connection
- Utils.verifySuccess(openResp.getStatus());
+ try {
+ Utils.verifySuccess(openResp.getStatus());
+ } catch (IoTDBSQLException e) {
+ // failed to connect, disconnect from the server
+ transport.close();
+ throw e;
+ }
if (!supportedProtocols.contains(openResp.getServerProtocolVersion())) {
throw new TException("Unsupported TsFile protocol");
}