Skip to content

Commit c8bf413

Browse files
mateizpwendell
authored andcommitted
[SPARK-1566] consolidate programming guide, and general doc updates
This is a fairly large PR to clean up and update the docs for 1.0. The major changes are: * A unified programming guide for all languages replaces language-specific ones and shows language-specific info in tabs * New programming guide sections on key-value pairs, unit testing, input formats beyond text, migrating from 0.9, and passing functions to Spark * Spark-submit guide moved to a separate page and expanded slightly * Various cleanups of the menu system, security docs, and others * Updated look of title bar to differentiate the docs from previous Spark versions You can find the updated docs at http://people.apache.org/~matei/1.0-docs/_site/ and in particular http://people.apache.org/~matei/1.0-docs/_site/programming-guide.html. Author: Matei Zaharia <[email protected]> Closes #896 from mateiz/1.0-docs and squashes the following commits: 03e6853 [Matei Zaharia] Some tweaks to configuration and YARN docs 0779508 [Matei Zaharia] tweak ef671d4 [Matei Zaharia] Keep frames in JavaDoc links, and other small tweaks 1bf4112 [Matei Zaharia] Review comments 4414f88 [Matei Zaharia] tweaks d04e979 [Matei Zaharia] Fix some old links to Java guide a34ed33 [Matei Zaharia] tweak 541bb3b [Matei Zaharia] miscellaneous changes fcefdec [Matei Zaharia] Moved submitting apps to separate doc 61d72b4 [Matei Zaharia] stuff 181f217 [Matei Zaharia] migration guide, remove old language guides e11a0da [Matei Zaharia] Add more API functions 6a030a9 [Matei Zaharia] tweaks 8db0ae3 [Matei Zaharia] Added key-value pairs section 318d2c9 [Matei Zaharia] tweaks 1c81477 [Matei Zaharia] New section on basics and function syntax e38f559 [Matei Zaharia] Actually added programming guide to Git a33d6fe [Matei Zaharia] First pass at updating programming guide to support all languages, plus other tweaks throughout 3b6a876 [Matei Zaharia] More CSS tweaks 01ec8bf [Matei Zaharia] More CSS tweaks e6d252e [Matei Zaharia] Change color of doc title bar to differentiate from 0.9.0
1 parent eeee978 commit c8bf413

27 files changed

+1767
-1122
lines changed

docs/_layouts/global.html

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
<title>{{ page.title }} - Spark {{site.SPARK_VERSION_SHORT}} Documentation</title>
1010
<meta name="description" content="">
1111

12+
{% if page.redirect %}
13+
<meta http-equiv="refresh" content="0; url={{page.redirect}}">
14+
<link rel="canonical" href="{{page.redirect}}" />
15+
{% endif %}
16+
1217
<link rel="stylesheet" href="css/bootstrap.min.css">
1318
<style>
1419
body {
@@ -61,15 +66,13 @@
6166
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Programming Guides<b class="caret"></b></a>
6267
<ul class="dropdown-menu">
6368
<li><a href="quick-start.html">Quick Start</a></li>
64-
<li><a href="scala-programming-guide.html">Spark in Scala</a></li>
65-
<li><a href="java-programming-guide.html">Spark in Java</a></li>
66-
<li><a href="python-programming-guide.html">Spark in Python</a></li>
69+
<li><a href="programming-guide.html">Spark Programming Guide</a></li>
6770
<li class="divider"></li>
6871
<li><a href="streaming-programming-guide.html">Spark Streaming</a></li>
6972
<li><a href="sql-programming-guide.html">Spark SQL</a></li>
7073
<li><a href="mllib-guide.html">MLlib (Machine Learning)</a></li>
71-
<li><a href="bagel-programming-guide.html">Bagel (Pregel on Spark)</a></li>
7274
<li><a href="graphx-programming-guide.html">GraphX (Graph Processing)</a></li>
75+
<li><a href="bagel-programming-guide.html">Bagel (Pregel on Spark)</a></li>
7376
</ul>
7477
</li>
7578

@@ -86,6 +89,8 @@
8689
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Deploying<b class="caret"></b></a>
8790
<ul class="dropdown-menu">
8891
<li><a href="cluster-overview.html">Overview</a></li>
92+
<li><a href="submitting-applications.html">Submitting Applications</a></li>
93+
<li class="divider"></li>
8994
<li><a href="ec2-scripts.html">Amazon EC2</a></li>
9095
<li><a href="spark-standalone.html">Standalone Mode</a></li>
9196
<li><a href="running-on-mesos.html">Mesos</a></li>
@@ -99,9 +104,10 @@
99104
<li><a href="configuration.html">Configuration</a></li>
100105
<li><a href="monitoring.html">Monitoring</a></li>
101106
<li><a href="tuning.html">Tuning Guide</a></li>
102-
<li><a href="hadoop-third-party-distributions.html">Running with CDH/HDP</a></li>
103-
<li><a href="hardware-provisioning.html">Hardware Provisioning</a></li>
104107
<li><a href="job-scheduling.html">Job Scheduling</a></li>
108+
<li><a href="security.html">Security</a></li>
109+
<li><a href="hardware-provisioning.html">Hardware Provisioning</a></li>
110+
<li><a href="hadoop-third-party-distributions.html">3<sup>rd</sup>-Party Hadoop Distros</a></li>
105111
<li class="divider"></li>
106112
<li><a href="building-with-maven.html">Building Spark with Maven</a></li>
107113
<li><a href="https://cwiki.apache.org/confluence/display/SPARK/Contributing+to+Spark">Contributing to Spark</a></li>

docs/bagel-programming-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ To use Bagel in your program, add the following SBT or Maven dependency:
2121

2222
# Programming Model
2323

24-
Bagel operates on a graph represented as a [distributed dataset](scala-programming-guide.html) of (K, V) pairs, where keys are vertex IDs and values are vertices plus their associated state. In each superstep, Bagel runs a user-specified compute function on each vertex that takes as input the current vertex state and a list of messages sent to that vertex during the previous superstep, and returns the new vertex state and a list of outgoing messages.
24+
Bagel operates on a graph represented as a [distributed dataset](programming-guide.html) of (K, V) pairs, where keys are vertex IDs and values are vertices plus their associated state. In each superstep, Bagel runs a user-specified compute function on each vertex that takes as input the current vertex state and a list of messages sent to that vertex during the previous superstep, and returns the new vertex state and a list of outgoing messages.
2525

2626
For example, we can use Bagel to implement PageRank. Here, vertices represent pages, edges represent links between pages, and messages represent shares of PageRank sent to the pages that a particular page links to.
2727

docs/building-with-maven.md

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ title: Building Spark with Maven
66
* This will become a table of contents (this text will be scraped).
77
{:toc}
88

9-
Building Spark using Maven requires Maven 3.0.4 or newer and Java 1.6 or newer.
9+
Building Spark using Maven requires Maven 3.0.4 or newer and Java 6+.
1010

1111

12-
## Setting up Maven's Memory Usage ##
12+
# Setting up Maven's Memory Usage
1313

1414
You'll need to configure Maven to use more memory than usual by setting `MAVEN_OPTS`. We recommend the following settings:
1515

16-
export MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512m"
16+
{% highlight bash %}
17+
export MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512m"
18+
{% endhighlight %}
1719

1820
If you don't run this, you may see errors like the following:
1921

@@ -25,9 +27,9 @@ If you don't run this, you may see errors like the following:
2527

2628
You can fix this by setting the `MAVEN_OPTS` variable as discussed before.
2729

28-
*Note: For Java 1.8 and above this step is not required.*
30+
**Note:** *For Java 8 and above this step is not required.*
2931

30-
## Specifying the Hadoop version ##
32+
# Specifying the Hadoop Version
3133

3234
Because HDFS is not protocol-compatible across versions, if you want to read from HDFS, you'll need to build Spark against the specific HDFS version in your environment. You can do this through the "hadoop.version" property. If unset, Spark will build against Hadoop 1.0.4 by default. Note that certain build profiles are required for particular Hadoop versions:
3335

@@ -46,14 +48,16 @@ Because HDFS is not protocol-compatible across versions, if you want to read fro
4648

4749
For Apache Hadoop versions 1.x, Cloudera CDH "mr1" distributions, and other Hadoop versions without YARN, use:
4850

49-
# Apache Hadoop 1.2.1
50-
$ mvn -Dhadoop.version=1.2.1 -DskipTests clean package
51+
{% highlight bash %}
52+
# Apache Hadoop 1.2.1
53+
mvn -Dhadoop.version=1.2.1 -DskipTests clean package
5154

52-
# Cloudera CDH 4.2.0 with MapReduce v1
53-
$ mvn -Dhadoop.version=2.0.0-mr1-cdh4.2.0 -DskipTests clean package
55+
# Cloudera CDH 4.2.0 with MapReduce v1
56+
mvn -Dhadoop.version=2.0.0-mr1-cdh4.2.0 -DskipTests clean package
5457

55-
# Apache Hadoop 0.23.x
56-
$ mvn -Phadoop-0.23 -Dhadoop.version=0.23.7 -DskipTests clean package
58+
# Apache Hadoop 0.23.x
59+
mvn -Phadoop-0.23 -Dhadoop.version=0.23.7 -DskipTests clean package
60+
{% endhighlight %}
5761

5862
For Apache Hadoop 2.x, 0.23.x, Cloudera CDH, and other Hadoop versions with YARN, you can enable the "yarn-alpha" or "yarn" profile and optionally set the "yarn.version" property if it is different from "hadoop.version". The additional build profile required depends on the YARN version:
5963

@@ -69,75 +73,77 @@ For Apache Hadoop 2.x, 0.23.x, Cloudera CDH, and other Hadoop versions with YARN
6973

7074
Examples:
7175

72-
# Apache Hadoop 2.0.5-alpha
73-
$ mvn -Pyarn-alpha -Dhadoop.version=2.0.5-alpha -DskipTests clean package
76+
{% highlight bash %}
77+
# Apache Hadoop 2.0.5-alpha
78+
mvn -Pyarn-alpha -Dhadoop.version=2.0.5-alpha -DskipTests clean package
7479

75-
# Cloudera CDH 4.2.0
76-
$ mvn -Pyarn-alpha -Dhadoop.version=2.0.0-cdh4.2.0 -DskipTests clean package
80+
# Cloudera CDH 4.2.0
81+
mvn -Pyarn-alpha -Dhadoop.version=2.0.0-cdh4.2.0 -DskipTests clean package
7782

78-
# Apache Hadoop 0.23.x
79-
$ mvn -Pyarn-alpha -Phadoop-0.23 -Dhadoop.version=0.23.7 -DskipTests clean package
83+
# Apache Hadoop 0.23.x
84+
mvn -Pyarn-alpha -Phadoop-0.23 -Dhadoop.version=0.23.7 -DskipTests clean package
8085

81-
# Apache Hadoop 2.2.X
82-
$ mvn -Pyarn -Phadoop-2.2 -Dhadoop.version=2.2.0 -DskipTests clean package
86+
# Apache Hadoop 2.2.X
87+
mvn -Pyarn -Phadoop-2.2 -Dhadoop.version=2.2.0 -DskipTests clean package
8388

84-
# Apache Hadoop 2.3.X
85-
$ mvn -Pyarn -Phadoop-2.3 -Dhadoop.version=2.3.0 -DskipTests clean package
89+
# Apache Hadoop 2.3.X
90+
mvn -Pyarn -Phadoop-2.3 -Dhadoop.version=2.3.0 -DskipTests clean package
8691

87-
# Apache Hadoop 2.4.X
88-
$ mvn -Pyarn -Phadoop-2.4 -Dhadoop.version=2.4.0 -DskipTests clean package
92+
# Apache Hadoop 2.4.X
93+
mvn -Pyarn -Phadoop-2.4 -Dhadoop.version=2.4.0 -DskipTests clean package
8994

90-
# Different versions of HDFS and YARN.
91-
$ mvn -Pyarn-alpha -Phadoop-2.3 -Dhadoop.version=2.3.0 -Dyarn.version=0.23.7 -DskipTests clean package
95+
# Different versions of HDFS and YARN.
96+
mvn -Pyarn-alpha -Phadoop-2.3 -Dhadoop.version=2.3.0 -Dyarn.version=0.23.7 -DskipTests clean package
97+
{% endhighlight %}
9298

93-
## Spark Tests in Maven ##
99+
# Spark Tests in Maven
94100

95101
Tests are run by default via the [ScalaTest Maven plugin](http://www.scalatest.org/user_guide/using_the_scalatest_maven_plugin). Some of the require Spark to be packaged first, so always run `mvn package` with `-DskipTests` the first time. You can then run the tests with `mvn -Dhadoop.version=... test`.
96102

97103
The ScalaTest plugin also supports running only a specific test suite as follows:
98104

99-
$ mvn -Dhadoop.version=... -DwildcardSuites=org.apache.spark.repl.ReplSuite test
105+
mvn -Dhadoop.version=... -DwildcardSuites=org.apache.spark.repl.ReplSuite test
100106

101107

102-
## Continuous Compilation ##
108+
# Continuous Compilation
103109

104110
We use the scala-maven-plugin which supports incremental and continuous compilation. E.g.
105111

106-
$ mvn scala:cc
112+
mvn scala:cc
107113

108114
should run continuous compilation (i.e. wait for changes). However, this has not been tested extensively.
109115

110-
## Using With IntelliJ IDEA ##
116+
# Using With IntelliJ IDEA
111117

112118
This setup works fine in IntelliJ IDEA 11.1.4. After opening the project via the pom.xml file in the project root folder, you only need to activate either the hadoop1 or hadoop2 profile in the "Maven Properties" popout. We have not tried Eclipse/Scala IDE with this.
113119

114-
## Building Spark Debian Packages ##
120+
# Building Spark Debian Packages
115121

116-
The maven build includes support for building a Debian package containing the assembly 'fat-jar', PySpark, and the necessary scripts and configuration files. This can be created by specifying the following:
122+
The Maven build includes support for building a Debian package containing the assembly 'fat-jar', PySpark, and the necessary scripts and configuration files. This can be created by specifying the following:
117123

118-
$ mvn -Pdeb -DskipTests clean package
124+
mvn -Pdeb -DskipTests clean package
119125

120126
The debian package can then be found under assembly/target. We added the short commit hash to the file name so that we can distinguish individual packages built for SNAPSHOT versions.
121127

122-
## Running java 8 test suites.
128+
# Running Java 8 Test Suites
123129

124-
Running only java 8 tests and nothing else.
130+
Running only Java 8 tests and nothing else.
125131

126-
$ mvn install -DskipTests -Pjava8-tests
132+
mvn install -DskipTests -Pjava8-tests
127133

128-
Java 8 tests are run when -Pjava8-tests profile is enabled, they will run in spite of -DskipTests.
134+
Java 8 tests are run when `-Pjava8-tests` profile is enabled, they will run in spite of `-DskipTests`.
129135
For these tests to run your system must have a JDK 8 installation.
130136
If you have JDK 8 installed but it is not the system default, you can set JAVA_HOME to point to JDK 8 before running the tests.
131137

132-
## Building for PySpark on YARN ##
138+
# Building for PySpark on YARN
133139

134-
PySpark on YARN is only supported if the jar is built with maven. Further, there is a known problem
135-
with building this assembly jar on Red Hat based operating systems (see SPARK-1753). If you wish to
140+
PySpark on YARN is only supported if the jar is built with Maven. Further, there is a known problem
141+
with building this assembly jar on Red Hat based operating systems (see [SPARK-1753](https://issues.apache.org/jira/browse/SPARK-1753)). If you wish to
136142
run PySpark on a YARN cluster with Red Hat installed, we recommend that you build the jar elsewhere,
137143
then ship it over to the cluster. We are investigating the exact cause for this.
138144

139-
## Packaging without Hadoop dependencies for deployment on YARN ##
145+
# Packaging without Hadoop Dependencies for YARN
140146

141-
The assembly jar produced by "mvn package" will, by default, include all of Spark's dependencies, including Hadoop and some of its ecosystem projects. On YARN deployments, this causes multiple versions of these to appear on executor classpaths: the version packaged in the Spark assembly and the version on each node, included with yarn.application.classpath. The "hadoop-provided" profile builds the assembly without including Hadoop-ecosystem projects, like ZooKeeper and Hadoop itself.
147+
The assembly jar produced by `mvn package` will, by default, include all of Spark's dependencies, including Hadoop and some of its ecosystem projects. On YARN deployments, this causes multiple versions of these to appear on executor classpaths: the version packaged in the Spark assembly and the version on each node, included with yarn.application.classpath. The `hadoop-provided` profile builds the assembly without including Hadoop-ecosystem projects, like ZooKeeper and Hadoop itself.
142148

143149

docs/cluster-overview.md

Lines changed: 6 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ title: Cluster Mode Overview
44
---
55

66
This document gives a short overview of how Spark runs on clusters, to make it easier to understand
7-
the components involved.
7+
the components involved. Read through the [application submission guide](submitting-applications.html)
8+
to submit applications to a cluster.
89

910
# Components
1011

@@ -50,107 +51,10 @@ The system currently supports three cluster managers:
5051
In addition, Spark's [EC2 launch scripts](ec2-scripts.html) make it easy to launch a standalone
5152
cluster on Amazon EC2.
5253

53-
# Bundling and Launching Applications
54-
55-
### Bundling Your Application's Dependencies
56-
If your code depends on other projects, you will need to package them alongside
57-
your application in order to distribute the code to a Spark cluster. To do this,
58-
to create an assembly jar (or "uber" jar) containing your code and its dependencies. Both
59-
[sbt](https://github.com/sbt/sbt-assembly) and
60-
[Maven](http://maven.apache.org/plugins/maven-shade-plugin/)
61-
have assembly plugins. When creating assembly jars, list Spark and Hadoop
62-
as `provided` dependencies; these need not be bundled since they are provided by
63-
the cluster manager at runtime. Once you have an assembled jar you can call the `bin/spark-submit`
64-
script as shown here while passing your jar.
65-
66-
For Python, you can use the `pyFiles` argument of SparkContext
67-
or its `addPyFile` method to add `.py`, `.zip` or `.egg` files to be distributed.
68-
69-
### Launching Applications with Spark submit
70-
71-
Once a user application is bundled, it can be launched using the `spark-submit` script located in
72-
the bin directory. This script takes care of setting up the classpath with Spark and its
73-
dependencies, and can support different cluster managers and deploy modes that Spark supports:
74-
75-
./bin/spark-submit \
76-
--class <main-class>
77-
--master <master-url> \
78-
--deploy-mode <deploy-mode> \
79-
... // other options
80-
<application-jar>
81-
[application-arguments]
82-
83-
main-class: The entry point for your application (e.g. org.apache.spark.examples.SparkPi)
84-
master-url: The URL of the master node (e.g. spark://23.195.26.187:7077)
85-
deploy-mode: Whether to deploy this application within the cluster or from an external client (e.g. client)
86-
application-jar: Path to a bundled jar including your application and all dependencies. The URL must be globally visible inside of your cluster, for instance, an `hdfs://` path or a `file://` path that is present on all nodes.
87-
application-arguments: Space delimited arguments passed to the main method of <main-class>, if any
88-
89-
To enumerate all options available to `spark-submit` run it with the `--help` flag. Here are a few
90-
examples of common options:
91-
92-
{% highlight bash %}
93-
# Run application locally
94-
./bin/spark-submit \
95-
--class org.apache.spark.examples.SparkPi
96-
--master local[8] \
97-
/path/to/examples.jar \
98-
100
99-
100-
# Run on a Spark standalone cluster
101-
./bin/spark-submit \
102-
--class org.apache.spark.examples.SparkPi
103-
--master spark://207.184.161.138:7077 \
104-
--executor-memory 20G \
105-
--total-executor-cores 100 \
106-
/path/to/examples.jar \
107-
1000
108-
109-
# Run on a YARN cluster
110-
HADOOP_CONF_DIR=XX ./bin/spark-submit \
111-
--class org.apache.spark.examples.SparkPi
112-
--master yarn-cluster \ # can also be `yarn-client` for client mode
113-
--executor-memory 20G \
114-
--num-executors 50 \
115-
/path/to/examples.jar \
116-
1000
117-
{% endhighlight %}
118-
119-
### Loading Configurations from a File
120-
121-
The `spark-submit` script can load default [Spark configuration values](configuration.html) from a
122-
properties file and pass them on to your application. By default it will read configuration options
123-
from `conf/spark-defaults.conf`. For more detail, see the section on
124-
[loading default configurations](configuration.html#loading-default-configurations).
125-
126-
Loading default Spark configurations this way can obviate the need for certain flags to
127-
`spark-submit`. For instance, if the `spark.master` property is set, you can safely omit the
128-
`--master` flag from `spark-submit`. In general, configuration values explicitly set on a
129-
`SparkConf` take the highest precedence, then flags passed to `spark-submit`, then values in the
130-
defaults file.
131-
132-
If you are ever unclear where configuration options are coming from, you can print out fine-grained
133-
debugging information by running `spark-submit` with the `--verbose` option.
134-
135-
### Advanced Dependency Management
136-
When using `spark-submit`, the application jar along with any jars included with the `--jars` option
137-
will be automatically transferred to the cluster. Spark uses the following URL scheme to allow
138-
different strategies for disseminating jars:
139-
140-
- **file:** - Absolute paths and `file:/` URIs are served by the driver's HTTP file server, and
141-
every executor pulls the file from the driver HTTP server.
142-
- **hdfs:**, **http:**, **https:**, **ftp:** - these pull down files and JARs from the URI as expected
143-
- **local:** - a URI starting with local:/ is expected to exist as a local file on each worker node. This
144-
means that no network IO will be incurred, and works well for large files/JARs that are pushed to each worker,
145-
or shared via NFS, GlusterFS, etc.
146-
147-
Note that JARs and files are copied to the working directory for each SparkContext on the executor nodes.
148-
This can use up a significant amount of space over time and will need to be cleaned up. With YARN, cleanup
149-
is handled automatically, and with Spark standalone, automatic cleanup can be configured with the
150-
`spark.worker.cleanup.appDataTtl` property.
151-
152-
For python, the equivalent `--py-files` option can be used to distribute .egg and .zip libraries
153-
to executors.
54+
# Submitting Applications
55+
56+
Applications can be submitted to a cluster of any type using the `spark-submit` script.
57+
The [application submission guide](submitting-applications.html) describes how to do this.
15458

15559
# Monitoring
15660

0 commit comments

Comments
 (0)