incubator-bigtop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bm...@apache.org
Subject svn commit: r1201178 - in /incubator/bigtop/branches/hadoop-0.23/bigtop-packages/src/rpm/hadoop: SOURCES/yarn-init.tmpl SPECS/hadoop.spec
Date Sat, 12 Nov 2011 03:43:38 GMT
Author: bmahe
Date: Sat Nov 12 03:43:38 2011
New Revision: 1201178

URL: http://svn.apache.org/viewvc?rev=1201178&view=rev
Log:
BIGTOP-254. Add working init scripts for yarn services

Added:
    incubator/bigtop/branches/hadoop-0.23/bigtop-packages/src/rpm/hadoop/SOURCES/yarn-init.tmpl
Modified:
    incubator/bigtop/branches/hadoop-0.23/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec

Added: incubator/bigtop/branches/hadoop-0.23/bigtop-packages/src/rpm/hadoop/SOURCES/yarn-init.tmpl
URL: http://svn.apache.org/viewvc/incubator/bigtop/branches/hadoop-0.23/bigtop-packages/src/rpm/hadoop/SOURCES/yarn-init.tmpl?rev=1201178&view=auto
==============================================================================
--- incubator/bigtop/branches/hadoop-0.23/bigtop-packages/src/rpm/hadoop/SOURCES/yarn-init.tmpl
(added)
+++ incubator/bigtop/branches/hadoop-0.23/bigtop-packages/src/rpm/hadoop/SOURCES/yarn-init.tmpl
Sat Nov 12 03:43:38 2011
@@ -0,0 +1,173 @@
+#!/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 Yarn @YARN_DAEMON@
+#
+# chkconfig: 345 85 15
+# description: Yarn @YARN_DAEMON@
+#
+### BEGIN INIT INFO
+# Provides:          yarn-@YARN_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: Hadoop @YARN_DAEMON@
+### END INIT INFO
+
+. /lib/lsb/init-functions
+. /etc/default/yarn
+
+# Autodetect JAVA_HOME if not defined
+if [ -e /usr/libexec/bigtop-detect-javahome ]; then
+  . /usr/libexec/bigtop-detect-javahome
+elif [ -e /usr/lib/bigtop-utils/bigtop-detect-javahome ]; then
+  . /usr/lib/bigtop-utils/bigtop-detect-javahome
+fi
+
+. /usr/libexec/yarn-config.sh 
+
+# FIXME: this needs to be removed once yarn-config.sh stop clobbering YARN_HOME
+. /etc/default/hadoop
+. /etc/default/yarn
+
+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
+EXEC_PATH=@YARN_COMMON_ROOT@/bin/yarn-daemon.sh
+CONFIG_PATH="@YARN_CONF_DIR@"
+YARN_PID_DIR=${YARN_PID_DIR:-/var/run/yarn}
+PIDFILE="$YARN_PID_DIR/yarn-$YARN_IDENT_STRING-@YARN_DAEMON@.pid"
+LOCKFILE="/var/lock/subsys/yarn-@YARN_DAEMON@"
+desc="Hadoop @YARN_DAEMON@ daemon"
+SLEEP_TIME=5
+
+start() {
+  [ -x $exec ] || exit $ERROR_PROGRAM_NOT_INSTALLED
+  [ -f $config ] || exit $ERROR_PROGRAM_NOT_CONFIGURED
+  log_success_msg "Starting $desc (yarn-@YARN_DAEMON@): "
+
+  su -s /bin/bash $YARN_IDENT_STRING -c "$EXEC_PATH --config '$CONFIG_PATH' start @YARN_DAEMON@
$DAEMON_FLAGS"
+
+  # Some processes are slow to start
+  sleep $SLEEP_TIME
+  checkstatusofproc
+  RETVAL=$?
+
+  [ $RETVAL -eq $RETVAL_SUCCESS ] && touch $LOCKFILE
+  return $RETVAL
+}
+
+stop() {
+  log_success_msg "Stopping $desc (yarn-@YARN_DAEMON@): "
+  start_daemon $EXEC_PATH --config "$CONFIG_PATH" stop @YARN_DAEMON@
+  RETVAL=$?
+
+  [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PIDFILE
+}
+
+restart() {
+  stop
+  start
+}
+
+
+checkstatusofproc(){
+  PROC_NAME="su"
+  pidofproc -p $PIDFILE $PROC_NAME > /dev/null
+}
+
+checkstatus(){
+  checkstatusofproc
+  status=$?
+
+  case "$status" in
+    $STATUS_RUNNING)
+      log_success_msg "@YARN_DAEMON@ is running"
+      ;;
+    $STATUS_DEAD)
+      log_failure_msg "@YARN_DAEMON@ is dead and pid file exists"
+      ;;
+    $STATUS_DEAD_AND_LOCK)
+      log_failure_msg "@YARN_DAEMON@ is dead and lock file exists"
+      ;;
+    $STATUS_NOT_RUNNING)
+      log_failure_msg "@YARN_DAEMON@ is not running"
+      ;;
+    *)
+      log_failure_msg "@YARN_DAEMON@ 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
+}
+
+yarnservice() {
+  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
+      ;;
+    *)
+      echo $"Usage: $0 {start|stop|status|restart|try-restart|condrestart}"
+      exit 1
+  esac
+}
+
+yarnservice "$1"
+
+exit $RETVAL

Modified: incubator/bigtop/branches/hadoop-0.23/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec
URL: http://svn.apache.org/viewvc/incubator/bigtop/branches/hadoop-0.23/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec?rev=1201178&r1=1201177&r2=1201178&view=diff
==============================================================================
--- incubator/bigtop/branches/hadoop-0.23/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec
(original)
+++ incubator/bigtop/branches/hadoop-0.23/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec
Sat Nov 12 03:43:38 2011
@@ -30,11 +30,12 @@
 %define lib_hadoop %{lib_hadoop_dirname}/%{name}
 %define log_hadoop_dirname /var/log
 %define log_hadoop %{log_hadoop_dirname}/%{name}
+%define log_yarn %{log_hadoop_dirname}/yarn
 %define bin_hadoop %{_bindir}
 %define man_hadoop %{_mandir}
 %define doc_hadoop %{_docdir}/%{name}-%{hadoop_version}
-%define hadoop_username mapred
-%define hadoop_services namenode secondarynamenode datanode jobtracker tasktracker
+%define hadoop_services namenode secondarynamenode datanode
+%define yarn_services resourcemanager nodemanager historyserver
 # Hadoop outputs built binaries into %{hadoop_build}
 %define hadoop_build_path build
 %define static_images_dir src/webapps/static/images
@@ -123,6 +124,7 @@ Source6: hadoop.1
 Source7: hadoop-fuse-dfs.1
 Source8: hadoop-fuse.default
 Source9: hadoop.nofiles.conf
+Source10: yarn-init.tmpl
 Patch0: HADOOP-7787.patch
 Patch1: HADOOP-7801.patch
 Patch2: HADOOP-7802.patch
@@ -220,22 +222,36 @@ The Data Nodes in the Hadoop Cluster are
 blocks of data over the network to Hadoop Distributed Filesystem
 (HDFS) clients.
 
+%package resourcemanager
+Summary: Yarn Resource Manager
+Group: System/Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description resourcemanager
+The resource manager manages the global assignment of compute resources to applications
 
-%package tasktracker
-Summary: Hadoop Task Tracker
+%package nodemanager
+Summary: Yarn Node Manager
 Group: System/Daemons
 Requires: %{name} = %{version}-%{release}
 
-%description tasktracker
-The tasktracker has a fixed number of work slots.  The jobtracker
-assigns MapReduce work to the tasktracker that is nearest the data
-with an available work slot.
+%description nodemanager
+The NodeManager is the per-machine framework agent who is responsible for
+containers, monitoring their resource usage (cpu, memory, disk, network) and
+reporting the same to the ResourceManager/Scheduler.
 
+%package historyserver
+Summary: Yarn History Server
+Group: System/Daemons
+Requires: %{name} = %{version}-%{release}
+
+%description historyserver
+The History server keeps records of the different activities being performed on a Apache
Hadoop cluster
 
 %package conf-pseudo
 Summary: Hadoop installation in pseudo-distributed mode
 Group: System/Daemons
-Requires: %{name} = %{version}-%{release}, %{name}-namenode = %{version}-%{release}, %{name}-datanode
= %{version}-%{release}, %{name}-secondarynamenode = %{version}-%{release}, %{name}-tasktracker
= %{version}-%{release}, %{name}-jobtracker = %{version}-%{release}
+Requires: %{name} = %{version}-%{release}, %{name}-namenode = %{version}-%{release}, %{name}-datanode
= %{version}-%{release}, %{name}-secondarynamenode = %{version}-%{release}, %{name}-resourcemanager
= %{version}-%{release}, %{name}-nodemanager = %{version}-%{release}, %{name}-historyserver
= %{version}-%{release}
 
 %description conf-pseudo
 Installation of this RPM will setup your machine to run in pseudo-distributed mode
@@ -325,6 +341,8 @@ orig_init_file=$RPM_SOURCE_DIR/hadoop-in
 orig_init_file=$RPM_SOURCE_DIR/hadoop-init.tmpl
 %endif
 
+yarn_orig_init_file=$RPM_SOURCE_DIR/yarn-init.tmpl
+
 # Generate the init.d scripts
 for service in %{hadoop_services}
 do
@@ -333,19 +351,21 @@ do
        %__sed -i -e 's|@HADOOP_COMMON_ROOT@|%{lib_hadoop}|' $init_file
        %__sed -i -e "s|@HADOOP_DAEMON@|${service}|" $init_file
        %__sed -i -e 's|@HADOOP_CONF_DIR@|%{config_hadoop}|' $init_file
-
-
-       case "$service" in
-         hadoop_services|namenode|secondarynamenode|datanode)
-             %__sed -i -e 's|@HADOOP_DAEMON_USER@|hdfs|' $init_file
-             ;;
-         jobtracker|tasktracker)
-             %__sed -i -e 's|@HADOOP_DAEMON_USER@|mapred|' $init_file
-             ;;
-       esac
-
+       %__sed -i -e 's|@HADOOP_DAEMON_USER@|hdfs|' $init_file
+       chmod 755 $init_file
+done
+for service in %{yarn_services}
+do
+       init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{name}-${service}
+       %__cp $yarn_orig_init_file $init_file
+       %__sed -i -e 's|@YARN_COMMON_ROOT@|%{lib_hadoop}|' $init_file
+       %__sed -i -e "s|@YARN_DAEMON@|${service}|" $init_file
+       %__sed -i -e 's|@YARN_CONF_DIR@|%{config_yarn}|' $init_file
+       %__sed -i -e 's|@YARN_DAEMON_USER@|yarn|' $init_file
        chmod 755 $init_file
 done
+
+
 %__install -d -m 0755 $RPM_BUILD_ROOT/etc/default
 %__cp $RPM_SOURCE_DIR/hadoop.default $RPM_BUILD_ROOT/etc/default/hadoop
 %__cp $RPM_SOURCE_DIR/yarn.default $RPM_BUILD_ROOT/etc/default/yarn
@@ -359,16 +379,16 @@ done
 # /var/log/hadoop
 %__install -d -m 0755 $RPM_BUILD_ROOT/var/log
 %__install -d -m 0775 $RPM_BUILD_ROOT/var/run/%{name}
+%__install -d -m 0775 $RPM_BUILD_ROOT/var/run/yarn
 %__install -d -m 0775 $RPM_BUILD_ROOT/%{log_hadoop}
+%__install -d -m 0775 $RPM_BUILD_ROOT/%{log_yarn}
 
 
 %pre
 getent group hadoop >/dev/null || groupadd -r hadoop
 getent group hdfs >/dev/null   || groupadd -r hdfs
-getent group mapred >/dev/null || groupadd -r mapred
 getent group yarn >/dev/null   || groupadd -r yarn
 
-getent passwd mapred >/dev/null || /usr/sbin/useradd --comment "Hadoop MapReduce" --shell
/bin/bash -M -r -g mapred -G hadoop --home %{lib_hadoop} mapred
 getent passwd hdfs >/dev/null || /usr/sbin/useradd --comment "Hadoop HDFS" --shell /bin/bash
-M -r -g hdfs -G hadoop --home %{lib_hadoop} hdfs
 getent passwd yarn >/dev/null || /usr/sbin/useradd --comment "Hadoop Yarn" --shell /bin/bash
-M -r -g yarn -G hadoop --home %{lib_hadoop} yarn
 
@@ -418,6 +438,8 @@ fi
 %{bin_hadoop}/mapred
 %attr(0775,root,hadoop) /var/run/%{name}
 %attr(0775,root,hadoop) %{log_hadoop}
+%attr(0775,root,hadoop) /var/run/yarn
+%attr(0775,root,hadoop) %{log_yarn}
 %{man_hadoop}/man1/hadoop.1.*
 
 %exclude %{lib_hadoop}/sbin
@@ -448,8 +470,9 @@ fi
 %service_macro namenode
 %service_macro secondarynamenode
 %service_macro datanode
-%service_macro jobtracker
-%service_macro tasktracker
+%service_macro resourcemanager
+%service_macro nodemanager
+%service_macro historyserver
 
 # Pseudo-distributed Hadoop installation
 %post conf-pseudo



Mime
View raw message