spark streaming检查点使用
来源:互联网 发布:js uikit miniui 编辑:程序博客网 时间:2024/06/10 04:08
import org.apache.spark._import org.apache.spark.streaming._/** * Created by code-pc on 16/3/14. */object Pi { def functionToCreateContext():StreamingContext={ def updateStateFunction(newValues: Seq[Int], runningCount: Option[Int]): Option[Int] = { Some(runningCount.getOrElse(0) + newValues.sum) } val conf = new SparkConf().setMaster("local[5]").setAppName("AndrzejApp") val ssc = new StreamingContext(conf, Seconds(4)) ssc.checkpoint("/tmp") val line = ssc.socketTextStream("127.0.0.1", 9997) val words=line.flatMap(_.split(" ")) val pairs=words.map((_,1)) val retDS = pairs.updateStateByKey[Int](updateStateFunction _) //retDS.repartition(1).saveAsTextFiles("/tmp/out") retDS.print() ssc } def main(args: Array[String]) { val context=StreamingContext.getOrCreate("/tmp",functionToCreateContext) context.start() context.awaitTermination() }}
tcp: nc -lk 9997
If the checkpointDirectory exists, then the context will be recreated from the checkpoint data.
0 0
- spark streaming检查点使用
- spark streaming 检查点机制(checkpoint)
- Spark 检查点
- 使用 Spark Streaming 检测关键词
- Spark Streaming基本使用介绍
- spark流数据处理:Spark Streaming的使用
- spark流数据处理:Spark Streaming的使用
- spark之设置检查点
- Spark Streaming
- spark streaming
- Spark/Streaming
- Spark Streaming
- spark streaming
- Spark Streaming
- Spark Streaming
- Spark Streaming
- Spark Streaming
- spark streaming
- day04 网络编程(一)
- nyist 一笔画问题
- 类的定义
- 通过Java链接sqlsever2008报1433端口错误分析
- 毕业设计第二十八天
- spark streaming检查点使用
- 点评互联网产品经理面试问题汇总(18问)
- Java——return的作用
- JS BOM
- [BZOJ 3295]动态逆序对
- 并查集基础
- 动态规划题目特性
- c/c++时间函数使用方法
- node.js用get方式获取网页中的链接