use of org.apache.storm.testing.FeederSpout in project streamline by hortonworks.
the class PrinterBolt method main.
public static void main(String[] args) throws Exception {
// if (!NimbusClient.isLocalOverride()) {
// throw new IllegalStateException("This example only works in local mode. "
// + "Run with storm local not storm jar");
// }
FeederSpout genderSpout = new FeederSpout(new Fields("id", "gender"));
FeederSpout ageSpout = new FeederSpout(new Fields("id", "age"));
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("genderSpout", genderSpout);
builder.setSpout("ageSpout", ageSpout);
// inner join of 'age' and 'gender' records on 'id' field
RealtimeJoinBolt joiner = new RealtimeJoinBolt(StreamKind.SOURCE).select("genderSpout:id,ageSpout:id,gender,age").from("genderSpout", 5, false).outerJoin("ageSpout", Duration.ofSeconds(5), false, Cmp.equal("genderSpout:id", "ageSpout:id")).withOutputStream("jstream");
builder.setBolt("joiner", joiner).fieldsGrouping("genderSpout", new Fields("id")).fieldsGrouping("ageSpout", new Fields("id"));
builder.setBolt("printer", new PrinterBolt()).shuffleGrouping("joiner", "jstream");
Config conf = new Config();
StormSubmitter.submitTopologyWithProgressBar("join-example", conf, builder.createTopology());
generateGenderData(genderSpout);
generateAgeData(ageSpout);
}
Aggregations