Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions samza-shell/src/main/bash/run-class.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,21 @@ else
JAR="$JAVA_HOME/bin/jar"
fi

# Create a separate directory for writing files related to classpath management. It is easier to manage
# permissions for the classpath-related files when they are in their own directory. An example of where
# this is helpful is when using container images which might have predefined permissions for certain
# directories.
CLASSPATH_WORKSPACE_DIR=$base_dir/classpath_workspace
mkdir -p $CLASSPATH_WORKSPACE_DIR
# file containing the classpath string; used to avoid passing long classpaths directly to the jar command
PATHING_MANIFEST_FILE=$CLASSPATH_WORKSPACE_DIR/manifest.txt
# jar file to include on the classpath for running the main class
PATHING_JAR_FILE=$CLASSPATH_WORKSPACE_DIR/pathing.jar

# Newlines and spaces are intended to ensure proper parsing of manifest in pathing jar
printf "Class-Path: \n $CLASSPATH \n" > manifest.txt
printf "Class-Path: \n $CLASSPATH \n" > $PATHING_MANIFEST_FILE
# Creates a new archive and adds custom manifest information to pathing.jar
eval "$JAR -cvmf manifest.txt pathing.jar"
eval "$JAR -cvmf $PATHING_MANIFEST_FILE $PATHING_JAR_FILE"

if [ -z "$JAVA_HOME" ]; then
JAVA="java"
Expand Down Expand Up @@ -151,11 +162,11 @@ fi
[[ $JAVA_OPTS != *-d64* ]] && check_and_enable_64_bit_mode

# HADOOP_CONF_DIR should be supplied to classpath explicitly for Yarn to parse configs
echo $JAVA $JAVA_OPTS -cp $HADOOP_CONF_DIR:pathing.jar "$@"
echo $JAVA $JAVA_OPTS -cp $HADOOP_CONF_DIR:$PATHING_JAR_FILE "$@"

## If localized resource lib directory is defined, then include it in the classpath.
if [[ -z "${ADDITIONAL_CLASSPATH_DIR}" ]]; then
exec $JAVA $JAVA_OPTS -cp $HADOOP_CONF_DIR:pathing.jar "$@"
exec $JAVA $JAVA_OPTS -cp $HADOOP_CONF_DIR:$PATHING_JAR_FILE "$@"
else
exec $JAVA $JAVA_OPTS -cp $HADOOP_CONF_DIR:pathing.jar:$ADDITIONAL_CLASSPATH_DIR "$@"
exec $JAVA $JAVA_OPTS -cp $HADOOP_CONF_DIR:$PATHING_JAR_FILE:$ADDITIONAL_CLASSPATH_DIR "$@"
fi