apache/spark — pull request #926 by srowen (2014-05-30 21:48:44+00:00)
Title: SPARK-1974. Most examples fail at startup because spark.master is not set

Most example code has a few lines like:

```
val sparkConf = new SparkConf().setAppName("Foo")
val sc = new SparkContext(sparkConf)
```

The `SparkContext` constructor throws a `SparkException` if `spark.master` is not set though, so this fails immediately.

This changes all examples to call `new SparkContext("local[2]", "Foo")` or similar. `local[2]` because it's necessary for streaming examples and because it's otherwise used as the default over `local[1]` in Spark.

(Since this started off when debugging the Kafka streaming code, I also included some refinements there to the logging and resource management. Lightly related.)