Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/1845#discussion_r16322977
--- Diff: bin/utils.sh ---
@@ -0,0 +1,108 @@
+#!/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.
+#
+
+# * ---------------------------------------------------- *
+# | Utility functions for launching Spark applications |
+# * ---------------------------------------------------- *
+
+# Parse the value of a config from a java properties file according to the
specifications in
+#
http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#load(java.io.Reader).
+# This accepts the name of the config as an argument, and expects the path
of the property
+# file to be found in PROPERTIES_FILE. The value is returned through
JAVA_PROPERTY_VALUE.
+parse_java_property() {
+ JAVA_PROPERTY_VALUE="" # return value
+ config_buffer="" # buffer for collecting parts of a config value
+ multi_line=0 # whether this config is spanning multiple lines
+ while read -r line; do
+ # Strip leading and trailing whitespace
+ line=$(echo "$line" | sed "s/^[[:space:]]\(.*\)[[:space:]]*$/\1/")
+ contains_config=$(echo "$line" | grep -e "^$1")
+ if [[ -n "$contains_config" || "$multi_line" == 1 ]]; then
+ has_more_lines=$(echo "$line" | grep -e "\\\\$")
+ if [[ -n "$has_more_lines" ]]; then
+ # Strip trailing backslash
+ line=$(echo "$line" | sed "s/\\\\$//")
+ config_buffer="$config_buffer $line"
+ multi_line=1
+ else
+ JAVA_PROPERTY_VALUE="$config_buffer $line"
+ break
+ fi
+ fi
+ done < "$PROPERTIES_FILE"
+
+ # Actually extract the value of the config
+ JAVA_PROPERTY_VALUE=$( \
+ echo "$JAVA_PROPERTY_VALUE" | \
+ sed "s/$1//" | \
+ sed "s/^[[:space:]]*[:=]\{0,1\}//" | \
+ sed "s/^[[:space:]]*\(.*\)[[:space:]]*$/\1/g" \
+ )
+ export JAVA_PROPERTY_VALUE
+}
+
+# Properly split java options, dealing with whitespace, double quotes and
backslashes.
+# This accepts a string and returns the resulting list through
SPLIT_JAVA_OPTS.
+split_java_options() {
+ SPLIT_JAVA_OPTS=() # return value
--- End diff --
Yeah, that does exactly what we want.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]