zoukankan      html  css  js  c++  java
  • storm trident function函数

    package cn.crxy.trident;


    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.TridentTopology;
    import storm.trident.operation.BaseFunction;
    import storm.trident.operation.TridentCollector;
    import storm.trident.testing.FixedBatchSpout;
    import storm.trident.tuple.TridentTuple;


    public class TridentLocalPologyFunction {
    public static class SumBolt extends BaseFunction{
    @Override
    public void execute(TridentTuple tuple, TridentCollector collector) {
    //List<Object> values = tuple.getValues();
    //System.err.println("values="+values.toString() );
    Integer value0 = tuple.getInteger(0);
    // Integer value1 = tuple.getInteger(1);
    // Integer value2 = tuple.getInteger(2);
    // Integer value3 = tuple.getInteger(3);
    //Integer value2 = tuple.getInteger(1);
    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();
    tridentTopology.newStream("spout1", spout).each(new Fields("sentence"), new SumBolt(), new Fields(""));
        LocalCluster localCluster = new LocalCluster();
        localCluster.submitTopology("trident", new Config(), tridentTopology.build());
    }
    }
  • 相关阅读:
    利用django创建一个投票网站(二)
    利用django创建一个投票网站(一)
    django models进行数据库增删查改
    用pyspider爬淘宝MM照片
    爬虫实现模拟登陆豆瓣
    python-study-32
    python-study-31
    python-study-30
    python-周考2
    python-周考3
  • 原文地址:https://www.cnblogs.com/gavanwanggw/p/6930136.html
Copyright © 2011-2022 走看看