hbase/bin/test/process_based_cluster.sh
mbautin a2c1c0cd3e [jira] [HBASE-5684] Make ProcessBasedLocalHBaseCluster run HDFS and make it more
robust

Summary:
Currently ProcessBasedLocalHBaseCluster runs on top of raw local filesystem. We
need it to start a process-based HDFS cluster as well. We also need to make the
whole thing more stable so we can use it in unit tests.

Also all logs of local HBase cluster daemons are now tailed to the primary log
of the unit test with the appropriate prefixes to make debugging easier.

This is a trunk diff. The 89-fb version is D2709.

Test Plan:
Run the new unit test multiple times (10x or 50x).
Run all unit tests.

Reviewers: tedyu, stack, lhofhansl, nspiegelberg, amirshim, JIRA

Reviewed By: tedyu

Differential Revision: https://reviews.facebook.net/D2757

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1326036 13f79535-47bb-0310-9956-ffa450edef68
2012-04-14 01:25:27 +00:00

91 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -e -u -o pipefail
SCRIPT_NAME=${0##*/}
SCRIPT_DIR=$(cd `dirname $0` && pwd )
print_usage() {
cat >&2 <<EOT
Usage: $SCRIPT_NAME <options>
Options:
--kill
Kill local process-based HBase cluster using pid files.
--show
Show HBase processes running on this machine
EOT
exit 1
}
show_processes() {
ps -ef | grep -P "(HRegionServer|HMaster|HQuorumPeer) start" | grep -v grep
}
cmd_specified() {
if [ "$CMD_SPECIFIED" ]; then
echo "Only one command can be specified" >&2
exit 1
fi
CMD_SPECIFIED=1
}
list_pid_files() {
LOCAL_CLUSTER_DIR=$SCRIPT_DIR/../../target/local_cluster
LOCAL_CLUSTER_DIR=$( cd $LOCAL_CLUSTER_DIR && pwd )
find $LOCAL_CLUSTER_DIR -name "*.pid"
}
if [ $# -eq 0 ]; then
print_usage
fi
IS_KILL=""
IS_SHOW=""
CMD_SPECIFIED=""
while [ $# -ne 0 ]; do
case "$1" in
-h|--help)
print_usage ;;
--kill)
IS_KILL=1
cmd_specified ;;
--show)
IS_SHOW=1
cmd_specified ;;
*)
echo "Invalid option: $1" >&2
exit 1
esac
shift
done
if [ "$IS_KILL" ]; then
list_pid_files | \
while read F; do
PID=`cat $F`
echo "Killing pid $PID from file $F"
# Kill may fail but that's OK, so turn off error handling for a moment.
set +e
kill -9 $PID
set -e
done
elif [ "$IS_SHOW" ]; then
PIDS=""
for F in `list_pid_files`; do
PID=`cat $F`
if [ -n "$PID" ]; then
if [ -n "$PIDS" ]; then
PIDS="$PIDS,"
fi
PIDS="$PIDS$PID"
fi
done
ps -p $PIDS
else
echo "No command specified" >&2
exit 1
fi