mirror of
https://github.com/apache/impala.git
synced 2026-01-07 09:02:19 -05:00
This should allow individual service components, such as a single nodemanager, to be shutdown for failure testing. The mini-cluster bundled with hadoop is a single process that does not expose the ability to control individual roles. Now each role can be controlled and configured independently of the others. Change-Id: Ic1d42e024226c6867e79916464d184fce886d783 Reviewed-on: http://gerrit.ent.cloudera.com:8080/1432 Tested-by: Casey Ching <casey@cloudera.com> Reviewed-by: Casey Ching <casey@cloudera.com> Reviewed-on: http://gerrit.ent.cloudera.com:8080/2297 Reviewed-by: Ishaan Joshi <ishaan@cloudera.com> Tested-by: Ishaan Joshi <ishaan@cloudera.com>
70 lines
1.3 KiB
Cheetah
70 lines
1.3 KiB
Cheetah
NODE_DIR="${NODE_DIR}"
|
|
PID_DIR="$NODE_DIR/var/run"
|
|
LOG_DIR="$NODE_DIR/var/log"
|
|
|
|
export HADOOP_CONF_DIR="$NODE_DIR/etc/hadoop/conf"
|
|
export YARN_CONF_DIR="$HADOOP_CONF_DIR"
|
|
|
|
# Mark each process so they can be killed if needed. This is a safety mechanism for
|
|
# stopping the processes if the pid file has been removed for whatever reason.
|
|
export HADOOP_OPTS+=" -D${KILL_CLUSTER_MARKER}"
|
|
export YARN_OPTS+=" -D${KILL_CLUSTER_MARKER}"
|
|
|
|
PID_FILE="$PID_DIR/$(basename $0)"
|
|
|
|
function do_start {
|
|
local CMD="$1"
|
|
shift
|
|
"$CMD" "$@" &> "$LOG_DIR/$(basename $0).out" &
|
|
local PID=$!
|
|
echo $PID > "$PID_FILE"
|
|
disown -h $PID
|
|
# Give the process some time to die... if thing go wrong it usually takes at least a
|
|
# few seconds for the process to totallly shutdown
|
|
sleep 5
|
|
kill -0 $PID
|
|
}
|
|
|
|
function read_pid {
|
|
if [[ -e "$PID_FILE" ]]; then
|
|
cat "$PID_FILE"
|
|
fi
|
|
}
|
|
|
|
function pid_exists {
|
|
kill -0 $1 &> /dev/null
|
|
}
|
|
|
|
function stop {
|
|
local PID=$(read_pid)
|
|
if [[ -z $PID ]]; then
|
|
echo No PID to stop
|
|
return
|
|
fi
|
|
if pid_exists $PID; then
|
|
kill $PID
|
|
fi
|
|
}
|
|
|
|
function restart {
|
|
if status &>/dev/null; then
|
|
stop
|
|
fi
|
|
start
|
|
}
|
|
|
|
function status {
|
|
local PID=$(read_pid)
|
|
if [[ -z $PID ]]; then
|
|
echo Not started
|
|
return 1
|
|
fi
|
|
|
|
if pid_exists $PID; then
|
|
echo Running
|
|
else
|
|
echo Not Running
|
|
return 1
|
|
fi
|
|
}
|