Spark Streaming Application Simple example
Package Com.orc.stream
Import org.apache.spark.{ sparkconf, Sparkcontext}
import org.apache.spark.streaming.{ Seconds, StreamingContext}
/**
* Created by Dengni on 2016/9/15. Today also are mid-Autumn Festival
* Scala 2.10.4 ; 2.11.X not Works
* Use method:
* Start this program in this window *
192.168.184.188 Start command nc-l 7777 input value to print
* Here's the problem:
* C: \users\dengni>ncat localhost 8080
* NCAT: Unable to connect because the target computer is actively rejecting.
*/
object sparkstreaming {
def main (args:array[string]) {
val conf = new sparkconf (). Setappname (" Streaming "). Setmaster (" local[2] ")
// val sc = new Sparkcontext (conf)
val SSC = new StreamingContext ( Conf,seconds ())
val lines = Ssc.sockettextstream ("192.168.184.188", 7777)
//val errorlines = Lines.filter (_.contains ("error"))
Lines.print ()
print ("1")
Ssc.start ()
println (2)
ssc.awaittermination ()
}
}