Spark Streaming Tutorials

Source: Internet
Author: User

Nonsense not to say, first, an example, a perceptual knowledge to introduce.

This example comes from the example of Spark's own, and the basic steps are as follows:

(1) Use the following command to enter a stream message:

$ nc-lk 9999

(2) Run Networkwordcount in a new terminal to count the number of words and output:

$ bin/run-example streaming.networkwordcount localhost 9999

(3) Type some content into the input process created in the first step and see the results in the terminal created in the second step, such as:

The contents of the first terminal input:

Hello World again

Output of the second port

-------------------------------------------
time:1436758706000 ms
-------------------------------------------
(again,1)
(hello,1)
(world,1)

To explain briefly, the above example prints the results by manually typing the content and passing it to spark streaming to count the number of words.

Attached code:

Package Org.apache.spark.examples.streamingimport Org.apache.spark.SparkConfimport org.apache.spark.streaming. {Seconds, streamingcontext}import org.apache.spark.storage.storagelevel/** * Counts words in UTF8 encoded, ' \ n ' Delimited text received from the network every second.  * * Usage:networkwordcount 

  

Spark Streaming Tutorials

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.