Finally, this can be further optimized by reusing connection objects across multiple RDDs/batches. One can maintain a static pool of connection objects than can be reused as RDDs of multiple batches are pushed to the external system, thus further reducing the overheads.

Scala
Python
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
}
}

http://spark.apache.org/docs/1.6.1/streaming-programming-guide.html#output-operations-on-dstreams

output-operations-on-dstreams的更多相关文章

  1. No output operations registered, so nothing to execute

    SparkStreaming和KafKa结合报错!报错之前代码如下: object KafkaWordCount{ val updateFunc = (iter:Iterator[(String,Se ...

  2. 2、 Spark Streaming方式从socket中获取数据进行简单单词统计

    Spark 1.5.2 Spark Streaming 学习笔记和编程练习 Overview 概述 Spark Streaming is an extension of the core Spark ...

  3. Spark Streaming编程指南

    Overview A Quick Example Basic Concepts Linking Initializing StreamingContext Discretized Streams (D ...

  4. 通过Spark Streaming的foreachRDD把处理后的数据写入外部存储系统中

    转载自:http://blog.csdn.net/erfucun/article/details/52312682 本博文主要内容包括: 技术实现foreachRDD与foreachPartition ...

  5. Spark的Streaming和Spark的SQL简单入门学习

    1.Spark Streaming是什么? a.Spark Streaming是什么? Spark Streaming类似于Apache Storm,用于流式数据的处理.根据其官方文档介绍,Spark ...

  6. Spark Streaming笔记

    Spark Streaming学习笔记 liunx系统的习惯创建hadoop用户在hadoop根目录(/home/hadoop)上创建如下目录app 存放所有软件的安装目录 app/tmp 存放临时文 ...

  7. Spark Streaming核心概念与编程

    Spark Streaming核心概念与编程 1. 核心概念 StreamingContext Create StreamingContext import org.apache.spark._ im ...

  8. Spark之 Spark Streaming流式处理

    SparkStreaming Spark Streaming类似于Apache Storm,用于流式数据的处理.Spark Streaming有高吞吐量和容错能力强等特点.Spark Streamin ...

  9. Spark Streaming - DStream

    1 Overview Spark Streaming is an extension of the core Spark API that enables scalable, high-through ...

  10. <译>Spark Sreaming 编程指南

    Spark Streaming 编程指南 Overview A Quick Example Basic Concepts Linking Initializing StreamingContext D ...

随机推荐

  1. numpy中的np.random.mtrand.RandomState

    1 RandomState 的应用场景概述 在训练神经网络时,苦于没有数据,此时numpy为我们提供了 “生产” 数据集的一种方式. 例如在搭建神经网络(一)中的 4.3 准备数据集 章节中就是采用n ...

  2. atom介绍

    在公司微信群,看到activate-power-mode插件的效果,很绚丽,才知道github自己出了一个自己的编辑器atom 官网地址 https://atom.io 官网看了下,atom编辑器的特 ...

  3. 还没被玩坏的robobrowser(5)——Beautiful Soup的过滤器

    背景 本节的知识还是属于Beautiful Soup的内容. Beautiful Soup的find和find_all方法非常强大,他们支持下面一些类型的过滤器. 字符串 最简单的过滤器是字符串.在搜 ...

  4. There is no Action mapped for namespace / and action name . - [unknown location]

    今天碰到了这个问题,原因不明白. 在webContent下建立了index.jsp后重启项目不报错了. 原因未知.

  5. JS 在 IE9 中出现奇怪的错误(参数是必选项 argument not optional)

    最近发现之前运行正常的网站,在 IE9 下会报这个错误.网上查了一下,发现是跟我的方法名字有关... 我起了一个叫做 addFilter 名字的方法,但是很不巧,IE9 里也有一个这个名字的方法,所以 ...

  6. 如何使Android应用支持多种屏幕分辨率

    原文:http://android.eoe.cn/topic/android_sdk 描述: 让您指定您的应用支持的屏幕的大小并且可以通过屏幕兼容模式来支持比您应用所支持更大的屏幕.所以这对于您需要在 ...

  7. Android:UI 沉浸式体验,适合第一屏的引导图片、预览图片。

    链接:http://www.cnblogs.com/liushilin/p/5799381.html

  8. SQLMap 学习

    注入完整流程:http://mp.weixin.qq.com/s/G_DUUVuPH9DeWagjELCPfA sqlmap命令:http://www.cnblogs.com/handt/p/855f ...

  9. iOS-登录认证/json解析

    用户输入用户名和密码,点击登录...我们把用户名和密码(用post方式或者get方式,get方式多用于测试看你需要)传给服务器,服务器进行判断,然后返回一个接口给我们(这里服务器返回的json接口,正 ...

  10. create-react-app 使用详解

    快速开始 npm install -g create-react-app create-react-app my-app cd my-app/ npm start 通过http://localhost ...