From ff854016794c4ac5d4c51d96923d72b5715e881b Mon Sep 17 00:00:00 2001 From: "13574798@qq.com" <13574798@qq.com> Date: Mon, 16 Dec 2024 23:09:00 +0800 Subject: [PATCH 1/6] add comment --- .../java/org/apache/amoro/server/AmoroServiceContainer.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/amoro-ams/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java b/amoro-ams/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java index 5c5ee9c46a..913cde3aff 100644 --- a/amoro-ams/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java +++ b/amoro-ams/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java @@ -181,6 +181,8 @@ private void addHandlerChain(RuntimeHandlerChain chain) { } public void dispose() { + //TODO if has optimizer, try to stop and wait it all stop + if (tableManagementServer != null && tableManagementServer.isServing()) { LOG.info("Stopping table management server..."); tableManagementServer.stop(); From b2a7295429ad30801016e7893e5b9847c6729ea5 Mon Sep 17 00:00:00 2001 From: "13574798@qq.com" <13574798@qq.com> Date: Tue, 17 Dec 2024 20:28:01 +0800 Subject: [PATCH 2/6] Revert "add comment" This reverts commit ff854016794c4ac5d4c51d96923d72b5715e881b. --- .../java/org/apache/amoro/server/AmoroServiceContainer.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/amoro-ams/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java b/amoro-ams/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java index 913cde3aff..5c5ee9c46a 100644 --- a/amoro-ams/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java +++ b/amoro-ams/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java @@ -181,8 +181,6 @@ private void addHandlerChain(RuntimeHandlerChain chain) { } public void dispose() { - //TODO if has optimizer, try to stop and wait it all stop - if (tableManagementServer != null && tableManagementServer.isServing()) { LOG.info("Stopping table management server..."); tableManagementServer.stop(); From 0ded0384cddabef7591fd332c0e78f97d30a30ee Mon Sep 17 00:00:00 2001 From: "13574798@qq.com" <13574798@qq.com> Date: Thu, 19 Dec 2024 22:30:19 +0800 Subject: [PATCH 3/6] add two scripts --- dist/src/main/amoro-bin/bin/start-all.sh | 0 dist/src/main/amoro-bin/bin/stop-all.sh | 2 ++ 2 files changed, 2 insertions(+) create mode 100644 dist/src/main/amoro-bin/bin/start-all.sh create mode 100644 dist/src/main/amoro-bin/bin/stop-all.sh diff --git a/dist/src/main/amoro-bin/bin/start-all.sh b/dist/src/main/amoro-bin/bin/start-all.sh new file mode 100644 index 0000000000..e69de29bb2 diff --git a/dist/src/main/amoro-bin/bin/stop-all.sh b/dist/src/main/amoro-bin/bin/stop-all.sh new file mode 100644 index 0000000000..05a7907cf5 --- /dev/null +++ b/dist/src/main/amoro-bin/bin/stop-all.sh @@ -0,0 +1,2 @@ +#!/bin/bash + From eeb2aaffec2700bf5d80960c877a41491e0377da Mon Sep 17 00:00:00 2001 From: "13574798@qq.com" <13574798@qq.com> Date: Thu, 19 Dec 2024 22:56:17 +0800 Subject: [PATCH 4/6] add two scripts --- dist/src/main/amoro-bin/bin/stop-all.sh | 55 +++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/dist/src/main/amoro-bin/bin/stop-all.sh b/dist/src/main/amoro-bin/bin/stop-all.sh index 05a7907cf5..15a2f766af 100644 --- a/dist/src/main/amoro-bin/bin/stop-all.sh +++ b/dist/src/main/amoro-bin/bin/stop-all.sh @@ -1,2 +1,57 @@ #!/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. +# +# Check for JAVA_HOME and set JPS_PATH accordingly +if [[ -d $JAVA_HOME ]]; then + JPS_PATH="$JAVA_HOME/bin/jps" +else + JPS_PATH="jps" # Fallback to system's PATH +fi + +# Define an array of target process names +TARGET_PROCESSES=("StandaloneOptimizer" "AmoroServiceContainer") + +# Specify the log file +LOG_FILE="kill_process.log" + +# Iterate over each target process name +for TARGET_PROCESS in "${TARGET_PROCESSES[@]}"; do + # Get the PIDs of all matching target processes using jps + PIDS=$($JPS_PATH | grep "$TARGET_PROCESS" | awk '{print $1}') + + # Check if any PIDs were found + if [ -z "$PIDS" ]; then + echo "$(date): No processes found matching '$TARGET_PROCESS'." | tee -a "$LOG_FILE" + continue + fi + + # Iterate through each PID and attempt to kill the process + echo "$(date): Found processes matching '$TARGET_PROCESS': $PIDS." | tee -a "$LOG_FILE" + for PID in $PIDS; do + echo "$(date): Attempting to kill process with PID $PID for '$TARGET_PROCESS'..." | tee -a "$LOG_FILE" + kill "$PID" + + # Check the kill status + if [ $? -eq 0 ]; then + echo "$(date): Successfully killed process with PID $PID for '$TARGET_PROCESS'." | tee -a "$LOG_FILE" + else + echo "$(date): Failed to kill process with PID $PID for '$TARGET_PROCESS'." | tee -a "$LOG_FILE" + fi + done +done \ No newline at end of file From 38f5c39ab929e62bba6e1f806528dc7c6c6b6f49 Mon Sep 17 00:00:00 2001 From: "13574798@qq.com" <13574798@qq.com> Date: Thu, 19 Dec 2024 22:59:14 +0800 Subject: [PATCH 5/6] add two scripts --- dist/src/main/amoro-bin/bin/{start-all.sh => restart-all.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename dist/src/main/amoro-bin/bin/{start-all.sh => restart-all.sh} (100%) diff --git a/dist/src/main/amoro-bin/bin/start-all.sh b/dist/src/main/amoro-bin/bin/restart-all.sh similarity index 100% rename from dist/src/main/amoro-bin/bin/start-all.sh rename to dist/src/main/amoro-bin/bin/restart-all.sh From 6295e35c208a66ae4f0a53107e8eb03ae6d2bcfc Mon Sep 17 00:00:00 2001 From: "13574798@qq.com" <13574798@qq.com> Date: Thu, 19 Dec 2024 23:10:46 +0800 Subject: [PATCH 6/6] add two scripts --- dist/src/main/amoro-bin/bin/restart-all.sh | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/dist/src/main/amoro-bin/bin/restart-all.sh b/dist/src/main/amoro-bin/bin/restart-all.sh index e69de29bb2..7452e01499 100644 --- a/dist/src/main/amoro-bin/bin/restart-all.sh +++ b/dist/src/main/amoro-bin/bin/restart-all.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Check for JAVA_HOME and set JPS_PATH accordingly +if [[ -d $JAVA_HOME ]]; then + JPS_PATH="$JAVA_HOME/bin/jps" +else + JPS_PATH="jps" # Fallback to system's PATH +fi + +# Log file +LOG_FILE="restart_process.log" + +# Define an array of target process names +TARGET_PROCESSES=("AmoroServiceContainer" "StandaloneOptimizer") + +# Iterate over each target process name +for TARGET_PROCESS in "${TARGET_PROCESSES[@]}"; do + echo "$(date): Checking for process '$TARGET_PROCESS'..." | tee -a "$LOG_FILE" + + # Find the PID of the target process + PID=$($JPS_PATH | grep "$TARGET_PROCESS" | awk '{print $1}') + + if [[ -z "$PID" ]]; then + echo "$(date): No process found matching '$TARGET_PROCESS'." | tee -a "$LOG_FILE" + continue + fi + + echo "$(date): Found process '$TARGET_PROCESS' with PID $PID." | tee -a "$LOG_FILE" + + # Retrieve the command line using ps + CMDLINE=$(ps -o args= -p "$PID") + + if [[ -z "$CMDLINE" ]]; then + echo "$(date): Failed to retrieve command line for PID $PID." | tee -a "$LOG_FILE" + continue + fi + + echo "$(date): Retrieved command line for '$TARGET_PROCESS': $CMDLINE" | tee -a "$LOG_FILE" + + # Kill the process + echo "$(date): Attempting to kill process with PID $PID for '$TARGET_PROCESS'..." | tee -a "$LOG_FILE" + kill "$PID" + + # Check if the process was successfully killed + if [[ $? -eq 0 ]]; then + echo "$(date): Successfully killed process with PID $PID for '$TARGET_PROCESS'." | tee -a "$LOG_FILE" + else + echo "$(date): Failed to kill process with PID $PID for '$TARGET_PROCESS'." | tee -a "$LOG_FILE" + continue + fi + + # Restart the process + echo "$(date): Restarting process '$TARGET_PROCESS' with original command line..." | tee -a "$LOG_FILE" + eval "$CMDLINE" & + + # Check if the restart was successful + if [[ $? -eq 0 ]]; then + echo "$(date): Successfully restarted process '$TARGET_PROCESS'." | tee -a "$LOG_FILE" + else + echo "$(date): Failed to restart process '$TARGET_PROCESS'." | tee -a "$LOG_FILE" + fi +done \ No newline at end of file