STORM_0007_Multi-Lang protocol of Storm/多语言协议的翻译
原始地址:
- 所有的协议的结束都使用一种line-reading机制,所以确保从输入修剪掉新行,并附加到输出上
- 所有的JSON类型的输入和输出都被任何一行含有end的行终结,确保不要出现在JSON中被解析出来。
- Initial Handshake
- 初始化握手适合各种类型的shell组件
- 对STDIN:设置一些info
- 这是一个JSON对象,包含配置,PID目录,和一个topo内容
{
"conf": {
"topology.message.timeout.secs": 3,
// 各种的配置信息,可以按照上面的格式去写
},
"pidDir": "...",
"context": {
"task->component": {
"1": "example-spout",
"2": "__acker",
"3": "example-bolt1",
"4": "example-bolt2"
},
"taskid": 3,
// 下面的设置仅仅试用0.10.0之后的版本
"componentid": "example-bolt"
"stream->target->grouping": {
"default": {
"example-bolt2": {
"type": "SHUFFLE"}}},
"streams": ["default"],
"stream->outputfields": {"default": ["word"]},
"source->stream->grouping": {
"example-spout": {
"default": {
"type": "FIELDS",
"fields": ["word"]
}
}
}
"source->stream->fields": {
"example-spout": {
"default": ["word"]
}
}
}
}脚本应当能创建出一个名字为PID的空文件,这个文件使得supervisor知道PID可以在随后关闭进程
自从0.10.0之后的版本的shell组件能配置的context被提高了,基本上包含了所有的方面的内容,可以被JVM使用。重要的特征是:stream->target->grouping和source->stream->grouping可以分别可以决定输入源和输出目标
- STDOUT:使用{"pid":1234}可以将PID打日志到log中。
- Spouts
- Shell Spout是同步的,要是没有输入就一直在while循环中休息
- 对STDIN
- next是ISpout的nextTuple,这样使用:{"command":"next"}
- ack这样使用{"command":"ack","id":"1231231"}
- fail这样使用{"command":"fail","id":"1231231"}
- 对STDOUT
- 结果可能是发射的东西或者是logs序列
- emit像这样
{
"command": "emit",
// The id for the tuple. Leave this out for an unreliable emit. The id can
// be a string or a number.
"id": "1231231",
// The id of the stream this tuple was emitted to. Leave this empty to emit to default stream.
"stream": "1",
// If doing an emit direct, indicate the task to send the tuple to
"task": 9,
// All the values in this tuple
"tuple": ["field1", 2, 3]
} - logs像这样
{
"command": "log",
// the message to log
"msg": "hello world!"
} - 对STDOUT
- 用sync命令去使得发射和打日志停止
{"command": "sync"}
直到发送另外的next或者ack或者fail指令的时候,ShellSpout才读取你的输出 和ISpout一样,如果没有流要发射的时候,应该在sync之前sleep一下,因为ShellSpout不会自动的sleep
- Bolts
- Shell Bolt协议是异步的,一旦STDIN的流可用时候你将收到这个流,你可以在任何时候写到STDOUT上,通过发射,ack,fail,log等
- 对STDIN:是一个tuple但是是JSON类型的tuple
{
// The tuple's id - this is a string to support languages lacking 64-bit precision
"id": "-6955786537413359385",
// The id of the component that created this tuple
"comp": "1",
// The id of the stream this tuple was emitted to
"stream": "1",
// The id of the task that created this tuple
"task": 9,
// All the values in this tuple
"tuple": ["snow white and the seven dwarfs", "field2", 3]
} - 对STDOUT:是一个ack,fail,log,或者emit。
- 下面是个emit的例子
{
"command": "emit",
// The ids of the tuples this output tuples should be anchored to
"anchors": ["1231231", "-234234234"],
// The id of the stream this tuple was emitted to. Leave this empty to emit to default stream.
"stream": "1",
// If doing an emit direct, indicate the task to send the tuple to
"task": 9,
// All the values in this tuple
"tuple": ["field1", 2, 3]
}如果不立即发射的话,你将接收到,发射流的task id。因为异步的特性,在读之后发射的话,可能收不到task id,可能会读取到上一个发射的task id或者新的发射进程。但是不管怎样,你将会按照发射的顺序接收到task id。
- ack的样子
{
"command": "ack",
// the id of the tuple to ack
"id": "123123"
} - fail的样子
{
"command": "fail",
// the id of the tuple to fail
"id": "123123"
} - log的样子
{
"command": "log",
// the message to log
"msg": "hello world!"
} - Handling Heartbeats(0.9.3之后的版本)
- 在storm0.9.3中,心跳已经被使用在ShellSpout或者ShellBolt和他们的多语言的子进程中,去监测这些子进程的hanging和zombie
- 对于Spout
- 因为是同步的,子进程总是在next()的最后发送sync,所以不用做太多去支持心跳的检测。但是在next()中不能让子进程sleep的时间超过timeout。
- 对于bolt
- 因为是异步的,所以ShellBolt总是定期的发送心跳包,格式如下
{
"id": "-6955786537413359385",
"comp": "1",
"stream": "__heartbeat",
// this shell bolt's system task id
"task": -1,
"tuple": []
}当子进程接收到心跳tuple的时候,会发送sync给ShellBolt
STORM_0007_Multi-Lang protocol of Storm/多语言协议的翻译的更多相关文章
- IMAP(Internet Mail Access Protocol,Internet邮件访问协议)以前称作交互邮件访问协议(Interactive Mail Access Protocol)。
IMAP(Internet Mail Access Protocol,Internet邮件访问协议)以前称作交互邮件访问协议(Interactive Mail Access Protocol).IMA ...
- Caused by: java.lang.ClassNotFoundException: backtype.storm.topology.IRichSpout
1:初次运行Strom程序出现如下所示的错误,贴一下,方便脑补,也希望帮助到看到的小伙伴: 错误如下所示,主要问题是刚开始使用maven获取jar包的时候需要写<scope>provide ...
- TFTP(Trivial File Transfer Protocol,简单文件传输协议)
TFTP(Trivial File Transfer Protocol,简单文件传输协议),是 TCP/IP 协议族中用来在客户机和服务器之间进行简单文件传输的协议,开销很小.这时候有人可能会纳闷,既 ...
- ICMP(Internet Control Message Protocol)网际控制报文协议初识
ICMP是(Internet Control Message Protocol)Internet控制报文协议.它是TCP/IP协议族的一个子协议,用于在IP主机.路由器之间传递控制消息.控制消息是指网 ...
- 多点触摸(MT)协议(翻译)
参考: http://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt 转自:http://www.arm9home.ne ...
- yaml语言在线可视化翻译
yaml语言在线可视化翻译 https://editor.swagger.io/
- Impala SQL 语言元素(翻译)[转载]
原 Impala SQL 语言元素(翻译) 本文来源于http://my.oschina.net/weiqingbin/blog/189413#OSC_h2_2 摘要 http://www.cloud ...
- Go语言使用百度翻译api
Go语言使用百度翻译api 之前做过一个使用百度翻译api的工具,这个工具用于用户的自动翻译功能,是使用C#调用百度翻译api接口,既然在学习Go语言,那必然也是要使用Go来玩耍一番.这里我是这么安排 ...
- 在centos 6.9下Protocol Buffers数据传输及存储协议的使用(python)
我们知道Protocol Buffers是Google定义的一种跨语言.跨平台.可扩展的数据传输及存储的协议,因为将字段协议分别放在传输两端,传输数据中只包含数据本身,不需要包含字段说明,所以传输数据 ...
随机推荐
- Linux 中open系统调用实现原理【转】
转自:http://blog.chinaunix.net/uid-25968088-id-3426026.html 目录 OPEN系统调用过程 Open在内核里面的入口函数时sys_open Sys_ ...
- c# 定时执行python脚本
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 这个Glance的界面该怎么看出问题,为什么状态是SOCKT?
这个glance的状态图有问题吗?
- oracle VS postgresql系列-行列转换
[需求]例如先有数据为 id | name ------+--------- | lottu | xuan | rax | ak | vincent 现在需要转换为 id | names ------ ...
- 每日一九度之 题目1033:继续xxx定律
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5502 解决:1351 题目描述: 当n为3时,我们在验证xxx定律的过程中会得到一个序列,3,5,8,4,2,1,将3称为关键数, ...
- ACM题目————小A的计算器
Description 以往的操作系统内部的数据表示都是二进制方式,小A新写了一个操作系统,系统内部的数据表示为26进制,其中0-25分别由a-z表示. 现在小A要在这个操作系统上实现一个计算器,这 ...
- 温故而知新 clone
浅复制(浅克隆) 被复制对象所有变量都含有与原来对象的相同值,对象中对其他对象的引用仍然指向原来的对象,换言之,复制对象只复制考虑的对象,而不复制所引用的对象.继承自java.lang.Object类 ...
- 【转】MYSQL入门学习之十三:自定义函数的基本操作
转载地址:http://www.2cto.com/database/201212/177382.html 一.自定义函数(UDF)的特性和功能 www.2cto.com 函数能分 ...
- Cookie机制(会话cookie和持久化cookie)在客户端保持HTTP状态信息的方案
1. Cookie只有一个name和一个value,不同于map;购物车设计的时候需要cookie,获取购物车的cookie id,以便于将物品多次放入购物车: 2.cookie获取了其地址,并且可以 ...
- Doubles 分类: POJ 2015-06-12 18:24 11人阅读 评论(0) 收藏
Doubles Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 19954 Accepted: 11536 Descrip ...