ppppoooo commented on code in PR #11788: URL: https://github.com/apache/iotdb/pull/11788#discussion_r1438082251
########## iotdb-core/node-commons/src/assembly/resources/sbin/clean-confignode.bat: ########## @@ -0,0 +1,82 @@ +@REM +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM +@echo off + +pushd %~dp0.. +if NOT DEFINED IOTDB_HOME set IOTDB_HOME=%cd% +popd + +set "reCheck=%1" +if not "%reCheck%" == "-f" ( + echo -n "Do you want to clean all the data in the IoTDB ? y/n (default n): " + set /p CLEAN_SERVICE= +) + +if not "%CLEAN_SERVICE%"=="y" if not "%CLEAN_SERVICE%"=="Y" ( + echo "Exiting..." + exit 0 +) + +rmdir /s /q "%IOTDB_HOME%\data\confignode\" 2>nul +set IOTDB_CONFIGNODE_CONFIG=%IOTDB_HOME%\conf\iotdb-confignode.properties +set "delimiter=,;" +for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^cn_system_dir" + %IOTDB_CONFIGNODE_CONFIG%') do ( + set cn_system_dir=%%i +) +if "%cn_system_dir%"=="" ( + set "cn_system_dir=data\confignode\system" +) + +setlocal enabledelayedexpansion +set "cn_system_dir=!cn_system_dir:%delimiter%= !" +for %%i in (%cn_system_dir%) do ( + set "var=%%i" + if "!var:~0,2!"=="\\" ( + rmdir /s /q "%%i" 2>nul + ) else if "!var:~1,3!"==":\\" ( + rmdir /s /q "%%i" 2>nul + ) else ( + rmdir /s /q "%IOTDB_HOME%\%%i" 2>nul + ) +) + +for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^cn_consensus_dir" + %IOTDB_CONFIGNODE_CONFIG%') do ( + set cn_consensus_dir=%%i +) +if "%cn_consensus_dir%"=="" ( +set "cn_consensus_dir=data\confignode\consensus" +) +setlocal enabledelayedexpansion +set "cn_consensus_dir=!cn_consensus_dir:%delimiter%= !" +for %%i in (%cn_consensus_dir%) do ( + set "var=%%i" + if "!var:~0,2!"=="\\" ( + rmdir /s /q "%%i" 2>nul + ) else if "!var:~1,3!"==":\\" ( Review Comment: Is this position always false ########## iotdb-core/node-commons/src/assembly/resources/sbin/clean-all.bat: ########## @@ -0,0 +1,38 @@ +@REM +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM + +@echo off + +SET /P CLEAN_SERVICE="Do you want to clean all the data in the IoTDB ? y/n (default n): " +IF NOT "%CLEAN_SERVICE%"=="y" IF NOT "%CLEAN_SERVICE%"=="Y" ( + ECHO Exiting... + EXIT /b +) + +pushd %~dp0.. +if NOT DEFINED IOTDB_HOME set IOTDB_HOME=%cd% +popd Review Comment: What is the function of this sentence, is it not necessary to ########## iotdb-core/node-commons/src/assembly/resources/sbin/clean-all.sh: ########## @@ -0,0 +1,103 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +read -p "Do you want to clean all the data in the IoTDB ? y/n (default n): " CLEAN_SERVICE +if [[ "$CLEAN_SERVICE" != "y" && "$CLEAN_SERVICE" != "Y" ]]; then + echo "Exiting..." + exit 0 +fi + +export IOTDB_HOME="`dirname "$0"`/.." +IOTDB_CLUSTER_PATH="${IOTDB_HOME}"/conf/iotdb-cluster.properties +# iotdb-cluster.properties does not exist, the current ICID is cleaned +if [ ! -f ${IOTDB_CLUSTER_PATH} ]; then + exec ${IOTDB_HOME}/sbin/clean-datanode.sh -f > /dev/null 2>&1 & + exec ${IOTDB_HOME}/sbin/clean-confignode.sh -f> /dev/null 2>&1 & + exec rm -rf ${IOTDB_HOME}/data/ +else + confignodeStr=$(sed '/^confignode_address_list=/!d;s/.*=//' "${IOTDB_CLUSTER_PATH}") + confignodeIps=(${confignodeStr//,/ }) + datanodeStr=$(sed '/^datanode_address_list=/!d;s/.*=//' "${IOTDB_CLUSTER_PATH}") + datanodeIps=(${datanodeStr//,/ }) + serverPort=$(sed '/^ssh_port=/!d;s/.*=//' "${IOTDB_CLUSTER_PATH}") + confignodePath=$(sed '/^confignode_deploy_path=/!d;s/.*=//' "${IOTDB_CLUSTER_PATH}") + datanodePath=$(sed '/^datanode_deploy_path=/!d;s/.*=//' "${IOTDB_CLUSTER_PATH}") + account=$(sed '/^ssh_account=/!d;s/.*=//' "${IOTDB_CLUSTER_PATH}") +# echo $confignodeIps $datanodeIps $confignodePaths $datanodePaths $account $serverPort +fi + +function validateParam() { + if [[ -z $1 || -z $2 || -z $3 || -z $4 || -z $5 || -z $6 ]]; then + echo "The iotdb-cluster.properties file is incomplete, the current 1C1D will be cleaned ... " + exec ${IOTDB_HOME}/sbin/clean-datanode.sh -f > /dev/null 2>&1 & + exec ${IOTDB_HOME}/sbin/clean-confignode.sh -f> /dev/null 2>&1 & + exit + fi +} + +validateParam $confignodeIps $datanodeIps $confignodePath $datanodePath $account $serverPort + +# By default disable strict host key checking +if [ "$IOTDB_SSH_OPTS" = "" ]; then + IOTDB_SSH_OPTS="-o StrictHostKeyChecking=no" +fi + +# duplicate removal +unique_array=($(awk -v RS=' ' '!a[$1]++' <<< ${datanodeIps[@]})) + # Clean the DataNode service +for datanodeIP in ${unique_array[@]};do + hasConfigNode="false" + for ((i=0; i<${#confignodeIps[@]}; i++)) + do + # 检查元素是否包含指定字符 + if [[ "${confignodeIps[$i]}" == *"$datanodeIP"* ]]; then + # 打印包含指定字符的元素 + hasConfigNode="true" + # 从数组中删除这个元素 + unset 'confignodeIps[$i]' Review Comment: Doesn't deleting while traversing overrun the array? ########## iotdb-core/node-commons/src/assembly/resources/sbin/clean-all.bat: ########## @@ -0,0 +1,38 @@ +@REM +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM + +@echo off + +SET /P CLEAN_SERVICE="Do you want to clean all the data in the IoTDB ? y/n (default n): " +IF NOT "%CLEAN_SERVICE%"=="y" IF NOT "%CLEAN_SERVICE%"=="Y" ( + ECHO Exiting... + EXIT /b +) + +pushd %~dp0.. Review Comment: What is the function of this sentence, is it not necessary to ########## iotdb-core/node-commons/src/assembly/resources/sbin/clean-all.sh: ########## @@ -0,0 +1,103 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +read -p "Do you want to clean all the data in the IoTDB ? y/n (default n): " CLEAN_SERVICE +if [[ "$CLEAN_SERVICE" != "y" && "$CLEAN_SERVICE" != "Y" ]]; then + echo "Exiting..." + exit 0 +fi + +export IOTDB_HOME="`dirname "$0"`/.." +IOTDB_CLUSTER_PATH="${IOTDB_HOME}"/conf/iotdb-cluster.properties +# iotdb-cluster.properties does not exist, the current ICID is cleaned +if [ ! -f ${IOTDB_CLUSTER_PATH} ]; then + exec ${IOTDB_HOME}/sbin/clean-datanode.sh -f > /dev/null 2>&1 & + exec ${IOTDB_HOME}/sbin/clean-confignode.sh -f> /dev/null 2>&1 & + exec rm -rf ${IOTDB_HOME}/data/ +else + confignodeStr=$(sed '/^confignode_address_list=/!d;s/.*=//' "${IOTDB_CLUSTER_PATH}") + confignodeIps=(${confignodeStr//,/ }) + datanodeStr=$(sed '/^datanode_address_list=/!d;s/.*=//' "${IOTDB_CLUSTER_PATH}") + datanodeIps=(${datanodeStr//,/ }) + serverPort=$(sed '/^ssh_port=/!d;s/.*=//' "${IOTDB_CLUSTER_PATH}") + confignodePath=$(sed '/^confignode_deploy_path=/!d;s/.*=//' "${IOTDB_CLUSTER_PATH}") + datanodePath=$(sed '/^datanode_deploy_path=/!d;s/.*=//' "${IOTDB_CLUSTER_PATH}") + account=$(sed '/^ssh_account=/!d;s/.*=//' "${IOTDB_CLUSTER_PATH}") +# echo $confignodeIps $datanodeIps $confignodePaths $datanodePaths $account $serverPort +fi + +function validateParam() { + if [[ -z $1 || -z $2 || -z $3 || -z $4 || -z $5 || -z $6 ]]; then + echo "The iotdb-cluster.properties file is incomplete, the current 1C1D will be cleaned ... " + exec ${IOTDB_HOME}/sbin/clean-datanode.sh -f > /dev/null 2>&1 & + exec ${IOTDB_HOME}/sbin/clean-confignode.sh -f> /dev/null 2>&1 & + exit Review Comment: Why isn't data deleted from this location? ########## iotdb-core/node-commons/src/assembly/resources/sbin/clean-datanode.bat: ########## @@ -0,0 +1,204 @@ +@REM +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM +@echo off + +pushd %~dp0.. +if NOT DEFINED IOTDB_HOME set IOTDB_HOME=%cd% +popd + +set "reCheck=%1" +echo %reCheck% +if not "%reCheck%" == "-f" ( + echo -n "Do you want to clean all the data in the IoTDB ? y/n (default n): " + set /p CLEAN_SERVICE= +) + +if not "%CLEAN_SERVICE%"=="y" if not "%CLEAN_SERVICE%"=="Y" ( + echo "Exiting..." + exit 0 +) + +rmdir /s /q "%IOTDB_HOME%\data\datanode\" 2>nul +set IOTDB_DATANODE_CONFIG=%IOTDB_HOME%\conf\iotdb-datanode.properties +set "delimiter=,;" +for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^dn_system_dir" + %IOTDB_DATANODE_CONFIG%') do ( + set dn_system_dir=%%i +) +if "%dn_system_dir%"=="" ( + set "dn_system_dir=data\confignode\system" +) +setlocal enabledelayedexpansion +set "dn_system_dir=!dn_system_dir:%delimiter%= !" +for %%i in (%dn_system_dir%) do ( + set "var=%%i" + if "!var:~0,2!"=="\\" ( + rmdir /s /q "%%i" 2>nul + ) else if "!var:~1,3!"==":\\" ( + rmdir /s /q "%%i" 2>nul + ) else ( + rmdir /s /q "%IOTDB_HOME%\%%i" 2>nul + ) +) + +for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^dn_data_dirs" + %IOTDB_DATANODE_CONFIG%') do ( + set dn_data_dirs=%%i +) +if "%dn_data_dirs%"=="" ( + set "dn_data_dirs=data\\datanode\\data" +) +setlocal enabledelayedexpansion +set "dn_data_dirs=!dn_data_dirs:%delimiter%= !" +for %%i in (%dn_data_dirs%) do ( + set "var=%%i" + if "!var:~0,2!"=="\\" ( + rmdir /s /q "%%i" 2>nul + ) else if "!var:~1,3!"==":\\" ( + rmdir /s /q "%%i" 2>nul + ) else ( + rmdir /s /q "%IOTDB_HOME%\%%i" 2>nul + ) +) + +for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^dn_consensus_dir" + %IOTDB_DATANODE_CONFIG%') do ( + set dn_consensus_dir=%%i +) +if "%dn_consensus_dir%"=="" ( + set "dn_consensus_dir=data\\datanode\\consensus" +) +setlocal enabledelayedexpansion Review Comment: Is it enough to set it up once -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
