cyclone
Write Storm topologies in JavaScript.
Basic Example
;;;; let builder = ;builder;builder;builder; Cyclone;
Spouts
To write a Spout, merely extend the provided Spout
class and write your own implementation.
; { return 'sentence' ; } { let rand = Math; this; ; }
Default Methods
-
log
-
emit
Overridable Methods
-
declareOutputFields()
(optional, defaults to[]
) -
getComponentConfiguration()
(optional, defaults to{}
) -
nextTuple(id, done)
(required) -
ack(id, done)
(optional) -
fail(id, done)
(optional)
Bolts
Similar to Spouts, Bolts are created by extending the provided Bolt
base class.
; { return 'words' ; } { let sentence = tuplevalues; let words = sentence; for let word of words this; ; }
Default Methods
-
log
-
emit
Overridable Methods
-
declareOutputFields()
(optional, defaults to[]
) -
getComponentConfiguration()
(optional, defaults to{}
) -
prepare(config, context, done)
(optional) -
process(tuple, done)
(required)
Running a local cluster
To run a local cluster simply run your topology file with the --local
flag. For
example, if the Basic Example above were your index.js file, simply run
$ node . --local
. You will need Apache Storm installed and on your path as well
as an invocation of run
in your topology file:
Cyclone;
Submitting a Topology
To submit a topology you will need Apache Storm installed an on your path. If
that's the case, the easiest way would be to run the cyclone
command against
your topology using an npm script:
In this case, the cyclone
command will default to using the entrypoint file as
identified in the "main"
package.json
property. Otherwise a topology can
be specified using the -t/--topology
flag. By default, this submits the topology
to the Nimbus host configured in ~/.storm/storm.yaml
.
# ~/.storm/storm.yaml nimbus.host: "255.255.255.255"