未验证 提交 59e2af7a 编写于 作者: X Xiangdong Huang 提交者: GitHub

Merge pull request #120 from apache/fix_70_71

[IOTDB-70][IOTDB-71]fix jira issue 70 71
......@@ -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)
......
......@@ -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");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册