Database Reference
In-Depth Information
and summation operations. Instead, implementations of the Aggregator
interface handle the task of counting events.
Aggregators come about in Trident because it is a fundamentally
batch-oriented system. An aggregator takes a batch as input and produces
an output according to the aggregation function. Although it is possible to
write custom aggregators most of the time, the built-in Count and Sum
aggregations are sufficient to accomplish most tasks. The following code
implements a trivial event counter in Trident using the topology submitter
interface developed in Chapter 5:
public StormTopology topology(String[] args) {
TridentTopology topology = new TridentTopology();
topology.newStream("input",
SimpleKafkaSpout. spout ().configure(args))
.aggregate( new Count(), new Fields("count"))
.each( new Fields("count"), new PostFilter ());
;
return topology.build();
}
The PostFilter class is a simple class designed to interface with the
node.js delivery mechanisms developed in Chapter 7, “Delivering Streaming
Metrics.” It implements the same functionality as the IRichBolt counter
in the previous section, pushing its results to a node.js application
listening on port 3000 by default.
Search WWH ::




Custom Search