首页 > 代码库 > storm trident function函数
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());
}
}
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());
}
}
storm trident function函数
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。