diff options
author | Venkata Ramana Gollamudi <ramana.gollamudi@huawei.com> | 2015-01-19 11:58:16 -0800 |
---|---|---|
committer | Josh Rosen <joshrosen@databricks.com> | 2015-01-19 12:00:33 -0800 |
commit | 74de94ea6db96a04b278c6106264313504d7b8f3 (patch) | |
tree | 98327f48da0ab75eb1e8e07f563cb551a597656a /bin/compute-classpath.sh | |
parent | 2604bc35d7205866e2b6c2d80f4b2ad715177642 (diff) | |
download | spark-74de94ea6db96a04b278c6106264313504d7b8f3.tar.gz spark-74de94ea6db96a04b278c6106264313504d7b8f3.tar.bz2 spark-74de94ea6db96a04b278c6106264313504d7b8f3.zip |
[SPARK-4504][Examples] fix run-example failure if multiple assembly jars exist
Fix run-example script to fail fast with useful error message if multiple
example assembly JARs are present.
Author: Venkata Ramana Gollamudi <ramana.gollamudi@huawei.com>
Closes #3377 from gvramana/run-example_fails and squashes the following commits:
fa7f481 [Venkata Ramana Gollamudi] Fixed review comments, avoiding ls output scanning.
6aa1ab7 [Venkata Ramana Gollamudi] Fix run-examples script error during multiple jars
Diffstat (limited to 'bin/compute-classpath.sh')
-rwxr-xr-x | bin/compute-classpath.sh | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/bin/compute-classpath.sh b/bin/compute-classpath.sh index 8f3b396ffd..9e8d0b7851 100755 --- a/bin/compute-classpath.sh +++ b/bin/compute-classpath.sh @@ -72,22 +72,25 @@ else assembly_folder="$ASSEMBLY_DIR" fi -num_jars="$(ls "$assembly_folder" | grep "spark-assembly.*hadoop.*\.jar$" | wc -l)" -if [ "$num_jars" -eq "0" ]; then - echo "Failed to find Spark assembly in $assembly_folder" - echo "You need to build Spark before running this program." - exit 1 -fi +num_jars=0 + +for f in ${assembly_folder}/spark-assembly*hadoop*.jar; do + if [[ ! -e "$f" ]]; then + echo "Failed to find Spark assembly in $assembly_folder" 1>&2 + echo "You need to build Spark before running this program." 1>&2 + exit 1 + fi + ASSEMBLY_JAR="$f" + num_jars=$((num_jars+1)) +done + if [ "$num_jars" -gt "1" ]; then - jars_list=$(ls "$assembly_folder" | grep "spark-assembly.*hadoop.*.jar$") - echo "Found multiple Spark assembly jars in $assembly_folder:" - echo "$jars_list" - echo "Please remove all but one jar." + echo "Found multiple Spark assembly jars in $assembly_folder:" 1>&2 + ls ${assembly_folder}/spark-assembly*hadoop*.jar 1>&2 + echo "Please remove all but one jar." 1>&2 exit 1 fi -ASSEMBLY_JAR="$(ls "$assembly_folder"/spark-assembly*hadoop*.jar 2>/dev/null)" - # Verify that versions of java used to build the jars and run Spark are compatible jar_error_check=$("$JAR_CMD" -tf "$ASSEMBLY_JAR" nonexistent/class/path 2>&1) if [[ "$jar_error_check" =~ "invalid CEN header" ]]; then |