Databases Reference
In-Depth Information
function storm_ack ( $id ) {
storm_send ([ "command" => "ack" , "id" => " $id " ]);
}
function storm_log ( $msg ) {
$msg = array ( "command" => "log" , "msg" => " $msg " );
storm_send ( $msg );
}
$config = json_decode ( read_msg (), true );
$heartbeatdir = $config [ 'pidDir' ];
$pid = getmypid ();
fclose ( fopen ( " $heartbeatdir / $pid " , "w" ));
storm_send ([ "pid" => $pid ]);
flush ();
while ( true ) {
$msg = read_msg ();
$tuple = json_decode ( $msg , true , 512 , JSON_BIGINT_AS_STRING );
if ( ! empty ( $tuple [ "id" ])) {
if ( isPrime ( $tuple [ "tuple" ][ 0 ])) {
storm_emit ( array ( $tuple [ "tuple" ][ 0 ]));
}
storm_ack ( $tuple [ "id" ]);
}
}
?>
It is important to put all these scripts in a special folder called multilang/
resources in your project directory. This folder gets included in the jar
file that is sent to the workers. If you don't put the scripts in that folder,
Storm won't be able to run them and will report an error.
 
Search WWH ::




Custom Search