Repository: bigtop Updated Branches: refs/heads/master 282f2a94c -> abd4db2e8
BIGTOP-1267. Add ZooKeeper REST server Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/abd4db2e Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/abd4db2e Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/abd4db2e Branch: refs/heads/master Commit: abd4db2e8680073368abb1eb9b570577d4a02655 Parents: 282f2a9 Author: Sean Mackrory <[email protected]> Authored: Mon Oct 6 08:02:39 2014 -0600 Committer: Sean Mackrory <[email protected]> Committed: Mon Oct 6 08:04:29 2014 -0600 ---------------------------------------------------------------------- .../src/common/zookeeper/ZOOKEEPER-1911.patch | 27 ++++++++ .../src/common/zookeeper/do-component-build | 8 ++- .../src/common/zookeeper/install_zookeeper.sh | 10 +++ .../src/common/zookeeper/zookeeper-rest.svc | 68 ++++++++++++++++++++ bigtop-packages/src/deb/zookeeper/control | 7 ++ bigtop-packages/src/deb/zookeeper/rules | 2 + .../src/deb/zookeeper/zookeeper-rest.postinst | 26 ++++++++ .../src/rpm/zookeeper/SPECS/zookeeper.spec | 41 +++++++++++- 8 files changed, 186 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bigtop/blob/abd4db2e/bigtop-packages/src/common/zookeeper/ZOOKEEPER-1911.patch ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/common/zookeeper/ZOOKEEPER-1911.patch b/bigtop-packages/src/common/zookeeper/ZOOKEEPER-1911.patch new file mode 100644 index 0000000..e4aceb0 --- /dev/null +++ b/bigtop-packages/src/common/zookeeper/ZOOKEEPER-1911.patch @@ -0,0 +1,27 @@ +diff --git src/contrib/rest/build.xml src/contrib/rest/build.xml +index 649dff7..fb628bc 100644 +--- src/contrib/rest/build.xml ++++ src/contrib/rest/build.xml +@@ -48,6 +48,22 @@ + </sequential> + </macrodef> + ++ <target name="package" depends="jar" unless="skip.contrib"> ++ <echo message="contrib: ${name}"/> ++ <mkdir dir="${dist.dir}${package.share}/contrib/${name}"/> ++ <copy todir="${dist.dir}${package.share}/contrib/${name}"> ++ <fileset dir="${build.dir}"> ++ <include name="zookeeper-${version}-${name}.jar" /> ++ </fileset> ++ </copy> ++ <copy todir="${dist.dir}${package.share}/contrib/${name}/lib"> ++ <fileset dir="${build.dir}/lib" /> ++ </copy> ++ <copy todir="${dist.dir}${package.share}/contrib/${name}/conf"> ++ <fileset dir="conf" /> ++ </copy> ++ </target> ++ + <target name="setjarname"> + <property name="jarname" + value="${build.dir}/zookeeper-${version}-${name}.jar"/> http://git-wip-us.apache.org/repos/asf/bigtop/blob/abd4db2e/bigtop-packages/src/common/zookeeper/do-component-build ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/common/zookeeper/do-component-build b/bigtop-packages/src/common/zookeeper/do-component-build index 1529c84..85abf3d 100644 --- a/bigtop-packages/src/common/zookeeper/do-component-build +++ b/bigtop-packages/src/common/zookeeper/do-component-build @@ -18,8 +18,14 @@ set -ex . `dirname ${0}`/bigtop.bom +# FIXME: Remove this file for ZooKeeper 3.4.7, 3.5.0 or later +patch -p0 < ZOOKEEPER-1911.patch + +ANT_OPTS="-Dversion=$ZOOKEEPER_VERSION -f build.xml $@" sed -i.orig -e 's#test-jar,api-report#test-jar#g' build.xml -ant -Dversion=$ZOOKEEPER_VERSION -f build.xml package "$@" +ant compile ${ANT_OPTS} +(cd src/contrib/rest && ant jar ${ANT_OPTS}) +ant package ${ANT_OPTS} mvn install:install-file -DcreateChecksum=true -DgroupId=org.apache.zookeeper -DartifactId=zookeeper -Dversion=$ZOOKEEPER_VERSION -Dpackaging=jar -Dfile=build/zookeeper-$ZOOKEEPER_VERSION.jar mvn install:install-file -DcreateChecksum=true -DgroupId=org.apache.zookeeper -DartifactId=zookeeper -Dversion=$ZOOKEEPER_VERSION -Dclassifier=tests -Dpackaging=jar -Dfile=build/zookeeper-$ZOOKEEPER_VERSION-test.jar http://git-wip-us.apache.org/repos/asf/bigtop/blob/abd4db2e/bigtop-packages/src/common/zookeeper/install_zookeeper.sh ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/common/zookeeper/install_zookeeper.sh b/bigtop-packages/src/common/zookeeper/install_zookeeper.sh index 8bd5073..e0edbd8 100755 --- a/bigtop-packages/src/common/zookeeper/install_zookeeper.sh +++ b/bigtop-packages/src/common/zookeeper/install_zookeeper.sh @@ -97,6 +97,10 @@ CONF_DIST_DIR=/etc/zookeeper/conf.dist/ install -d -m 0755 $PREFIX/$LIB_DIR/ rm -f $BUILD_DIR/zookeeper-*-javadoc.jar $BUILD_DIR/zookeeper-*-bin.jar $BUILD_DIR/zookeeper-*-sources.jar $BUILD_DIR/zookeeper-*-test.jar cp $BUILD_DIR/zookeeper*.jar $PREFIX/$LIB_DIR/ +install -d -m 0755 ${PREFIX}/${LIB_DIR}/contrib +for module in rest; do + cp -r ${BUILD_DIR}/contrib/${module} ${PREFIX}/${LIB_DIR}/contrib/ +done # Make a symlink of zookeeper.jar to zookeeper-version.jar for x in $PREFIX/$LIB_DIR/zookeeper*jar ; do @@ -113,6 +117,12 @@ install -d -m 0755 $PREFIX/$CONF_DIST_DIR cp zoo.cfg $BUILD_DIR/conf/* $PREFIX/$CONF_DIST_DIR/ ln -s $CONF_DIR $PREFIX/$LIB_DIR/conf +install -d -m 0755 ${PREFIX}/${LIB_DIR}/contrib +for module in rest; do + cp -r ${BUILD_DIR}/contrib/${module} ${PREFIX}/${LIB_DIR}/contrib/ + mv ${PREFIX}/${LIB_DIR}/contrib/${module}/conf ${PREFIX}/${CONF_DIST_DIR}/${module} +done + # Copy in the /usr/bin/zookeeper-server wrapper install -d -m 0755 $PREFIX/$LIB_DIR/bin # FIXME: a workaround in preparation for Zookeeper 3.5 http://git-wip-us.apache.org/repos/asf/bigtop/blob/abd4db2e/bigtop-packages/src/common/zookeeper/zookeeper-rest.svc ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/common/zookeeper/zookeeper-rest.svc b/bigtop-packages/src/common/zookeeper/zookeeper-rest.svc new file mode 100644 index 0000000..22dbf01 --- /dev/null +++ b/bigtop-packages/src/common/zookeeper/zookeeper-rest.svc @@ -0,0 +1,68 @@ +# 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="zookeeper-rest" +DESC="ZooKeeper REST Server" +SVC_USER="${ZOOKEEPER_USER:-zookeeper}" +WORKING_DIR="/var/run/zookeeper" +DAEMON_FLAGS="" +CONF_DIR="/etc/zookeeper/conf/rest" +PIDFILE="/var/run/zookeeper/zookeeper-rest-$SVC_USER.pid" + +generate_start() { + +cat <<'__EOT__' +start() { + log_success_msg "Starting ${DESC}: " + + ZOOKEEPER_HOME=${ZOOKEEPER_HOME:-/usr/lib/zookeeper} + CLASSPATH="${ZOOKEEPER_HOME}/contrib/rest/*:${ZOOKEEPER_HOME}/contrib/rest/lib/*" + CLASSPATH="${ZOOKEEPER_HOME}/*:${ZOOKEEPER_HOME}/lib/*:${CONF_DIR}:${CLASSPATH}" + CMD="${JAVA_HOME}/bin/java -cp ${CLASSPATH} org.apache.zookeeper.server.jersey.RestMain" + + LOG_FILE=/var/log/zookeeper/zookeeper-rest.out + + su -s /bin/bash -c "nohup ${CMD} > $LOG_FILE 2>&1 < /dev/null &"'echo $! '"> $PIDFILE" $SVC_USER + + [ $RETVAL -eq $RETVAL_SUCCESS ] && touch $LOCKFILE + return $RETVAL +} +__EOT__ + +} + +generate_stop() { + +cat <<'__EOT__' +stop() { + log_success_msg "Stopping ${DESC}: " + checkstatusofproc + if [ "$?" = "$STATUS_RUNNING" ] ; then + if [ -f ${PIDFILE} ]; then + PID=`cat ${PIDFILE}` + if [ -n ${PID} ]; then + kill -KILL ${PID} &>/dev/null + fi + fi + RETVAL=$? + else + RETVAL=$RETVAL_SUCCESS + fi + + [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PIDFILE +} +__EOT__ + +} http://git-wip-us.apache.org/repos/asf/bigtop/blob/abd4db2e/bigtop-packages/src/deb/zookeeper/control ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/deb/zookeeper/control b/bigtop-packages/src/deb/zookeeper/control index 6ec811c..5fd7171 100755 --- a/bigtop-packages/src/deb/zookeeper/control +++ b/bigtop-packages/src/deb/zookeeper/control @@ -31,3 +31,10 @@ Architecture: all Depends: zookeeper (= ${source:Version}) Description: The Hadoop Zookeeper server This package starts the zookeeper server on startup + +Package: zookeeper-rest +Architecture: all +Depends: zookeeper (= ${source:Version}) +Description: The Zookeeper REST server + This package starts the zookeeper REST server on startup + http://git-wip-us.apache.org/repos/asf/bigtop/blob/abd4db2e/bigtop-packages/src/deb/zookeeper/rules ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/deb/zookeeper/rules b/bigtop-packages/src/deb/zookeeper/rules index 70ec4c4..532b9ec 100755 --- a/bigtop-packages/src/deb/zookeeper/rules +++ b/bigtop-packages/src/deb/zookeeper/rules @@ -29,6 +29,7 @@ zookeeper_pkg_name=zookeeper dh $@ override_dh_auto_build: + cp debian/ZOOKEEPER-1911.patch ./ bash debian/do-component-build -Divy.home=${HOME}/.ivy2 mkdir -p debian/tmp tar cf - --exclude=debian/\* . | (cd debian/tmp && tar xf -) @@ -38,4 +39,5 @@ override_dh_auto_install: bash -x debian/install_zookeeper.sh \ --build-dir=build/zookeeper-${ZOOKEEPER_BASE_VERSION} \ --prefix=debian/$(zookeeper_pkg_name) + bash debian/init.d.tmpl debian/zookeeper-rest.svc deb debian/zookeeper-rest/etc/init.d/zookeeper-rest dh_install -i http://git-wip-us.apache.org/repos/asf/bigtop/blob/abd4db2e/bigtop-packages/src/deb/zookeeper/zookeeper-rest.postinst ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/deb/zookeeper/zookeeper-rest.postinst b/bigtop-packages/src/deb/zookeeper/zookeeper-rest.postinst new file mode 100644 index 0000000..5798929 --- /dev/null +++ b/bigtop-packages/src/deb/zookeeper/zookeeper-rest.postinst @@ -0,0 +1,26 @@ +#!/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. + +set -e +if [ -x "/etc/init.d/zookeeper-rest" ]; then + update-rc.d zookeeper-rest defaults >/dev/null + if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then + invoke-rc.d zookeeper-rest start || : + else + /etc/init.d/zookeeper-rest start || : + fi +fi + http://git-wip-us.apache.org/repos/asf/bigtop/blob/abd4db2e/bigtop-packages/src/rpm/zookeeper/SPECS/zookeeper.spec ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/rpm/zookeeper/SPECS/zookeeper.spec b/bigtop-packages/src/rpm/zookeeper/SPECS/zookeeper.spec index 44e834a..3ba6dd7 100644 --- a/bigtop-packages/src/rpm/zookeeper/SPECS/zookeeper.spec +++ b/bigtop-packages/src/rpm/zookeeper/SPECS/zookeeper.spec @@ -19,6 +19,7 @@ %define run_zookeeper /var/run/%{name} %define vlb_zookeeper /var/lib/%{name} %define svc_zookeeper %{name}-server +%define svc_zookeeper_rest %{name}-rest %define man_dir %{_mandir} %if %{?suse_version:1}0 @@ -75,6 +76,9 @@ Source4: zookeeper-server.sh.suse Source5: zookeeper.1 Source6: zoo.cfg Source7: zookeeper.default +Source8: init.d.tmpl +Source9: zookeeper-rest.svc +Source10: ZOOKEEPER-1911.patch BuildArch: noarch BuildRequires: autoconf, automake Requires(pre): coreutils, /usr/sbin/groupadd, /usr/sbin/useradd @@ -122,10 +126,22 @@ Requires: redhat-lsb %description server This package starts the zookeeper server on startup +%package rest +Summary: ZooKeeper REST Server +Group: System/Daemons +Requires: %{name} = %{version}-%{release} +Requires(pre): %{name} = %{version}-%{release} +Requires(post): %{chkconfig_dep} +Requires(preun): %{service_dep}, %{chkconfig_dep} + +%description rest +This package starts the zookeeper REST server on startup + %prep %setup -n %{name}-%{zookeeper_base_version} %build +cp $RPM_SOURCE_DIR/ZOOKEEPER-1911.patch ./ bash %{SOURCE1} %install @@ -147,6 +163,9 @@ init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{svc_zookeeper} %__cp $orig_init_file $init_file chmod 755 $init_file +# Install Zookeeper REST server init script +init_file=$RPM_BUILD_ROOT/%{initd_dir}/zookeeper-rest +bash $RPM_SOURCE_DIR/init.d.tmpl $RPM_SOURCE_DIR/zookeeper-rest.svc rpm $init_file %pre getent group zookeeper >/dev/null || groupadd -r zookeeper @@ -179,8 +198,19 @@ if [ $1 -ge 1 ]; then service %{svc_zookeeper} condrestart > /dev/null 2>&1 fi -%files server - %attr(0755,root,root) %{initd_dir}/%{svc_zookeeper} +%post rest + chkconfig --add %{svc_zookeeper_rest} + +%preun rest +if [ $1 = 0 ] ; then + service %{svc_zookeeper_rest} stop > /dev/null 2>&1 + chkconfig --del %{svc_zookeeper_rest} +fi + +%postun rest +if [ $1 -ge 1 ]; then + service %{svc_zookeeper_rest} condrestart > /dev/null 2>&1 +fi ####################### #### FILES SECTION #### @@ -196,3 +226,10 @@ fi %{bin_zookeeper}/zookeeper-server-cleanup %doc %{doc_zookeeper} %{man_dir}/man1/zookeeper.1.* + +%files server +%attr(0755,root,root) %{initd_dir}/%{svc_zookeeper} + +%files rest +%attr(0755,root,root) %{initd_dir}/%{svc_zookeeper_rest} +
