Spark Streaming Application Simple example __spark

Source: Internet
Author: User

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 ()


  }

}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.