This is an automated email from the ASF dual-hosted git repository. rong pushed a commit to branch sync-huge-tsfile-v2 in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 185d6417049f50fa641fc6dbfc5c823351e019cd Author: Steve Yurong Su <[email protected]> AuthorDate: Thu May 9 00:36:32 2024 +0800 Pipe: globally adjust timeout when syncing huge tsfiles --- .../pipe/connector/client/IoTDBClientManager.java | 17 ++++++++++------- .../pipe/connector/client/IoTDBSyncClientManager.java | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/client/IoTDBClientManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/client/IoTDBClientManager.java index bb1f0062363..a3643a2c10c 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/client/IoTDBClientManager.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/client/IoTDBClientManager.java @@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory; import java.net.SocketTimeoutException; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; public abstract class IoTDBClientManager { @@ -42,7 +43,8 @@ public abstract class IoTDBClientManager { protected boolean supportModsIfIsDataNodeReceiver = true; private static final int MAX_CONNECTION_TIMEOUT_MS = 24 * 60 * 60 * 1000; // 1 day - protected int connectionTimeout = PipeConfig.getInstance().getPipeConnectorTransferTimeoutMs(); + protected static final AtomicInteger CONNECTION_TIMEOUT_MS = + new AtomicInteger(PipeConfig.getInstance().getPipeConnectorTransferTimeoutMs()); protected IoTDBClientManager(List<TEndPoint> endPointList, boolean useLeaderCache) { this.endPointList = endPointList; @@ -59,17 +61,18 @@ public abstract class IoTDBClientManager { int newConnectionTimeout; try { newConnectionTimeout = - Math.min(Math.toIntExact(connectionTimeout * 2L), MAX_CONNECTION_TIMEOUT_MS); + Math.min( + Math.toIntExact(CONNECTION_TIMEOUT_MS.get() * 2L), MAX_CONNECTION_TIMEOUT_MS); } catch (ArithmeticException arithmeticException) { newConnectionTimeout = MAX_CONNECTION_TIMEOUT_MS; } - if (newConnectionTimeout != connectionTimeout) { - connectionTimeout = newConnectionTimeout; + if (newConnectionTimeout != CONNECTION_TIMEOUT_MS.get()) { + CONNECTION_TIMEOUT_MS.set(newConnectionTimeout); LOGGER.info( "Pipe connection timeout is adjusted to {} ms ({} mins)", - connectionTimeout, - connectionTimeout / 60000.0); + newConnectionTimeout, + newConnectionTimeout / 60000.0); } return; } @@ -77,6 +80,6 @@ public abstract class IoTDBClientManager { } public int getConnectionTimeout() { - return connectionTimeout; + return CONNECTION_TIMEOUT_MS.get(); } } diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/client/IoTDBSyncClientManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/client/IoTDBSyncClientManager.java index a29d7bdb0a2..667313e1976 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/client/IoTDBSyncClientManager.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/client/IoTDBSyncClientManager.java @@ -193,7 +193,7 @@ public abstract class IoTDBSyncClientManager extends IoTDBClientManager implemen resp.getStatus()); } else { clientAndStatus.setRight(true); - client.setTimeout(connectionTimeout); + client.setTimeout(CONNECTION_TIMEOUT_MS.get()); LOGGER.info( "Handshake success. Target server ip: {}, port: {}", client.getIpAddress(),
