/**
* Created by Administrator on 2016/9/24 0024.
*/
package com.keduo
import java.util.Properties
import org.apache.log4j.{Level, Logger}
import org.apache.spark.streaming.{Seconds, StreamingContext}
import org.apache.spark.{SparkConf, SparkContext}
object SparkStreamingLocalfile {
def main(args: Array[String]): Unit = {
Logger.getLogger("org.apache.spark").setLevel(Level.WARN);
Logger.getLogger("org.eclipse.jetty.server").setLevel(Level.OFF);
val sparkConf = new SparkConf().setAppName("SparkStreamingLocalfile").setMaster("local[2]");
val ssc = new StreamingContext(sparkConf,Seconds(60))
val fileStream= ssc.fileStream("d:/WordCount.txt")
fileStream.print()
val textFileStream=ssc.textFileStream("d:/WordCount.txt")
val words = textFileStream.flatMap(_.split(" "))
val wordCounts = words.map(x => (x, 1))
wordCounts.print()
textFileStream.print()
ssc.start()
ssc.awaitTermination()
}
}
网上怎么也查不到资料,半天时间就这么没有了
|