You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2023/03/09 02:58:47 UTC

[hbase] branch branch-2.5 updated: HBASE-27669 chaos-daemon.sh should make use hbase script start/stop chaosagent and chaos monkey runner (#5078)

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

zhangduo pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.5 by this push:
     new ab8aa620302 HBASE-27669 chaos-daemon.sh should make use hbase script start/stop chaosagent and chaos monkey runner (#5078)
ab8aa620302 is described below

commit ab8aa62030264eed588fb78315b2bf2d57b8a3fa
Author: Rajeshbabu Chintaguntla <ch...@gmail.com>
AuthorDate: Thu Mar 9 08:16:25 2023 +0530

    HBASE-27669 chaos-daemon.sh should make use hbase script start/stop chaosagent and chaos monkey runner (#5078)
    
    Co-authored-by: Rajeshbabu Chintaguntla <rc...@visa.com>
    Signed-off-by: Duo Zhang <zh...@apache.org>
    (cherry picked from commit bc8b13e468a258b4ee47e40cf3645bf27d66471d)
---
 bin/chaos-daemon.sh                                | 26 +++++++++++-----------
 bin/hbase                                          |  4 ++++
 .../apache/hadoop/hbase/HBaseClusterManager.java   |  2 +-
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/bin/chaos-daemon.sh b/bin/chaos-daemon.sh
index 084e519321a..8e27f4a5d9f 100644
--- a/bin/chaos-daemon.sh
+++ b/bin/chaos-daemon.sh
@@ -19,7 +19,7 @@
 # */
 #
 
-usage="Usage: chaos-daemon.sh (start|stop) chaosagent"
+usage="Usage: chaos-daemon.sh (start|stop) (chaosagent|chaosmonkeyrunner)"
 
 # if no args specified, show usage
 if [ $# -le 1 ]; then
@@ -51,11 +51,6 @@ bin=$(cd "$bin">/dev/null || exit; pwd)
 . "$bin"/hbase-config.sh
 . "$bin"/hbase-common.sh
 
-CLASSPATH=$HBASE_CONF_DIR
-for f in ../lib/*.jar; do
-  CLASSPATH=${CLASSPATH}:$f
-done
-
 # get log directory
 if [ "$HBASE_LOG_DIR" = "" ]; then
   export HBASE_LOG_DIR="$HBASE_HOME/logs"
@@ -79,7 +74,7 @@ if [ "$JAVA_HOME" = "" ]; then
 fi
 
 export HBASE_LOG_PREFIX=hbase-$HBASE_IDENT_STRING-$command-$HOSTNAME
-export CHAOS_LOGFILE=$HBASE_LOG_PREFIX.log
+export HBASE_LOGFILE=$HBASE_LOG_PREFIX.log
 
 if [ -z "${HBASE_ROOT_LOGGER}" ]; then
 export HBASE_ROOT_LOGGER=${HBASE_ROOT_LOGGER:-"INFO,RFA"}
@@ -89,7 +84,7 @@ if [ -z "${HBASE_SECURITY_LOGGER}" ]; then
 export HBASE_SECURITY_LOGGER=${HBASE_SECURITY_LOGGER:-"INFO,RFAS"}
 fi
 
-CHAOS_LOGLOG=${CHAOS_LOGLOG:-"${HBASE_LOG_DIR}/${CHAOS_LOGFILE}"}
+CHAOS_LOGLOG=${CHAOS_LOGLOG:-"${HBASE_LOG_DIR}/${HBASE_LOGFILE}"}
 CHAOS_PID=$HBASE_PID_DIR/hbase-$HBASE_IDENT_STRING-$command.pid
 
 if [ -z "$CHAOS_JAVA_OPTS" ]; then
@@ -101,15 +96,20 @@ case $startStop in
 (start)
     check_before_start
     echo running $command
-    CMD="${JAVA_HOME}/bin/java -Dapp.home=${HBASE_CONF_DIR}/../  ${CHAOS_JAVA_OPTS} -cp ${CLASSPATH} org.apache.hadoop.hbase.chaos.ChaosService -$command start &>> ${CHAOS_LOGLOG} &"
-
-    eval $CMD
+    command_args=""
+    if [ "$command" = "chaosagent" ]; then
+      command_args=" -${command} start"
+    elif [ "$command" = "chaosmonkeyrunner" ]; then
+      command_args="-c $HBASE_CONF_DIR $@"
+    fi
+    HBASE_OPTS="$HBASE_OPTS $CHAOS_JAVA_OPTS" . $bin/hbase --config "${HBASE_CONF_DIR}" $command $command_args >> ${CHAOS_LOGLOG} 2>&1 &
     PID=$(echo $!)
+    disown -h -r
     echo ${PID} >${CHAOS_PID}
 
-    echo "Chaos ${1} process Started with ${PID} !"
+    echo "Chaos ${command} process Started with ${PID} !"
     now=$(date)
-    echo "${now} Chaos ${1} process Started with ${PID} !" >>${CHAOS_LOGLOG}
+    echo "${now} Chaos ${command} process Started with ${PID} !" >>${CHAOS_LOGLOG}
     ;;
 
 (stop)
diff --git a/bin/hbase b/bin/hbase
index 02a021ec04f..6833ebfe760 100755
--- a/bin/hbase
+++ b/bin/hbase
@@ -710,6 +710,10 @@ elif [ "$COMMAND" = "pre-upgrade" ] ; then
   CLASS='org.apache.hadoop.hbase.tool.PreUpgradeValidator'
 elif [ "$COMMAND" = "completebulkload" ] ; then
   CLASS='org.apache.hadoop.hbase.tool.BulkLoadHFilesTool'
+elif [ "$COMMAND" = "chaosagent" ] ; then
+  CLASS='org.apache.hadoop.hbase.chaos.ChaosService'
+elif [ "$COMMAND" = "chaosmonkeyrunner" ] ; then
+  CLASS='org.apache.hadoop.hbase.chaos.util.ChaosMonkeyRunner'
 elif [ "$COMMAND" = "hbtop" ] ; then
   CLASS='org.apache.hadoop.hbase.hbtop.HBTop'
   if [ -n "${shaded_jar}" ] ; then
diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java
index cd1c6773634..a73748d5c4f 100644
--- a/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java
+++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java
@@ -217,7 +217,7 @@ public class HBaseClusterManager extends Configured implements ClusterManager {
     }
 
     public String signalCommand(ServiceType service, String signal) {
-      return String.format("%s | xargs sudo kill -s %s", findPidCommand(service), signal);
+      return String.format("%s | xargs kill -s %s", findPidCommand(service), signal);
     }
   }