You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by lt...@apache.org on 2020/02/10 12:39:09 UTC
[incubator-iotdb] 02/03: add timeout to create connection
This is an automated email from the ASF dual-hosted git repository.
lta pushed a commit to branch add_sync_design_doc
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 2673f4d2363a3a8440097549e6b472002197b6bc
Author: lta <li...@163.com>
AuthorDate: Mon Feb 10 16:59:38 2020 +0800
add timeout to create connection
---
.../java/org/apache/iotdb/db/sync/sender/transfer/SyncClient.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/sync/sender/transfer/SyncClient.java b/server/src/main/java/org/apache/iotdb/db/sync/sender/transfer/SyncClient.java
index 1699d08..6f84e85 100644
--- a/server/src/main/java/org/apache/iotdb/db/sync/sender/transfer/SyncClient.java
+++ b/server/src/main/java/org/apache/iotdb/db/sync/sender/transfer/SyncClient.java
@@ -87,6 +87,8 @@ public class SyncClient implements ISyncClient {
private static final int BATCH_LINE = 1000;
+ private static final int TIMEOUT_MS = 1000;
+
/**
* When transferring schema information, it is a better choice to transfer only new schema
* information, avoiding duplicate data transmission. The schema log is self-increasing, so the
@@ -269,7 +271,7 @@ public class SyncClient implements ISyncClient {
@Override
public void establishConnection(String serverIp, int serverPort) throws SyncConnectionException {
- transport = new TSocket(serverIp, serverPort);
+ transport = new TSocket(serverIp, serverPort, TIMEOUT_MS);
TProtocol protocol = new TBinaryProtocol(transport);
serviceClient = new SyncService.Client(protocol);
try {
@@ -673,12 +675,12 @@ public class SyncClient implements ISyncClient {
private File getLockFile() {
return new File(IoTDBDescriptor.getInstance().getConfig().getSyncDir(),
- SyncConstant.LOCK_FILE_NAME);
+ config.getSyncReceiverName() + File.separator + SyncConstant.LOCK_FILE_NAME);
}
private File getUuidFile() {
return new File(IoTDBDescriptor.getInstance().getConfig().getSyncDir(),
- SyncConstant.UUID_FILE_NAME);
+ config.getSyncReceiverName() + File.separator + SyncConstant.UUID_FILE_NAME);
}
private static class InstanceHolder {