use of org.apache.storm.LocalCluster in project storm by apache.
the class TridentEsTopology method main.
public static void main(String[] args) throws Exception {
int batchSize = 100;
FixedBatchSpout spout = new FixedBatchSpout(batchSize);
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout", spout);
EsConfig esConfig = new EsConfig(EsConstants.clusterName, new String[] { "localhost:9300" });
Fields esFields = new Fields("index", "type", "source");
EsTupleMapper tupleMapper = EsTestUtil.generateDefaultTupleMapper();
StateFactory factory = new EsStateFactory(esConfig, tupleMapper);
TridentState state = stream.partitionPersist(factory, esFields, new EsUpdater(), new Fields());
EsTestUtil.startEsNode();
EsTestUtil.waitForSeconds(5);
try (LocalCluster cluster = new LocalCluster();
LocalTopology topo = cluster.submitTopology(TOPOLOGY_NAME, null, topology.build())) {
EsTestUtil.waitForSeconds(20);
}
System.exit(0);
}
use of org.apache.storm.LocalCluster in project storm by apache.
the class WordCountTrident method main.
public static void main(String[] args) throws Exception {
Config conf = new Config();
conf.setMaxSpoutPending(5);
if (args.length == 1) {
try (LocalCluster cluster = new LocalCluster();
LocalTopology topo = cluster.submitTopology("wordCounter", conf, buildTopology(args[0]))) {
Thread.sleep(60 * 1000);
}
System.exit(0);
} else if (args.length == 2) {
conf.setNumWorkers(3);
StormSubmitter.submitTopology(args[1], conf, buildTopology(args[0]));
} else {
System.out.println("Usage: TridentFileTopology <hdfs url> [topology name]");
}
}
use of org.apache.storm.LocalCluster 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);
if (args != null && args.length > 0) {
conf.setNumWorkers(1);
StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology());
} else {
try (LocalCluster cluster = new LocalCluster();
LocalTopology topo = cluster.submitTopology("test", conf, builder.createTopology())) {
Utils.sleep(40000);
}
}
}
use of org.apache.storm.LocalCluster 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);
if (args != null && args.length > 0) {
conf.setNumWorkers(1);
StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology());
} else {
try (LocalCluster cluster = new LocalCluster();
LocalTopology topo = cluster.submitTopology("test", conf, builder.createTopology())) {
Utils.sleep(40000);
}
}
}
use of org.apache.storm.LocalCluster 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);
}
}
Aggregations