Spark Streaming的foreachRDD把处理后的数据写入外部存储系统中
2016-05-27 16:18
337 查看
1.代码
dstream.foreachRDD { rdd =>
rdd.foreachPartition { partitionOfRecords =>
// ConnectionPool is a static, lazily initialized pool of connections
val connection = ConnectionPool.getConnection()
partitionOfRecords.foreach(record => connection.send(record))
ConnectionPool.returnConnection(connection) // return to the pool for future reuse
}}
dstream.foreachRDD { rdd =>
rdd.foreachPartition { partitionOfRecords =>
// ConnectionPool is a static, lazily initialized pool of connections
val connection = ConnectionPool.getConnection()
partitionOfRecords.foreach(record => connection.send(record))
ConnectionPool.returnConnection(connection) // return to the pool for future reuse
}}
相关文章推荐
- 单例模式的八种写法比较
- Spark Streaming的window操作实战模拟新浪微博、百度、京东等热点搜索词案例实战
- 维基百科中凹函数的定义 Concave function
- 快速排序
- bootstrap 中 css 与 javascript 的使用
- Android Studio下实现隐藏标题栏和状态栏的闪屏页
- 通达OA工作流设计-关联子菜单(多级联动)及数据选择控件应用
- 用unordered_map代替hash_map
- SparkStreaming 实现广告计费系统中在线黑名单过滤实战
- Android Fragment的标准写法
- jqgrid json
- 百度定位+广播检测网络(小白版)
- 维基百科中凸函数的定义 Convex function
- SparkStreaming updateStateByKey 基本操作
- Java集合类详解
- 二叉树(二叉链表实现)JAVA代码
- vim简介及配置
- uses crt;
- PHP explode 按照固定字符截字符串成数组
- EBS查看报表或者账单的职责