diff --git build.xml build.xml index 86b1fd9..067086a 100644 --- build.xml +++ build.xml @@ -426,6 +426,21 @@ + + + + + + + + + + + + + + + @@ -446,7 +461,15 @@ - + + + + + + + + + diff --git conf/templeton-default.xml conf/templeton-default.xml deleted file mode 100644 index bdd86d0..0000000 --- conf/templeton-default.xml +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - - - - - templeton.port - 50111 - The HTTP port for the main server. - - - - templeton.hadoop.conf.dir - ${env.HADOOP_CONF_DIR} - The path to the Hadoop configuration. - - - - templeton.jar - ${env.TEMPLETON_HOME}/templeton-0.1.0-dev.jar - The path to the Templeton jar file. - - - - templeton.libjars - ${env.TEMPLETON_HOME}/lib/zookeeper-3.3.4.jar - Jars to add to the classpath. - - - - templeton.override.jars - hdfs:///user/templeton/ugi.jar - - Jars to add the the HADOOP_CLASSPATH for all Map Reduce jobs. - This is a list of jars that must exist on hdfs that are added - to the Distributed Cache. - - - - - templeton.override.enabled - true - - Enable the override path in templeton.override.jars - - - - - templeton.streaming.jar - hdfs:///user/templeton/hadoop-streaming.jar - The hdfs path to the Hadoop streaming jar file. - - - - templeton.hadoop - ${env.HADOOP_PREFIX}/bin/hadoop - The path to the Hadoop executable. - - - - templeton.pig.archive - hdfs:///user/templeton/pig-0.9.2.tar.gz - The path to the Pig archive. - - - - templeton.pig.path - pig-0.9.2.tar.gz/pig-0.9.2/bin/pig - The path to the Pig executable. - - - - templeton.hcat - ${env.HCAT_PREFIX}/bin/hcat - The path to the hcatalog executable. - - - - templeton.hive.archive - hdfs:///user/templeton/hcatalog-0.3.0.tar.gz - The path to the Hive archive. - - - - templeton.hive.path - hcatalog-0.3.0.tar.gz/hcatalog-0.3.0/bin/hive - The path to the Hive executable. - - - - templeton.hive.properties - hive.metastore.local=false,hive.metastore.uris=thrift://localhost:9933,hive.metastore.sasl.enabled=false - Properties to set when running hive. - - - - templeton.exec.encoding - UTF-8 - The encoding of the stdout and stderr data. - - - - templeton.exec.timeout - 10000 - - How long in milliseconds a program is allowed to run on the - Templeton box. - - - - - templeton.exec.max-procs - 16 - The maximum number of processes allowed to run at once. - - - - templeton.exec.max-output-bytes - 1048576 - - The maximum number of bytes from stdout or stderr stored in ram. - - - - - templeton.exec.envs - HADOOP_PREFIX,HADOOP_HOME,JAVA_HOME - The environment variables passed through to exec. - - - - templeton.zookeeper.hosts - 127.0.0.1:2181 - ZooKeeper servers, as comma separated host:port pairs - - - - templeton.zookeeper.session-timeout - 30000 - ZooKeeper session timeout in milliseconds - - - - templeton.callback.retry.interval - 10000 - How long to wait between callback retry attempts in milliseconds - - - - templeton.callback.retry.attempts - 5 - How many times to retry the callback - - - - templeton.storage.class - org.apache.hcatalog.templeton.tool.HDFSStorage - The class to use as storage - - - - templeton.storage.root - /templeton-hadoop - The path to the directory to use for storage - - - - templeton.hdfs.cleanup.interval - 43200000 - The maximum delay between a thread's cleanup checks - - - - templeton.hdfs.cleanup.maxage - 604800000 - The maximum age of a templeton job - - - - templeton.zookeeper.cleanup.interval - 43200000 - The maximum delay between a thread's cleanup checks - - - - templeton.zookeeper.cleanup.maxage - 604800000 - The maximum age of a templeton job - - - diff --git conf/templeton-log4j.properties conf/templeton-log4j.properties deleted file mode 100644 index aa10199..0000000 --- conf/templeton-log4j.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# templeton-log4j - configure the Templeton logging system - -# Define some default values that can be overridden by system properties -templeton.root.logger = DEBUG, standard -templeton.log.dir = . -templeton.log.file = templeton.log - -log4j.rootLogger = ${templeton.root.logger} - -# Logging Threshold -log4j.threshhold = DEBUG - -log4j.appender.standard = org.apache.log4j.DailyRollingFileAppender -log4j.appender.standard.File = ${templeton.log.dir}/${templeton.log.file} - -# Rollver at midnight -log4j.appender.DRFA.DatePattern = .yyyy-MM-dd - -log4j.appender.DRFA.layout = org.apache.log4j.PatternLayout - -log4j.appender.standard.layout = org.apache.log4j.PatternLayout -log4j.appender.standard.layout.conversionPattern = %-5p | %d{DATE} | %c | %m%n - -# Class logging settings -log4j.logger.com.sun.jersey = DEBUG -log4j.logger.com.sun.jersey.spi.container.servlet.WebComponent = ERROR -log4j.logger.org.apache.hadoop = INFO -log4j.logger.org.apache.hadoop.conf = WARN -log4j.logger.org.apache.zookeeper = WARN -log4j.logger.org.eclipse.jetty = INFO diff --git conf/webhcat-default.xml conf/webhcat-default.xml new file mode 100644 index 0000000..bdd86d0 --- /dev/null +++ conf/webhcat-default.xml @@ -0,0 +1,211 @@ + + + + + + + + + + + templeton.port + 50111 + The HTTP port for the main server. + + + + templeton.hadoop.conf.dir + ${env.HADOOP_CONF_DIR} + The path to the Hadoop configuration. + + + + templeton.jar + ${env.TEMPLETON_HOME}/templeton-0.1.0-dev.jar + The path to the Templeton jar file. + + + + templeton.libjars + ${env.TEMPLETON_HOME}/lib/zookeeper-3.3.4.jar + Jars to add to the classpath. + + + + templeton.override.jars + hdfs:///user/templeton/ugi.jar + + Jars to add the the HADOOP_CLASSPATH for all Map Reduce jobs. + This is a list of jars that must exist on hdfs that are added + to the Distributed Cache. + + + + + templeton.override.enabled + true + + Enable the override path in templeton.override.jars + + + + + templeton.streaming.jar + hdfs:///user/templeton/hadoop-streaming.jar + The hdfs path to the Hadoop streaming jar file. + + + + templeton.hadoop + ${env.HADOOP_PREFIX}/bin/hadoop + The path to the Hadoop executable. + + + + templeton.pig.archive + hdfs:///user/templeton/pig-0.9.2.tar.gz + The path to the Pig archive. + + + + templeton.pig.path + pig-0.9.2.tar.gz/pig-0.9.2/bin/pig + The path to the Pig executable. + + + + templeton.hcat + ${env.HCAT_PREFIX}/bin/hcat + The path to the hcatalog executable. + + + + templeton.hive.archive + hdfs:///user/templeton/hcatalog-0.3.0.tar.gz + The path to the Hive archive. + + + + templeton.hive.path + hcatalog-0.3.0.tar.gz/hcatalog-0.3.0/bin/hive + The path to the Hive executable. + + + + templeton.hive.properties + hive.metastore.local=false,hive.metastore.uris=thrift://localhost:9933,hive.metastore.sasl.enabled=false + Properties to set when running hive. + + + + templeton.exec.encoding + UTF-8 + The encoding of the stdout and stderr data. + + + + templeton.exec.timeout + 10000 + + How long in milliseconds a program is allowed to run on the + Templeton box. + + + + + templeton.exec.max-procs + 16 + The maximum number of processes allowed to run at once. + + + + templeton.exec.max-output-bytes + 1048576 + + The maximum number of bytes from stdout or stderr stored in ram. + + + + + templeton.exec.envs + HADOOP_PREFIX,HADOOP_HOME,JAVA_HOME + The environment variables passed through to exec. + + + + templeton.zookeeper.hosts + 127.0.0.1:2181 + ZooKeeper servers, as comma separated host:port pairs + + + + templeton.zookeeper.session-timeout + 30000 + ZooKeeper session timeout in milliseconds + + + + templeton.callback.retry.interval + 10000 + How long to wait between callback retry attempts in milliseconds + + + + templeton.callback.retry.attempts + 5 + How many times to retry the callback + + + + templeton.storage.class + org.apache.hcatalog.templeton.tool.HDFSStorage + The class to use as storage + + + + templeton.storage.root + /templeton-hadoop + The path to the directory to use for storage + + + + templeton.hdfs.cleanup.interval + 43200000 + The maximum delay between a thread's cleanup checks + + + + templeton.hdfs.cleanup.maxage + 604800000 + The maximum age of a templeton job + + + + templeton.zookeeper.cleanup.interval + 43200000 + The maximum delay between a thread's cleanup checks + + + + templeton.zookeeper.cleanup.maxage + 604800000 + The maximum age of a templeton job + + + diff --git conf/webhcat-log4j.properties conf/webhcat-log4j.properties new file mode 100644 index 0000000..aa10199 --- /dev/null +++ conf/webhcat-log4j.properties @@ -0,0 +1,31 @@ +# +# templeton-log4j - configure the Templeton logging system + +# Define some default values that can be overridden by system properties +templeton.root.logger = DEBUG, standard +templeton.log.dir = . +templeton.log.file = templeton.log + +log4j.rootLogger = ${templeton.root.logger} + +# Logging Threshold +log4j.threshhold = DEBUG + +log4j.appender.standard = org.apache.log4j.DailyRollingFileAppender +log4j.appender.standard.File = ${templeton.log.dir}/${templeton.log.file} + +# Rollver at midnight +log4j.appender.DRFA.DatePattern = .yyyy-MM-dd + +log4j.appender.DRFA.layout = org.apache.log4j.PatternLayout + +log4j.appender.standard.layout = org.apache.log4j.PatternLayout +log4j.appender.standard.layout.conversionPattern = %-5p | %d{DATE} | %c | %m%n + +# Class logging settings +log4j.logger.com.sun.jersey = DEBUG +log4j.logger.com.sun.jersey.spi.container.servlet.WebComponent = ERROR +log4j.logger.org.apache.hadoop = INFO +log4j.logger.org.apache.hadoop.conf = WARN +log4j.logger.org.apache.zookeeper = WARN +log4j.logger.org.eclipse.jetty = INFO diff --git webhcat/svr/src/main/bin/templeton_config.sh webhcat/svr/src/main/bin/templeton_config.sh deleted file mode 100644 index fff987e..0000000 --- webhcat/svr/src/main/bin/templeton_config.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env 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. - -#==================================== -#Default config param values -#==================================== - -# The file containing the running pid -PID_FILE=./templeton.pid - -#default log directory -TEMPLETON_LOG_DIR=${TEMPLETON_LOG_DIR:-.} - -# The console error log -ERROR_LOG=${TEMPLETON_LOG_DIR}/templeton-console-error.log - -# The console log -CONSOLE_LOG=${TEMPLETON_LOG_DIR}/templeton-console.log - -# The name of the templeton jar file -TEMPLETON_JAR=webhcat-0.5.0-SNAPSHOT.jar - -# How long to wait before testing that the process started correctly -SLEEP_TIME_AFTER_START=10 - -#================================================ -#See if the default configs have been overwritten -#================================================ - -#These parameters can be overriden by templeton-env.sh -# the root of the TEMPLETON installation -export TEMPLETON_PREFIX=`dirname "$this"`/.. - -#check to see if the conf dir is given as an optional argument -if [ $# -gt 1 ] -then - if [ "--config" = "$1" ] - then - shift - confdir=$1 - shift - TEMPLETON_CONF_DIR=$confdir - fi -fi - -# Allow alternate conf dir location. -if [ -e "${TEMPLETON_PREFIX}/conf/templeton-env.sh" ]; then - DEFAULT_CONF_DIR=${TEMPLETON_PREFIX}/"conf" -else - DEFAULT_CONF_DIR="/etc/hcatalog" -fi -TEMPLETON_CONF_DIR="${TEMPLETON_CONF_DIR:-$DEFAULT_CONF_DIR}" - -#users can add various env vars to templeton-env.sh in the conf -#rather than having to export them before running the command -if [ -f "${TEMPLETON_CONF_DIR}/templeton-env.sh" ]; then - . "${TEMPLETON_CONF_DIR}/templeton-env.sh" -fi - -#==================================== -#determine where hadoop is -#==================================== - -#check HADOOP_HOME and then check HADOOP_PREFIX -if [ -f ${HADOOP_HOME}/bin/hadoop ]; then - HADOOP_PREFIX=$HADOOP_HOME -#if this is an rpm install check for /usr/bin/hadoop -elif [ -f ${TEMPLETON_PREFIX}/bin/hadoop ]; then - HADOOP_PREFIX=$TEMPLETON_PREFIX -#otherwise see if HADOOP_PREFIX is defined -elif [ ! -f ${HADOOP_PREFIX}/bin/hadoop ]; then - echo "Hadoop not found." - exit 1 -fi - - - - - diff --git webhcat/svr/src/main/bin/templeton_server.sh webhcat/svr/src/main/bin/templeton_server.sh deleted file mode 100755 index c50c59c..0000000 --- webhcat/svr/src/main/bin/templeton_server.sh +++ /dev/null @@ -1,237 +0,0 @@ -#!/usr/bin/env 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. - -# -# Support functions -# - -# Follow symlinks on Linux and Darwin -function real_script_name() { - local base=$1 - local real - if readlink -f $base >/dev/null 2>&1; then - # Darwin/Mac OS X - real=`readlink -f $base` - fi - if [[ "$?" != "0" || -z "$real" ]]; then - # Linux - local bin=$(cd -P -- "$(dirname -- "$base")">/dev/null && pwd -P) - local script="$(basename -- "$base")" - real="$bin/$script" - fi - echo "$real" -} - -function usage() { - echo "usage: $0 [start|stop|foreground]" - echo " start Start the Templeton Server" - echo " stop Stop the Templeton Server" - echo " foreground Run the Templeton Server in the foreground" - exit 1 -} - -# Print an error message and exit -function die() { - echo "templeton: $@" 1>&2 - exit 1 -} - -# Print an message -function log() { - echo "templeton: $@" -} - -# Find the templeton jar -function find_jar_path() { - for dir in "." "build" "share/hcatalog/"; do - local jar="$base_dir/$dir/$TEMPLETON_JAR" - if [[ -f $jar ]]; then - echo $jar - break - fi - done -} - -# Find the templeton classpath -function find_classpath() { - local classpath="" - for dir in "share/hcatalog" "build/ivy/lib/templeton" "conf" ; do - local path="$base_dir/$dir" - - if [[ -d $path ]]; then - for jar_or_conf in $path/*; do - if [[ -z "$classpath" ]]; then - classpath="$jar_or_conf" - else - classpath="$classpath:$jar_or_conf" - fi - done - fi - done - - if [[ -n "$TEMPLETON_CONF_DIR" ]]; then - if [[ -z "$classpath" ]]; then - classpath="$TEMPLETON_CONF_DIR" - else - classpath="$classpath:$TEMPLETON_CONF_DIR" - fi - fi - - # Append hcat classpath - local hcat_classpath - hcat_classpath=`hcat -classpath` - if [[ "$?" != "0" ]]; then - die "Unable to get the hcatalog classpath" - fi - echo "$classpath:$hcat_classpath" -} - -# Check if the pid is running -function check_pid() { - local pid=$1 - if ps -p $pid > /dev/null; then - return 0 - else - return 1 - fi -} - -# Start the templeton server in the foreground -function foreground_templeton() { - $start_cmd -} - -# Start the templeton server in the background. Record the PID for -# later use. -function start_templeton() { - if [[ -f $PID_FILE ]]; then - # Check if there is a server running - local pid=`cat $PID_FILE` - if check_pid $pid; then - die "already running on process $pid" - fi - fi - - log "starting ..." - log "$start_cmd" - nohup $start_cmd >>$CONSOLE_LOG 2>>$ERROR_LOG & - local pid=$! - - if [[ -z "${pid}" ]] ; then # we failed right off - die "failed to start. Check logs in " `dirname $ERROR_LOG` - fi - - sleep $SLEEP_TIME_AFTER_START - - if check_pid $pid; then - echo $pid > $PID_FILE - log "starting ... started." - else - die "failed to start. Check logs in " `dirname $ERROR_LOG` - fi -} - -# Stop a running server -function stop_templeton() { - local pid - if [[ -f $PID_FILE ]]; then - # Check if there is a server running - local check=`cat $PID_FILE` - if check_pid $check; then - pid=$check - fi - fi - - if [[ -z "$pid" ]]; then - log "no running server found" - else - log "stopping ..." - kill $pid - sleep $SLEEP_TIME_AFTER_START - if check_pid $pid; then - die "failed to stop" - else - log "stopping ... stopped" - fi - fi -} - -# -# Build command line and run -# - -this=`real_script_name "${BASH_SOURCE-$0}"` -this_bin=`dirname $this` -base_dir="$this_bin/.." - -if [[ -f "$base_dir/libexec/templeton_config.sh" ]]; then - . "$base_dir/libexec/templeton_config.sh" -else - . "$this_bin/templeton_config.sh" -fi - -JAR=`find_jar_path` -if [[ -z "$JAR" ]]; then - die "No templeton jar found" -fi - -CLASSPATH=`find_classpath` -if [[ -z "$CLASSPATH" ]]; then - die "No classpath or jars found" -fi -CLASSPATH="$JAR:$CLASSPATH" - -if [[ -z "$HADOOP_CLASSPATH" ]]; then - export HADOOP_CLASSPATH="$CLASSPATH" -else - export HADOOP_CLASSPATH="$CLASSPATH:$HADOOP_CLASSPATH" -fi - -if [[ -z "$TEMPLETON_LOG4J" ]]; then - if [[ -f "$base_dir/conf/templeton-log4j.properties" ]]; then - TEMPLETON_LOG4J="$base_dir/conf/templeton-log4j.properties"; - elif [[ -f "$base_dir/conf/templeton-log4j.properties" ]]; then - TEMPLETON_LOG4J="$base_dir/conf/templeton-log4j.properties"; - else - TEMPLETON_LOG4J="templeton-log4j.properties"; - fi -fi - -export HADOOP_USER_CLASSPATH_FIRST=true -export HADOOP_OPTS="-Dtempleton.log.dir=$TEMPLETON_LOG_DIR -Dlog4j.configuration=$TEMPLETON_LOG4J" - -start_cmd="$HADOOP_PREFIX/bin/hadoop jar $JAR org.apache.hcatalog.templeton.Main " - - -cmd=$1 -case $cmd in - start) - start_templeton - ;; - stop) - stop_templeton - ;; - foreground) - foreground_templeton - ;; - *) - usage - ;; -esac - -log "done" diff --git webhcat/svr/src/main/bin/webhcat_config.sh webhcat/svr/src/main/bin/webhcat_config.sh new file mode 100755 index 0000000..90f4f79 --- /dev/null +++ webhcat/svr/src/main/bin/webhcat_config.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env 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. + +#==================================== +#Default config param values +#==================================== + +# The file containing the running pid +PID_FILE=./webhcat.pid + +#default log directory +WEBHCAT_LOG_DIR=${WEBHCAT_LOG_DIR:-.} + +# The console error log +ERROR_LOG=${WEBHCAT_LOG_DIR}/webhcat-console-error.log + +# The console log +CONSOLE_LOG=${WEBHCAT_LOG_DIR}/webhcat-console.log + +# The name of the webhcat jar file +WEBHCAT_JAR=webhcat-0.5.0-SNAPSHOT.jar + +# How long to wait before testing that the process started correctly +SLEEP_TIME_AFTER_START=10 + +#================================================ +#See if the default configs have been overwritten +#================================================ + +#These parameters can be overriden by webhcat-env.sh +# the root of the WEBHCAT installation +export WEBHCAT_PREFIX=`dirname "$this"`/.. + +#check to see if the conf dir is given as an optional argument +if [ $# -gt 1 ] +then + if [ "--config" = "$1" ] + then + shift + confdir=$1 + shift + WEBHCAT_CONF_DIR=$confdir + fi +fi + +# Allow alternate conf dir location. +if [ -e "${WEBHCAT_PREFIX}/etc/webhcat/webhcat-env.sh" ]; then + DEFAULT_CONF_DIR=${WEBHCAT_PREFIX}/"etc/webhcat" +else + DEFAULT_CONF_DIR="/etc/webhcat" +fi +WEBHCAT_CONF_DIR="${WEBHCAT_CONF_DIR:-$DEFAULT_CONF_DIR}" + +#users can add various env vars to webhcat-env.sh in the conf +#rather than having to export them before running the command +if [ -f "${WEBHCAT_CONF_DIR}/webhcat-env.sh" ]; then + . "${WEBHCAT_CONF_DIR}/webhcat-env.sh" +fi + +#==================================== +#determine where hadoop is +#==================================== + +#check HADOOP_HOME and then check HADOOP_PREFIX +if [ -f ${HADOOP_HOME}/bin/hadoop ]; then + HADOOP_PREFIX=$HADOOP_HOME +#if this is an rpm install check for /usr/bin/hadoop +elif [ -f ${WEBHCAT_PREFIX}/bin/hadoop ]; then + HADOOP_PREFIX=$WEBHCAT_PREFIX +#otherwise see if HADOOP_PREFIX is defined +elif [ ! -f ${HADOOP_PREFIX}/bin/hadoop ]; then + echo "Hadoop not found." + exit 1 +fi diff --git webhcat/svr/src/main/bin/webhcat_server.sh webhcat/svr/src/main/bin/webhcat_server.sh new file mode 100755 index 0000000..b27f4e7 --- /dev/null +++ webhcat/svr/src/main/bin/webhcat_server.sh @@ -0,0 +1,237 @@ +#!/usr/bin/env 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. + +# +# Support functions +# + +# Follow symlinks on Linux and Darwin +function real_script_name() { + local base=$1 + local real + if readlink -f $base >/dev/null 2>&1; then + # Darwin/Mac OS X + real=`readlink -f $base` + fi + if [[ "$?" != "0" || -z "$real" ]]; then + # Linux + local bin=$(cd -P -- "$(dirname -- "$base")">/dev/null && pwd -P) + local script="$(basename -- "$base")" + real="$bin/$script" + fi + echo "$real" +} + +function usage() { + echo "usage: $0 [start|stop|foreground]" + echo " start Start the Webhcat Server" + echo " stop Stop the Webhcat Server" + echo " foreground Run the Webhcat Server in the foreground" + exit 1 +} + +# Print an error message and exit +function die() { + echo "webhcat: $@" 1>&2 + exit 1 +} + +# Print an message +function log() { + echo "webhcat: $@" +} + +# Find the webhcat jar +function find_jar_path() { + for dir in "." "build" "share/hcatalog/"; do + local jar="$base_dir/$dir/$WEBHCAT_JAR" + if [[ -f $jar ]]; then + echo $jar + break + fi + done +} + +# Find the webhcat classpath +function find_classpath() { + local classpath="" + for dir in "share/webhcat/svr/" "share/webhcat/svr/lib/" "conf" ; do + local path="$base_dir/$dir" + + if [[ -d $path ]]; then + for jar_or_conf in $path/*; do + if [[ -z "$classpath" ]]; then + classpath="$jar_or_conf" + else + classpath="$classpath:$jar_or_conf" + fi + done + fi + done + + if [[ -n "$WEBHCAT_CONF_DIR" ]]; then + if [[ -z "$classpath" ]]; then + classpath="$WEBHCAT_CONF_DIR" + else + classpath="$classpath:$WEBHCAT_CONF_DIR" + fi + fi + + # Append hcat classpath + local hcat_classpath + hcat_classpath=`hcat -classpath` + if [[ "$?" != "0" ]]; then + die "Unable to get the hcatalog classpath" + fi + echo "$classpath:$hcat_classpath" +} + +# Check if the pid is running +function check_pid() { + local pid=$1 + if ps -p $pid > /dev/null; then + return 0 + else + return 1 + fi +} + +# Start the webhcat server in the foreground +function foreground_webhcat() { + $start_cmd +} + +# Start the webhcat server in the background. Record the PID for +# later use. +function start_webhcat() { + if [[ -f $PID_FILE ]]; then + # Check if there is a server running + local pid=`cat $PID_FILE` + if check_pid $pid; then + die "already running on process $pid" + fi + fi + + log "starting ..." + log "$start_cmd" + nohup $start_cmd >>$CONSOLE_LOG 2>>$ERROR_LOG & + local pid=$! + + if [[ -z "${pid}" ]] ; then # we failed right off + die "failed to start. Check logs in " `dirname $ERROR_LOG` + fi + + sleep $SLEEP_TIME_AFTER_START + + if check_pid $pid; then + echo $pid > $PID_FILE + log "starting ... started." + else + die "failed to start. Check logs in " `dirname $ERROR_LOG` + fi +} + +# Stop a running server +function stop_webhcat() { + local pid + if [[ -f $PID_FILE ]]; then + # Check if there is a server running + local check=`cat $PID_FILE` + if check_pid $check; then + pid=$check + fi + fi + + if [[ -z "$pid" ]]; then + log "no running server found" + else + log "stopping ..." + kill $pid + sleep $SLEEP_TIME_AFTER_START + if check_pid $pid; then + die "failed to stop" + else + log "stopping ... stopped" + fi + fi +} + +# +# Build command line and run +# + +this=`real_script_name "${BASH_SOURCE-$0}"` +this_bin=`dirname $this` +base_dir="$this_bin/.." + +if [[ -f "$base_dir/libexec/webhcat_config.sh" ]]; then + . "$base_dir/libexec/webhcat_config.sh" +else + . "$this_bin/webhcat_config.sh" +fi + +JAR=`find_jar_path` +if [[ -z "$JAR" ]]; then + die "No webhcat jar found" +fi + +CLASSPATH=`find_classpath` +if [[ -z "$CLASSPATH" ]]; then + die "No classpath or jars found" +fi +CLASSPATH="$JAR:$CLASSPATH" + +if [[ -z "$HADOOP_CLASSPATH" ]]; then + export HADOOP_CLASSPATH="$CLASSPATH" +else + export HADOOP_CLASSPATH="$CLASSPATH:$HADOOP_CLASSPATH" +fi + +if [[ -z "$WEBHCAT_LOG4J" ]]; then + if [[ -f "$base_dir/conf/webhcat-log4j.properties" ]]; then + WEBHCAT_LOG4J="$base_dir/conf/webhcat-log4j.properties"; + elif [[ -f "$base_dir/conf/webhcat-log4j.properties" ]]; then + WEBHCAT_LOG4J="$base_dir/conf/webhcat-log4j.properties"; + else + WEBHCAT_LOG4J="webhcat-log4j.properties"; + fi +fi + +export HADOOP_USER_CLASSPATH_FIRST=true +export HADOOP_OPTS="-Dwebhcat.log.dir=$WEBHCAT_LOG_DIR -Dlog4j.configuration=$WEBHCAT_LOG4J" + +start_cmd="$HADOOP_PREFIX/bin/hadoop jar $JAR org.apache.hcatalog.templeton.Main " + + +cmd=$1 +case $cmd in + start) + start_webhcat + ;; + stop) + stop_webhcat + ;; + foreground) + foreground_webhcat + ;; + *) + usage + ;; +esac + +log "done" diff --git webhcat/svr/src/main/java/org/apache/hcatalog/templeton/AppConfig.java webhcat/svr/src/main/java/org/apache/hcatalog/templeton/AppConfig.java index 28e96e3..d8c124a 100644 --- webhcat/svr/src/main/java/org/apache/hcatalog/templeton/AppConfig.java +++ webhcat/svr/src/main/java/org/apache/hcatalog/templeton/AppConfig.java @@ -38,11 +38,11 @@ import org.apache.hcatalog.templeton.tool.ZooKeeperStorage; * * The Templeton specific configuration is split into two layers * - * 1. templeton-default.xml - All the configuration variables that + * 1. webhcat-default.xml - All the configuration variables that * Templeton needs. These are the defaults that ship with the app * and should only be changed be the app developers. * - * 2. templeton-site.xml - The (possibly empty) configuration that the + * 2. webhcat-site.xml - The (possibly empty) configuration that the * system administrator can set variables for their Hadoop cluster. * * The configuration files are loaded in this order with later files @@ -71,8 +71,8 @@ public class AppConfig extends Configuration { public static final String TEMPLETON_HOME_VAR = "TEMPLETON_HOME"; public static final String[] TEMPLETON_CONF_FILENAMES = { - "templeton-default.xml", - "templeton-site.xml" + "webhcat-default.xml", + "webhcat-site.xml" }; public static final String PORT = "templeton.port";