天天看点

Storm-源码分析- spout (backtype.storm.spout)

ispout作为实现spout的核心interface, spout负责feeding message, 并且track这些message. 

如果需要spout track发出的message, 必须给出message-id, 这个message-id可以是任意类型, 但是如果不指定或将message-id置空, storm就不会track这个message

必须要注意的是, spout线程会在一个线程中调用ack, fail, nexttuple, 所以不用考虑互斥, 但是也要这些function中, 避免任意的block

用于expose spout发送(emit) tuples的接口 

和bolt的output collector相比, spout的output collector可以指定message-id, 用于spout track该message

emit

list<integer> emit(string streamid, list<object> tuple, object messageid) 

emit, 3个参数, 发送到的streamid, tuple, 和message-id 

        如果streamid为空, 则发送到默认stream, utils.default_stream_id 

        如果messageid为空, 则spout不会track this message 

        1个返回值, 最终发送到的task ids

emitdirect

void emitdirect(int taskid, string streamid, list<object> tuple, object messageid)

directgrouping, 直接通过taskid指定发送的task

继续阅读