Skip to content

Commit fa11ef8

Browse files
committed
Parse the properties file only if the special configs exist
1 parent 371cac4 commit fa11ef8

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

bin/spark-submit

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,27 @@ unset EXECUTOR_EXTRA_JAVA_OPTIONS
6060
#
6161
if [[ -f "$PROPERTIES_FILE" ]]; then
6262
echo "Using properties file $PROPERTIES_FILE." 1>&2
63-
# This exports the value of the given key into JAVA_PROPERTY_VALUE
64-
parse_java_property "spark.driver.memory"
65-
DRIVER_MEMORY_CONF="$JAVA_PROPERTY_VALUE"
66-
parse_java_property "spark.driver.extraLibraryPath"
67-
DRIVER_EXTRA_LIBRARY_PATH="$JAVA_PROPERTY_VALUE"
68-
parse_java_property "spark.driver.extraClassPath"
69-
DRIVER_EXTRA_CLASSPATH="$JAVA_PROPERTY_VALUE"
70-
parse_java_property "spark.driver.extraJavaOptions"
71-
DRIVER_EXTRA_JAVA_OPTS="$JAVA_PROPERTY_VALUE"
72-
parse_java_property "spark.executor.extraJavaOptions"
73-
EXECUTOR_EXTRA_JAVA_OPTS="$JAVA_PROPERTY_VALUE"
74-
if [[ -n "DRIVER_EXTRA_JAVA_OPTS" ]]; then
75-
export DRIVER_EXTRA_JAVA_OPTS
76-
fi
77-
if [[ -n "EXECUTOR_EXTRA_JAVA_OPTS" ]]; then
78-
export EXECUTOR_EXTRA_JAVA_OPTS
63+
# Parse the properties file here only if these special configs exist
64+
should_parse=$(grep -e "spark.driver.extra*\|spark.*.extraJavaOptions" "$PROPERTIES_FILE")
65+
if [[ -n "$should_parse" ]]; then
66+
# This exports the value of the given key into JAVA_PROPERTY_VALUE
67+
parse_java_property "spark.driver.memory"
68+
DRIVER_MEMORY_CONF="$JAVA_PROPERTY_VALUE"
69+
parse_java_property "spark.driver.extraLibraryPath"
70+
DRIVER_EXTRA_LIBRARY_PATH="$JAVA_PROPERTY_VALUE"
71+
parse_java_property "spark.driver.extraClassPath"
72+
DRIVER_EXTRA_CLASSPATH="$JAVA_PROPERTY_VALUE"
73+
parse_java_property "spark.driver.extraJavaOptions"
74+
DRIVER_EXTRA_JAVA_OPTS="$JAVA_PROPERTY_VALUE"
75+
parse_java_property "spark.executor.extraJavaOptions"
76+
EXECUTOR_EXTRA_JAVA_OPTS="$JAVA_PROPERTY_VALUE"
77+
# Export these for SparkSubmitArguments.scala to consume
78+
if [[ -n "DRIVER_EXTRA_JAVA_OPTS" ]]; then
79+
export DRIVER_EXTRA_JAVA_OPTS
80+
fi
81+
if [[ -n "EXECUTOR_EXTRA_JAVA_OPTS" ]]; then
82+
export EXECUTOR_EXTRA_JAVA_OPTS
83+
fi
7984
fi
8085
elif [[ "$PROPERTIES_FILE" != "$DEFAULT_PROPERTIES_FILE" ]]; then
8186
echo "Warning: properties file $PROPERTIES_FILE does not exist." 1>&2

0 commit comments

Comments
 (0)