Ensure assertions in Graph.apply are asserted.

The Graph.apply test in GraphSuite had some assertions in a closure in
a graph transformation. This caused two problems:

1. because assert() was called, test classes were reachable from the
closures, which made them not serializable, and

2. (more importantly) these assertions never actually executed, since
they occurred within a lazy map()

This commit simply changes the Graph.apply test to collects the graph
triplets so it can assert about each triplet from a map method.
Test cases for SPARK-897.

Tests to make sure that passing an unserializable closure
to a transformation fails fast.
Adds proactive closure-serializablilty checking

ClosureCleaner.clean now checks to ensure that its closure argument
is serializable by default and throws a SparkException with the
underlying NotSerializableException in the detail message otherwise.
As a result, transformation invocations with unserializable closures
will fail at their call sites rather than when they actually execute.

ClosureCleaner.clean now takes a second boolean argument; pass false
to disable serializability-checking behavior at call sites where this
behavior isn't desired.
Make proactive serializability checking optional.

SparkContext.clean uses ClosureCleaner's proactive serializability
checking by default.  This commit adds an overloaded clean method
to SparkContext that allows clients to specify that serializability
checking should not occur as part of closure cleaning.
Don't check serializability of DStream transforms.

Since the DStream is reachable from within these closures, they aren't
checkable by the straightforward technique of passing them to the
closure serializer.
Remove closure-serializablity test in DAGScheduler

Since all closures that will be marshaled via the DAGScheduler will
already be checked to ensure serializability at transformation or
action invocation by ClosureCleaner.clean, there is no need to check
these for serializability again when jobs are submitted.
Added tests for variable capture in closures

The two tests added to ClosureCleanerSuite ensure that variable values
are captured at RDD definition time, not at job-execution time.
Predictable closure environment capture

The environments of serializable closures are now captured as
part of closure cleaning. Since we already proactively check most
closures for serializability, ClosureCleaner.clean now returns
the result of deserializing the serialized version of the cleaned
closure.