use of org.apache.storm.starter.bolt.PrinterBolt in project flink by apache.
the class PrintSampleStream method main.
public static void main(String[] args) throws Exception {
if (args.length < 4) {
System.err.println("Usage: PrintSampleStream <consumer-key> <consumer-secret> <access-token> <access-token-secret>");
return;
}
String consumerKey = args[0];
String consumerSecret = args[1];
String accessToken = args[2];
String accessTokenSecret = args[3];
// keywords start with the 5th parameter
String[] keyWords = Arrays.copyOfRange(args, 4, args.length);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("twitter", new TwitterSampleSpout(consumerKey, consumerSecret, accessToken, accessTokenSecret, keyWords));
builder.setBolt("print", new PrinterBolt()).shuffleGrouping("twitter");
Config conf = new Config();
final FlinkLocalCluster cluster = FlinkLocalCluster.getLocalCluster();
cluster.submitTopology("Print", conf, FlinkTopology.createTopology(builder));
Utils.sleep(10 * 1000);
cluster.shutdown();
}
use of org.apache.storm.starter.bolt.PrinterBolt in project storm by apache.
the class SlidingTupleTsTopology method main.
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
BaseWindowedBolt bolt = new SlidingWindowSumBolt().withWindow(new Duration(5, TimeUnit.SECONDS), new Duration(3, TimeUnit.SECONDS)).withTimestampField("ts").withLag(new Duration(5, TimeUnit.SECONDS));
builder.setSpout("integer", new RandomIntegerSpout(), 1);
builder.setBolt("slidingsum", bolt, 1).shuffleGrouping("integer");
builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("slidingsum");
Config conf = new Config();
conf.setDebug(true);
String topoName = "test";
if (args != null && args.length > 0) {
topoName = args[0];
}
conf.setNumWorkers(1);
StormSubmitter.submitTopologyWithProgressBar(topoName, conf, builder.createTopology());
}
use of org.apache.storm.starter.bolt.PrinterBolt in project storm by apache.
the class SlidingWindowTopology method main.
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("integer", new RandomIntegerSpout(), 1);
builder.setBolt("slidingsum", new SlidingWindowSumBolt().withWindow(Count.of(30), Count.of(10)), 1).shuffleGrouping("integer");
builder.setBolt("tumblingavg", new TumblingWindowAvgBolt().withTumblingWindow(Count.of(3)), 1).shuffleGrouping("slidingsum");
builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("tumblingavg");
Config conf = new Config();
conf.setDebug(true);
String topoName = "test";
if (args != null && args.length > 0) {
topoName = args[0];
}
conf.setNumWorkers(1);
StormSubmitter.submitTopologyWithProgressBar(topoName, conf, builder.createTopology());
}
use of org.apache.storm.starter.bolt.PrinterBolt in project storm by apache.
the class StatefulWindowingTopology method main.
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("spout", new RandomIntegerSpout());
builder.setBolt("sumbolt", new WindowSumBolt().withWindow(new Count(5), new Count(3)).withMessageIdField("msgid"), 1).shuffleGrouping("spout");
builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("sumbolt");
Config conf = new Config();
conf.setDebug(false);
// conf.put(Config.TOPOLOGY_STATE_PROVIDER, "org.apache.storm.redis.state.RedisKeyValueStateProvider");
String topoName = "test";
if (args != null && args.length > 0) {
topoName = args[0];
}
conf.setNumWorkers(1);
StormSubmitter.submitTopologyWithProgressBar(topoName, conf, builder.createTopology());
}
use of org.apache.storm.starter.bolt.PrinterBolt in project storm by apache.
the class JoinBoltExample 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
JoinBolt joiner = new JoinBolt("genderSpout", "id").join("ageSpout", "id", "genderSpout").select("genderSpout:id,ageSpout:id,gender,age").withTumblingWindow(new BaseWindowedBolt.Duration(10, TimeUnit.SECONDS));
builder.setBolt("joiner", joiner).fieldsGrouping("genderSpout", new Fields("id")).fieldsGrouping("ageSpout", new Fields("id"));
builder.setBolt("printer", new PrinterBolt()).shuffleGrouping("joiner");
Config conf = new Config();
StormSubmitter.submitTopologyWithProgressBar("join-example", conf, builder.createTopology());
generateGenderData(genderSpout);
generateAgeData(ageSpout);
}
Aggregations