流计算框架storm概览

news2024/10/2 14:21:05

Attention: 

supervison 和 nimbus的状态都实时保存在zookeeper集群中和本地.  Enchance, this means you can kill -9 Nimbus or the Supervisors and they'll start back up as nothing happened. 

Topologies

1. storm jar all-my-code.jar org.apache.storm.MyTopology arg1 arg2   

The main function of the class defines the topology and submits it to Nimbus. 

The storm jar part takes care of connecting to Nimbus and uploading the jar.

2. Since topology definitions are just Thrift structs, and Nimbus is a Thrift service, you can create and submit topologies using any programming language.    (相当于任何语言都可以进行http协议,提交服务器一样.)

(Thrift是一种接口描述语言和二进制通讯协议,它被用来定义和创建跨语言的服务。它被当作一个远程过程调用(RPC)框架来使用,是由Facebook为“大规模跨语言服务开发”而开发的。)

Streams

The core abstraction in Storm is the "stream".  A stream is an unbounded sequence of tuples.

Networks of spouts and bolts are packaged into a "topology" which is the top-level abstraction that you submit to Storm clusters for execution.

When a spout or bolt emits a tuple to a stream, it sends the tuple to every bolt that subscribed to that stream.

 

Data model

   Storm uses tuples(元组,数组.) as its data model. A tuple is a named list of values, and a field in a tuple can be an object of any type.

   Every node in a topology must declare the output fields for the tuples it emits.

   

A simple topology

TopologyBuilder builder = new TopologyBuilder();        
builder.setSpout("words", new TestWordSpout(), 10);        
builder.setBolt("exclaim1", new ExclamationBolt(), 3)
        .shuffleGrouping("words");
builder.setBolt("exclaim2", new ExclamationBolt(), 2)
        .shuffleGrouping("exclaim1");
 

Running ExclamationTopology in local mode

To run a topology in local mode run the command storm local instead of storm jar.

Stream groupings

TopologyBuilder builder = new TopologyBuilder();

builder.setSpout("sentences", new RandomSentenceSpout(), 5);        
builder.setBolt("split", new SplitSentence(), 8)
        .shuffleGrouping("sentences");
builder.setBolt("count", new WordCount(), 12)
        .fieldsGrouping("split", new Fields("word"));

 

分组类型的区别: shuffleGrouping, fieldsGrouping
shuffleGrouping 随机发送tuple给bolt.
fieldsGrouping 按照固定字段去发送tuple给bolt.

Fields groupings are the basis of implementing streaming joins and streaming aggregations as well as a plethora of other use cases. Underneath the hood, fields groupings are implemented using mod hashing.

字段分组是实现流连接和流聚合以及大量其他用例的基础。在幕后,字段分组是使用mod哈希实现的。

Defining Bolts in other languages

 Storm ships with adapter libraries for Ruby, Python, and Fancy.

public static class SplitSentence extends ShellBolt implements IRichBolt {
    public SplitSentence() {
        super("python", "splitsentence.py");
    }

    public void declareOutputFields(OutputFieldsDeclarer declarer) {
        declarer.declare(new Fields("word"));
    }
}
 

import storm

class SplitSentenceBolt(storm.BasicBolt):
    def process(self, tup):
        words = tup.values[0].split(" ")
        for word in words:
          storm.emit([word])

SplitSentenceBolt().run()

Trident (achieve exactly-once messaging semantics for most computations) 

Storm guarantees that every message will be played through the topology at least once. A common question asked is "how do you do things like counting on top of Storm? Won't you overcount?" Storm has a higher level API called Trudent that let you achieve exactly-once messaging semantics for most computations.  

大多数计算实现一次消息传递语义, 对统计具有重要意义.

Trident developed from an earlier effort to provide exactly-once guarantees for Storm

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/380318.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

父类子类静态代码块、构造代码块、构造方法执行顺序

github:https://github.com/nocoders/java-everything.git 名词解释 静态代码块:java中使用static关键字修饰的代码块,每个代码块只会执行一次,JVM加载类时会执行静态代码块中的代码,静态代码块先于主方法执行。构造代码块&#…

[Java面经] 三年工作经验, 极兔一二面

极兔一二面面经: 1. mysql的acid怎么实现的 这一点先回答ACID分别是A(原子性),C(一致性),I(隔离性),D(持久性), 其中持久性是数据库落磁盘的操作,无需额外实现. 隔离性是通过事务的隔离级别来实现, MySQL默认的隔离级别是RR(可重复读), 虽然上面还有一层Serializable(串行化…

如何在canvas中模拟css的背景图片样式

笔者开源了一个Web思维导图mind-map,最近在优化背景图片效果的时候遇到了一个问题,页面上展示时背景图片是通过css使用background-image渲染的,而导出的时候实际上是绘制到canvas上导出的,那么就会有个问题,css的背景图…

【日常总结】docker容器相互调用,占用服务器带宽解决方案

目录 一、场景: 1. 环境 2. 项目背景: 3. 全球时区解决方案 4. 方案二步骤 二、问题 三、产生原因 四、解决方案 五、解决步骤 六、整改效果 一、场景: docker容器相互调用,占用慢服务器带宽,导致netty连接的…

go 切片(slice)原理及用法注意事项

切片(slice)定义 go语言中的slice是一种数据结构,其定义为一个结构体,如下所示; type SliceHeader struct {Data uintptr // 指向底层数组的指针Len int // 切片的长度Cap int // 切片的容量 }切片与数组 切片的底层数据存储结构是 数组切片较为灵活,能动态扩容,而数组是定…

vue2使用v-viewer实现图片预览ImagePreview

追溯&#xff1a; View UI Plus 是 View Design 设计体系中基于 Vue.js 3 的一套 UI 组件库&#xff0c;里面有个组件ImagePreview可以实现“图片预览”。 使用ImagePreview组件&#xff0c;报错&#xff1a; [Vue warn]: Unknown custom element: <ImagePreview> - d…

odoo15 标题栏自定义

odoo15 标题栏自定义 如何显示为自定义呢 效果如下: 代码分析: export class WebClient extends Component {setup() {this.menuService = useService("menu");this.actionService = useService("action");this.title = useService("title&…

在Docker 上完成对Springboot+Mysql+Redis的前后端分离项目的部署(全流程,全截图)

本文章全部阅读大约2小时&#xff0c;包含一个完整的springboot vue mysqlredis前后端分离项目的部署在docker上的全流程&#xff0c;比较复杂&#xff0c;请做好心理准备&#xff0c;遇到问题可留言或则私信 目录 1 安装Docker&#xff0c;以及简单使用参照 2 Docker部署m…

HOT100--(3)无重复字符的最长子串

点击查看题目详情 大思路&#xff1a; 创建哈希表&#xff0c;元素类型为<char, int>&#xff0c;分别是字符与其对应下标 用哈希表来存储未重复的子串&#xff0c;若有重复则记录下当前子串最大值maxhashsize 并且开始以相同方法记录下一子串 遍历完成以后&#xff0c…

Android OpenCV(七十三):吊打高斯模糊的StackBlur Android 实践

前言 OpenCV 4.7.0 2022年12月28日Release,ChangeLog中提到 Stackblur algorithm implementation. Stackblur是一种高斯模糊的快速近似,由Mario Klingemann发明。其计算耗时不会随着kernel size的增大而增加,专为大kernel size的模糊滤波场景量身定制。 使用建议:当kerne…

[RDMA-高级计算机网络report] Congestion Control for Large-Scale RDMA Departments

本文主要解决的问题是在RoCEv2体系中&#xff0c;基于优先级的拥塞控制PFC是一种粗粒度的机制。 它在端口&#xff08;或端口加优先级&#xff09;级别上运行&#xff0c;并且不区分流。PAUSE机制是基于每个端口&#xff08;和优先级&#xff09;的&#xff0c;而不是基于每个流…

mysql数据库之索引使用原则

一、最左前缀法则。 1、如果索引使用了多列&#xff08;联合索引&#xff09;&#xff0c;要遵守最左前缀法则。最左前缀法则指的是查询从索引的最左列开始&#xff0c;并且不跳过索引中的列。 如果跳跃到某一列&#xff0c;索引将部分失效&#xff08;后面的字段索引失效&am…

springboot启动时遇见的版本不同、无法启动、自动停止问题解决方案

Springboot项目启动失败初来乍到&#xff0c;听说springboot很好用&#xff0c;很简便&#xff0c;于是爱搞事情的我就打算试试&#xff0c;因为最近在找工作&#xff0c;很多软件开发的也要求springboot的使用&#xff0c;于是我就开启了springboot的学习之旅&#xff0c;打算…

Vue3 企业级项目实战:认识 Spring Boot

Vue3 企业级项目实战 - 程序员十三 - 掘金小册Vue3 Element Plus Spring Boot 企业级项目开发&#xff0c;升职加薪&#xff0c;快人一步。。「Vue3 企业级项目实战」由程序员十三撰写&#xff0c;2744人购买https://s.juejin.cn/ds/S2RkR9F/ 越来越流行的 Spring Boot Spr…

人工智能及其应用(蔡自兴)期末复习

人工智能及其应用&#xff08;蔡自兴&#xff09;期末复习 相关资料&#xff1a; 人工智能期末复习 人工智能复习题 人工智能模拟卷 人工智能期末练习题 1 ⭐️绪论 人工智能&#xff1a;人工智能就是用人工的方法在机器&#xff08;计算机&#xff09;上实现的智能&#xff0…

攻不下dfs不参加比赛(八)

标题 为什么练dfs题目重点为什么练dfs 相信学过数据结构的朋友都知道dfs(深度优先搜索)是里面相当重要的一种搜索算法,可能直接说大家感受不到有条件的大家可以去看看一些算法比赛。这些比赛中每一届或多或少都会牵扯到dfs,可能提到dfs大家都知道但是我们为了避免眼高手低有…

2.2 数据库的常用操作

文章目录1.分类2.创建数据库3.删除数据库4.查看所有数据库5.备份数据库6.数据库维护7.数据库使用与结构7.1 数据库的使用7.2 数据库结构虽然我们已经安装了可视化视图软件&#xff0c;但前期为了熟悉管理命令行的操作&#xff0c;我们暂时先在管理命令窗口进行操作&#xff1a;…

关于.bashrc和setup.bash的理解

在创建了ROS的workspace后&#xff0c;需要将workspace中的setup.bash文件写入~/.bashrc 文件中&#xff0c;让其启动&#xff1a; source /opt/ros/melodic/setup.bash这句话的目的就是在开新的terminal的时候&#xff0c;运行这个setup.bash&#xff0c;而这个setup.bash的作…

【2373. 矩阵中的局部最大值】

来源&#xff1a;力扣&#xff08;LeetCode&#xff09; 描述&#xff1a; 给你一个大小为 n x n 的整数矩阵 grid 。 生成一个大小为 (n - 2) x (n - 2) 的整数矩阵 maxLocal &#xff0c;并满足&#xff1a; maxLocal[i][j] 等于 grid 中以 i 1 行和 j 1 列为中心的 3 …

搭建私人《我的世界》服务器,使用Cpolar内网穿透更简单

文章目录1.前言2.本地服务器搭建2.1 设置环境变量2.2 进行《我的世界》服务器端设置2.3 测试和使用3.本地MC服务器的内网穿透3.1.Cpolar云端设置3.2.Cpolar本地设置3.3.测试和使用4.结语1.前言 要说去年游戏圈的重磅大瓜&#xff0c;想必网易和暴雪的分家必能上榜。虽然两家大…