celeborn/bin/rss-class
2021-12-28 20:57:35 +08:00

80 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
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[@]}"