spark streaming 5: InputDStream
InputDStream的继承关系。他们都是使用InputDStream这个抽象类的接口进行操作的。特别注意ReceiverInputDStream这个类,大部分时候我们使用的是它作为扩展的基类,因为它才能(更容易)使接收数据的工作分散到各个worker上执行,更符合分布式计算的理念。
所有的输入流都某个时间间隔将数据以block的形式保存到spark memory中,但以spark core不同的是,spark streaming默认是将对象序列化后保存到内存中。
/** * This is the abstract base class . This class provides methods * start() and stop() which is called by Spark Streaming system to . * Input streams that can  For example, * FileInputDStream, a subclass of InputDStream, monitors a HDFS directory from the driver for * new files and generates RDDs with the new files. . * * @param ssc_ Streaming context that will execute this input stream */abstract class T@transient extends Tprivatevar lastValidTimenull

  graphthis

/** * Abstract class for defining any [[org.apache.spark.streaming.dstream.InputDStream]] * that has to start a receiver on worker nodes to receive external data. *  * @param ssc_ Streaming context that will execute this input stream * @tparam T Class type of the object of this stream */abstract class T@transient extends T/** Keeps all received blocks information */  private lazy val new , /** This is an unique identifier for the network input stream. */  val id 

/** * Gets the receiver object that will be sent to the worker nodes * to receive data. This method needs to defined by any specific implementation * of a NetworkInputDStream. */def getReceiver(): Receiver[T]

最终都是以BlockRDD返回的
/** Ask ReceiverInputTracker for received data blocks and generates RDDs with them. */override def compute(validTime: Time): Option[RDD[T]] = {// If this is called for any time before the start time of the context,  // then this returns an empty RDD. This may happen when recovering from a  // master failure  if (validTime >= graph.startTime) {val blockInfo = ssc.scheduler.receiverTracker.getReceivedBlockInfo(id)receivedBlockInfo(validTime) = blockInfoval blockIds = blockInfo.map(_.blockId.asInstanceOf[BlockId])Some(new BlockRDD[T](ssc.sc, blockIds))  } else {Some(new BlockRDD[T](ssc.sc, Array[BlockId]()))  }}

From WizNote

posted on 2015-02-05 17:17 过雁 阅读(...) 评论(...) 编辑 收藏

转载于:https://www.cnblogs.com/zwCHAN/p/4275348.html

spark streaming 5: InputDStream相关推荐

  1. Spark Streaming笔记整理(二):案例、SSC、数据源与自定义Receiver

    [TOC] 实时WordCount案例 主要是监听网络端口中的数据,并实时进行wc的计算. Java版 测试代码如下: package cn.xpleaf.bigdata.spark.java.str ...

  2. 大数据技术之Spark Streaming概述

    前言 数据处理延迟的长短 实时数据处理:毫秒级别 离线数据处理:小时 or 天 数据处理的方式 流式(streaming)数据处理 批量(batch)数据处理 spark Streaming也是基于s ...

  3. Spark Streaming 常见的输入数据源(以WordCount计算为例)

      SparkStreaming中的数据抽象叫做DStream.DStream是抽象类,它把连续的数据流拆成很多的小RDD数据块, 这叫做"微批次", spark的流式处理, 都是 ...

  4. Spark Streaming揭秘 Day9 从Receiver的设计到Spark框架的扩展

    Spark Streaming揭秘 Day9 从Receiver的设计到Spark框架的扩展 Receiver是SparkStreaming的输入数据来源,从对Receiver整个生命周期的设计,我们 ...

  5. Spark Streaming Backpressure分析

    转载自:http://www.cnblogs.com/barrenlake/p/5349949.html# 1.为什么引入Backpressure 默认情况下,Spark Streaming通过Rec ...

  6. string 中的offset_Kafka+Spark Streaming管理offset的两种方法

    ​Kafka配合Spark Streaming是大数据领域常见的黄金搭档之一,主要是用于数据实时入库或分析. 为了应对可能出现的引起Streaming程序崩溃的异常情况,我们一般都需要手动管理好Kaf ...

  7. Spark Streaming 实战案例(一)

    本节主要内容 本节部分内容来自官方文档:http://spark.apache.org/docs/latest/streaming-programming-guide.html#mllib-opera ...

  8. Spark Streaming 实现思路与模块概述

    Spark Streaming 实现思路与模块概述 [酷玩 Spark] Spark Streaming 源码解析系列 ,返回目录请 猛戳这里 「腾讯·广点通」技术团队荣誉出品 本文内容适用范围: 2 ...

  9. spark streaming 的 Job创建、调度、提交

    2019独角兽企业重金招聘Python工程师标准>>> 上文已经从源码分析了Receiver接收的数据交由BlockManager管理,整个数据接收流都已经运转起来了,那么让我们回到 ...

最新文章

  1. JAVA中jsp怎么接收参数_如何使用JSP从URL获取参数
  2. java难点解析(七)-抽象类
  3. Python之Pandas:pandas.DataFrame.to_csv函数的简介、具体案例、使用方法详细攻略
  4. STM32 CJSON解析说明
  5. mq服务器与客户端消息同步,使用 ActiveMQ 实现JMS 异步调用
  6. axios 注册拦截器 cdn引用_PicGo+jsDelivr+GitHub搭建免费cdn加速的图床
  7. ThinkPHP对Cookie的支持
  8. jemter的竞品分析
  9. OPC DA通讯 KEP6.4 DCOM 配置脚本
  10. 不会使用Spring的配置文件,赶紧把这个甩给他
  11. Redmi K50评测:顶级2K屏加持 无愧全价位焊门员
  12. 为什么说“不要教你的孩子学编程”?
  13. DP练习(初级):ZigZag
  14. tuned-adm性能优化工具详解
  15. linux 7启动xserver,linux7.x下配置nginx开机自启动
  16. PAT-A1020:Tree Traversal(二叉树的重建及其中序、后序遍历)
  17. 圈圈教你玩USB(第二版) 笔记
  18. 在c语言中字母是几个字节的,在c语言中int占几个字节
  19. 学习java之前应该先了解哪些知识?
  20. 常用的一些vba代码

热门文章

  1. Docker 安装redis(四)
  2. [SQL Server]无法创建 SSIS 运行时对象,请验证 DTS.dll 是否可用及是否已注册
  3. PYthon3:函数实现“自动售卖机”功能
  4. CodeForces - 707C
  5. python -os、sys
  6. Android开发中Handler的经典总结
  7. jquery防止冒泡
  8. 洛谷P4382 劈配
  9. Properties文件读取学习笔记
  10. 运用Handler.post()方法进行数据更新跟用Message对比(18)