Database Reference
In-Depth Information
6. Execute the topology using the run command and you should be able to
see the output as shown in the following screenshot:
To understand the functioning of the topology, let's take a look at the code and understand
the flow and functioning of each component in the topology:
// instantiates the new builder object
TopologyBuilder builder = new TopologyBuilder();
// Adds a new spout of type "RandomSentenceSpout" with a
parallelism hint of 5
builder.setSpout("spout", new RandomSentenceSpout(), 5);
Starting with the main function, in the WordCountTopology.java class, we find the
TopologyBuilder object called builder ; this is important to understand as this is
the class that provides us with a template to define the topology. This class exposes the
API to configure and wire in various spouts and bolts into a topology—a topology that is
essentially a thrift structure at the end.
In the preceding code snippet, we created a TopologyBuilder object and used the
template to perform the following:
setSpout -RandomSentenceSpout : This generates random sentences.
Please note that we are using a property called parallelism hint, which is set to 5
here. This is the property that identifies how many instances of this component
Search WWH ::




Custom Search