This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 1c6f926cf48 Change the clean script to a destory script and add a stop 
operation … (#11879)
1c6f926cf48 is described below

commit 1c6f926cf4820c65e6eb5a5b3be5e0bf3e9b51ab
Author: Summer <[email protected]>
AuthorDate: Mon Jan 15 18:41:09 2024 +0800

    Change the clean script to a destory script and add a stop operation … 
(#11879)
    
    Co-authored-by: 2b3c511 <[email protected]>
---
 .../sbin/{clean-all.bat => destroy-all.bat}        | 22 ++++----
 .../sbin/{clean-all.sh => destroy-all.sh}          | 58 ++++++++++++----------
 ...clean-confignode.bat => destroy-confignode.bat} | 34 +++++++------
 .../{clean-confignode.sh => destroy-confignode.sh} |  7 ++-
 .../{clean-datanode.bat => destroy-datanode.bat}   | 14 +++---
 .../{clean-datanode.sh => destroy-datanode.sh}     |  7 ++-
 .../src/assembly/resources/sbin/start-all.sh       |  9 ++--
 .../src/assembly/resources/sbin/stop-all.sh        | 15 +++---
 8 files changed, 90 insertions(+), 76 deletions(-)

diff --git a/iotdb-core/node-commons/src/assembly/resources/sbin/clean-all.bat 
b/iotdb-core/node-commons/src/assembly/resources/sbin/destroy-all.bat
similarity index 68%
rename from iotdb-core/node-commons/src/assembly/resources/sbin/clean-all.bat
rename to iotdb-core/node-commons/src/assembly/resources/sbin/destroy-all.bat
index b470f994b23..634cd2dd384 100644
--- a/iotdb-core/node-commons/src/assembly/resources/sbin/clean-all.bat
+++ b/iotdb-core/node-commons/src/assembly/resources/sbin/destroy-all.bat
@@ -16,23 +16,27 @@
 @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 0
+echo "Do you want to clean 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..."
+  goto finally
 )
 
 pushd %~dp0..
 if NOT DEFINED IOTDB_HOME set IOTDB_HOME=%cd%
 popd
 
+start cmd /c "%IOTDB_HOME%\\sbin\\stop-standalone.bat -f"
+timeout /t 5 > nul
 rmdir /s /q "%IOTDB_HOME%\\data\\"
 
-start cmd /c "%IOTDB_HOME%\\sbin\\clean-datanode.bat -f"
-start cmd /c "%IOTDB_HOME%\\sbin\\clean-confignode.bat -f"
+start cmd /c "%IOTDB_HOME%\\sbin\\destroy-datanode.bat -f"
+start cmd /c "%IOTDB_HOME%\\sbin\\destroy-confignode.bat -f"
 
-ECHO Cluster cleanup complete ...
-exit 0
\ No newline at end of file
+ECHO "Cluster cleanup complete ..."
+:finally
+exit /b
\ No newline at end of file
diff --git a/iotdb-core/node-commons/src/assembly/resources/sbin/clean-all.sh 
b/iotdb-core/node-commons/src/assembly/resources/sbin/destroy-all.sh
similarity index 64%
rename from iotdb-core/node-commons/src/assembly/resources/sbin/clean-all.sh
rename to iotdb-core/node-commons/src/assembly/resources/sbin/destroy-all.sh
index c90f960c858..251499f8042 100644
--- a/iotdb-core/node-commons/src/assembly/resources/sbin/clean-all.sh
+++ b/iotdb-core/node-commons/src/assembly/resources/sbin/destroy-all.sh
@@ -28,8 +28,8 @@ export IOTDB_HOME="`dirname "$0"`/.."
 IOTDB_CLUSTER_PATH="${IOTDB_HOME}"/conf/iotdb-cluster.properties
 if [ ! -f ${IOTDB_CLUSTER_PATH} ]; then
   exec rm -rf ${IOTDB_HOME}/data/
-  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 ${IOTDB_HOME}/sbin/destroy-datanode.sh -f >/dev/null 2>&1 &
+  exec ${IOTDB_HOME}/sbin/destroy-confignode.sh -f >/dev/null 2>&1 &
   exit 0
 else
   confignodeStr=$(sed '/^confignode_address_list=/!d;s/.*=//' 
"${IOTDB_CLUSTER_PATH}")
@@ -45,9 +45,10 @@ 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/stop-standalone.sh -f >/dev/null 2>&1 &
     exec rm -rf ${IOTDB_HOME}/data/
-    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 ${IOTDB_HOME}/sbin/destroy-datanode.sh -f >/dev/null 2>&1 &
+    exec ${IOTDB_HOME}/sbin/destroy-confignode.sh -f >/dev/null 2>&1 &
     exit
   fi
 }
@@ -59,36 +60,39 @@ if [ "$IOTDB_SSH_OPTS" = "" ]; then
 fi
 
 unique_array=($(awk -v RS=' ' '!a[$1]++' <<< ${datanodeIps[@]}))
+confignodeIps=($(awk -v RS=' ' '!a[$1]++' <<< ${confignodeIps[@]}))
+size=${#confignodeIps[@]}
 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]'
-              break
-          fi
-      done
-      if [[ "$hasConfigNode" == "true" ]]; then
-        echo "The system starts to clean data of DataNodes and ConfigNode of 
$datanodeIP"
-        ssh $IOTDB_SSH_OPTS -p $serverPort ${account}@$datanodeIP "
-          nohup bash $datanodePath/sbin/clean-datanode.sh -f >/dev/null 2>&1 &
-          sleep 3
-          nohup bash $confignodePath/sbin/clean-confignode.sh -f >/dev/null 
2>&1 &
-          "
-      else
-        echo "The system starts to clean data of DataNodes of $datanodeIP"
-        ssh $IOTDB_SSH_OPTS -p $serverPort ${account}@$datanodeIP "
-            nohup bash $datanodePath/sbin/clean-datanode.sh -f >/dev/null 2>&1 
& >/dev/null 2>&1 &
-          "
+  for ((i=0; i<$size; i++))
+    do
+      if [[ "${confignodeIps[$i]}" == "" ]]; then
+        continue
+      elif [[ "${confignodeIps[$i]}" == *"$datanodeIP"* ]]; then
+        hasConfigNode="true"
+        unset 'confignodeIps[$i]'
+        break
       fi
+    done
+    if [[ "$hasConfigNode" == "true" ]]; then
+      echo "The system starts to clean data of DataNodes and ConfigNode of 
$datanodeIP"
+      ssh $IOTDB_SSH_OPTS -p $serverPort ${account}@$datanodeIP "
+        nohup bash $datanodePath/sbin/destroy-datanode.sh -f >/dev/null 2>&1 &
+        sleep 3
+        nohup bash $confignodePath/sbin/destroy-confignode.sh -f >/dev/null 
2>&1 &
+        "
+    else
+      echo "The system starts to clean data of DataNodes of $datanodeIP"
+      ssh $IOTDB_SSH_OPTS -p $serverPort ${account}@$datanodeIP "
+          nohup bash $datanodePath/sbin/destroy-datanode.sh -f >/dev/null 2>&1 
& >/dev/null 2>&1 &
+        "
+    fi
 done
 
-unique_array=($(awk -v RS=' ' '!a[$1]++' <<< ${confignodeIps[@]}))
-for confignodeIP in ${unique_array[@]};do
+for confignodeIP in ${confignodeIps[@]};do
   echo "The system starts to clear data of ConfigNodes of $confignodeIP"
   ssh $IOTDB_SSH_OPTS -p $serverPort ${account}@$confignodeIP "
-      nohup bash $confignodePath/sbin/clean-confignode.sh -f >/dev/null 2>&1 &
+      nohup bash $confignodePath/sbin/destroy-confignode.sh -f >/dev/null 2>&1 
&
   "
 done
 
diff --git 
a/iotdb-core/node-commons/src/assembly/resources/sbin/clean-confignode.bat 
b/iotdb-core/node-commons/src/assembly/resources/sbin/destroy-confignode.bat
similarity index 81%
rename from 
iotdb-core/node-commons/src/assembly/resources/sbin/clean-confignode.bat
rename to 
iotdb-core/node-commons/src/assembly/resources/sbin/destroy-confignode.bat
index f43ae1a0347..c25485b38b8 100644
--- a/iotdb-core/node-commons/src/assembly/resources/sbin/clean-confignode.bat
+++ b/iotdb-core/node-commons/src/assembly/resources/sbin/destroy-confignode.bat
@@ -17,22 +17,23 @@
 @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): 
"
+    echo "Do you want to clean the data of confignode 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
+  goto finally
 )
 
+start cmd /c "%IOTDB_HOME%\\sbin\\stop-confignode.bat -f"
+timeout /t 3 > nul
 rmdir /s /q "%IOTDB_HOME%\data\confignode\" 2>nul
 set IOTDB_CONFIGNODE_CONFIG=%IOTDB_HOME%\conf\iotdb-confignode.properties
 set "delimiter=,;"
@@ -41,7 +42,7 @@ for /f  "eol=# tokens=2 delims==" %%i in ('findstr /i 
"^cn_system_dir"
   set cn_system_dir=%%i
 )
 if "%cn_system_dir%"=="" (
-    set "cn_system_dir=data\confignode\system"
+  set "cn_system_dir=data\confignode\system"
 )
 
 setlocal enabledelayedexpansion
@@ -49,11 +50,11 @@ 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
+     rmdir /s /q "%%i" 2>nul
   ) else if "!var:~1,3!"==":\\" (
-      rmdir /s /q "%%i" 2>nul
+     rmdir /s /q "%%i" 2>nul
   ) else (
-      rmdir /s /q "%IOTDB_HOME%\%%i" 2>nul
+     rmdir /s /q "%IOTDB_HOME%\%%i" 2>nul
   )
 )
 
@@ -68,15 +69,18 @@ set "cn_consensus_dir=data\confignode\consensus"
 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!"==":\\" (
-        rmdir /s /q "%%i" 2>nul
-    ) else (
-        rmdir /s /q "%IOTDB_HOME%\%%i" 2>nul
-    )
+  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
+  )
 )
 
 endlocal
 
-echo "ConfigNode clean done ..."
\ No newline at end of file
+echo "ConfigNode clean done ..."
+
+:finally
+exit /b
\ No newline at end of file
diff --git 
a/iotdb-core/node-commons/src/assembly/resources/sbin/clean-confignode.sh 
b/iotdb-core/node-commons/src/assembly/resources/sbin/destroy-confignode.sh
similarity index 89%
rename from 
iotdb-core/node-commons/src/assembly/resources/sbin/clean-confignode.sh
rename to 
iotdb-core/node-commons/src/assembly/resources/sbin/destroy-confignode.sh
index 2e3239a3502..88a5e348830 100644
--- a/iotdb-core/node-commons/src/assembly/resources/sbin/clean-confignode.sh
+++ b/iotdb-core/node-commons/src/assembly/resources/sbin/destroy-confignode.sh
@@ -24,13 +24,13 @@ fi
 
 reCheck=$1
 if [[ "$reCheck" != "-f" ]]; then
-  read -p "Do you want to clean all the data in the IoTDB ? y/n (default n): " 
CLEAN_SERVICE
+  read -p "Do you want to clean data of confignode in the IoTDB ? y/n (default 
n): " CLEAN_SERVICE
   if [[ "$CLEAN_SERVICE" != "y" && "$CLEAN_SERVICE" != "Y" ]]; then
     echo "Exiting..."
-    exit 0
+    exit 1
   fi
 fi
-
+nohup bash ${IOTDB_HOME}/sbin/stop-confignode.sh -f >/dev/null 2>&1 &
 rm -rf ${IOTDB_HOME}/data/confignode/ >/dev/null 2>&1 &
 
 IOTDB_CONFIGNODE_CONFIG=${IOTDB_HOME}/conf/iotdb-confignode.properties
@@ -51,5 +51,4 @@ function clearPath {
 clearPath $cn_system_dir
 clearPath $cn_consensus_dir
 
-exit
 echo "ConfigNode clean done ..."
\ No newline at end of file
diff --git 
a/iotdb-core/node-commons/src/assembly/resources/sbin/clean-datanode.bat 
b/iotdb-core/node-commons/src/assembly/resources/sbin/destroy-datanode.bat
similarity index 95%
rename from 
iotdb-core/node-commons/src/assembly/resources/sbin/clean-datanode.bat
rename to 
iotdb-core/node-commons/src/assembly/resources/sbin/destroy-datanode.bat
index 8f876061008..744fb09a953 100644
--- a/iotdb-core/node-commons/src/assembly/resources/sbin/clean-datanode.bat
+++ b/iotdb-core/node-commons/src/assembly/resources/sbin/destroy-datanode.bat
@@ -17,23 +17,22 @@
 @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): 
"
+    echo "Do you want to clean the data of datanode 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
+  goto finally
 )
-
+start cmd /c "%IOTDB_HOME%\\sbin\\stop-datanode.bat -f"
+timeout /t 3 > nul
 rmdir /s /q "%IOTDB_HOME%\data\datanode\" 2>nul
 set IOTDB_DATANODE_CONFIG=%IOTDB_HOME%\conf\iotdb-datanode.properties
 set "delimiter=,;"
@@ -200,4 +199,7 @@ for %%i in (%sort_tmp_dir%) do (
 )
 
 endlocal
-echo "DataNode clean done ..."
\ No newline at end of file
+echo "DataNode clean done ..."
+
+:finally
+exit /b
\ No newline at end of file
diff --git 
a/iotdb-core/node-commons/src/assembly/resources/sbin/clean-datanode.sh 
b/iotdb-core/node-commons/src/assembly/resources/sbin/destroy-datanode.sh
similarity index 93%
rename from 
iotdb-core/node-commons/src/assembly/resources/sbin/clean-datanode.sh
rename to 
iotdb-core/node-commons/src/assembly/resources/sbin/destroy-datanode.sh
index cb0542b8ced..98e287ef4e6 100644
--- a/iotdb-core/node-commons/src/assembly/resources/sbin/clean-datanode.sh
+++ b/iotdb-core/node-commons/src/assembly/resources/sbin/destroy-datanode.sh
@@ -19,18 +19,17 @@
 #
 
 reCheck=$1
-echo $reCheck
 if [[ "$reCheck" != "-f" ]]; then
-  read -p "Do you want to clean all the data in the IoTDB ? y/n (default n): " 
CLEAN_SERVICE
+  read -p "Do you want to clean data of datanode in the IoTDB ? y/n (default 
n): " CLEAN_SERVICE
   if [[ "$CLEAN_SERVICE" != "y" && "$CLEAN_SERVICE" != "Y" ]]; then
     echo "Exiting..."
-    exit 0
+    exit 1
   fi
 fi
-
 if [ -z "${IOTDB_HOME}" ]; then
   export IOTDB_HOME="$(cd "`dirname "$0"`"/..; pwd)"
 fi
+nohup bash ${IOTDB_HOME}/sbin/stop-datanode.sh -f >/dev/null 2>&1 &
 
 rm -rf ${IOTDB_HOME}/data/datanode/ >/dev/null 2>&1 &
 IOTDB_DATANODE_CONFIG=${IOTDB_HOME}/conf/iotdb-datanode.properties
diff --git a/iotdb-core/node-commons/src/assembly/resources/sbin/start-all.sh 
b/iotdb-core/node-commons/src/assembly/resources/sbin/start-all.sh
index c7d8e948008..255985170ad 100644
--- a/iotdb-core/node-commons/src/assembly/resources/sbin/start-all.sh
+++ b/iotdb-core/node-commons/src/assembly/resources/sbin/start-all.sh
@@ -48,11 +48,14 @@ if [ "$IOTDB_SSH_OPTS" = "" ]; then
   IOTDB_SSH_OPTS="-o StrictHostKeyChecking=no"
 fi
 
+size=${#datanodeIps[@]}
 for confignodeIP in ${confignodeIps[@]};do
   hasDataNode="false"
-  for ((i=0; i<${#datanodeIps[@]}; i++))
+  for ((i=0; i<$size; i++))
   do
-      if [[ "${datanodeIps[$i]}" == *"$confignodeIP"* ]]; then
+      if [[ "${datanodeIps[$i]}" == "" ]]; then
+        continue
+      elif [[ "${datanodeIps[$i]}" == *"$confignodeIP"* ]]; then
           hasDataNode="true"
           unset 'datanodeIps[$i]'
           break
@@ -69,13 +72,11 @@ for confignodeIP in ${confignodeIps[@]};do
     echo "The system starts the ConfigNode of $confignodeIP"
     ssh $IOTDB_SSH_OPTS -p $serverPort ${account}@$confignodeIP "nohup bash 
$confignodePath/sbin/start-confignode.sh >/dev/null 2>&1 &"
   fi
-  sleep 3
 done
 
 for datanodeIP in ${datanodeIps[@]};do
   echo "The system starts the DataNode of $datanodeIP"
   ssh $IOTDB_SSH_OPTS -p $serverPort ${account}@$datanodeIP "nohup bash 
$datanodePath/sbin/start-datanode.sh >/dev/null 2>&1 &"
-  sleep 3
 done
 
 echo "Cluster startup complete ..."
diff --git a/iotdb-core/node-commons/src/assembly/resources/sbin/stop-all.sh 
b/iotdb-core/node-commons/src/assembly/resources/sbin/stop-all.sh
index b59f03e9a82..c162b78b2e1 100644
--- a/iotdb-core/node-commons/src/assembly/resources/sbin/stop-all.sh
+++ b/iotdb-core/node-commons/src/assembly/resources/sbin/stop-all.sh
@@ -33,7 +33,6 @@ else
   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() {
@@ -48,21 +47,23 @@ if [ "$IOTDB_SSH_OPTS" = "" ]; then
   IOTDB_SSH_OPTS="-o StrictHostKeyChecking=no"
 fi
 
+size=${#confignodeIps[@]}
 for datanodeIP in ${datanodeIps[@]};do
   hasConfigNode="false"
-  for ((i=0; i<${#confignodeIps[@]}; i++))
+  for ((i=0; i<$size; i++))
     do
-        if [[ "${confignodeIps[$i]}" == *"$datanodeIP"* ]]; then
-            hasConfigNode="true"
-            unset 'confignodeIps[$i]'
-            break
+        if [[ "${confignodeIps[$i]}" == "" ]]; then
+          continue
+        elif [[ "${confignodeIps[$i]}" == *"$datanodeIP"* ]]; then
+          hasConfigNode="true"
+          unset 'confignodeIps[$i]'
+          break
         fi
     done
     if [[ "$hasConfigNode" == "true" ]]; then
       echo "The system stops the DataNode and ConfigNode of $datanodeIP"
       ssh $IOTDB_SSH_OPTS -p $serverPort ${account}@$datanodeIP "
         nohup bash $datanodePath/sbin/stop-datanode.sh
-        sleep 3
         nohup bash $confignodePath/sbin/stop-confignode.sh
         "
     else

Reply via email to