celeborn/bin/rss-class

96 lines
2.6 KiB
Bash
Executable File

#!/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.
#
if [ -z "${RSS_HOME}" ]; then
export RSS_HOME="$(cd "`dirname "$0"`"/..; pwd)"
fi
export RSS_CONF_DIR="${RSS_CONF_DIR:-"${RSS_HOME}/conf"}"
if [ -z "$RSS_ENV_LOADED" ]; then
export RSS_ENV_LOADED=1
if [ -f "${RSS_CONF_DIR}/rss-env.sh" ]; then
# Promote all variable declarations to environment (exported) variables
set -a
. "${RSS_CONF_DIR}/rss-env.sh"
set +a
fi
fi
# Find the java binary
if [ -n "${JAVA_HOME}" ]; then
RUNNER="${JAVA_HOME}/bin/java"
else
if [ "$(command -v java)" ]; then
RUNNER="java"
else
echo "JAVA_HOME is not set" >&2
exit 1
fi
fi
# Find RSS jars.
for i in "$@"
do
if [ "$i" == "com.aliyun.emr.rss.service.deploy.master.Master" ] ; then
LAUNCH_CLASS=com.aliyun.emr.rss.service.deploy.master.Master
fi
if [ "$i" == "com.aliyun.emr.rss.service.deploy.worker.Worker" ] ; then
LAUNCH_CLASS=com.aliyun.emr.rss.service.deploy.worker.Worker
fi
done
if [ "${LAUNCH_CLASS}" == "com.aliyun.emr.rss.service.deploy.master.Master" ] ; then
if [ -d "${RSS_HOME}/master-jars" ]; then
RSS_JARS_DIR="${RSS_HOME}/master-jars"
else
RSS_JARS_DIR="${RSS_HOME}/master/target"
fi
fi
if [ "${LAUNCH_CLASS}" == "com.aliyun.emr.rss.service.deploy.worker.Worker" ] ; then
if [ -d "${RSS_HOME}/worker-jars" ]; then
RSS_JARS_DIR="${RSS_HOME}/worker-jars"
else
RSS_JARS_DIR="${RSS_HOME}/worker/target"
fi
fi
if [ ! -d "$RSS_JARS_DIR" ]; then
echo "Failed to find RSS jars directory ($RSS_JARS_DIR)." 1>&2
echo "You need to build RSS with the target \"package\" before running this program." 1>&2
exit 1
else
RSS_CLASSPATH="$RSS_CONF_DIR:$HADOOP_CONF_DIR:$RSS_JARS_DIR/*"
fi
# Turn off posix mode since it does not allow process substitution
set +o posix
CMD=()
CMD+=("$RUNNER")
CMD=(${CMD[@]} "$RSS_JAVA_OPTS")
CMD+=("-cp")
CMD+=("$RSS_CLASSPATH")
CMD=(${CMD[@]} "$@")
COUNT=${#CMD[@]}
exec "${CMD[@]}"