use of com.twitter.heron.api.tuple.Tuple in project incubator-heron by apache.
the class WindowedBoltExecutor method newWindowLifecycleListener.
protected WindowLifecycleListener<Tuple> newWindowLifecycleListener() {
return new WindowLifecycleListener<Tuple>() {
@Override
public void onExpiry(List<Tuple> tuples) {
for (Tuple tuple : tuples) {
windowedOutputCollector.ack(tuple);
}
}
@Override
public void onActivation(List<Tuple> tuples, List<Tuple> newTuples, List<Tuple> expiredTuples, Long timestamp) {
windowedOutputCollector.setContext(tuples);
boltExecute(tuples, newTuples, expiredTuples, timestamp);
}
};
}
use of com.twitter.heron.api.tuple.Tuple in project incubator-heron by apache.
the class TopologyManagerTest method getTestTopology.
/**
* Construct the test topology
*/
public static TopologyAPI.Topology getTestTopology() {
TopologyBuilder topologyBuilder = new TopologyBuilder();
topologyBuilder.setSpout(STREAM_ID, new BaseRichSpout() {
private static final long serialVersionUID = 5406114907377311020L;
@Override
public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
outputFieldsDeclarer.declare(new Fields(STREAM_ID));
}
@Override
public void open(Map<String, Object> map, TopologyContext topologyContext, SpoutOutputCollector spoutOutputCollector) {
}
@Override
public void nextTuple() {
}
}, 2);
topologyBuilder.setBolt(BOLT_ID, new BaseBasicBolt() {
private static final long serialVersionUID = 4398578755681473899L;
@Override
public void execute(Tuple tuple, BasicOutputCollector basicOutputCollector) {
}
@Override
public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
}
}, 2).shuffleGrouping(STREAM_ID);
Config conf = new Config();
conf.setDebug(true);
conf.setMaxSpoutPending(10);
conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, "-XX:+HeapDumpOnOutOfMemoryError");
conf.setComponentRam(STREAM_ID, ByteAmount.fromMegabytes(500));
conf.setComponentRam(BOLT_ID, ByteAmount.fromGigabytes(1));
conf.setMessageTimeoutSecs(1);
return topologyBuilder.createTopology().setName("topology-name").setConfig(conf).setState(TopologyAPI.TopologyState.RUNNING).getTopology();
}
use of com.twitter.heron.api.tuple.Tuple in project streaming-samples by ashvina.
the class TotalRanker method execute.
@Override
public void execute(Tuple tuple, BasicOutputCollector collector) {
restriction.execute();
Rankings partialRank = (Rankings) tuple.getValueByField(FIELD_RANKING);
rankings.updateWith(partialRank);
if (System.currentTimeMillis() - previousEmitTime > emitRate.toMillis()) {
String result = rankings.getRankings().stream().map(trend -> trend.getObject() + ":" + trend.getCount()).collect(Collectors.joining(", "));
System.out.println(result);
previousEmitTime = System.currentTimeMillis();
}
}
Aggregations