Created
January 14, 2016 05:52
-
-
Save praveend/2ca728ca3839a09875e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Created by praveendevarao on 12/01/16. | |
| */ | |
| import org.apache.spark._ | |
| import org.apache.spark.storage.StorageLevel | |
| import org.apache.spark.streaming._ | |
| import org.apache.spark.streaming.StreamingContext._ | |
| object WordCount { | |
| def main(args: Array[String]) { | |
| val conf = new SparkConf().setMaster("local[*]").setAppName("streamapp") | |
| conf.set("spark.streaming.concurrentJobs","2") | |
| val ssc = new StreamingContext(conf, Seconds(1)) | |
| val lines = ssc.socketTextStream("localhost", 9999, StorageLevel.MEMORY_AND_DISK_SER) | |
| //val lines1 = ssc.socketTextStream("localhost", 8888, StorageLevel.MEMORY_AND_DISK_SER) | |
| val words = lines.flatMap(_.split(" ")) | |
| val wordCounts = words.map(x => (x, 1)).reduceByKey(_ + _) | |
| wordCounts.print() | |
| ssc.start() | |
| ssc.awaitTermination() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment