Databases Reference
In-Depth Information
In the constructor, just tell Storm how to run the PHP script. This is the equivalent of
the following bash command:
php -f PrimeNumbersFilterBolt.php
The PrimeNumbersFilterBolt PHP script reads tuples from standard input, processes
them, and emits, acks, or fails to standard output. Before going over the implementation
of the PrimeNumbersFilterBolt.php script, let's look in more detail at how the multilang
protocol works.
The Multilang Protocol Specification
The protocol relies on standard input and standard output as a channel of communi-
cation between processes. Follow the steps a script needs to take in order to work:
1. Initiate a handshake.
2. Start looping.
3. Read or write tuples.
There is a special way of logging from your script that uses Storm's built-
in logging mechanism, so you don't need to implement your own log-
ging system.
Let's take a look at the detail of each of these steps, and how to implement it using a
PHP script.
Initial Handshake
In order to control the process (to start and stop it), Storm needs to know the process
ID (PID) of the script it is executing. According to the multilang protocol, the first thing
that will happen when your process starts is that Storm will send a JSON object with
storm configuration, topology context, and a PID directory to standard input. It will
look something like the following code block:
{
"conf" : {
"topology.message.timeout.secs" : 3 ,
// etc
},
"context" : {
"task->component" : {
"1" : "example-spout" ,
"2" : "__acker" ,
"3" : "example-bolt"
},
"taskid" : 3
},
 
Search WWH ::




Custom Search