Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Suggestions from TD
  • Loading branch information
pwendell committed May 9, 2014
commit 3eb7803b37af9c0647d493f3bd45867fc5c53bf0
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,22 @@ And run the following command, which should also return 1000:
## Example Programs

Spark also comes with several sample programs in the `examples` directory.
To run one of them, use the `./bin/spark-submit` script. For example:
To run one of them, use `./bin/run-example <class> [<params>]`. For example:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: What does the notation [< ... >] mean? I think it's clearer if it's just [params]


./bin/spark-submit \
--class org.apache.spark.examples.SparkLR \
--master local[2] \
lib/spark-examples*.jar
./bin/run-example org.apache.spark.examples.SparkLR

will run the Logistic Regression example locally on 2 CPUs.
will run the Logistic Regression example locally.

Many of the example programs print usage help if no params are given.
You can set the MASTER environment variable when running examples to submit
examples to a cluster. This can be a mesos:// or spark:// URL,
"yarn-cluster" or "yarn-client" to run on YARN, and "local" to run
locally with one thread, or "local[N]" to run locally with N thread. You
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N threads

can also use an abbreviated class name if the class is in the `examples`
package. For instance:

MASTER=spark://host:7077 ./bin/run-example SparkPi

When running Spark examples you can pass `--master` parameter to the submission
script. This can be a mesos:// or spark:// URL, "yarn-cluster" or "yarn-client"
to run on YARN, and "local" to run locally with one thread, or "local[N]" to
run locally with N thread.
Many of the example programs print usage help if no params are given.

## Running Tests

Expand Down
30 changes: 14 additions & 16 deletions bin/run-example
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,25 @@ if [[ -z $SPARK_EXAMPLES_JAR ]]; then
exit 1
fi

SPARK_EXAMPLES_JAR_REL=${SPARK_EXAMPLES_JAR#$FWDIR/}

EXAMPLE_CLASS="<example-class>"
EXAMPLE_ARGS="[<example args>]"
EXAMPLE_MASTER=${MASTER:-"<master>"}
EXAMPLE_MASTER=${MASTER:-"local[2]"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a consistent default. Should we use local[*] as in spark-submit?


if [ -n "$1" ]; then
EXAMPLE_CLASS="$1"
shift
else
echo "usage: ./bin/run-example <example-class> [<example-args>]"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops sorry there's another one

echo " - set MASTER=XX to use a specific master"
echo " - can use abbreviated example class name (e.g. SparkPi)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should also add an example for say MLlib or Sql examples; people might try to run MovieLensALS directly given this message. Perhaps something like (e.g. SparkPi, mllib.MovieLensALS)

echo
exit -1
fi

if [ -n "$1" ]; then
EXAMPLE_ARGS="$@"
if [[ ! $EXAMPLE_CLASS == org.apache.spark.examples* ]]; then
EXAMPLE_CLASS="org.apache.spark.examples.$EXAMPLE_CLASS"
fi

echo "NOTE: This script has been replaced with ./bin/spark-submit. Please run:" >&2
echo
echo "./bin/spark-submit \\" >&2
echo " --master $EXAMPLE_MASTER \\" >&2
echo " --class $EXAMPLE_CLASS \\" >&2
echo " $SPARK_EXAMPLES_JAR_REL \\" >&2
echo " $EXAMPLE_ARGS" >&2
echo
exit 1
./bin/spark-submit \
--master $EXAMPLE_MASTER \
--class $EXAMPLE_CLASS \
$SPARK_EXAMPLES_JAR \
"$@"