Skip to content

Commit 4a481f0

Browse files
authored
Remove the code check port is occupied and resolve the problem that can't rename file successfully (#16889)
1 parent bfa71e0 commit 4a481f0

File tree

3 files changed

+3
-86
lines changed

3 files changed

+3
-86
lines changed

iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/file/SystemPropertiesHandler.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
import org.apache.iotdb.commons.conf.ConfigurationFileUtils;
2323
import org.apache.iotdb.commons.conf.IoTDBConstant;
24+
import org.apache.iotdb.commons.utils.FileUtils;
2425

2526
import org.apache.ratis.util.AutoCloseableLock;
26-
import org.apache.ratis.util.FileUtils;
2727
import org.slf4j.Logger;
2828
import org.slf4j.LoggerFactory;
2929

@@ -184,15 +184,8 @@ private void replaceFormalFile() throws IOException {
184184
"Delete formal system properties file fail: %s", formalFile.getAbsoluteFile());
185185
throw new IOException(msg);
186186
}
187-
try {
188-
FileUtils.move(tmpFile.toPath(), formalFile.toPath());
189-
} catch (IOException e) {
190-
String msg =
191-
String.format(
192-
"Failed to replace formal system properties file, you may manually rename it: %s -> %s",
193-
tmpFile.getAbsolutePath(), formalFile.getAbsolutePath());
194-
throw new IOException(msg, e);
195-
}
187+
188+
FileUtils.moveFileSafe(tmpFile, formalFile);
196189
}
197190

198191
public void resetFilePath(String filePath) {

scripts/sbin/windows/start-confignode.bat

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -111,34 +111,6 @@ IF DEFINED CONFIG_FILE (
111111
set cn_consensus_port=10720
112112
)
113113

114-
echo Check whether the ports are occupied....
115-
set occupied=0
116-
set cn_internal_port_occupied=0
117-
set cn_consensus_port_occupied=0
118-
for /f "tokens=1,3,7 delims=: " %%i in ('netstat /ano') do (
119-
if %%i==TCP (
120-
if %%j==%cn_internal_port% (
121-
if !cn_internal_port_occupied!==0 (
122-
echo The cn_internal_port %cn_internal_port% is already occupied, pid:%%k
123-
set occupied=1
124-
set cn_internal_port_occupied=1
125-
)
126-
) else if %%j==%cn_consensus_port% (
127-
if !cn_consensus_port_occupied!==0 (
128-
echo The cn_consensus_port %cn_consensus_port% is already occupied, pid:%%k
129-
set occupied=1
130-
set cn_consensus_port_occupied=1
131-
)
132-
)
133-
)
134-
)
135-
136-
if %occupied%==1 (
137-
echo There exists occupied port, please change the configuration.
138-
TIMEOUT /T 10 /NOBREAK
139-
exit 0
140-
)
141-
142114
set CONF_PARAMS=-s
143115
if NOT DEFINED MAIN_CLASS set MAIN_CLASS=org.apache.iotdb.confignode.service.ConfigNode
144116
if NOT DEFINED JAVA_HOME goto :err

scripts/sbin/windows/start-datanode.bat

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -146,54 +146,6 @@ IF DEFINED CONFIG_FILE (
146146
set dn_data_region_consensus_port=10760
147147
)
148148

149-
echo Check whether the ports are occupied....
150-
set occupied=0
151-
set dn_rpc_port_occupied=0
152-
set dn_internal_port_occupied=0
153-
set dn_mpp_data_exchange_port_occupied=0
154-
set dn_schema_region_consensus_port_occupied=0
155-
set dn_data_region_consensus_port_occupied=0
156-
for /f "tokens=1,3,7 delims=: " %%i in ('netstat /ano') do (
157-
if %%i==TCP (
158-
if %%j==%dn_rpc_port% (
159-
if !dn_rpc_port_occupied!==0 (
160-
echo The dn_rpc_port %dn_rpc_port% is already occupied, pid:%%k
161-
set occupied=1
162-
set dn_rpc_port_occupied=1
163-
)
164-
) else if %%j==%dn_internal_port% (
165-
if !dn_internal_port_occupied!==0 (
166-
echo The dn_internal_port %dn_internal_port% is already occupied, pid:%%k
167-
set occupied=1
168-
set dn_internal_port_occupied=1
169-
)
170-
) else if %%j==%dn_mpp_data_exchange_port% (
171-
if !dn_mpp_data_exchange_port_occupied!==0 (
172-
echo The dn_mpp_data_exchange_port %dn_mpp_data_exchange_port% is already occupied, pid:%%k
173-
set occupied=1
174-
set dn_mpp_data_exchange_port_occupied=1
175-
)
176-
) else if %%j==%dn_schema_region_consensus_port% (
177-
if !dn_schema_region_consensus_port_occupied!==0 (
178-
echo The dn_schema_region_consensus_port %dn_schema_region_consensus_port% is already occupied, pid:%%k
179-
set occupied=1
180-
set dn_schema_region_consensus_port_occupied=1
181-
)
182-
) else if %%j==%dn_data_region_consensus_port% (
183-
if !dn_data_region_consensus_port_occupied!==0 (
184-
echo The dn_data_region_consensus_port %dn_data_region_consensus_port% is already occupied, pid:%%k
185-
set occupied=1
186-
)
187-
)
188-
)
189-
)
190-
191-
if %occupied%==1 (
192-
echo There exists occupied port, please change the configuration.
193-
TIMEOUT /T 10 /NOBREAK
194-
exit 0
195-
)
196-
197149
@setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
198150
set CONF_PARAMS=-s
199151
if NOT DEFINED MAIN_CLASS set MAIN_CLASS=org.apache.iotdb.db.service.DataNode

0 commit comments

Comments
 (0)