This is an automated email from the ASF dual-hosted git repository. jackietien pushed a commit to branch ty/object_type in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit f74eb2671a248a62e6ba5ce486aff8435d1e2f0a Author: libo <[email protected]> AuthorDate: Wed Dec 10 12:22:24 2025 +0800 Remove the code check port is occupied and resolve the problem that can't rename file successfully (#16889) (cherry picked from commit 4a481f02bf8856b6588f371bbfed9b1359b9ce55) --- .../commons/file/SystemPropertiesHandler.java | 13 ++---- scripts/sbin/windows/start-confignode.bat | 28 ------------- scripts/sbin/windows/start-datanode.bat | 48 ---------------------- 3 files changed, 3 insertions(+), 86 deletions(-) diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/file/SystemPropertiesHandler.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/file/SystemPropertiesHandler.java index dfbb2104cfb..ab28952dbcd 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/file/SystemPropertiesHandler.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/file/SystemPropertiesHandler.java @@ -21,9 +21,9 @@ package org.apache.iotdb.commons.file; import org.apache.iotdb.commons.conf.ConfigurationFileUtils; import org.apache.iotdb.commons.conf.IoTDBConstant; +import org.apache.iotdb.commons.utils.FileUtils; import org.apache.ratis.util.AutoCloseableLock; -import org.apache.ratis.util.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -184,15 +184,8 @@ public abstract class SystemPropertiesHandler { "Delete formal system properties file fail: %s", formalFile.getAbsoluteFile()); throw new IOException(msg); } - try { - FileUtils.move(tmpFile.toPath(), formalFile.toPath()); - } catch (IOException e) { - String msg = - String.format( - "Failed to replace formal system properties file, you may manually rename it: %s -> %s", - tmpFile.getAbsolutePath(), formalFile.getAbsolutePath()); - throw new IOException(msg, e); - } + + FileUtils.moveFileSafe(tmpFile, formalFile); } public void resetFilePath(String filePath) { diff --git a/scripts/sbin/windows/start-confignode.bat b/scripts/sbin/windows/start-confignode.bat index 2501a0645c2..64efa6f5580 100644 --- a/scripts/sbin/windows/start-confignode.bat +++ b/scripts/sbin/windows/start-confignode.bat @@ -111,34 +111,6 @@ IF DEFINED CONFIG_FILE ( set cn_consensus_port=10720 ) -echo Check whether the ports are occupied.... -set occupied=0 -set cn_internal_port_occupied=0 -set cn_consensus_port_occupied=0 -for /f "tokens=1,3,7 delims=: " %%i in ('netstat /ano') do ( - if %%i==TCP ( - if %%j==%cn_internal_port% ( - if !cn_internal_port_occupied!==0 ( - echo The cn_internal_port %cn_internal_port% is already occupied, pid:%%k - set occupied=1 - set cn_internal_port_occupied=1 - ) - ) else if %%j==%cn_consensus_port% ( - if !cn_consensus_port_occupied!==0 ( - echo The cn_consensus_port %cn_consensus_port% is already occupied, pid:%%k - set occupied=1 - set cn_consensus_port_occupied=1 - ) - ) - ) -) - -if %occupied%==1 ( - echo There exists occupied port, please change the configuration. - TIMEOUT /T 10 /NOBREAK - exit 0 -) - set CONF_PARAMS=-s if NOT DEFINED MAIN_CLASS set MAIN_CLASS=org.apache.iotdb.confignode.service.ConfigNode if NOT DEFINED JAVA_HOME goto :err diff --git a/scripts/sbin/windows/start-datanode.bat b/scripts/sbin/windows/start-datanode.bat index 30a7aa50e83..0cf3e648783 100755 --- a/scripts/sbin/windows/start-datanode.bat +++ b/scripts/sbin/windows/start-datanode.bat @@ -146,54 +146,6 @@ IF DEFINED CONFIG_FILE ( set dn_data_region_consensus_port=10760 ) -echo Check whether the ports are occupied.... -set occupied=0 -set dn_rpc_port_occupied=0 -set dn_internal_port_occupied=0 -set dn_mpp_data_exchange_port_occupied=0 -set dn_schema_region_consensus_port_occupied=0 -set dn_data_region_consensus_port_occupied=0 -for /f "tokens=1,3,7 delims=: " %%i in ('netstat /ano') do ( - if %%i==TCP ( - if %%j==%dn_rpc_port% ( - if !dn_rpc_port_occupied!==0 ( - echo The dn_rpc_port %dn_rpc_port% is already occupied, pid:%%k - set occupied=1 - set dn_rpc_port_occupied=1 - ) - ) else if %%j==%dn_internal_port% ( - if !dn_internal_port_occupied!==0 ( - echo The dn_internal_port %dn_internal_port% is already occupied, pid:%%k - set occupied=1 - set dn_internal_port_occupied=1 - ) - ) else if %%j==%dn_mpp_data_exchange_port% ( - if !dn_mpp_data_exchange_port_occupied!==0 ( - echo The dn_mpp_data_exchange_port %dn_mpp_data_exchange_port% is already occupied, pid:%%k - set occupied=1 - set dn_mpp_data_exchange_port_occupied=1 - ) - ) else if %%j==%dn_schema_region_consensus_port% ( - if !dn_schema_region_consensus_port_occupied!==0 ( - echo The dn_schema_region_consensus_port %dn_schema_region_consensus_port% is already occupied, pid:%%k - set occupied=1 - set dn_schema_region_consensus_port_occupied=1 - ) - ) else if %%j==%dn_data_region_consensus_port% ( - if !dn_data_region_consensus_port_occupied!==0 ( - echo The dn_data_region_consensus_port %dn_data_region_consensus_port% is already occupied, pid:%%k - set occupied=1 - ) - ) - ) -) - -if %occupied%==1 ( - echo There exists occupied port, please change the configuration. - TIMEOUT /T 10 /NOBREAK - exit 0 -) - @setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS set CONF_PARAMS=-s if NOT DEFINED MAIN_CLASS set MAIN_CLASS=org.apache.iotdb.db.service.DataNode
