Databases Reference
In-Depth Information
builder . setBolt ( "word-counter" , new WordCounter (), 2 )
. shuffleGrouping ( "word-normalizer" );
If you rerun the program, you'll see:
-- Word Counter [word-counter-2] --
application: 1
is: 1
great: 1
are: 1
powerful: 1
Storm: 3
-- Word Counter [word-counter-3] --
really: 1
is: 1
but: 1
great: 1
test: 1
simple: 1
an: 1
very: 1
Awesome! It's so easy to change the level of parallelism (in real life, of course, each
instance would run on a separate machine). But there seems to be a problem: the words
is and great have been counted once in each instance of WordCounter . Why? When you
use shuffleGrouping , you are telling Storm to send each message to an instance of your
bolt in randomly distributed fashion. In this example, it'd be ideal to always send the
same word to the same WordCounter . To do so, you can change shuffleGrouping("word-
normalizer") to fieldsGrouping("word-normalizer",new Fields("word")) . Try it out
and rerun the program to confirm the results. You'll see more about groupings and
message flow in later chapters.
Conclusion
We've discussed the difference between Storm's Local and Remote operation modes,
and the power and ease of development with Storm. You also learned more about some
basic Storm concepts, which we'll explain in depth in the following chapters.
 
Search WWH ::




Custom Search