use of backtype.storm.topology.TopologyBuilder in project storm-hbase by jrkinley.
the class HBaseExampleTopology method main.
/**
* @param args
*/
public static void main(String[] args) {
TopologyBuilder builder = new TopologyBuilder();
// Add test spout
builder.setSpout("spout", new TestSpout(), 1);
// Build TupleTableConifg
TupleTableConfig config = new TupleTableConfig("shorturl", "shortid");
config.setBatch(false);
config.addColumn("data", "url");
config.addColumn("data", "user");
config.addColumn("data", "date");
// Add HBaseBolt
builder.setBolt("hbase", new HBaseBolt(config), 1).shuffleGrouping("spout");
Config stormConf = new Config();
stormConf.setDebug(true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("hbase-example", stormConf, builder.createTopology());
Utils.sleep(10000);
cluster.shutdown();
}
use of backtype.storm.topology.TopologyBuilder in project storm-hbase by jrkinley.
the class HBaseCountersTopology method main.
/**
* @param args
*/
public static void main(String[] args) {
TopologyBuilder builder = new TopologyBuilder();
// Add test spout
builder.setSpout("spout", new TestSpout(), 1);
// Build TupleTableConifg
TupleTableConfig config = new TupleTableConfig("shorturl", "shortid");
config.setBatch(false);
/*
* By default the HBaseCountersBolt will use the tuple output fields value
* to set the CQ name. For example if the 'date' output field exists in the
* tuple then its value (e.g. "YYYYMMDD") will be used to set the counters
* CQ. However, the 'clicks' output field does not exist in the tuple so in
* this case the counters CQ will be set to the given field name 'clicks'.
*/
config.addColumn("data", "clicks");
config.addColumn("daily", "date");
// Add HBaseBolt
builder.setBolt("hbase-counters", new HBaseCountersBolt(config), 1).shuffleGrouping("spout");
Config stormConf = new Config();
stormConf.setDebug(true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("hbase-example", stormConf, builder.createTopology());
Utils.sleep(10000);
cluster.shutdown();
}
use of backtype.storm.topology.TopologyBuilder in project jstorm by alibaba.
the class TestBackpressure method test.
/**
* Can't run
*/
public static void test() {
int spout_Parallelism_hint = JStormUtils.parseInt(conf.get(TOPOLOGY_SPOUT_PARALLELISM_HINT), 1);
int split_Parallelism_hint = JStormUtils.parseInt(conf.get(TOPOLOGY_SPLIT_PARALLELISM_HINT), 1);
int count_Parallelism_hint = JStormUtils.parseInt(conf.get(TOPOLOGY_COUNT_PARALLELISM_HINT), 2);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("spout", new FastRandomSentenceSpout(), spout_Parallelism_hint);
builder.setBolt("split", new SplitSentence(), split_Parallelism_hint).shuffleGrouping("spout");
builder.setBolt("count", new WordCount(), count_Parallelism_hint).fieldsGrouping("split", new Fields("word"));
String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
String topologyName = className[className.length - 1];
isLocal = JStormHelper.localMode(conf);
conf.put(ConfigExtension.TOPOLOGY_BACKPRESSURE_ENABLE, true);
conf.setNumWorkers(8);
try {
JStormHelper.runTopology(builder.createTopology(), topologyName, conf, 60 * 2, new Validator(conf), isLocal);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Assert.fail("Failed");
}
}
use of backtype.storm.topology.TopologyBuilder in project jstorm by alibaba.
the class SlidingWindowTopology method test.
public static void test() {
String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
String topologyName = className[className.length - 1];
try {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("integer", new RandomIntegerSpout(), 1);
builder.setBolt("slidingsum", new SlidingWindowSumBolt().withWindow(new Count(30), new Count(10)), 1).shuffleGrouping("integer");
builder.setBolt("tumblingavg", new TumblingWindowAvgBolt().withTumblingWindow(new Count(3)), 1).shuffleGrouping("slidingsum");
builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("tumblingavg");
conf.setDebug(true);
JStormHelper.runTopology(builder.createTopology(), topologyName, conf, 60, new JStormHelper.CheckAckedFail(conf), isLocal);
} catch (Exception e) {
// TODO Auto-generated catch block
e.fillInStackTrace();
Assert.fail("Failed to submit topology");
}
}
use of backtype.storm.topology.TopologyBuilder in project jstorm by alibaba.
the class FastWordCountTopology method test.
public static void test() {
int spout_Parallelism_hint = JStormUtils.parseInt(conf.get(TOPOLOGY_SPOUT_PARALLELISM_HINT), 1);
int split_Parallelism_hint = JStormUtils.parseInt(conf.get(TOPOLOGY_SPLIT_PARALLELISM_HINT), 1);
int count_Parallelism_hint = JStormUtils.parseInt(conf.get(TOPOLOGY_COUNT_PARALLELISM_HINT), 2);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("spout", new FastRandomSentenceSpout(), spout_Parallelism_hint);
builder.setBolt("split", new SplitSentence(), split_Parallelism_hint).localOrShuffleGrouping("spout");
builder.setBolt("count", new WordCount(), count_Parallelism_hint).fieldsGrouping("split", new Fields("word"));
String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
String topologyName = className[className.length - 1];
isLocal = JStormHelper.localMode(conf);
try {
JStormHelper.runTopology(builder.createTopology(), topologyName, conf, 60, new JStormHelper.CheckAckedFail(conf), isLocal);
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Failed");
}
}
Aggregations