Skip to content

Commit cee3b43

Browse files
mateizpwendell
authored andcommitted
Merge pull request alteryx#63 from pwendell/master
Fixing spark streaming example and a bug in examples build. - Examples assembly included a log4j.properties which clobbered Spark's - Example had an error where some classes weren't serializable - Did some other clean-up in this example (cherry picked from commit 28e9c2a) Signed-off-by: Patrick Wendell <pwendell@gmail.com>
1 parent 1d92983 commit cee3b43

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

examples/src/main/scala/org/apache/spark/streaming/examples/clickstream/PageViewGenerator.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@
1717

1818
package org.apache.spark.streaming.examples.clickstream
1919

20-
import java.net.{InetAddress,ServerSocket,Socket,SocketException}
21-
import java.io.{InputStreamReader, BufferedReader, PrintWriter}
20+
import java.net.ServerSocket
21+
import java.io.PrintWriter
2222
import util.Random
2323

2424
/** Represents a page view on a website with associated dimension data.*/
25-
class PageView(val url : String, val status : Int, val zipCode : Int, val userID : Int) {
25+
class PageView(val url : String, val status : Int, val zipCode : Int, val userID : Int)
26+
extends Serializable {
2627
override def toString() : String = {
2728
"%s\t%s\t%s\t%s\n".format(url, status, zipCode, userID)
2829
}
2930
}
30-
object PageView {
31+
32+
object PageView extends Serializable {
3133
def fromString(in : String) : PageView = {
3234
val parts = in.split("\t")
3335
new PageView(parts(0), parts(1).toInt, parts(2).toInt, parts(3).toInt)
@@ -39,6 +41,9 @@ object PageView {
3941
* This should be used in tandem with PageViewStream.scala. Example:
4042
* $ ./run-example spark.streaming.examples.clickstream.PageViewGenerator 44444 10
4143
* $ ./run-example spark.streaming.examples.clickstream.PageViewStream errorRatePerZipCode localhost 44444
44+
*
45+
* When running this, you may want to set the root logging level to ERROR in
46+
* conf/log4j.properties to reduce the verbosity of the output.
4247
* */
4348
object PageViewGenerator {
4449
val pages = Map("http://foo.com/" -> .7,

project/SparkBuild.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ object SparkBuild extends Build {
311311
mergeStrategy in assembly := {
312312
case m if m.toLowerCase.endsWith("manifest.mf") => MergeStrategy.discard
313313
case m if m.toLowerCase.matches("meta-inf.*\\.sf$") => MergeStrategy.discard
314+
case "log4j.properties" => MergeStrategy.discard
314315
case "META-INF/services/org.apache.hadoop.fs.FileSystem" => MergeStrategy.concat
315316
case "reference.conf" => MergeStrategy.concat
316317
case _ => MergeStrategy.first

0 commit comments

Comments
 (0)