Skip to content

Commit 082d601

Browse files
authored
Merge branch 'branch-2' into HBASE-24833-branch-2
2 parents 98119eb + 2bb7beb commit 082d601

1,028 files changed

Lines changed: 29860 additions & 32699 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bin/chaos-daemon.sh

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/usr/bin/env bash
2+
#
3+
#/**
4+
# * Licensed to the Apache Software Foundation (ASF) under one
5+
# * or more contributor license agreements. See the NOTICE file
6+
# * distributed with this work for additional information
7+
# * regarding copyright ownership. The ASF licenses this file
8+
# * to you under the Apache License, Version 2.0 (the
9+
# * "License"); you may not use this file except in compliance
10+
# * with the License. You may obtain a copy of the License at
11+
# *
12+
# * http://www.apache.org/licenses/LICENSE-2.0
13+
# *
14+
# * Unless required by applicable law or agreed to in writing, software
15+
# * distributed under the License is distributed on an "AS IS" BASIS,
16+
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# * See the License for the specific language governing permissions and
18+
# * limitations under the License.
19+
# */
20+
#
21+
22+
usage="Usage: chaos-daemon.sh (start|stop) chaosagent"
23+
24+
# if no args specified, show usage
25+
if [ $# -le 1 ]; then
26+
echo "$usage"
27+
exit 1
28+
fi
29+
30+
# get arguments
31+
startStop=$1
32+
shift
33+
34+
command=$1
35+
shift
36+
37+
check_before_start(){
38+
#ckeck if the process is not running
39+
mkdir -p "$HBASE_PID_DIR"
40+
if [ -f "$CHAOS_PID" ]; then
41+
if kill -0 "$(cat "$CHAOS_PID")" > /dev/null 2>&1; then
42+
echo "$command" running as process "$(cat "$CHAOS_PID")". Stop it first.
43+
exit 1
44+
fi
45+
fi
46+
}
47+
48+
bin=`dirname "${BASH_SOURCE-$0}"`
49+
bin=$(cd "$bin">/dev/null || exit; pwd)
50+
51+
. "$bin"/hbase-config.sh
52+
. "$bin"/hbase-common.sh
53+
54+
CLASSPATH=$HBASE_CONF_DIR
55+
for f in ../lib/*.jar; do
56+
CLASSPATH=${CLASSPATH}:$f
57+
done
58+
59+
# get log directory
60+
if [ "$HBASE_LOG_DIR" = "" ]; then
61+
export HBASE_LOG_DIR="$HBASE_HOME/logs"
62+
fi
63+
64+
if [ "$HBASE_PID_DIR" = "" ]; then
65+
HBASE_PID_DIR=/tmp
66+
fi
67+
68+
if [ "$HBASE_IDENT_STRING" = "" ]; then
69+
export HBASE_IDENT_STRING="$USER"
70+
fi
71+
72+
if [ "$JAVA_HOME" != "" ]; then
73+
#echo "run java in $JAVA_HOME"
74+
JAVA_HOME=$JAVA_HOME
75+
fi
76+
if [ "$JAVA_HOME" = "" ]; then
77+
echo "Error: JAVA_HOME is not set."
78+
exit 1
79+
fi
80+
81+
export HBASE_LOG_PREFIX=hbase-$HBASE_IDENT_STRING-$command-$HOSTNAME
82+
export CHAOS_LOGFILE=$HBASE_LOG_PREFIX.log
83+
84+
if [ -z "${HBASE_ROOT_LOGGER}" ]; then
85+
export HBASE_ROOT_LOGGER=${HBASE_ROOT_LOGGER:-"INFO,RFA"}
86+
fi
87+
88+
if [ -z "${HBASE_SECURITY_LOGGER}" ]; then
89+
export HBASE_SECURITY_LOGGER=${HBASE_SECURITY_LOGGER:-"INFO,RFAS"}
90+
fi
91+
92+
CHAOS_LOGLOG=${CHAOS_LOGLOG:-"${HBASE_LOG_DIR}/${CHAOS_LOGFILE}"}
93+
CHAOS_PID=$HBASE_PID_DIR/hbase-$HBASE_IDENT_STRING-$command.pid
94+
95+
if [ -z "$CHAOS_JAVA_OPTS" ]; then
96+
CHAOS_JAVA_OPTS="-Xms1024m -Xmx4096m"
97+
fi
98+
99+
case $startStop in
100+
101+
(start)
102+
check_before_start
103+
echo running $command
104+
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} &"
105+
106+
eval $CMD
107+
PID=$(echo $!)
108+
echo ${PID} >${CHAOS_PID}
109+
110+
echo "Chaos ${1} process Started with ${PID} !"
111+
now=$(date)
112+
echo "${now} Chaos ${1} process Started with ${PID} !" >>${CHAOS_LOGLOG}
113+
;;
114+
115+
(stop)
116+
echo stopping $command
117+
if [ -f $CHAOS_PID ]; then
118+
pidToKill=`cat $CHAOS_PID`
119+
# kill -0 == see if the PID exists
120+
if kill -0 $pidToKill > /dev/null 2>&1; then
121+
echo -n stopping $command
122+
echo "`date` Terminating $command" >> $CHAOS_LOGLOG
123+
kill $pidToKill > /dev/null 2>&1
124+
waitForProcessEnd $pidToKill $command
125+
else
126+
retval=$?
127+
echo no $command to stop because kill -0 of pid $pidToKill failed with status $retval
128+
fi
129+
else
130+
echo no $command to stop because no pid file $CHAOS_PID
131+
fi
132+
rm -f $CHAOS_PID
133+
;;
134+
135+
(*)
136+
echo $usage
137+
exit 1
138+
;;
139+
140+
esac

bin/hbase

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ if [ "${INTERNAL_CLASSPATH}" != "true" ]; then
256256

257257
# If command needs our shaded mapreduce, use it
258258
# N.B "mapredcp" is not included here because in the shaded case it skips our built classpath
259-
declare -a commands_in_mr_jar=("hbck" "snapshot" "canary" "regionsplitter" "pre-upgrade")
259+
declare -a commands_in_mr_jar=("hbck" "snapshot" "regionsplitter" "pre-upgrade")
260260
for c in "${commands_in_mr_jar[@]}"; do
261261
if [ "${COMMAND}" = "${c}" ]; then
262262
# If we didn't find a jar above, this will just be blank and the
@@ -507,13 +507,22 @@ fi
507507
# figure out which class to run
508508
if [ "$COMMAND" = "shell" ] ; then
509509
#find the hbase ruby sources
510+
# assume we are in a binary install if lib/ruby exists
510511
if [ -d "$HBASE_HOME/lib/ruby" ]; then
511-
HBASE_OPTS="$HBASE_OPTS -Dhbase.ruby.sources=$HBASE_HOME/lib/ruby"
512+
# We want jruby to consume these things rather than our bootstrap script;
513+
# jruby will look for the env variable 'JRUBY_OPTS'.
514+
JRUBY_OPTS="${JRUBY_OPTS} -X+O"
515+
export JRUBY_OPTS
516+
# hbase-shell.jar contains a 'jar-bootstrap.rb'
517+
# for more info see
518+
# https://github.com/jruby/jruby/wiki/StandaloneJarsAndClasses#standalone-executable-jar-files
519+
CLASS="org.jruby.JarBootstrapMain"
520+
# otherwise assume we are running in a source checkout
512521
else
513522
HBASE_OPTS="$HBASE_OPTS -Dhbase.ruby.sources=$HBASE_HOME/hbase-shell/src/main/ruby"
523+
CLASS="org.jruby.Main -X+O ${JRUBY_OPTS} ${HBASE_HOME}/hbase-shell/src/main/ruby/jar-bootstrap.rb"
514524
fi
515525
HBASE_OPTS="$HBASE_OPTS $HBASE_SHELL_OPTS"
516-
CLASS="org.jruby.Main -X+O ${JRUBY_OPTS} ${HBASE_HOME}/bin/hirb.rb"
517526
elif [ "$COMMAND" = "hbck" ] ; then
518527
# Look for the -j /path/to/HBCK2.jar parameter. Else pass through to hbck.
519528
case "${1}" in

0 commit comments

Comments
 (0)