use of org.apache.storm.testing.MemoryTransactionalSpout in project storm by apache.
the class TransactionalGlobalCount method main.
public static void main(String[] args) throws Exception {
MemoryTransactionalSpout spout = new MemoryTransactionalSpout(DATA, new Fields("word"), PARTITION_TAKE_PER_BATCH);
TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder("global-count", "spout", spout, 3);
builder.setBolt("partial-count", new BatchCount(), 5).noneGrouping("spout");
builder.setBolt("sum", new UpdateGlobalCount()).globalGrouping("partial-count");
Config config = new Config();
config.setDebug(true);
config.setMaxSpoutPending(3);
try (LocalCluster cluster = new LocalCluster();
LocalTopology topo = cluster.submitTopology("global-count-topology", config, builder.buildTopology())) {
Thread.sleep(3000);
}
}
use of org.apache.storm.testing.MemoryTransactionalSpout in project storm by apache.
the class TransactionalWords method main.
public static void main(String[] args) throws Exception {
MemoryTransactionalSpout spout = new MemoryTransactionalSpout(DATA, new Fields("word"), PARTITION_TAKE_PER_BATCH);
TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder("top-n-words", "spout", spout, 2);
builder.setBolt("count", new KeyedCountUpdater(), 5).fieldsGrouping("spout", new Fields("word"));
builder.setBolt("bucketize", new Bucketize()).noneGrouping("count");
builder.setBolt("buckets", new BucketCountUpdater(), 5).fieldsGrouping("bucketize", new Fields("bucket"));
Config config = new Config();
config.setDebug(true);
config.setMaxSpoutPending(3);
try (LocalCluster cluster = new LocalCluster();
LocalTopology topo = cluster.submitTopology("top-n-topology", config, builder.buildTopology())) {
Thread.sleep(3000);
}
}
Aggregations