• storm trident merger





    import java.util.List;
    import backtype.storm.Config;
    import backtype.storm.LocalCluster;
    import backtype.storm.generated.StormTopology;
    import backtype.storm.tuple.Fields;
    import backtype.storm.tuple.Values;
    import storm.trident.Stream;
    import storm.trident.TridentTopology;
    import storm.trident.operation.BaseFunction;
    import storm.trident.operation.TridentCollector;
    import storm.trident.testing.FixedBatchSpout;
    import storm.trident.tuple.TridentTuple;


    public class TridentLocalPologyMeger {
    public static class SumBolt extends BaseFunction{
    @Override
    public void execute(TridentTuple tuple, TridentCollector collector) {
    Integer value0 = tuple.getInteger(0);
    System.err.println("value0="+value0 );



    }

    }
    public static void main(String[] args) {
    //输出为new Fields("sentence")
    FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 1, new Values(9999));
    spout.setCycle(true);
    TridentTopology tridentTopology = new TridentTopology();
    Stream newStream = tridentTopology.newStream("spout1", spout);
    tridentTopology.merge(newStream)
    .each(new Fields("sentence"), new SumBolt(), new Fields(""));

        LocalCluster localCluster = new LocalCluster();
        localCluster.submitTopology("trident", new Config(), tridentTopology.build());
    }
    }
  • 相关阅读:
    HDU 2112 HDU Today
    HDU 1869 六度分离
    HDU 3790 最短路径问题
    HDU2066 一个人的旅行
    HDU1596 find the safest road(最短路)
    HDU 1254 推箱子(双重bfs)
    HDU 1429 胜利大逃亡(续) (bfs+状态压缩)
    HDU 1045 Fire Net
    数据结构之单链表头插法,尾插法
    Java--会移动、反弹的球
  • 原文地址:https://www.cnblogs.com/gccbuaa/p/7273609.html
Copyright © 2020-2023  润新知