@Override public void execute(TridentTuple tuple, Object result, TridentCollector collector) { collector.emit(new Values(result)); } }
@Override public void finishBatch() { for (Object key : _counts.keySet()) { _collector.emit(new Values(_id, key, _counts.get(key))); } }
@Override public void updateObject() { this.object = new TupleImplExt(topologyContext, new Values(TimeUtils.current_time_secs()), (int) Constants.SYSTEM_TASK_ID, Constants.SYSTEM_TICK_STREAM_ID); }
@Override public Values execute(TridentTuple input) { return new Values(input.getStringByField("word").toUpperCase()); } };
@Override public void nextTuple() { String sentence = CHOICES[index++]; if (index >= CHOICES.length) { index = 0; } collector.emit(new Values(sentence)); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String word = tuple.getString(0); Integer count = counts.get(word); if (count == null) count = 0; count++; counts.put(word, count); collector.emit(new Values(word, count)); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String args = tuple.getString(0); String returnInfo = tuple.getString(1); long requestId = rand.nextLong(); collector.emit(ARGS_STREAM, new Values(requestId, args)); collector.emit(RETURN_STREAM, new Values(requestId, returnInfo)); collector.emit(ID_STREAM, new Values(requestId)); }
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String sentence = tuple.getString(0); for (String word : sentence.split(" ")) { collector.emit(new Values(word)); } } }
@Override public void execute(Tuple tuple) { String sentence = tuple.getString(0); for (String word : sentence.split("\\s+")) { collector.emit(new Values(word)); } }
protected void startInitState() { LOG.info("Start to retrieve the initial state from topology master"); // retrieve state from topology master TopoMasterCtrlEvent event = new TopoMasterCtrlEvent(EventType.transactionInitState); outputCollector.emitDirectCtrl(topologyMasterId, Common.TOPOLOGY_MASTER_CONTROL_STREAM_ID, new Values(event), null); }
@Override public void updateState(Snapshottable state, List<TridentTuple> tuples, TridentCollector collector) { if (tuples.size() != 1) { throw new IllegalArgumentException("Combiner state updater should receive a single tuple. Received: " + tuples.toString()); } Object newVal = state.update(new CombinerValueUpdater(_agg, tuples.get(0).getValue(0))); collector.emit(new Values(newVal)); }
@Override public void execute(TridentTuple tuple, TridentCollector collector) { List l = (List) tuple.getValue(0); if (l != null) { for (Object o : l) { collector.emit(new Values(o)); } } }
@Override public void nextTuple() { String sentence = CHOICES[index]; collector.emit(new Values(sentence), ++msgId); index = (++index) % CHOICES.length; printSendTps(1); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { Object id = tuple.getValue(0); String url = tuple.getString(1); List<String> tweeters = TWEETERS_DB.get(url); if (tweeters != null) { for (String tweeter : tweeters) { collector.emit(new Values(id, tweeter)); } } }
@Override public void nextTuple() { int n = tupleNumPerBatch; while (--n >= 0) { collector.emit(new Values(CHOICES[index])); index = (++index) % CHOICES.length; } collector.emitBarrier(); printSendTps(tupleNumPerBatch); }
private void fail(long batchId) { TopoMasterCtrlEvent event = new TopoMasterCtrlEvent(EventType.transactionRollback); event.addEventValue(batchId); outputCollector.emitDirectCtrl(topologyMasterId, Common.TOPOLOGY_MASTER_CONTROL_STREAM_ID, new Values(event), null); }
public void fail(long id) { // If any failure, send rollback request to TM TopoMasterCtrlEvent event = new TopoMasterCtrlEvent(EventType.transactionRollback); event.addEventValue(id); outputCollector.emitDirectCtrl(topologyMasterId, Common.TOPOLOGY_MASTER_CONTROL_STREAM_ID, null, new Values(event)); }
@Override public void updateState(Snapshottable state, List<TridentTuple> tuples, TridentCollector collector) { Object newVal = state.update(new ReducerValueUpdater(_agg, tuples)); collector.emit(new Values(newVal)); }
public void execute(Tuple tuple) { if (tuple.getValues().size() == 0) { _expectExcevieNum--; } else { JStormUtils.sleepMs(1); _collector.emit(tuple, new Values(tuple.getValues())); _collector.ack(tuple); } }