Java Code Examples for org.apache.storm.testing.FeederSpout#feed()

The following examples show how to use org.apache.storm.testing.FeederSpout#feed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RTJoinExampleTopology.java    From streamline with Apache License 2.0 5 votes vote down vote up
private static void generateGenderData(FeederSpout genderSpout) {
    for (int i = 0; i < 10; i++) {
        String gender;
        if (i % 2 == 0) {
            gender = "male";
        }
        else {
            gender = "female";
        }
        genderSpout.feed(new Values(i, gender));
    }
}
 
Example 2
Source File: SingleJoinExample.java    From storm-net-adapter with Apache License 2.0 5 votes vote down vote up
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("gender", genderSpout);
    builder.setSpout("age", ageSpout);
    builder.setBolt("join", new SingleJoinBolt(new Fields("gender", "age"))).fieldsGrouping("gender", new Fields("id"))
           .fieldsGrouping("age", new Fields("id"));

    Config conf = new Config();
    conf.setDebug(true);
    StormSubmitter.submitTopology("join-example", conf, builder.createTopology());

    for (int i = 0; i < 10; i++) {
        String gender;
        if (i % 2 == 0) {
            gender = "male";
        } else {
            gender = "female";
        }
        genderSpout.feed(new Values(i, gender));
    }

    for (int i = 9; i >= 0; i--) {
        ageSpout.feed(new Values(i, i + 20));
    }
}
 
Example 3
Source File: JoinBoltExample.java    From storm-net-adapter with Apache License 2.0 5 votes vote down vote up
private static void generateGenderData(FeederSpout genderSpout) {
    for (int i = 0; i < 10; i++) {
        String gender;
        if (i % 2 == 0) {
            gender = "male";
        } else {
            gender = "female";
        }
        genderSpout.feed(new Values(i, gender));
    }
}
 
Example 4
Source File: RTJoinExampleTopology.java    From streamline with Apache License 2.0 4 votes vote down vote up
private static void generateAgeData(FeederSpout ageSpout) {
    for (int i = 9; i >= 0; i--) {
        ageSpout.feed(new Values(i, i + 20));
    }
}
 
Example 5
Source File: JoinBoltExample.java    From storm-net-adapter with Apache License 2.0 4 votes vote down vote up
private static void generateAgeData(FeederSpout ageSpout) {
    for (int i = 9; i >= 0; i--) {
        ageSpout.feed(new Values(i, i + 20));
    }
}