Search in sources :

Example 11 with FeederSpout

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);
}
Also used : Fields(org.apache.storm.tuple.Fields) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) Config(org.apache.storm.Config) FeederSpout(org.apache.storm.testing.FeederSpout)

Aggregations

FeederSpout (org.apache.storm.testing.FeederSpout)11 Fields (org.apache.storm.tuple.Fields)10 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)9 Values (org.apache.storm.tuple.Values)8 Config (org.apache.storm.Config)6 LocalCluster (org.apache.storm.LocalCluster)6 AckFailMapTracker (org.apache.storm.testing.AckFailMapTracker)6 Test (org.junit.jupiter.api.Test)6 StormTopology (org.apache.storm.generated.StormTopology)5 IntegrationTest (org.apache.storm.testing.IntegrationTest)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 HashMap (java.util.HashMap)2 PrinterBolt (org.apache.storm.starter.bolt.PrinterBolt)2 SingleJoinBolt (org.apache.storm.starter.bolt.SingleJoinBolt)2 FlinkLocalCluster (org.apache.flink.storm.api.FlinkLocalCluster)1 BoltFileSink (org.apache.flink.storm.util.BoltFileSink)1 NullTerminatingSpout (org.apache.flink.storm.util.NullTerminatingSpout)1 TupleOutputFormatter (org.apache.flink.storm.util.TupleOutputFormatter)1 ILocalTopology (org.apache.storm.ILocalCluster.ILocalTopology)1 JoinBolt (org.apache.storm.bolt.JoinBolt)1