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());
}
}