You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by rv...@apache.org on 2013/05/02 03:22:18 UTC
[1/5] git commit: BIGTOP-946. solr-server runlevels are wrong in
debian
Updated Branches:
refs/heads/master 39af29da4 -> 25463a414
BIGTOP-946. solr-server runlevels are wrong in debian
Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/e4e85d12
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/e4e85d12
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/e4e85d12
Branch: refs/heads/master
Commit: e4e85d125c20d686f565cf0b3b69b66fad51498b
Parents: 39af29d
Author: Sean Mackrory <ma...@gmail.com>
Authored: Mon Apr 29 09:57:48 2013 -0700
Committer: Roman Shaposhnik <rv...@cloudera.com>
Committed: Wed May 1 15:56:43 2013 -0700
----------------------------------------------------------------------
bigtop-packages/src/common/solr/solr-server.init | 145 -----------------
bigtop-packages/src/rpm/solr/solr-server.init | 145 +++++++++++++++++
2 files changed, 145 insertions(+), 145 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/bigtop/blob/e4e85d12/bigtop-packages/src/common/solr/solr-server.init
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/solr/solr-server.init b/bigtop-packages/src/common/solr/solr-server.init
deleted file mode 100644
index 6d1a035..0000000
--- a/bigtop-packages/src/common/solr/solr-server.init
+++ /dev/null
@@ -1,145 +0,0 @@
-#!/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.
-#
-# Starts a Solr server
-#
-# chkconfig: 345 90 10
-# description: Solr server
-#
-### BEGIN INIT INFO
-# Provides: solr-server
-# Required-Start: $remote_fs
-# Should-Start:
-# Required-Stop: $remote_fs
-# Should-Stop:
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 2 6
-# Short-Description: Solr server
-### END INIT INFO
-
-. /lib/lsb/init-functions
-
-STATUS_RUNNING=0
-STATUS_DEAD=1
-STATUS_DEAD_AND_LOCK=2
-STATUS_NOT_RUNNING=3
-
-ERROR_PROGRAM_NOT_INSTALLED=5
-
-SOLR_RUN_DIR=/var/run/solr
-SOLR_HOME=/usr/lib/solr
-SOLR_USER=solr
-
-SOLR_LOCK_DIR="/var/lock/subsys/"
-LOCKFILE="${SOLR_LOCK_DIR}/solr"
-desc="Solr server daemon"
-
-EXEC_PATH=$SOLR_HOME/bin/solrd
-SOLR_PID_FILE=${SOLR_RUN_DIR}/solr.pid
-
-# These directories may be tmpfs and may or may not exist
-# depending on the OS (ex: /var/lock/subsys does not exist on debian/ubuntu)
-for dir in "$SOLR_RUN_DIR" "$SOLR_LOCK_DIR"; do
- [ -d "${dir}" ] || install -d -m 0755 -o $SOLR_USER -g $SOLR_USER ${dir}
-done
-
-SOLR_SHUTDOWN_TIMEOUT=${SOLR_SHUTDOWN_TIMEOUT:-60}
-
-start() {
- [ -x $exec ] || exit $ERROR_PROGRAM_NOT_INSTALLED
-
- checkstatus
- status=$?
- if [ "$status" -eq "$STATUS_RUNNING" ]; then
- exit 0
- fi
-
- log_success_msg "Starting $desc: "
- /bin/su -s /bin/bash -c "${EXEC_PATH} start" $SOLR_USER
- RETVAL=$?
- [ $RETVAL -eq 0 ] && touch $LOCKFILE
- return $RETVAL
-}
-
-stop() {
- if [ ! -e $SOLR_PID_FILE ]; then
- log_failure_msg "$desc is not running"
- exit 0
- fi
-
- log_success_msg "Stopping ${desc}: "
-
- /bin/su -s /bin/bash -c "${EXEC_PATH} stop $SOLR_SHUTDOWN_TIMEOUT -force" $SOLR_USER
- rm -f $LOCKFILE $SOLR_PID_FILE
- return 0
-}
-
-restart() {
- stop
- start
-}
-
-checkstatus(){
- pidofproc -p $SOLR_PID_FILE java > /dev/null
- status=$?
-
- case "$status" in
- $STATUS_RUNNING)
- log_success_msg "$desc is running"
- ;;
- $STATUS_DEAD)
- log_failure_msg "$desc is dead and pid file exists"
- ;;
- $STATUS_DEAD_AND_LOCK)
- log_failure_msg "$desc is dead and lock file exists"
- ;;
- $STATUS_NOT_RUNNING)
- log_failure_msg "$desc agent is not running"
- ;;
- *)
- log_failure_msg "$desc agent status is unknown"
- ;;
- esac
- return $status
-}
-
-condrestart(){
- [ -e ${LOCKFILE} ] && restart || :
-}
-
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- checkstatus
- ;;
- restart)
- restart
- ;;
- condrestart|try-restart)
- condrestart
- ;;
- *)
- echo $"Usage: $0 {start|stop|status|restart|try-restart|condrestart}"
- exit 1
-esac
-
-exit $RETVAL
http://git-wip-us.apache.org/repos/asf/bigtop/blob/e4e85d12/bigtop-packages/src/rpm/solr/solr-server.init
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/solr/solr-server.init b/bigtop-packages/src/rpm/solr/solr-server.init
new file mode 100644
index 0000000..6d1a035
--- /dev/null
+++ b/bigtop-packages/src/rpm/solr/solr-server.init
@@ -0,0 +1,145 @@
+#!/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.
+#
+# Starts a Solr server
+#
+# chkconfig: 345 90 10
+# description: Solr server
+#
+### BEGIN INIT INFO
+# Provides: solr-server
+# Required-Start: $remote_fs
+# Should-Start:
+# Required-Stop: $remote_fs
+# Should-Stop:
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
+# Short-Description: Solr server
+### END INIT INFO
+
+. /lib/lsb/init-functions
+
+STATUS_RUNNING=0
+STATUS_DEAD=1
+STATUS_DEAD_AND_LOCK=2
+STATUS_NOT_RUNNING=3
+
+ERROR_PROGRAM_NOT_INSTALLED=5
+
+SOLR_RUN_DIR=/var/run/solr
+SOLR_HOME=/usr/lib/solr
+SOLR_USER=solr
+
+SOLR_LOCK_DIR="/var/lock/subsys/"
+LOCKFILE="${SOLR_LOCK_DIR}/solr"
+desc="Solr server daemon"
+
+EXEC_PATH=$SOLR_HOME/bin/solrd
+SOLR_PID_FILE=${SOLR_RUN_DIR}/solr.pid
+
+# These directories may be tmpfs and may or may not exist
+# depending on the OS (ex: /var/lock/subsys does not exist on debian/ubuntu)
+for dir in "$SOLR_RUN_DIR" "$SOLR_LOCK_DIR"; do
+ [ -d "${dir}" ] || install -d -m 0755 -o $SOLR_USER -g $SOLR_USER ${dir}
+done
+
+SOLR_SHUTDOWN_TIMEOUT=${SOLR_SHUTDOWN_TIMEOUT:-60}
+
+start() {
+ [ -x $exec ] || exit $ERROR_PROGRAM_NOT_INSTALLED
+
+ checkstatus
+ status=$?
+ if [ "$status" -eq "$STATUS_RUNNING" ]; then
+ exit 0
+ fi
+
+ log_success_msg "Starting $desc: "
+ /bin/su -s /bin/bash -c "${EXEC_PATH} start" $SOLR_USER
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch $LOCKFILE
+ return $RETVAL
+}
+
+stop() {
+ if [ ! -e $SOLR_PID_FILE ]; then
+ log_failure_msg "$desc is not running"
+ exit 0
+ fi
+
+ log_success_msg "Stopping ${desc}: "
+
+ /bin/su -s /bin/bash -c "${EXEC_PATH} stop $SOLR_SHUTDOWN_TIMEOUT -force" $SOLR_USER
+ rm -f $LOCKFILE $SOLR_PID_FILE
+ return 0
+}
+
+restart() {
+ stop
+ start
+}
+
+checkstatus(){
+ pidofproc -p $SOLR_PID_FILE java > /dev/null
+ status=$?
+
+ case "$status" in
+ $STATUS_RUNNING)
+ log_success_msg "$desc is running"
+ ;;
+ $STATUS_DEAD)
+ log_failure_msg "$desc is dead and pid file exists"
+ ;;
+ $STATUS_DEAD_AND_LOCK)
+ log_failure_msg "$desc is dead and lock file exists"
+ ;;
+ $STATUS_NOT_RUNNING)
+ log_failure_msg "$desc agent is not running"
+ ;;
+ *)
+ log_failure_msg "$desc agent status is unknown"
+ ;;
+ esac
+ return $status
+}
+
+condrestart(){
+ [ -e ${LOCKFILE} ] && restart || :
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ checkstatus
+ ;;
+ restart)
+ restart
+ ;;
+ condrestart|try-restart)
+ condrestart
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|try-restart|condrestart}"
+ exit 1
+esac
+
+exit $RETVAL
[4/5] git commit: BIGTOP-936. Use init script templates for HBase.
Posted by rv...@apache.org.
BIGTOP-936. Use init script templates for HBase.
Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/d0aafdf2
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/d0aafdf2
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/d0aafdf2
Branch: refs/heads/master
Commit: d0aafdf23d62ba27f7629fe07dde0625146ede80
Parents: 2fc2307
Author: Sean Mackrory <ma...@gmail.com>
Authored: Thu Apr 25 08:55:48 2013 -0700
Committer: Roman Shaposhnik <rv...@cloudera.com>
Committed: Wed May 1 18:20:15 2013 -0700
----------------------------------------------------------------------
bigtop-packages/src/common/hbase/hbase.svc | 81 ++++++
.../src/deb/hbase/install_init_scripts.sh | 18 +-
bigtop-packages/src/deb/hbase/service-init.d.tpl | 219 ---------------
bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh | 192 -------------
.../src/rpm/hbase/SOURCES/hbase.sh.suse | 138 ---------
bigtop-packages/src/rpm/hbase/SPECS/hbase.spec | 26 +--
bigtop-packages/src/templates/init.d.tmpl | 2 +-
7 files changed, 96 insertions(+), 580 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/common/hbase/hbase.svc
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/hbase/hbase.svc b/bigtop-packages/src/common/hbase/hbase.svc
new file mode 100644
index 0000000..c3a9d16
--- /dev/null
+++ b/bigtop-packages/src/common/hbase/hbase.svc
@@ -0,0 +1,81 @@
+# 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.
+
+DAEMON="hbase-@HBASE_DAEMON@"
+DESC="HBase @HBASE_DAEMON@ daemon"
+EXEC_PATH="/usr/lib/hbase/bin/hbase-daemon.sh"
+SVC_USER="hbase"
+DAEMON_FLAGS=""
+CONF_DIR="/etc/hbase/conf"
+PIDFILE="/var/run/hbase/hbase-${DAEMON}.pid"
+LOCKDIR="/var/lock/subsys"
+LOCKFILE="${DAEMON}"
+
+generate_functions() {
+cat <<'__EOT__'
+
+hbase_env() {
+ export HBASE_HOME=/usr/lib/hbase
+ . /etc/default/hbase
+}
+
+__EOT__
+}
+
+generate_start() {
+
+cat <<'__EOT__'
+start() {
+ hbase_env
+
+ [ -x $EXEC_PATH ] || exit $ERROR_PROGRAM_NOT_INSTALLED
+ log_success_msg "Starting $DESC (${DAEMON}): "
+
+ checkstatusofproc
+ status=$?
+ if [ "$status" -eq "$STATUS_RUNNING" ]; then
+ log_success_msg "${DESC} is running"
+ exit 0
+ fi
+
+ su -s /bin/sh hbase -c "${EXEC_PATH} start @HBASE_DAEMON@"
+
+ checkstatusofproc
+ RETVAL=$?
+ [ $RETVAL -eq $STATUS_RUNNING ] && touch $LOCKFILE
+ return $RETVAL
+}
+__EOT__
+
+}
+
+generate_stop() {
+
+cat <<'__EOT__'
+stop() {
+ hbase_env
+
+ log_success_msg "Stopping $DESC (${DAEMON}): "
+ su -s /bin/sh hbase -c "${EXEC_PATH} stop @HBASE_DAEMON@"
+ sleep 3
+ RETVAL=$?
+
+ [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PIDFILE
+ return $RETVAL
+}
+__EOT__
+
+}
+
http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/deb/hbase/install_init_scripts.sh
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/hbase/install_init_scripts.sh b/bigtop-packages/src/deb/hbase/install_init_scripts.sh
index 1f3c151..07e8f21 100755
--- a/bigtop-packages/src/deb/hbase/install_init_scripts.sh
+++ b/bigtop-packages/src/deb/hbase/install_init_scripts.sh
@@ -17,26 +17,20 @@
SRC_PKG=hbase
for node in master regionserver rest thrift ; do
- case $service in
- master) chkconfig="2345 85 15" ;;
- thrift) chkconfig="2345 86 14" ;;
- regionserver) chkconfig="2345 87 13" ;;
- rest) chkconfig="2345 88 12" ;;
- *) chkconfig="2345 89 13" ;;
- esac
service_pkgdir=debian/$SRC_PKG-$node
debdir=$service_pkgdir/DEBIAN
- template="debian/service-init.d.tpl"
+ mkdir -p $service_pkgdir/etc/init.d/ $debdir
if [ "$node" == "regionserver" ] ; then
# Region servers start from a different template that allows
# them to run multiple concurrent instances of the daemon
- template="debian/regionserver-init.d.tpl"
+ template=debian/regionserver-init.d.tpl
sed -i -e "s|@INIT_DEFAULT_START@|2 3 4 5|" $template
sed -i -e "s|@INIT_DEFAULT_STOP@|0 1 6|" $template
+ sed -e "s|@HBASE_DAEMON@|$node|" -e "s|@CHKCONFIG@|2345 87 13|" $template > $service_pkgdir/etc/init.d/$SRC_PKG-$node
+ else
+ sed -e "s|@HBASE_DAEMON@|$node|" debian/hbase.svc > debian/hbase-$node.svc
+ bash debian/init.d.tmpl debian/hbase-$node.svc deb $service_pkgdir/etc/init.d/$SRC_PKG-$node
fi
-
- mkdir -p $service_pkgdir/etc/init.d/ $debdir
- sed -e "s|@HBASE_DAEMON@|$node|" -e "s|@CHKCONFIG@|$chkconfig|" $template > $service_pkgdir/etc/init.d/$SRC_PKG-$node
sed -e "s|@HBASE_DAEMON@|$node|" debian/service-postinst.tpl > $debdir/postinst
sed -e "s|@HBASE_DAEMON@|$node|" debian/service-postrm.tpl > $debdir/postrm
echo /etc/init.d/$SRC_PKG-$node > $debdir/conffiles
http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/deb/hbase/service-init.d.tpl
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/hbase/service-init.d.tpl b/bigtop-packages/src/deb/hbase/service-init.d.tpl
deleted file mode 100644
index 9260c71..0000000
--- a/bigtop-packages/src/deb/hbase/service-init.d.tpl
+++ /dev/null
@@ -1,219 +0,0 @@
-#! /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.
-
-# skeleton example file to build /etc/init.d/ scripts.
-# This file should be used to construct scripts for /etc/init.d.
-#
-# Written by Miquel van Smoorenburg <mi...@cistron.nl>.
-# Modified for Debian
-# by Ian Murdock <im...@gnu.ai.mit.edu>.
-# Further changes by Javier Fernandez-Sanguino <jf...@debian.org>
-#
-# Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl
-#
-# chkconfig: @CHKCONFIG@
-# description: Summary: HBase is the Hadoop database. Use it when you
-# need random, realtime read/write access to your Big Data. This project's
-# goal is the hosting of very large tables -- billions of rows X millions
-# of columns -- atop clusters of commodity hardware.
-# processname: HBase
-#
-### BEGIN INIT INFO
-# Provides: hbase-@HBASE_DAEMON@
-# Required-Start: $network $local_fs $remote_fs
-# Required-Stop: $remote_fs
-# Should-Start: $named
-# Should-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Hadoop HBase @HBASE_DAEMON@ daemon
-### END INIT INFO
-
-set -e
-
-. /etc/default/hadoop
-
-# Our default HBASE_HOME and HBASE_PID_DIR
-export HBASE_HOME=/usr/lib/hbase
-export HBASE_PID_DIR=/var/run/hbase
-
-# Include HBase defaults if available
-if [ -f /etc/default/hbase ] ; then
- . /etc/default/hbase
-fi
-
-# Autodetect JAVA_HOME if not defined
-. /usr/lib/bigtop-utils/bigtop-detect-javahome
-
-if [ -z "$HBASE_PID_DIR" -o -z "$HBASE_HOME" ]; then
- echo No HBASE_HOME or HBASE_PID_DIR set.
- exit 1
-fi
-
-
-install -d -m 0755 -o hbase -g hbase ${HBASE_PID_DIR}
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON_SCRIPT=$HBASE_HOME/bin/hbase-daemon.sh
-NAME=hbase-@HBASE_DAEMON@
-DESC="Hadoop HBase @HBASE_DAEMON@ daemon"
-PID_FILE=$HBASE_PID_DIR/hbase-hbase-@HBASE_DAEMON@.pid
-
-
-DODTIME=3 # Time to wait for the server to die, in seconds
- # If this value is set too low you might not
- # let some servers to die gracefully and
- # 'restart' will not work
-
-# Checks if the given pid represents a live process.
-# Returns 0 if the pid is a live process, 1 otherwise
-hbase_is_process_alive() {
- local pid="$1"
- ps -fp $pid | grep $pid | grep @HBASE_DAEMON@ > /dev/null 2>&1
-}
-
-# Check if the process associated to a pidfile is running.
-# Return 0 if the pidfile exists and the process is running, 1 otherwise
-hbase_check_pidfile() {
- local pidfile="$1" # IN
- local pid
-
- pid=`cat "$pidfile" 2>/dev/null`
- if [ "$pid" = '' ]; then
- # The file probably does not exist or is empty.
- return 1
- fi
-
- set -- $pid
- pid="$1"
-
- hbase_is_process_alive $pid
-}
-
-# Kill the process associated to a pidfile
-hbase_stop_pidfile() {
- local pidfile="$1" # IN
- local pid
-
- pid=`cat "$pidfile" 2>/dev/null`
- if [ "$pid" = '' ]; then
- # The file probably does not exist or is empty. Success
- return 0
- fi
-
- set -- $pid
- pid="$1"
-
- # First try the easy way
- if hbase_process_kill "$pid" 15; then
- return 0
- fi
-
- # Otherwise try the hard way
- if hbase_process_kill "$pid" 9; then
- return 0
- fi
-
- return 1
-}
-
-hbase_process_kill() {
- local pid="$1" # IN
- local signal="$2" # IN
- local second
-
- kill -$signal $pid 2>/dev/null
-
- # Wait a bit to see if the dirty job has really been done
- for second in 0 1 2 3 4 5 6 7 8 9 10; do
- if hbase_is_process_alive "$pid"; then
- # Success
- return 0
- fi
-
- sleep 1
- done
-
- # Timeout
- return 1
-}
-
-
-start() {
- su -s /bin/sh hbase -c "$DAEMON_SCRIPT start @HBASE_DAEMON@"
-}
-stop() {
- su -s /bin/sh hbase -c "$DAEMON_SCRIPT stop @HBASE_DAEMON@"
-}
-
-
-case "$1" in
- start)
- echo -n "Starting $DESC: "
- start
- if hbase_check_pidfile $PID_FILE ; then
- echo "$NAME."
- else
- echo "ERROR."
- fi
- ;;
- stop)
- echo -n "Stopping $DESC: "
- stop
- if hbase_check_pidfile $PID_FILE ; then
- echo 'ERROR'
- else
- echo "$NAME."
- fi
- ;;
- force-stop)
- echo -n "Forcefully stopping $DESC: "
- hbase_stop_pidfile $PID_FILE
- if hbase_check_pidfile $PID_FILE ; then
- echo "$NAME."
- else
- echo " ERROR."
- fi
- ;;
- force-reload)
- # check wether $DAEMON is running. If so, restart
- hbase_check_pidfile $PID_FILE && $0 restart
- ;;
- restart)
- echo -n "Restarting $DESC: "
- stop
- [ -n "$DODTIME" ] && sleep $DODTIME
- $0 start
- ;;
- status)
- echo -n "$NAME is "
- if hbase_check_pidfile $PID_FILE ; then
- echo "running"
- else
- echo "not running."
- exit 1
- fi
- ;;
- *)
- N=/etc/init.d/$NAME
- # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
- echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2
- exit 1
- ;;
-esac
-
-exit 0
http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh b/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh
deleted file mode 100755
index 3cdcea4..0000000
--- a/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh
+++ /dev/null
@@ -1,192 +0,0 @@
-#!/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.
-#
-# chkconfig: @CHKCONFIG@
-# description: Summary: HBase is the Hadoop database. Use it when you
-# need random, realtime read/write access to your Big Data. This project's
-# goal is the hosting of very large tables -- billions of rows X millions
-# of columns -- atop clusters of commodity hardware.
-# processname: HBase
-# pidfile: /usr/lib/hbase/pids/hadoop_hbase.pid
-### BEGIN INIT INFO
-# Provides: HBase
-# Required-Start: $network $local_fs
-# Required-Stop:
-# Should-Start: $named
-# Should-Stop:
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 2 6
-# Short-Description: HBase
-### END INIT INFO
-set -e
-
-. /etc/default/hadoop
-. /etc/default/hbase
-
-# Autodetect JAVA_HOME if not defined
-. /usr/lib/bigtop-utils/bigtop-detect-javahome
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON_SCRIPT="/usr/lib/hbase/bin/hbase-daemon.sh"
-NAME=HBase
-DESC="HBase daemon"
-
-install -d -m 0755 -o hbase -g hbase ${HBASE_PID_DIR}
-
-PID_FILE=${HBASE_PID_DIR}/hbase-hbase-@HBASE_DAEMON@.pid
-
-
-
-DODTIME=3
-
-
-hadoop_is_process_alive() {
- local pid="$1"
- ps -fp $pid | grep $pid | grep -i @HBASE_DAEMON@ > /dev/null 2>&1
-}
-
-hadoop_check_pidfile() {
- local pidfile="$1" # IN
- local pid
-
- pid=`cat "$pidfile" 2>/dev/null`
- if [ "$pid" = '' ]; then
- # The file probably does not exist or is empty.
- return 1
- fi
-
- set -- $pid
- pid="$1"
-
- hadoop_is_process_alive $pid
-}
-hadoop_check_pidfile() {
- local pidfile="$1" # IN
- local pid
-
- pid=`cat "$pidfile" 2>/dev/null`
- if [ "$pid" = '' ]; then
- # The file probably does not exist or is empty.
- return 1
- fi
-
- set -- $pid
- pid="$1"
-
- hadoop_is_process_alive $pid
-}
-
-hadoop_process_kill() {
- local pid="$1" # IN
- local signal="$2" # IN
- local second
-
- kill -$signal $pid 2>/dev/null
-
- # Wait a bit to see if the dirty job has really been done
- for second in 0 1 2 3 4 5 6 7 8 9 10; do
- if hadoop_is_process_alive "$pid"; then
- # Success
- return 0
- fi
-
- sleep 1
- done
-
- # Timeout
- return 1
-}
-hadoop_stop_pidfile() {
- local pidfile="$1" # IN
- local pid
-
- pid=`cat "$pidfile" 2>/dev/null`
- if [ "$pid" = '' ]; then
- # The file probably does not exist or is empty. Success
- return 0
- fi
-
- set -- $pid
- pid="$1"
-
- # First try the easy way
- if hadoop_process_kill "$pid" 15; then
- return 0
- fi
-
- # Otherwise try the hard way
- if hadoop_process_kill "$pid" 9; then
- return 0
- fi
-
- return 1
-}
-
-
-start() {
- su -s /bin/sh hbase -c "${DAEMON_SCRIPT} start @HBASE_DAEMON@"
-}
-stop() {
- su -s /bin/sh hbase -c "${DAEMON_SCRIPT} stop @HBASE_DAEMON@"
-}
-
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- force-stop)
- echo -n "Forcefully stopping $DESC: "
- hadoop_stop_pidfile $PID_FILE
- if ! hadoop_check_pidfile $PID_FILE ; then
- echo "$NAME."
- else
- echo " ERROR."
- fi
- ;;
- force-reload|condrestart|try-restart)
- # check wether $DAEMON is running. If so, restart
- hadoop_check_pidfile $PID_FILE && $0 restart
- ;;
- restart|reload)
- echo -n "Restarting $DESC: "
- stop
- [ -n "$DODTIME" ] && sleep $DODTIME
- $0 start
- ;;
- status)
- echo -n "$NAME is "
- if hadoop_check_pidfile $PID_FILE ; then
- echo "running"
- else
- echo "not running."
- exit 1
- fi
- ;;
-
- *)
- N=/etc/init.d/$NAME
- # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
- echo "Usage: $N {start|stop|restart|force-reload|status|force-stop|condrestart|try-restart}" >&2
-
- exit 1
- ;;
-esac
-
-exit 0
http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh.suse
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh.suse b/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh.suse
deleted file mode 100644
index 5452e00..0000000
--- a/bigtop-packages/src/rpm/hbase/SOURCES/hbase.sh.suse
+++ /dev/null
@@ -1,138 +0,0 @@
-#!/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.
-#
-# Starts a HBase @HBASE_DAEMON@
-#
-# chkconfig: @CHKCONFIG@
-# description: Summary: HBase is the Hadoop database. Use it when you
-# need random, realtime read/write access to your Big Data. This project's
-# goal is the hosting of very large tables -- billions of rows X millions
-# of columns -- atop clusters of commodity hardware.
-# processname: HBase
-#
-### BEGIN INIT INFO
-# Provides: HBase-@HBASE_DAEMON@
-# Required-Start: $syslog $remote_fs
-# Should-Start:
-# Required-Stop: $syslog $remote_fs
-# Should-Stop:
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 2 6
-# Short-Description: HBase @HBASE_DAEMON@
-### END INIT INFO
-
-. /lib/lsb/init-functions
-. /etc/default/hadoop
-. /etc/default/hbase
-
-# Autodetect JAVA_HOME if not defined
-. /usr/lib/bigtop-utils/bigtop-detect-javahome
-
-STATUS_RUNNING=0
-STATUS_DEAD=1
-STATUS_DEAD_AND_LOCK=2
-STATUS_NOT_RUNNING=3
-
-ERROR_PROGRAM_NOT_INSTALLED=5
-
-USER=hbase
-DESC="HBase master daemon"
-DAEMON_SCRIPT="/usr/lib/hbase/bin/hbase-daemon.sh"
-
-if [ -f /usr/lib/hbase/bin/hbase-config.sh ] ; then
- . /usr/lib/hbase/bin/hbase-config.sh
-fi
-install -d -m 0755 -o $USER -g hbase ${HBASE_PID_DIR}
-
-PID_FILE=${HBASE_PID_DIR}/hbase-hbase-@HBASE_DAEMON@.pid
-LOCKFILE="/var/lock/subsys/hbase-@HBASE_DAEMON@"
-
-
-start() {
- [ -x $DAEMON_SCRIPT ] || exit $ERROR_PROGRAM_NOT_INSTALLED
- log_success_msg "Starting $desc (hbase-@HBASE_DAEMON@): "
- start_daemon -u $USER $DAEMON_SCRIPT start @HBASE_DAEMON@
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch $LOCKFILE
- return $RETVAL
-}
-
-stop() {
- log_success_msg "Stopping $desc (hbase-@HBASE_DAEMON@): "
- start_daemon -u $USER $DAEMON_SCRIPT stop @HBASE_DAEMON@
- RETVAL=$?
- sleep 5
- echo
- [ $RETVAL -eq 0 ] && rm -f $LOCKFILE $PID_FILE
-}
-
-restart() {
- stop
- start
-}
-
-checkstatus(){
- pidofproc -p $PID_FILE java > /dev/null
- status=$?
-
- case "$status" in
- $STATUS_RUNNING)
- log_success_msg "@HBASE_DAEMON@ is running"
- ;;
- $STATUS_DEAD)
- log_failure_msg "@HBASE_DAEMON@ is dead and pid file exists"
- ;;
- $STATUS_DEAD_AND_LOCK)
- log_failure_msg "@HBASE_DAEMON@ is dead and lock file exists"
- ;;
- $STATUS_NOT_RUNNING)
- log_failure_msg "@HBASE_DAEMON@ is not running"
- ;;
- *)
- log_failure_msg "@HBASE_DAEMON@ status is unknown"
- ;;
- esac
- return $status
-}
-
-condrestart(){
- [ -e $LOCKFILE ] && restart || :
-}
-
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- checkstatus
- ;;
- restart)
- restart
- ;;
- condrestart|try-restart)
- condrestart
- ;;
- *)
- echo $"Usage: $0 {start|stop|status|restart|try-restart|condrestart}"
- exit 1
-esac
-
-exit $RETVAL
http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec b/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec
index ee15e4d..37e683b 100644
--- a/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec
+++ b/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec
@@ -86,8 +86,8 @@ License: APL2
Source0: %{name}-%{hbase_base_version}.tar.gz
Source1: do-component-build
Source2: install_hbase.sh
-Source3: hbase.sh
-Source4: hbase.sh.suse
+Source3: hbase.svc
+Source4: init.d.tmpl
Source5: hbase.default
Source6: hbase.nofiles.conf
Source7: regionserver-init.d.tpl
@@ -259,32 +259,22 @@ ln -s %{_localstatedir}/log/%{name} %{buildroot}/%{logs_hbase}
%__install -d -m 0755 %{buildroot}/%{_localstatedir}/run/%{name}
ln -s %{_localstatedir}/run/%{name} %{buildroot}/%{pids_hbase}
-%if %{?suse_version:1}0
-orig_init_file=%{SOURCE4}
-%else
-orig_init_file=%{SOURCE3}
-%endif
-
for service in %{hbase_services}
do
- case $service in
- master) chkconfig="345 85 15" ;;
- thrift) chkconfig="345 86 14" ;;
- regionserver) chkconfig="345 87 13" ;;
- rest) chkconfig="345 88 12" ;;
- *) chkconfig="345 89 13" ;;
- esac
init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{name}-${service}
- %__cp $orig_init_file $init_file
if [[ "$service" = "regionserver" ]] ; then
# Region servers start from a different template that allows
# them to run multiple concurrent instances of the daemon
%__cp %{SOURCE7} $init_file
%__sed -i -e "s|@INIT_DEFAULT_START@|3 4 5|" $init_file
%__sed -i -e "s|@INIT_DEFAULT_STOP@|0 1 2 6|" $init_file
+ %__sed -i -e "s|@CHKCONFIG@|345 87 13|" $init_file
+ %__sed -i -e "s|@HBASE_DAEMON@|${service}|" $init_file
+ else
+ %__sed -e "s|@HBASE_DAEMON@|${service}|" %{SOURCE3} > ${RPM_SOURCE_DIR}/hbase-${service}.node
+ bash %{SOURCE4} ${RPM_SOURCE_DIR}/hbase-${service}.node rpm $init_file
fi
- %__sed -i -e "s|@CHKCONFIG@|${chkconfig}|" $init_file
- %__sed -i -e "s|@HBASE_DAEMON@|${service}|" $init_file
+
chmod 755 $init_file
done
http://git-wip-us.apache.org/repos/asf/bigtop/blob/d0aafdf2/bigtop-packages/src/templates/init.d.tmpl
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/templates/init.d.tmpl b/bigtop-packages/src/templates/init.d.tmpl
index 61db5d5..9f51414 100644
--- a/bigtop-packages/src/templates/init.d.tmpl
+++ b/bigtop-packages/src/templates/init.d.tmpl
@@ -21,7 +21,7 @@
# a mandatory argument of a file containing the configuration for the service.
# The argument file should be a valid piece of bash code since it gets directly
# source into this template. E.g.
-# $ bash ./init.d.tmpl hadoop-hdfs-namenode.svc > hadoop-hdfs-namenode
+# $ bash ./init.d.tmpl hadoop-hdfs-namenode.svc rpm hadoop-hdfs-namenode
#
# You must declare the following in your .svc configuration file:
# DAEMON="name of the resulting init.d script"
[2/5] git commit: BIGTOP-935. Use init script templates for hive
Posted by rv...@apache.org.
BIGTOP-935. Use init script templates for hive
Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/a3537219
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/a3537219
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/a3537219
Branch: refs/heads/master
Commit: a3537219bd0e6a880f23ed54f6db39f6bf58b96f
Parents: e4e85d1
Author: Sean Mackrory <ma...@gmail.com>
Authored: Tue Apr 23 10:19:39 2013 -0700
Committer: Roman Shaposhnik <rv...@cloudera.com>
Committed: Wed May 1 16:56:40 2013 -0700
----------------------------------------------------------------------
bigtop-packages/src/common/hive/hive-metastore.svc | 72 +++++
bigtop-packages/src/common/hive/hive-server.svc | 72 +++++
bigtop-packages/src/common/hive/hive.sh | 164 -----------
bigtop-packages/src/common/hive/hive.sh.suse | 221 ---------------
.../src/deb/hive/install_init_scripts.sh | 34 ---
bigtop-packages/src/deb/hive/rules | 4 +-
bigtop-packages/src/deb/hive/service-init.d.tpl | 167 -----------
bigtop-packages/src/rpm/hive/SPECS/hive.spec | 12 +-
8 files changed, 152 insertions(+), 594 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/common/hive/hive-metastore.svc
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/hive/hive-metastore.svc b/bigtop-packages/src/common/hive/hive-metastore.svc
new file mode 100644
index 0000000..10a9a62
--- /dev/null
+++ b/bigtop-packages/src/common/hive/hive-metastore.svc
@@ -0,0 +1,72 @@
+# 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.
+
+DAEMON="hive-metastore"
+DESC="Hive Metastore"
+EXEC_PATH="/usr/lib/hive/bin/hive"
+SVC_USER="hive"
+DAEMON_FLAGS=""
+CONF_DIR="/etc/hive/conf"
+PIDFILE="/var/run/hive/${DAEMON}.pid"
+LOCKDIR="/var/lock/subsys"
+LOCKFILE="${DAEMON}"
+
+generate_start() {
+
+cat <<'__EOT__'
+start() {
+ [ -x $EXE_FILE ] || exit $ERROR_PROGRAM_NOT_INSTALLED
+ log_success_msg "Starting $DESC (${DAEMON}): "
+
+ checkstatusofproc
+ status=$?
+ if [ "$status" -eq "$STATUS_RUNNING" ]; then
+ log_success_msg "${DESC} is running"
+ exit 0
+ fi
+
+ LOG_FILE=/var/log/hive/${DAEMON}.out
+
+ exec_env="HADOOP_OPTS=\"-Dhive.log.dir=`dirname $LOG_FILE` -Dhive.log.file=${DAEMON}.log -Dhive.log.threshold=INFO\""
+
+ su -s /bin/sh $SVC_USER -c "$exec_env nohup nice -n 0 \
+ $EXEC_PATH --service metastore $PORT \
+ > $LOG_FILE 2>&1 < /dev/null & "'echo $! '"> $PIDFILE"
+ sleep 3
+
+ checkstatusofproc
+ RETVAL=$?
+ [ $RETVAL -eq $STATUS_RUNNING ] && touch $LOCKFILE
+ return $RETVAL
+}
+__EOT__
+
+}
+
+generate_stop() {
+
+cat <<'__EOT__'
+stop() {
+ log_success_msg "Stopping $DESC (${DAEMON}): "
+ killproc -p $PIDFILE java
+ RETVAL=$?
+
+ [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PIDFILE
+ return $RETVAL
+}
+__EOT__
+
+}
+
http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/common/hive/hive-server.svc
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/hive/hive-server.svc b/bigtop-packages/src/common/hive/hive-server.svc
new file mode 100644
index 0000000..049e814
--- /dev/null
+++ b/bigtop-packages/src/common/hive/hive-server.svc
@@ -0,0 +1,72 @@
+# 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.
+
+DAEMON="hive-server"
+DESC="Hive Server"
+EXEC_PATH="/usr/lib/hive/bin/hive"
+SVC_USER="hive"
+DAEMON_FLAGS=""
+CONF_DIR="/etc/hive/conf"
+PIDFILE="/var/run/hive/${DAEMON}.pid"
+LOCKDIR="/var/lock/subsys"
+LOCKFILE="${DAEMON}"
+
+generate_start() {
+
+cat <<'__EOT__'
+start() {
+ [ -x $EXE_FILE ] || exit $ERROR_PROGRAM_NOT_INSTALLED
+ log_success_msg "Starting $DESC (${DAEMON}): "
+
+ checkstatusofproc
+ status=$?
+ if [ "$status" -eq "$STATUS_RUNNING" ]; then
+ log_success_msg "${DESC} is running"
+ exit 0
+ fi
+
+ LOG_FILE=/var/log/hive/${DAEMON}.out
+
+ exec_env="HADOOP_OPTS=\"-Dhive.log.dir=`dirname $LOG_FILE` -Dhive.log.file=${DAEMON}.log -Dhive.log.threshold=INFO\""
+
+ su -s /bin/sh $SVC_USER -c "$exec_env nohup nice -n 0 \
+ $EXEC_PATH --service hiveserver $PORT \
+ > $LOG_FILE 2>&1 < /dev/null & "'echo $! '"> $PIDFILE"
+ sleep 3
+
+ checkstatusofproc
+ RETVAL=$?
+ [ $RETVAL -eq $STATUS_RUNNING ] && touch $LOCKFILE
+ return $RETVAL
+}
+__EOT__
+
+}
+
+generate_stop() {
+
+cat <<'__EOT__'
+stop() {
+ log_success_msg "Stopping $DESC (${DAEMON}): "
+ killproc -p $PIDFILE java
+ RETVAL=$?
+
+ [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PIDFILE
+ return $RETVAL
+}
+__EOT__
+
+}
+
http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/common/hive/hive.sh
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/hive/hive.sh b/bigtop-packages/src/common/hive/hive.sh
deleted file mode 100755
index 0a61453..0000000
--- a/bigtop-packages/src/common/hive/hive.sh
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/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.
-#
-#
-#
-# Starts a Hive @HIVE_DAEMON@
-#
-# chkconfig: 345 90 10
-# description: Starts a Hive @HIVE_DAEMON@
-# processname: hive
-# pidfile: /var/run/hive/hive-@HIVE_DAEMON@.pid
-### BEGIN INIT INFO
-# Provides: hive-@HIVE_DAEMON@
-# Required-Start: $syslog $remote_fs
-# Should-Start:
-# Required-Stop: $syslog $remote_fs
-# Should-Stop:
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 2 6
-# Short-Description: Starts a Hive @HIVE_DAEMON@
-### END INIT INFO
-
-source /lib/lsb/init-functions
-
-# Autodetect JAVA_HOME if not defined
-. /usr/lib/bigtop-utils/bigtop-detect-javahome
-
-RETVAL_SUCCESS=0
-
-STATUS_RUNNING=0
-STATUS_DEAD=1
-STATUS_DEAD_AND_LOCK=2
-STATUS_NOT_RUNNING=3
-
-ERROR_PROGRAM_NOT_INSTALLED=5
-ERROR_PROGRAM_NOT_CONFIGURED=6
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-NAME="hive-@HIVE_DAEMON@"
-DESC="Hive @HIVE_DAEMON@ daemon"
-SYS_FILE="/etc/default/${NAME}"
-EXE_FILE="/usr/lib/hive/bin/hive"
-PID_FILE="/var/run/hive/${NAME}.pid"
-LOCKFILE="/var/lock/subsys/${NAME}"
-LOG_FILE="/var/log/hive/${NAME}.out"
-HIVE_USER="hive"
-HIVE_HOME="`eval echo ~$HIVE_USER`"
-NICENESS="+0"
-TIMEOUT=3
-USER="hive"
-
-[ -f $SYS_FILE ] && . $SYS_FILE
-
-hive_start() {
- [ -x $EXE_FILE ] || exit $ERROR_PROGRAM_NOT_INSTALLED
-
- exec_env="HADOOP_OPTS=\"-Dhive.log.dir=`dirname $LOG_FILE` -Dhive.log.file=${NAME}.log -Dhive.log.threshold=INFO\""
- service_name="@HIVE_DAEMON@"
- if [ $service_name = "server" ] ; then
- service_name="hiveserver"
- fi
-
- if [ -x /sbin/runuser ]; then
- SU="runuser -s /bin/bash $USER"
- else
- SU="su -s /bin/sh $USER"
- fi
-
- log_success_msg "Starting $desc (${NAME}): "
- $SU -c "cd $HIVE_HOME ; $exec_env nohup \
- $EXE_FILE --service $service_name $PORT \
- > $LOG_FILE 2>&1 < /dev/null & "'echo $! '"> $PID_FILE"
-
- RETVAL=$?
- [ $RETVAL -eq $RETVAL_SUCCESS ] && touch $LOCKFILE
- return $RETVAL
-}
-
-hive_stop() {
- log_success_msg "Stopping $desc (${NAME}): "
- killproc -p $PID_FILE java
- RETVAL=$?
-
- [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PID_FILE
- return $RETVAL
-}
-
-hive_restart() {
- hive_stop
- [ -n "$TIMEOUT" ] && sleep $TIMEOUT
- hive_start
-}
-
-hive_status() {
- echo -n "Checking for service $desc: "
- pidofproc -p $PID_FILE java > /dev/null
- status=$?
-
- case "$status" in
- $STATUS_RUNNING)
- log_success_msg "@HIVE_DAEMON@ is running"
- ;;
- $STATUS_DEAD)
- log_failure_msg "@HIVE_DAEMON@ is dead and pid file exists"
- ;;
- $STATUS_DEAD_AND_LOCK)
- log_failure_msg "@HIVE_DAEMON@ is dead and lock file exists"
- ;;
- $STATUS_NOT_RUNNING)
- log_failure_msg "@HIVE_DAEMON@ is not running"
- ;;
- *)
- log_failure_msg "@HIVE_DAEMON@ status is unknown"
- ;;
- esac
- return $status
-}
-
-RETVAL=0
-
-case "$1" in
- start)
- hive_start
- ;;
-
- stop|force-stop)
- hive_stop
- ;;
-
- force-reload|condrestart|try-restart)
- [ -e $LOCKFILE ] && hive_restart || :
- ;;
-
- restart|reload)
- hive_restart
- ;;
-
- status)
- hive_status
- ;;
-
- *)
- N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|restart|reload|condrestart|try-restart|force-reload|status|force-stop}" >&2
-
- exit 1
- ;;
-esac
-
-exit $RETVAL
http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/common/hive/hive.sh.suse
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/hive/hive.sh.suse b/bigtop-packages/src/common/hive/hive.sh.suse
deleted file mode 100644
index e079481..0000000
--- a/bigtop-packages/src/common/hive/hive.sh.suse
+++ /dev/null
@@ -1,221 +0,0 @@
-#!/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.
-
-# Starts a Hive @HIVE_DAEMON@
-#
-# chkconfig: 345 90 10
-# description: Starts a Hive @HIVE_DAEMON@
-# processname: hive
-#
-### BEGIN INIT INFO
-# Provides: hive-@HIVE_DAEMON@
-# Required-Start: $syslog $remote_fs
-# Should-Start:
-# Required-Stop: $syslog $remote_fs
-# Should-Stop:
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 2 6
-# Short-Description: Hive @HIVE_DAEMON@
-### END INIT INFO
-
-. /lib/lsb/init-functions
-
-# Autodetect JAVA_HOME if not defined
-. /usr/lib/bigtop-utils/bigtop-detect-javahome
-
-# Modelled after $HADOOP_HOME/bin/hadoop-daemon.sh
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-NAME="hive-@HIVE_DAEMON@"
-SYS_FILE="/etc/default/${NAME}"
-EXE_FILE="/usr/lib/hive/bin/hive"
-PID_FILE="/var/run/hive/${NAME}.pid"
-LOCKFILE="/var/lock/subsys/${NAME}"
-LOG_FILE="/var/log/hive/${NAME}.out"
-HIVE_USER="hive"
-NICENESS="0"
-DESC="Hive daemon"
-
-DODTIME=3
-SLAVE_TIMEOUT=300
-
-[ -f $SYS_FILE ] && . $SYS_FILE
-
-hive_die() {
- echo "$@"
- exit 1
-}
-hive_is_process_alive() {
- local pid="$1"
- kill -0 $pid > /dev/null 2>&1
-}
-hive_check_pidfile() {
- local pidfile="$1" # IN
- local pid
-
- pid=`cat "$pidfile" 2>/dev/null`
- if [ "$pid" = '' ]; then
- # The file probably does not exist or is empty.
- return 1
- fi
-
- set -- $pid
- pid="$1"
-
- hive_is_process_alive $pid
-}
-hive_process_kill() {
- local pid="$1" # IN
- local signal="$2" # IN
- local second
-
- kill -$signal $pid 2>/dev/null
-
- for second in 0 1 2 3 4 5 6 7 8 9 10; do
- hive_is_process_alive "$pid" || return 0
- sleep 1
- done
-
- return 1
-}
-hive_stop_pidfile() {
- local pidfile="$1" # IN
- local pid
-
- pid=`cat "$pidfile" 2>/dev/null`
- if [ "$pid" = '' ]; then
- # The file probably does not exist or is empty. Success
- return 0
- fi
-
- set -- $pid
- pid="$1"
-
- # First try the easy way
- if hive_process_kill "$pid" 15; then
- return 0
- fi
-
- # Otherwise try the hard way
- if hive_process_kill "$pid" 9; then
- return 0
- fi
-
- return 1
-}
-
-hive_start() {
- ERROR_PROGRAM_NOT_INSTALLED=5
-
- [ -x $EXE_FILE ] || exit $ERROR_PROGRAM_NOT_INSTALLED
- log_success_msg "Starting $desc (${NAME}): "
-
- if hive_check_pidfile $PID_FILE ; then
- exit 0
- fi
-
- exec_env="HADOOP_OPTS=\"-Dhive.log.dir=`dirname $LOG_FILE` -Dhive.log.file=${NAME}.log -Dhive.log.threshold=INFO\""
- service_name="@HIVE_DAEMON@"
- if [ $service_name = "server" ] ; then
- service_name="hiveserver"
- fi
- su -s /bin/sh $HIVE_USER \
- -c "$exec_env nohup nice -n $NICENESS \
- $EXE_FILE --service $service_name $PORT \
- > $LOG_FILE 2>&1 < /dev/null & "'echo $! '"> $PID_FILE"
- sleep 3
-
- hive_check_pidfile $PID_FILE
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch $LOCKFILE
- return $RETVAL
-}
-hive_stop() {
- log_success_msg "Stopping $desc (${NAME}): "
- if [ -f $PID_FILE ]; then
- hive_stop_pidfile $PID_FILE
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && rm -f $LOCKFILE $PID_FILE
- fi
-}
-hive_restart() {
- hive_stop
- [ -n "$DODTIME" ] && sleep $DODTIME
- hive_start
-}
-hive_status() {
- local STATUS_RUNNING=0
- local STATUS_DEAD=1
- local STATUS_DEAD_AND_LOCK=2
- local STATUS_NOT_RUNNING=3
- local DAEMON="${NAME}"
-
- pidofproc -p $PID_FILE java > /dev/null
- status=$?
-
- case "$status" in
- $STATUS_RUNNING)
- log_success_msg "$DAEMON is running"
- ;;
- $STATUS_DEAD)
- log_failure_msg "$DAEMON is dead and pid file exists"
- ;;
- $STATUS_DEAD_AND_LOCK)
- log_failure_msg "$DAEMON is dead and lock file exists"
- ;;
- $STATUS_NOT_RUNNING)
- log_failure_msg "$DAEMON is not running"
- ;;
- *)
- log_failure_msg "$DAEMON status is unknown"
- ;;
- esac
- return $status
-}
-
-case "$1" in
- start)
- hive_start
- ;;
-
- stop|force-stop)
- hive_stop
- ;;
-
- force-reload|condrestart|try-restart)
- [ -e $LOCKFILE ] && hive_restart || :
- ;;
-
- restart|reload)
- hive_restart
- ;;
-
- status)
- hive_status
- ;;
-
- *)
- N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|restart|reload|condrestart|try-restart|force-reload|status|force-stop}" >&2
-
- exit 1
- ;;
-esac
-
-exit $RETVAL
http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/deb/hive/install_init_scripts.sh
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/hive/install_init_scripts.sh b/bigtop-packages/src/deb/hive/install_init_scripts.sh
deleted file mode 100755
index 6c9e789..0000000
--- a/bigtop-packages/src/deb/hive/install_init_scripts.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-# 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.
-
-
-SRC_PKG=hive
-for node in server metastore ; do
- service_pkgdir=debian/$SRC_PKG-$node
- debdir=$service_pkgdir/DEBIAN
- template="debian/service-init.d.tpl"
-
- mkdir -p $service_pkgdir/etc/init.d/ $service_pkgdir/etc/default/ $debdir
- cp debian/$SRC_PKG-${node}.default $service_pkgdir/etc/default/$SRC_PKG-$node
- sed -e "s|@HIVE_DAEMON@|$node|" $template > $service_pkgdir/etc/init.d/$SRC_PKG-$node
- sed -e "s|@HIVE_DAEMON@|$node|" debian/service-postinst.tpl > $debdir/postinst
- sed -e "s|@HIVE_DAEMON@|$node|" debian/service-postrm.tpl > $debdir/postrm
- chmod 755 $debdir/postinst $debdir/postrm $service_pkgdir/etc/init.d*
-
- mkdir -p $service_pkgdir/usr/share/lintian/overrides
- echo "$SRC_PKG-$node: new-package-should-close-itp-bug" > $service_pkgdir/usr/share/lintian/overrides/$SRC_PKG-$node
-
-done
http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/deb/hive/rules
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/hive/rules b/bigtop-packages/src/deb/hive/rules
index 85289ca..a1d4f1c 100755
--- a/bigtop-packages/src/deb/hive/rules
+++ b/bigtop-packages/src/deb/hive/rules
@@ -33,8 +33,8 @@ override_dh_auto_build:
bash debian/do-component-build -Divy.home=${HOME}/.ivy2
touch $@
-server metastore: debian/service-init.d.tpl
- sed -e "s|@HIVE_DAEMON@|$@|" $< > debian/${hive_pkg_name}-$@.init
+server metastore:
+ bash debian/init.d.tmpl debian/hive-$@.svc deb debian/${hive_pkg_name}-$@.init
override_dh_auto_install: metastore server
cp debian/hive-site.xml .
http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/deb/hive/service-init.d.tpl
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/hive/service-init.d.tpl b/bigtop-packages/src/deb/hive/service-init.d.tpl
deleted file mode 100644
index 0473cbb..0000000
--- a/bigtop-packages/src/deb/hive/service-init.d.tpl
+++ /dev/null
@@ -1,167 +0,0 @@
-#! /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.
-
-# skeleton example file to build /etc/init.d/ scripts.
-# This file should be used to construct scripts for /etc/init.d.
-#
-# Written by Miquel van Smoorenburg <mi...@cistron.nl>.
-# Modified for Debian
-# by Ian Murdock <im...@gnu.ai.mit.edu>.
-# Further changes by Javier Fernandez-Sanguino <jf...@debian.org>
-#
-# Starts a Hive @HIVE_DAEMON@
-#
-# chkconfig: 345 85 15
-# description: Starts a Hive @HIVE_DAEMON@
-# processname: hive
-#
-### BEGIN INIT INFO
-# Provides: hive-@HIVE_DAEMON@
-# Required-Start: $syslog $remote_fs
-# Should-Start:
-# Required-Stop: $syslog $remote_fs
-# Should-Stop:
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 2 6
-# Short-Description: Starts a Hive @HIVE_DAEMON@
-### END INIT INFO
-
-source /lib/lsb/init-functions
-
-# Autodetect JAVA_HOME if not defined
-. /usr/lib/bigtop-utils/bigtop-detect-javahome
-
-RETVAL_SUCCESS=0
-
-STATUS_RUNNING=0
-STATUS_DEAD=1
-STATUS_DEAD_AND_LOCK=2
-STATUS_NOT_RUNNING=3
-STATUS_DEBIAN_NOT_RUNNING=4
-
-ERROR_PROGRAM_NOT_INSTALLED=5
-ERROR_PROGRAM_NOT_CONFIGURED=6
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-NAME="hive-@HIVE_DAEMON@"
-DESC="Hive @HIVE_DAEMON@ daemon"
-SYS_FILE="/etc/default/${NAME}"
-EXE_FILE="/usr/lib/hive/bin/hive"
-PID_FILE="/var/run/hive/${NAME}.pid"
-LOCKFILE="/var/lock/subsys/${NAME}"
-LOG_FILE="/var/log/hive/${NAME}.out"
-HIVE_USER="hive"
-HIVE_HOME="`eval echo ~$HIVE_USER`"
-NICENESS="+0"
-TIMEOUT=3
-
-install -d -m 0755 -o ${HIVE_USER} -g ${HIVE_USER} `dirname ${PID_FILE}`
-
-[ -f $SYS_FILE ] && . $SYS_FILE
-
-hive_start() {
- [ -x $EXE_FILE ] || exit $ERROR_PROGRAM_NOT_INSTALLED
-
- exec_env="HADOOP_OPTS=\"-Dhive.log.dir=`dirname $LOG_FILE` -Dhive.log.file=${NAME}.log -Dhive.log.threshold=INFO\""
- service_name="@HIVE_DAEMON@"
- if [ $service_name = "server" ] ; then
- service_name="hiveserver"
- fi
-
- log_success_msg "Starting $desc (${NAME}): "
- /sbin/start-stop-daemon --quiet --oknodo --start --user $HIVE_USER --name java --background \
- --chuid $HIVE_USER --nicelevel $NICENESS --chdir $HIVE_HOME \
- --make-pidfile --pidfile $PID_FILE --startas /bin/sh -- \
- -c "$exec_env exec $EXE_FILE --service $service_name $PORT > $LOG_FILE 2>&1 < /dev/null"
-
- RETVAL=$?
- [ $RETVAL -eq $RETVAL_SUCCESS ] && touch $LOCKFILE
- return $RETVAL
-}
-
-hive_stop() {
- log_success_msg "Stopping $desc (${NAME}): "
- killproc -p $PID_FILE java
- RETVAL=$?
-
- [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PID_FILE
- return $RETVAL
-}
-
-hive_restart() {
- hive_stop
- [ -n "$TIMEOUT" ] && sleep $TIMEOUT
- hive_start
-}
-
-hive_status() {
- echo -n "Checking for service $desc: "
- pidofproc -p $PID_FILE java > /dev/null
- RETVAL=$?
-
- case "$RETVAL" in
- $STATUS_RUNNING)
- log_success_msg "@HIVE_DAEMON@ is running"
- ;;
- $STATUS_DEAD)
- log_failure_msg "@HIVE_DAEMON@ is dead and pid file exists"
- ;;
- $STATUS_DEAD_AND_LOCK)
- log_failure_msg "@HIVE_DAEMON@ is dead and lock file exists"
- ;;
- $STATUS_NOT_RUNNING|$STATUS_DEBIAN_NOT_RUNNING)
- log_failure_msg "@HIVE_DAEMON@ is not running"
- ;;
- *)
- log_failure_msg "@HIVE_DAEMON@ status is unknown"
- ;;
- esac
- return $RETVAL
-}
-
-RETVAL=0
-
-case "$1" in
- start)
- hive_start
- ;;
-
- stop|force-stop)
- hive_stop
- ;;
-
- force-reload|condrestart|try-restart)
- [ -e $LOCKFILE ] && hive_restart || :
- ;;
-
- restart|reload)
- hive_restart
- ;;
-
- status)
- hive_status
- ;;
-
- *)
- N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|restart|reload|condrestart|try-restart|force-reload|status|force-stop}" >&2
-
- exit 1
- ;;
-esac
-
-exit $RETVAL
http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/rpm/hive/SPECS/hive.spec
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/hive/SPECS/hive.spec b/bigtop-packages/src/rpm/hive/SPECS/hive.spec
index 1fbb3d1..f700d89 100644
--- a/bigtop-packages/src/rpm/hive/SPECS/hive.spec
+++ b/bigtop-packages/src/rpm/hive/SPECS/hive.spec
@@ -63,12 +63,14 @@ BuildArch: noarch
Source0: %{name}-%{hive_base_version}.tar.gz
Source1: do-component-build
Source2: install_hive.sh
-Source3: hive.sh
+Source3: init.d.tmpl
Source4: hive-site.xml
Source5: hive-server.default
Source6: hive-metastore.default
Source7: hive.1
Source8: hive-site.xml
+Source9: hive-server.svc
+Source10: hive-metastore.svc
Requires: hadoop-client, bigtop-utils >= 0.6, hbase, zookeeper
Obsoletes: %{name}-webinterface
@@ -142,7 +144,6 @@ cp $RPM_SOURCE_DIR/hive-site.xml .
--build-dir=%{hive_dist} \
--doc-dir=%{doc_hive}
-%__install -d -m 0755 $RPM_BUILD_ROOT/%{initd_dir}/
%__install -d -m 0755 $RPM_BUILD_ROOT/etc/default/
%__install -m 0644 %{SOURCE6} $RPM_BUILD_ROOT/etc/default/%{name}-metastore
%__install -m 0644 %{SOURCE5} $RPM_BUILD_ROOT/etc/default/%{name}-server
@@ -159,10 +160,9 @@ cp $RPM_SOURCE_DIR/hive-site.xml .
for service in %{hive_services}
do
- init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{name}-${service}
- %__cp %{SOURCE3} $init_file
- %__sed -i -e "s|@HIVE_DAEMON@|${service}|" $init_file
- chmod 755 $init_file
+ # Install init script
+ init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{name}-${service}
+ bash $RPM_SOURCE_DIR/init.d.tmpl $RPM_SOURCE_DIR/hive-${service}.svc rpm $init_file
done
%pre
[3/5] git commit: BIGTOP-732. Support running multiple HBase region
servers
Posted by rv...@apache.org.
BIGTOP-732. Support running multiple HBase region servers
Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/2fc2307c
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/2fc2307c
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/2fc2307c
Branch: refs/heads/master
Commit: 2fc2307c743250146d30a6a81b4f1581eac2076e
Parents: a353721
Author: Sean Mackrory <ma...@gmail.com>
Authored: Thu Apr 18 13:46:13 2013 -0700
Committer: Roman Shaposhnik <rv...@cloudera.com>
Committed: Wed May 1 17:51:57 2013 -0700
----------------------------------------------------------------------
bigtop-packages/src/common/hbase/hbase.default | 7 +
.../src/common/hbase/regionserver-init.d.tpl | 412 +++++++++++++++
.../src/deb/hbase/install_init_scripts.sh | 9 +-
bigtop-packages/src/deb/hbase/rules | 4 +-
bigtop-packages/src/rpm/hbase/SPECS/hbase.spec | 18 +-
5 files changed, 442 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/bigtop/blob/2fc2307c/bigtop-packages/src/common/hbase/hbase.default
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/hbase/hbase.default b/bigtop-packages/src/common/hbase/hbase.default
index 53dee46..3371a2b 100644
--- a/bigtop-packages/src/common/hbase/hbase.default
+++ b/bigtop-packages/src/common/hbase/hbase.default
@@ -17,3 +17,10 @@ export HBASE_PID_DIR="/var/run/hbase"
export HBASE_LOG_DIR="/var/log/hbase"
export HBASE_IDENT_STRING=hbase
export HBASE_THRIFT_MODE="-nonblocking"
+
+# Up to 100 region servers can be run on a single host by specifying offsets
+# here or as CLI args when using init scripts. Each offset identifies an
+# instance and is used to determine the network ports it uses. Each instance
+# will have have its own log and pid files.
+#
+# REGIONSERVER_OFFSETS="1 2 3"
http://git-wip-us.apache.org/repos/asf/bigtop/blob/2fc2307c/bigtop-packages/src/common/hbase/regionserver-init.d.tpl
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/hbase/regionserver-init.d.tpl b/bigtop-packages/src/common/hbase/regionserver-init.d.tpl
new file mode 100644
index 0000000..8f45eb6
--- /dev/null
+++ b/bigtop-packages/src/common/hbase/regionserver-init.d.tpl
@@ -0,0 +1,412 @@
+#! /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.
+
+# This file is used to run multiple instances of certain HBase daemons using init scripts.
+# It replaces the local-regionserver.sh and local-master.sh scripts for Bigtop packages.
+# By default, this script runs a single daemon normally. If offsets are provided, additional
+# daemons are run, identified by the offset in log and pid files, and listening on the default
+# port + the offset. Offsets can be provided as arguments when invoking init scripts directly:
+#
+# /etc/init.d/hbase-@HBASE_DAEMON@ start 1 2 3 4
+#
+# or you can list the offsets to run in /etc/init.d/@HBASE_DAEMON@_offsets:
+#
+# echo "@HBASE_DAEMON@_OFFSETS='1 2 3 4' >> /etc/default/hbase"
+# sudo service hbase-$HBASE_DAEMON@ start
+#
+# Offsets specified on the command-line always override the offsets file. If no offsets are
+# specified on the command-line when stopping or restarting daemons, all running instances of the
+# daemon are stopped (regardless of the contents of the offsets file).
+
+# chkconfig: @CHKCONFIG@
+# description: Summary: HBase is the Hadoop database. Use it when you need random, realtime read/write access to your Big Data. This project's goal is the hosting of very large tables -- billions of rows X millions of columns -- atop clusters of commodity hardware.
+# processname: HBase
+#
+### BEGIN INIT INFO
+# Provides: hbase-@HBASE_DAEMON@
+# Required-Start: $network $local_fs $remote_fs
+# Required-Stop: $remote_fs
+# Should-Start: $named
+# Should-Stop:
+# Default-Start: @INIT_DEFAULT_START@
+# Default-Stop: @INIT_DEFAULT_STOP@
+# Short-Description: Hadoop HBase @HBASE_DAEMON@ daemon
+### END INIT INFO
+
+. /etc/default/hadoop
+. /etc/default/hbase
+
+# Autodetect JAVA_HOME if not defined
+. /usr/lib/bigtop-utils/bigtop-detect-javahome
+
+# Our default HBASE_HOME, HBASE_PID_DIR and HBASE_CONF_DIR
+export HBASE_HOME=${HBASE_HOME:-/usr/lib/hbase}
+export HBASE_PID_DIR=${HBASE_PID_DIR:-/var/run/hbase}
+export HBASE_LOG_DIR=${HBASE_LOG_DIR:-/var/log/hbase}
+
+install -d -m 0755 -o hbase -g hbase ${HBASE_PID_DIR}
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON_SCRIPT=$HBASE_HOME/bin/hbase-daemon.sh
+NAME=hbase-@HBASE_DAEMON@
+DESC="Hadoop HBase @HBASE_DAEMON@ daemon"
+PID_FILE=$HBASE_PID_DIR/hbase-hbase-@HBASE_DAEMON@.pid
+CONF_DIR=/etc/hbase/conf
+
+DODTIME=3 # Time to wait for the server to die, in seconds
+ # If this value is set too low you might not
+ # let some servers to die gracefully and
+ # 'restart' will not work
+
+UPPERCASE_HBASE_DAEMON=$(echo @HBASE_DAEMON@ | tr '[:lower:]' '[:upper:]')
+
+ALL_OFFSET_DAEMONS_RUNNING=0
+SOME_OFFSET_DAEMONS_FAILING=1
+NO_OFFSET_DAEMONS_RUNNING=2
+INVALID_OFFSETS_PROVIDED=3
+
+# These limits are not easily configurable - they are enforced by HBase
+if [ "@HBASE_DAEMON@" == "master" ] ; then
+ FIRST_PORT=60000
+ FIRST_INFO_PORT=60010
+ OFFSET_LIMIT=10
+elif [ "@HBASE_DAEMON@" == "regionserver" ] ; then
+ FIRST_PORT=60200
+ FIRST_INFO_PORT=60300
+ OFFSET_LIMIT=100
+fi
+
+validate_offsets() {
+ for OFFSET in $1; do
+ if [[ ! $OFFSET =~ ^((0)|([1-9][0-9]{0,2}))$ ]]; then
+ echo "ERROR: All offsets must be positive integers (no leading zeros, max $OFFSET_LIMIT)"
+ exit $INVALID_OFFSETS_PROVIDED
+ fi
+ if [ ${OFFSET} -lt 0 ] ; then
+ echo "ERROR: Cannot start @HBASE_DAEMON@ with negative offset" >&2
+ exit $INVALID_OFFSETS_PROVIDED
+ fi
+ if [ ${OFFSET} -ge ${OFFSET_LIMIT} ] ; then
+ echo "ERROR: Cannot start @HBASE_DAEMON@ with offset higher than $OFFSET_LIMIT" >&2
+ exit $INVALID_OFFSETS_PROVIDED
+ fi
+ done
+}
+
+offset_pidfile() {
+ echo $HBASE_PID_DIR/hbase-hbase-$1-@HBASE_DAEMON@.pid
+}
+
+OFFSETS_FROM_CLI="${*:2}"
+validate_offsets "$OFFSETS_FROM_CLI"
+if [ -n "$(eval echo \${${UPPERCASE_HBASE_DAEMON}_OFFSETS})" ] ; then
+ OFFSETS_FROM_DEFAULT="$(eval echo \${${UPPERCASE_HBASE_DAEMON}_OFFSETS})"
+ validate_offsets "$OFFSETS_FROM_DEFAULT"
+fi
+OFFSET_PID_FILES="`ls $HBASE_PID_DIR/hbase-hbase-*-@HBASE_DAEMON@.pid 2>/dev/null`"
+if [ -n "$OFFSET_PID_FILES" ] ; then
+ OFFSETS_FROM_PIDS=`echo "$OFFSET_PID_FILES" | sed "s#$HBASE_PID_DIR/hbase-hbase-##" | sed "s#-.*##"`
+fi
+
+multi_hbase_daemon_check_pidfiles() {
+ if [ -z "$OFFSETS_FROM_PIDS" ] ; then
+ return $NO_OFFSET_DAEMONS_RUNNING
+ fi
+ if [ -n "$OFFSETS_FROM_CLI" ] ; then
+ OFFSETS="$OFFSETS_FROM_CLI"
+ else
+ OFFSETS="$OFFSETS_FROM_PIDS"
+ fi
+
+ RESULT=$ALL_OFFSET_DAEMONS_RUNNING
+ for OFFSET in $OFFSETS; do
+ echo -n "HBase @HBASE_DAEMON@ $OFFSET: "
+ if hbase_check_pidfile `offset_pidfile $OFFSET` ; then
+ echo "running"
+ else
+ echo "not running"
+ RESULT=$SOME_OFFSET_DAEMONS_FAILING
+ fi
+ done
+ return $RESULT
+}
+
+multi_hbase_daemon_stop_pidfiles() {
+ if [ -z "$OFFSETS_FROM_PIDS" ] ; then
+ return $NO_OFFSET_DAEMONS_RUNNING
+ fi
+ if [ -n "$OFFSETS_FROM_CLI" ] ; then
+ OFFSETS="$OFFSETS_FROM_CLI"
+ else
+ OFFSETS="$OFFSETS_FROM_PIDS"
+ fi
+
+ RESULT=$NO_OFFSET_DAEMONS_RUNNING
+ for OFFSET in $OFFSETS; do
+ echo -n "Forcefully stopping HBase @HBASE_DAEMON@ $OFFSET: "
+ PID_FILE=`offset_pidfile $OFFSET`
+ hbase_stop_pidfile $PID_FILE
+ if hbase_check_pidfile $PID_FILE ; then
+ echo "ERROR."
+ else
+ echo "OK."
+ rm -f $PID_FILE
+ fi
+ done
+ return $RESULT
+}
+
+# Starts and stops multiple instances of HBase daemons
+multi_hbase_daemon() {
+ COMMAND=$1
+ OFFSETS="$OFFSETS_FROM_CLI"
+ if [ "$COMMAND" == "start" ] ; then
+ ACTION="Starting"
+ RUNNING="OK"
+ STOPPED="ERROR"
+ if [ -z "$OFFSETS_FROM_CLI" ] ; then
+ OFFSETS="$OFFSETS_FROM_DEFAULT"
+ fi
+ elif [ "$COMMAND" == "stop" ] ; then
+ ACTION="Stopping"
+ RUNNING="ERROR"
+ STOPPED="OK"
+ if [ -z "$OFFSETS_FROM_CLI" ] ; then
+ OFFSETS="$OFFSETS_FROM_PIDS"
+ fi
+ else
+ echo "ERROR: Illegal command: $COMMAND"
+ exit 1
+ fi
+
+ export HBASE_${UPPERCASE_HBASE_DAEMON}_OPTS=" "
+
+ for OFFSET in ${OFFSETS} ; do
+ echo -n "$ACTION @HBASE_DAEMON@ daemon $OFFSET: "
+ export HBASE_IDENT_STRING="hbase-${OFFSET}"
+ LOG_FILE="$HBASE_LOG_DIR/hbase-$HBASE_IDENT_STRING-@HBASE_DAEMON@-$HOSTNAME.pid"
+ PID_FILE="$HBASE_PID_DIR/hbase-$HBASE_IDENT_STRING-@HBASE_DAEMON@.pid"
+ HBASE_MULTI_ARGS="-D hbase.@HBASE_DAEMON@.port=`expr ${FIRST_PORT} + $OFFSET` \
+ -D hbase.@HBASE_DAEMON@.info.port=`expr ${FIRST_INFO_PORT} + ${OFFSET}`"
+ hbase_check_pidfile $PID_FILE
+ STATUS=$?
+ if [[ "$STATUS" == "0" && "$COMMAND" == "start" ]] ; then
+ echo "Already running"
+ continue
+ elif [[ "$STATUS" != "0" && "$COMMAND" == "stop" ]] ; then
+ rm -f $PID_FILE
+ echo "Already stopped"
+ continue
+ fi
+ su -s /bin/bash hbase -c "${DAEMON_SCRIPT} ${COMMAND} regionserver ${HBASE_MULTI_ARGS} >> ${LOG_FILE}"
+ if [[ "$COMMAND" == "stop" ]] ; then
+ rm -f $PID_FILE
+ fi
+ if hbase_check_pidfile $PID_FILE ; then
+ echo "$RUNNING"
+ else
+ echo "$STOPPED"
+ fi
+ done
+ return 0
+}
+
+# Checks if the given pid represents a live process.
+# Returns 0 if the pid is a live process, 1 otherwise
+hbase_is_process_alive() {
+ local pid="$1"
+ ps -fp $pid | grep $pid | grep @HBASE_DAEMON@ > /dev/null 2>&1
+}
+
+# Check if the process associated to a pidfile is running.
+# Return 0 if the pidfile exists and the process is running, 1 otherwise
+hbase_check_pidfile() {
+ local pidfile="$1" # IN
+ local pid
+
+ pid=`cat "$pidfile" 2>/dev/null`
+ if [ "$pid" = '' ]; then
+ # The file probably does not exist or is empty.
+ return 1
+ fi
+
+ set -- $pid
+ pid="$1"
+
+ hbase_is_process_alive $pid
+}
+
+# Kill the process associated to a pidfile
+hbase_stop_pidfile() {
+ local pidfile="$1" # IN
+ local pid
+
+ pid=`cat "$pidfile" 2>/dev/null`
+ if [ "$pid" = '' ]; then
+ # The file probably does not exist or is empty. Success
+ return 0
+ fi
+
+ set -- $pid
+ pid="$1"
+
+ # First try the easy way
+ if hbase_process_kill "$pid" 15; then
+ rm $pidfile
+ return 0
+ fi
+
+ # Otherwise try the hard way
+ if hbase_process_kill "$pid" 9; then
+ rm $pidfile
+ return 0
+ fi
+
+ return 1
+}
+
+hbase_process_kill() {
+ local pid="$1" # IN
+ local signal="$2" # IN
+ local second
+
+ kill -$signal $pid 2>/dev/null
+
+ # Wait a bit to see if the dirty job has really been done
+ for second in 0 1 2 3 4 5 6 7 8 9 10; do
+ if hbase_is_process_alive "$pid"; then
+ # Success
+ return 0
+ fi
+
+ sleep 1
+ done
+
+ # Timeout
+ return 1
+}
+
+start() {
+ if [ -n "${OFFSETS_FROM_CLI}${OFFSETS_FROM_DEFAULT}" ] ; then
+ if hbase_check_pidfile $PID_FILE ; then
+ echo "$NAME has already been started - cannot start other @HBASE_DAEMON@ daemons."
+ exit 1
+ fi
+ multi_hbase_daemon "start"
+ exit $?
+ fi
+ multi_hbase_daemon_check_pidfiles > /dev/null
+ if [ "$?" != "$NO_OFFSET_DAEMONS_RUNNING" ] ; then
+ echo "Cannot start $NAME - other @HBASE_DAEMON@ daemons have already been started."
+ exit 1
+ fi
+ echo -n "Starting $DESC: "
+ su -s /bin/sh hbase -c "$DAEMON_SCRIPT start @HBASE_DAEMON@"
+ if hbase_check_pidfile $PID_FILE ; then
+ echo "$NAME."
+ else
+ echo "ERROR."
+ fi
+}
+stop() {
+ if [ -n "${OFFSETS_FROM_CLI}${OFFSETS_FROM_PIDS}" ] ; then
+ multi_hbase_daemon "stop"
+ return "$?"
+ fi
+
+ echo -n "Stopping $DESC: "
+ su -s /bin/sh hbase -c "$DAEMON_SCRIPT stop @HBASE_DAEMON@"
+ if hbase_check_pidfile $PID_FILE ; then
+ echo "ERROR."
+ else
+ echo "$NAME."
+ fi
+}
+
+force_stop() {
+ MULTI_HBASE_DAEMON_STATUS_TEXT=`multi_hbase_daemon_check_pidfiles`
+ MULTI_HBASE_DAEMON_STATUS=$?
+ if [ "$MULTI_HBASE_DAEMON_STATUS" == "$NO_OFFSET_DAEMONS_RUNNING" ] ; then
+ echo -n "Forcefully stopping $DESC: "
+ hbase_stop_pidfile $PID_FILE
+ if hbase_check_pidfile $PID_FILE ; then
+ echo " ERROR."
+ else
+ echo "$NAME."
+ fi
+ else
+ multi_hbase_daemon_stop_pidfiles
+ fi
+}
+
+force_reload() {
+ # check wether $DAEMON is running. If so, restart
+ hbase_check_pidfile $PID_FILE && $0 restart $OFFSETS_FROM_CLI
+}
+
+restart() {
+ echo -n "Restarting $DESC: "
+ stop
+ [ -n "$DODTIME" ] && sleep $DODTIME
+ $0 start $OFFSETS_FROM_CLI
+}
+
+status() {
+ MULTI_HBASE_DAEMON_STATUS_TEXT=`multi_hbase_daemon_check_pidfiles`
+ MULTI_HBASE_DAEMON_STATUS=$?
+ if [ "$MULTI_HBASE_DAEMON_STATUS" == "$NO_OFFSET_DAEMONS_RUNNING" ] ; then
+ echo -n "$NAME is "
+ if hbase_check_pidfile $PID_FILE ; then
+ echo "running"
+ else
+ echo "not running."
+ exit 1
+ fi
+ else
+ IFS=''
+ echo $MULTI_HBASE_DAEMON_STATUS_TEXT
+ exit $MULTI_HBAE_DAEMONS_STATUS
+ fi
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ force-stop)
+ force_stop
+ ;;
+ force-reload)
+ force_reload
+ ;;
+ restart)
+ restart
+ ;;
+ status)
+ status
+ ;;
+ *)
+ N=/etc/init.d/$NAME
+ echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2
+ exit 1
+ ;;
+esac
+
+exit 0
http://git-wip-us.apache.org/repos/asf/bigtop/blob/2fc2307c/bigtop-packages/src/deb/hbase/install_init_scripts.sh
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/hbase/install_init_scripts.sh b/bigtop-packages/src/deb/hbase/install_init_scripts.sh
index f60059c..1f3c151 100755
--- a/bigtop-packages/src/deb/hbase/install_init_scripts.sh
+++ b/bigtop-packages/src/deb/hbase/install_init_scripts.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -27,6 +27,13 @@ for node in master regionserver rest thrift ; do
service_pkgdir=debian/$SRC_PKG-$node
debdir=$service_pkgdir/DEBIAN
template="debian/service-init.d.tpl"
+ if [ "$node" == "regionserver" ] ; then
+ # Region servers start from a different template that allows
+ # them to run multiple concurrent instances of the daemon
+ template="debian/regionserver-init.d.tpl"
+ sed -i -e "s|@INIT_DEFAULT_START@|2 3 4 5|" $template
+ sed -i -e "s|@INIT_DEFAULT_STOP@|0 1 6|" $template
+ fi
mkdir -p $service_pkgdir/etc/init.d/ $debdir
sed -e "s|@HBASE_DAEMON@|$node|" -e "s|@CHKCONFIG@|$chkconfig|" $template > $service_pkgdir/etc/init.d/$SRC_PKG-$node
http://git-wip-us.apache.org/repos/asf/bigtop/blob/2fc2307c/bigtop-packages/src/deb/hbase/rules
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/hbase/rules b/bigtop-packages/src/deb/hbase/rules
index 9a6ddc8..9c8f68a 100755
--- a/bigtop-packages/src/deb/hbase/rules
+++ b/bigtop-packages/src/deb/hbase/rules
@@ -36,7 +36,7 @@ override_dh_auto_build:
override_dh_auto_install:
cp debian/hbase.default debian/${hbase_pkg_name}/etc/default/${hbase_pkg_name}
- sh -x debian/install_hbase.sh \
+ bash -x debian/install_hbase.sh \
--build-dir=build \
--conf-dir=/etc/hbase/conf.dist \
--doc-dir=usr/share/doc/${hbase_pkg_name}-doc \
@@ -56,4 +56,4 @@ override_dh_auto_install:
find debian/tmp/usr/lib/${hbase_pkg_name}/bin debian/tmp/usr/lib/${hbase_pkg_name}/lib -name \*.rb -exec chmod 644 {} \;
### webapps should not be executable either
find debian/tmp/usr/lib/${hbase_pkg_name}/hbase-webapps -type f -exec chmod 644 {} \;
- sh debian/install_init_scripts.sh
+ bash debian/install_init_scripts.sh
http://git-wip-us.apache.org/repos/asf/bigtop/blob/2fc2307c/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec b/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec
index d698bdf..ee15e4d 100644
--- a/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec
+++ b/bigtop-packages/src/rpm/hbase/SPECS/hbase.spec
@@ -90,6 +90,7 @@ Source3: hbase.sh
Source4: hbase.sh.suse
Source5: hbase.default
Source6: hbase.nofiles.conf
+Source7: regionserver-init.d.tpl
BuildArch: noarch
Requires: coreutils, /usr/sbin/useradd, /sbin/chkconfig, /sbin/service
Requires: hadoop-hdfs, zookeeper >= 3.3.1, bigtop-utils >= 0.6
@@ -273,11 +274,18 @@ do
rest) chkconfig="345 88 12" ;;
*) chkconfig="345 89 13" ;;
esac
- init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{name}-${service}
- %__cp $orig_init_file $init_file
- %__sed -i -e "s|@CHKCONFIG@|${chkconfig}|" $init_file
- %__sed -i -e "s|@HBASE_DAEMON@|${service}|" $init_file
- chmod 755 $init_file
+ init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{name}-${service}
+ %__cp $orig_init_file $init_file
+ if [[ "$service" = "regionserver" ]] ; then
+ # Region servers start from a different template that allows
+ # them to run multiple concurrent instances of the daemon
+ %__cp %{SOURCE7} $init_file
+ %__sed -i -e "s|@INIT_DEFAULT_START@|3 4 5|" $init_file
+ %__sed -i -e "s|@INIT_DEFAULT_STOP@|0 1 2 6|" $init_file
+ fi
+ %__sed -i -e "s|@CHKCONFIG@|${chkconfig}|" $init_file
+ %__sed -i -e "s|@HBASE_DAEMON@|${service}|" $init_file
+ chmod 755 $init_file
done
# FIXME: BIGTOP-648 workaround for HBASE-6263
[5/5] git commit: BIGTOP-959. get rid of hadoop specific init.d.tmpl
Posted by rv...@apache.org.
BIGTOP-959. get rid of hadoop specific init.d.tmpl
Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/25463a41
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/25463a41
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/25463a41
Branch: refs/heads/master
Commit: 25463a4144b34e293778ee47569de2657be85a1e
Parents: d0aafdf
Author: Roman Shaposhnik <rv...@cloudera.com>
Authored: Wed May 1 17:45:47 2013 -0700
Committer: Roman Shaposhnik <rv...@cloudera.com>
Committed: Wed May 1 18:20:21 2013 -0700
----------------------------------------------------------------------
bigtop-packages/src/common/hadoop/init.d.tmpl | 279 -----------------
bigtop-packages/src/deb/hadoop/rules | 2 +-
bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec | 8 +-
3 files changed, 2 insertions(+), 287 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/bigtop/blob/25463a41/bigtop-packages/src/common/hadoop/init.d.tmpl
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/hadoop/init.d.tmpl b/bigtop-packages/src/common/hadoop/init.d.tmpl
deleted file mode 100755
index 7e3d454..0000000
--- a/bigtop-packages/src/common/hadoop/init.d.tmpl
+++ /dev/null
@@ -1,279 +0,0 @@
-#!/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.
-
-# This is a poor man's templating engine for generating init.d scripts to
-# support all the Apache services that Bigtop distro has. An actual init.d
-# script gets generate via running this script under bash and giving it
-# a mandatory argument of a file containing the configuration for the service.
-# The argument file should be a valid piece of bash code since it gets directly
-# source into this template. E.g.
-# $ bash ./init.d.tmpl hadoop-hdfs-namenode.svc > hadoop-hdfs-namenode
-#
-# You must declare the following in your .svc configuration file:
-# DAEMON="name of the resulting init.d script"
-# DESC="Free form human readable description of the service"
-# EXEC_PATH="path to the upstream daemon management script"
-# SVC_USER="user to run this service as"
-# DAEMON_FLAGS="flags to be passed to the $EXEC_PATH"
-# CONF_DIR="path to the configuration directory"
-# PIDFILE="file holding a PID of the running daemon"
-# LOCKFILE="file signifying the service lock"
-#
-# CHKCONFIG="chkconfig(8) registration signature"
-# INIT_DEFAULT_START="run levels to use"
-# INIT_DEFAULT_STOP="run levels not to use ;-)"
-#
-# You can, also, override parts of the generated init.d script by providing
-# function definitions for: generate_start, generate_stop and generate_extra_commands.
-# See the default implemenations below and feel free to customize. Also look
-# for exising .svc files in common to see how different services are tweaking
-# the defaults.
-#
-# Of course, if this whole templating thing grows too big we might need to
-# consider a real templating engine (I have played with m4, but it seems
-# qutie brittle when used for manipulating pieces of the shell code -- think
-# $0 the like).
-
-if [ $# -lt 1 ] ; then
- echo "Usage: ${BASH_SOURCE-0} service.definition.svc"
- exit 1
-fi
-
-generate_start() {
-
-cat <<'__EOT__'
-
-start() {
- [ -x $EXEC_PATH ] || exit $ERROR_PROGRAM_NOT_INSTALLED
- [ -d $CONF_DIR ] || exit $ERROR_PROGRAM_NOT_CONFIGURED
- log_success_msg "Starting ${DESC}: "
-
- su -s /bin/bash $SVC_USER -c "$EXEC_PATH --config '$CONF_DIR' start $DAEMON_FLAGS"
-
- # Some processes are slow to start
- sleep $SLEEP_TIME
- checkstatusofproc
- RETVAL=$?
-
- [ $RETVAL -eq $RETVAL_SUCCESS ] && touch $LOCKFILE
- return $RETVAL
-}
-
-__EOT__
-
-}
-
-generate_stop() {
-
-cat <<'__EOT__'
-
-stop() {
- log_success_msg "Stopping ${DESC}: "
- start_daemon $EXEC_PATH --config "$CONF_DIR" stop $DAEMON_FLAGS
- RETVAL=$?
-
- [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PIDFILE
-}
-
-__EOT__
-
-}
-
-generate_extra_commands() {
-
-cat <<'__EOT__'
- *)
- echo $"Usage: $0 {start|stop|status|restart|try-restart|condrestart}"
- exit 1
-__EOT__
-
-}
-
-###################################################################
-# Some reasonable defaults for the run-level settings, these are
-# tweaked on a per-OS basis from the SPEC/rules files that call us
-# and can be further tweaked inside of individual .svc templates
-CHKCONFIG=${CHKCONFIG:-"2345 85 15"}
-INIT_DEFAULT_START=${INIT_DEFAULT_START:-"2 3 4 5"}
-INIT_DEFAULT_STOP=${INIT_DEFAULT_STOP:-"0 1 6"}
-
-###################################################################
-# NOTE how we are sourcing the argument here so that a user-defined
-# settings have a chance to override the default values for
-# generate_start, generate_stop and generate_extra_commands. If you
-# ever want to make this template even more flexible -- define the
-# default values above this line
-. $1
-
-cat <<__EOT__
-#!/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.
-#
-# Starts a $DESC
-#
-# chkconfig: $CHKCONFIG
-# description: $DESC
-#
-### BEGIN INIT INFO
-# Provides: $DAEMON
-# Short-Description: $DESC
-# Default-Start: $INIT_DEFAULT_START
-# Default-Stop: $INIT_DEFAULT_STOP
-# Required-Start: \$syslog \$remote_fs
-# Required-Stop: \$syslog \$remote_fs
-# Should-Start:
-# Should-Stop:
-### END INIT INFO
-
-. /lib/lsb/init-functions
-. /etc/default/hadoop
-
-if [ -f /etc/default/$DAEMON ] ; then
- . /etc/default/$DAEMON
-fi
-
-# Autodetect JAVA_HOME if not defined
-. /usr/lib/bigtop-utils/bigtop-detect-javahome
-
-RETVAL_SUCCESS=0
-
-STATUS_RUNNING=0
-STATUS_DEAD=1
-STATUS_DEAD_AND_LOCK=2
-STATUS_NOT_RUNNING=3
-STATUS_OTHER_ERROR=102
-
-
-ERROR_PROGRAM_NOT_INSTALLED=5
-ERROR_PROGRAM_NOT_CONFIGURED=6
-
-
-RETVAL=0
-SLEEP_TIME=5
-PROC_NAME="java"
-
-DAEMON="$DAEMON"
-DESC="$DESC"
-EXEC_PATH="$EXEC_PATH"
-SVC_USER="$SVC_USER"
-DAEMON_FLAGS="$DAEMON_FLAGS"
-CONF_DIR="$CONF_DIR"
-PIDFILE="$PIDFILE"
-LOCKDIR="$LOCKDIR"
-LOCKFILE="\$LOCKDIR/$LOCKFILE"
-
-install -d -m 0755 -o $SVC_USER -g $SVC_USER $(dirname $PIDFILE) 1>/dev/null 2>&1 || :
-[ -d "\$LOCKDIR" ] || install -d -m 0755 \$LOCKDIR 1>/dev/null 2>&1 || :
-__EOT__
-
-generate_start
-generate_stop
-
-cat <<'__EOT__'
-restart() {
- stop
- start
-}
-
-checkstatusofproc(){
- pidofproc -p $PIDFILE $PROC_NAME > /dev/null
-}
-
-checkstatus(){
- checkstatusofproc
- status=$?
-
- case "$status" in
- $STATUS_RUNNING)
- log_success_msg "${DESC} is running"
- ;;
- $STATUS_DEAD)
- log_failure_msg "${DESC} is dead and pid file exists"
- ;;
- $STATUS_DEAD_AND_LOCK)
- log_failure_msg "${DESC} is dead and lock file exists"
- ;;
- $STATUS_NOT_RUNNING)
- log_failure_msg "${DESC} is not running"
- ;;
- *)
- log_failure_msg "${DESC} status is unknown"
- ;;
- esac
- return $status
-}
-
-condrestart(){
- [ -e $LOCKFILE ] && restart || :
-}
-
-check_for_root() {
- if [ $(id -ur) -ne 0 ]; then
- echo 'Error: root user required'
- echo
- exit 1
- fi
-}
-
-service() {
- case "$1" in
- start)
- check_for_root
- start
- ;;
- stop)
- check_for_root
- stop
- ;;
- status)
- checkstatus
- RETVAL=$?
- ;;
- restart)
- check_for_root
- restart
- ;;
- condrestart|try-restart)
- check_for_root
- condrestart
- ;;
-__EOT__
-
-generate_extra_commands
-
-cat <<'__EOT__'
- esac
-}
-
-service "$1"
-
-exit $RETVAL
-__EOT__
http://git-wip-us.apache.org/repos/asf/bigtop/blob/25463a41/bigtop-packages/src/deb/hadoop/rules
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/hadoop/rules b/bigtop-packages/src/deb/hadoop/rules
index a27c205..80d870e 100755
--- a/bigtop-packages/src/deb/hadoop/rules
+++ b/bigtop-packages/src/deb/hadoop/rules
@@ -44,7 +44,7 @@ hadoop_svcs=hdfs-namenode hdfs-secondarynamenode hdfs-datanode hdfs-zkfc hdfs-jo
mapreduce-historyserver httpfs
$(hadoop_svcs): debian/init.d.tmpl
- bash $< debian/hadoop-$@.svc > debian/hadoop-$@.init
+ bash $< debian/hadoop-$@.svc deb debian/hadoop-$@.init
cp debian/$(firstword $(subst -, ,$@)).default debian/tmp/etc/default/hadoop-$@
echo /etc/default/hadoop-$@ >> debian/hadoop-$@.install
# FIXME: workaround for BIGTOP-105
http://git-wip-us.apache.org/repos/asf/bigtop/blob/25463a41/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec b/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec
index 3854156..4bdf038 100644
--- a/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec
+++ b/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec
@@ -489,13 +489,7 @@ echo 'export JSVC_HOME=%{libexecdir}/bigtop-utils' >> $RPM_BUILD_ROOT/etc/defaul
# Generate the init.d scripts
for service in %{hadoop_services}
do
- init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{name}-${service}
- # On RedHat, SuSE and Mageia run-level 2 is networkless, hence excluding it
- env CHKCONFIG="345 85 15" \
- INIT_DEFAULT_START="3 4 5" \
- INIT_DEFAULT_STOP="0 1 2 6" \
- bash $RPM_SOURCE_DIR/init.d.tmpl $RPM_SOURCE_DIR/%{name}-${service}.svc > $init_file
- chmod 755 $init_file
+ bash %{SOURCE11} $RPM_SOURCE_DIR/%{name}-${service}.svc rpm $RPM_BUILD_ROOT/%{initd_dir}/%{name}-${service}
cp $RPM_SOURCE_DIR/${service/-*/}.default $RPM_BUILD_ROOT/etc/default/%{name}-${service}
chmod 644 $RPM_BUILD_ROOT/etc/default/%{name}-${service}
done