Databases Reference
In-Depth Information
CHAPTER 3
Topologies
In this chapter, you'll see how to pass tuples between the different components of a
Storm
topology
, and how to deploy a topology into a running Storm cluster.
Stream Grouping
One of the most important things that you need to do when designing a topology is to
define how data is exchanged between components (how streams are consumed by the
bolts). A
Stream Grouping
specifies which stream(s) are consumed by each
bolt
and
how the stream will be consumed.
A node can emit more than one
stream
of data. A stream grouping allows
us to choose which stream to receive.
The stream grouping is set when the topology is defined, as we saw in
Chapter 2
:
...
builder
.
setBolt
(
"word-normalizer"
,
new
WordNormalizer
())
.
shuffleGrouping
(
"word-reader"
);
...
In the preceding code block, a bolt is set on the topology builder, and then a source is
set using the
shuffle stream grouping
. A stream grouping normally takes the source
component ID as a parameter, and optionally other parameters as well, depending on
the kind of stream grouping.
There can be more than one source per
InputDeclarer
, and each source
can be grouped with a different stream grouping.