+2 votes
in Apache Storm by
What is TopologyBuilder class?

1 Answer

0 votes
by
java.lang.Object -> org.apache.storm.topology.TopologyBuilder

public class TopologyBuilder

extends Object

TopologyBuilder exposes the Java API for specifying a topology for Storm to execute. Topologies are Thrift structures in the end, but since the Thrift API is so verbose, TopologyBuilder greatly eases the process of creating topologies.

The template for creating and submitting a topology looks something like:

TopologyBuilder builder = new TopologyBuilder();

builder.setSpout(“1”, new TestWordSpout(true), 5);

builder.setSpout(“2”, new TestWordSpout(true), 3);

builder.setBolt(“3”, new TestWordCounter(), 3)

.fieldsGrouping(“1”, new Fields(“word”))

.fieldsGrouping(“2”, new Fields(“word”));

builder.setBolt(“4”, new TestGlobalCount())

.globalGrouping(“1”);

Map conf = new HashMap();

conf.put(Config.TOPOLOGY_WORKERS, 4);

StormSubmitter.submitTopology(“mytopology”, conf, builder.createTopology());

Related questions

+2 votes
asked Jul 3, 2021 in Apache Storm by rajeshsharma
+2 votes
asked Jul 2, 2021 in Apache Storm by rajeshsharma
...