You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@storm.apache.org by Jonathan Yom-Tov <jo...@gmail.com> on 2014/11/06 17:49:43 UTC

How to implement loops and multiple inputs/outputs

I want to implement the following topology in Storm:

    a1->a2->a3->a4
        |        |
         -<----<


    b1->b2->b3->b4
        |        |
         -<----<

Note that a1, b1 and a2, b2 etc. are identical bolts. There are two
identical streams but tuples passed between the bolts must remain within
the stream. There is also a loop leading from a3->a1, b3->b1.

To implement the separate streams I thought of either using fieldsGrouping
on a streamID field or creating a separate streamID for each stream. The
latter option seems better but my implementation below seems inelegant.

    builder.setBolt("a2", new A2(), 1).shuffleGrouping("a1", "streamA");
    builder.setBolt("b2", new B2(), 1).shuffleGrouping("b1", "streamB");

And then continuing in the same vein to implement the second requirement:

    builder.setBolt("a1", new A2(), 1).shuffleGrouping("a3", "stream1");

Is there a better way?