use of com.alipay.dw.jstorm.transcation.TransactionTestTopology.TxSplitSentence in project jstorm by alibaba.
the class TransactionFastWordCountWindowedState method test.
public static void test() throws Exception {
TransactionTopologyBuilder builder = new TransactionTopologyBuilder();
if (isLocal) {
conf.put("tuple.num.per.batch", 100);
conf.put("transaction.scheduler.spout", false);
conf.put("transaction.exactly.cache.type", "default");
conf.put("transaction.topology", true);
}
int spoutParallelismHint = JStormUtils.parseInt(conf.get(TOPOLOGY_SPOUT_PARALLELISM_HINT), 1);
int splitParallelismHint = JStormUtils.parseInt(conf.get(TOPOLOGY_SPLIT_PARALLELISM_HINT), 1);
int countParallelismHint = JStormUtils.parseInt(conf.get(TOPOLOGY_COUNT_PARALLELISM_HINT), 1);
builder.setSpout("spout", new TxFastRandomSentenceSpout(), spoutParallelismHint);
builder.setBolt("split", new TxSplitSentence(), splitParallelismHint).localOrShuffleGrouping("spout");
WordCount wordCount = new WordCount();
builder.setBolt("count", wordCount.timeWindow(Time.seconds(60L)).withTransactionStateOperator(wordCount), countParallelismHint).fieldsGrouping("split", new Fields("word"));
builder.enableHdfs();
String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
String topologyName = className[className.length - 1];
StormSubmitter.submitTopology(topologyName, conf, builder.createTopology());
}
use of com.alipay.dw.jstorm.transcation.TransactionTestTopology.TxSplitSentence in project jstorm by alibaba.
the class TransactionStateTest method main.
public static void main(String[] args) throws Exception {
Map conf = JStormHelper.getConfig(args);
int spoutParallelism = JStormUtils.parseInt(conf.get(SPOUT_PARALLELISM_HINT), 1);
int splitParallelism = JStormUtils.parseInt(conf.get(SPLIT_PARALLELISM_HINT), 2);
int countParallelism = JStormUtils.parseInt(conf.get(COUNT_PARALLELISM_HINT), 2);
TransactionTopologyBuilder builder = new TransactionTopologyBuilder();
builder.setSpout("spout", new ScheduleTxSpout(), spoutParallelism);
builder.setBolt("split", new TxSplitSentence(), splitParallelism).localOrShuffleGrouping("spout");
builder.setBolt("count", new RocksDbCount(), countParallelism).fieldsGrouping("split", new Fields("word"));
builder.enableHdfs();
String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
String topologyName = className[className.length - 1];
StormSubmitter.submitTopology(topologyName, conf, builder.createTopology());
}
Aggregations