Database Reference
In-Depth Information
A graph, of course, is a structure that contains vertices (nodes) connected
together with edges. In this case, the edges are directed, which means that
data only flows in a single direction along the edge.
These graphs are also acyclic, which means that the arrangement of edges
may not form a loop. Otherwise, the data would flow infinitely around the
topology. A simple topology is shown in
Figure 5.3
,
with an input spout and
two layers of bolts. The Storm framework can increase the bolt parallelism
as needed to maintain performance.
Topologies are built in Storm using the
TopologyBuilder
class and
created by a call to
createTopology
:
public static void
main(String[] args) {
TopologyBuilder builder =
new
TopologyBuilder();
defineTopology
(builder,args);
StormTopology topology = builder.createTopology();
The
defineTopology
method is where the graph itself is constructed.
Each vertex in the topology consists of a unique name and the definition
of either a spout or a bolt. A spout is Storm's data input mechanism and is
added using the
setSpout
method:
public static void
defineTopology(TopologyBuilder
builder
,String[] args) {
builder.setSpout("input",
new
BasicSpout());