spark-streaming first insight
一、
Spark Streaming 构建在Spark core API之上,具备可伸缩,高吞吐,可容错的流处理模块。
1)支持多种数据源,如Kafka,Flume,Socket,文件等;
- Basic sources: Sources directly available in the StreamingContext API. Examples: file systems, and socket connections.
- Advanced sources: Sources like Kafka, Flume, Kinesis, etc. are available through extra utility classes. These require linking against extra dependencies.
2)处理完成数据可写入Kafka,Hdfs,本地文件等多种地方;
DStream:
Spark Streaming对持续流入的数据有个高层的抽像:
It represents a continuous stream of data
a DStream is represented by a continuous series of RDDs,Each RDD in a DStream contains data from a certain interval
Any operation applied on a DStream translates to operations on the underlying RDDs.
什么是RDD?
RDD是Resilient Distributed Dataset的缩写,中文译为弹性分布式数据集,是Spark中最重要的概念。
RDD是只读的、分区的,可容错的数据集合。
何为弹性?
RDD可在内存、磁盘之间任意切换
RDD可以转换成其它RDD,可由其它RDD生成
RDD可存储任意类型数据
二、基本概念
1)add dependency
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.11</artifactId>
<version>2.3.1</version>
</dependency>
其它想关依赖查询:
https://search.maven.org/search?q=g:org.apache.spark%20AND%20v:2.2.0
2)文件作为DStream源,是如何被监控的?
1)文件格式须一致
2)根据modify time开成流,而非create time
3)处理时,当前文件变更不会在此window处理,即不会reread
4)可以调用 FileSystem.setTimes()来修改文件时间,使其在下个window被处理,即使文件内容未被修改过
三、Transform operation
window operation
Spark Streaming also provides windowed computations, which allow you to apply transformations over a sliding window of data.
every time the window slides over a source DStream, the source RDDs that fall within the window are combined and operated upon to produce the RDDs of the windowed DStream.
在一个时间窗口内的RDD被合并为一个RDD来处理。
Any window operation needs to specify two parameters:
window length: The duration of the window
sliding interval: The interval at which the window operation if performed
四、Output operation
使用foreachRDD
dstream.foreachRDD is a powerful primitive that allows data to be sent out to external systems. However, it is important to understand how to use this primitive correctly and efficiently.
CheckPoint概念
Performance Tuning
Fault-tolerance Semantics
spark-streaming first insight的更多相关文章
- Offset Management For Apache Kafka With Apache Spark Streaming
An ingest pattern that we commonly see being adopted at Cloudera customers is Apache Spark Streaming ...
- Spark踩坑记——Spark Streaming+Kafka
[TOC] 前言 在WeTest舆情项目中,需要对每天千万级的游戏评论信息进行词频统计,在生产者一端,我们将数据按照每天的拉取时间存入了Kafka当中,而在消费者一端,我们利用了spark strea ...
- Spark Streaming+Kafka
Spark Streaming+Kafka 前言 在WeTest舆情项目中,需要对每天千万级的游戏评论信息进行词频统计,在生产者一端,我们将数据按照每天的拉取时间存入了Kafka当中,而在消费者一端, ...
- Storm介绍及与Spark Streaming对比
Storm介绍 Storm是由Twitter开源的分布式.高容错的实时处理系统,它的出现令持续不断的流计算变得容易,弥补了Hadoop批处理所不能满足的实时要求.Storm常用于在实时分析.在线机器学 ...
- flume+kafka+spark streaming整合
1.安装好flume2.安装好kafka3.安装好spark4.流程说明: 日志文件->flume->kafka->spark streaming flume输入:文件 flume输 ...
- spark streaming kafka example
// scalastyle:off println package org.apache.spark.examples.streaming import kafka.serializer.String ...
- Spark Streaming中动态Batch Size实现初探
本期内容 : BatchDuration与 Process Time 动态Batch Size Spark Streaming中有很多算子,是否每一个算子都是预期中的类似线性规律的时间消耗呢? 例如: ...
- Spark Streaming源码解读之No Receivers彻底思考
本期内容 : Direct Acess Kafka Spark Streaming接收数据现在支持的两种方式: 01. Receiver的方式来接收数据,及输入数据的控制 02. No Receive ...
- Spark Streaming架构设计和运行机制总结
本期内容 : Spark Streaming中的架构设计和运行机制 Spark Streaming深度思考 Spark Streaming的本质就是在RDD基础之上加上Time ,由Time不断的运行 ...
- Spark Streaming中空RDD处理及流处理程序优雅的停止
本期内容 : Spark Streaming中的空RDD处理 Spark Streaming程序的停止 由于Spark Streaming的每个BatchDuration都会不断的产生RDD,空RDD ...
随机推荐
- JavaScript 上万条数据 导出Excel文件 页面卡死
最近项目要js实现将数据导出excel文件,网上很多插件实现~~那个开心呀,谁知道后面数据量达到上万条时出问题:浏览器不仅卡死,导出的excel文件一直提示网络失败.... debug调试发现var ...
- Linux安装配置NFS教程(CentOS 6.5)
一.服务端安装nfs 1.1安装 yum install -y rpcbind yum install -y nfs-utils 1.2配置nfs共享目录 这里以/nfs目录为例 mkdir /nfs ...
- Linux 控制CPU使用率
曾经看过<编程之美>上提到说使 CPU的使用率固定在百分之多少.然后这次刚好要用到这个东西,下面是一个简单的实现.基于多线程: Linux 版本: #include <iostrea ...
- !important 的绝对控制样式
<head> <style type="text/css"> div{background-color: blue !important;} </st ...
- GCC 命令行详解 -L 指定库的路径 -l 指定需连接的库名 zhuan
1.gcc包含的c/c++编译器gcc,cc,c++,g++,gcc和cc是一样的,c++和g++是一样的,(没有看太明白前面这半句是什么意思:))一般c程序就用gcc编译,c++程序就用g++编译 ...
- OO Summary Ⅱ
[第五次作业——多线程电梯] 类图 度量 协作图 设计分析: 多线程电梯是我第一次接触多线程,因此真的是无(瞎)从(g)下(2)手(写),感觉仿佛只是用一个调度器来调度3部电梯但又总觉得好像哪里不太对 ...
- Linux查看某个进程的磁盘IO读写情况 pidstat
一.现象 1)钉钉告警不断,告警如下CPU使用达到100% 普罗米修斯监控 2)查看数据库,没有发现比平时同一时段,业务量的增加.但是,数据库显示latch free等告警,验证了CPU使用过高导致. ...
- java IO实例
import java.io.*; /** * Created by CLY on 2017/7/23. */ public class Main { public static void main( ...
- redis、memcache、mongoDB 对比
从以下几个维度,对 redis.memcache.mongoDB 做了对比. 1.性能 都比较高,性能对我们来说应该都不是瓶颈. 总体来讲,TPS 方面 redis 和 memcache 差不多,要大 ...
- 4.2 C++虚成员函数
参考:http://www.weixueyuan.net/view/6371.html 总结: virtual关键字仅用于函数声明,如果函数是在类外定义,则不需要再加上virtual关键字了. 在C+ ...