Search in sources :

Example 1 with TxSplitSentence

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());
}
Also used : TransactionTopologyBuilder(com.alibaba.jstorm.transactional.TransactionTopologyBuilder) Fields(backtype.storm.tuple.Fields) TxSplitSentence(com.alipay.dw.jstorm.transcation.TransactionTestTopology.TxSplitSentence)

Example 2 with TxSplitSentence

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());
}
Also used : TransactionTopologyBuilder(com.alibaba.jstorm.transactional.TransactionTopologyBuilder) Fields(backtype.storm.tuple.Fields) ScheduleTxSpout(com.alipay.dw.jstorm.transcation.TransactionTestTopology.ScheduleTxSpout) HashMap(java.util.HashMap) Map(java.util.Map) TxSplitSentence(com.alipay.dw.jstorm.transcation.TransactionTestTopology.TxSplitSentence)

Aggregations

Fields (backtype.storm.tuple.Fields)2 TransactionTopologyBuilder (com.alibaba.jstorm.transactional.TransactionTopologyBuilder)2 TxSplitSentence (com.alipay.dw.jstorm.transcation.TransactionTestTopology.TxSplitSentence)2 ScheduleTxSpout (com.alipay.dw.jstorm.transcation.TransactionTestTopology.ScheduleTxSpout)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1