I am new in storm and trying to understand the flow of execution of different methods from spout
to bolt
.
Like spout has different methods like
nextTuple()
open()
declareOutputFields()
activate()
deactivate()
and bolt has methods like
prepare()
execute()
cleanup()
declareOutputFields()
so can anyone tell me the sequence of execution of these methods ?
First, when your topology is started...
- Create Spouts and Bolts
declareOutputFields
- Spouts/Bolts serialized and assigned to workers
Second, in each worker somewhere on the cluster...
- Spouts
open
and Boltsprepare
(happens once) - In a loop...
- Spouts call
ack
,fail
, andnextTuple
- Bolts call
execute
- Spouts call
If your topology is deactivated...
- Your spouts
deactivate
method will be called. When you activate the topology again thenactivate
will be called.
If your topology is killed...
- Spouts might have
close
called - Bolts might have
cleanup
called
Note:
There is no guarentee that close will be called, because the supervisor kill -9's worker processes on the cluster. source
来源:https://stackoverflow.com/questions/28981197/execution-flow-of-a-storm-program