private void registerMetrics(Tuple input) { synchronized (metricNames) { metricNames.get().addAll((Set<String>) input.getValue(0)); } }
@Override public void execute(Tuple input) { Object value = input.getValue(0); if (input.getSourceStreamId().equals(TopologyMaster.USER_DEFINED_STREAM)) { TMUdfMessage message = (TMUdfMessage) value; LOG.info("Received TM UDF message trigged by task-{}", message.spoutTaskId); } else { LOG.info("Received unkown message: {}", input); } }
@Override public void execute(Tuple tuple) { Object key = tuple.getValue(1); int curr = Utils.get(_counts, key, 0); _counts.put(key, curr + 1); }
@Override public void execute(Tuple input, BasicOutputCollector collector) { BatchId batchId = (BatchId) input.getValue(0); for (int i = 0; i < batchSize; i++) { long value = rand.nextInt(10); collector.emit(new Values(batchId, value)); } }
public void fail(Tuple tuple) { Object id = tuple.getValue(0); synchronized (_tracked) { TrackingInfo track = _tracked.get(id); if (track != null) track.failed = true; } checkFinishId(tuple, TupleType.REGULAR); _delegate.fail(tuple); }
private void countObjAndAck(Tuple tuple) { Object obj = tuple.getValue(0); counter.incrementCount(obj); collector.ack(tuple); }
@Override public void execute(Tuple tuple, IKvState<String, Integer> state, TimeWindow window) { String word = (String) tuple.getValue(0); Integer count = state.get(word); if (count == null) count = 0; state.put(word, ++count); }
@Override public void execute(Tuple input, BasicOutputCollector collector) { BatchId id = (BatchId) input.getValue(0); Long value = input.getLong(1); AtomicLong counter = counters.get(id); if (counter == null) { counter = new AtomicLong(0); counters.put(id, counter); } counter.addAndGet(value); }
@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)); } } }
public void handlePostCommit(Tuple tuple) { basicCollector.setContext(tuple); try { BatchId id = (BatchId) tuple.getValue(0); ((IPostCommit) delegate).postCommit(id, basicCollector); } catch (Exception e) { LOG.info("Failed to do postCommit,", e); } collector.ack(tuple); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { Object id = tuple.getValue(0); String tweeter = tuple.getString(1); List<String> followers = FOLLOWERS_DB.get(tweeter); if (followers != null) { for (String follower : followers) { collector.emit(new Values(id, follower)); } } }
@Override public void execute(Tuple input, BasicOutputCollector collector) { Object id = input.getValue(0); String word = input.getString(1); for (int i = 0; i < word.length(); i++) { if (word.charAt(i) == 'a') { collector.emit("multi", new Values(id, word.substring(0, i))); } } collector.emit("single", new Values(id, word)); }
@Override public void execute(Tuple input) { Object id = input.getValue(0); IBatchBolt bolt = getBatchBolt(id); try { bolt.execute(input); _collector.ack(input); } catch (FailedException e) { LOG.error("Failed to process tuple in batch", e); _collector.fail(input); } }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String arg = tuple.getString(0); Object retInfo = tuple.getValue(1); collector.emit(new Values(arg + "!!!", retInfo)); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String input = tuple.getString(1); collector.emit(new Values(tuple.getValue(0), input + "!")); }
public void execute(Tuple tuple, BasicOutputCollector collector) { tpsCounter.count(); Long tupleId = tuple.getLong(0); Pair pair = (Pair) tuple.getValue(1); sum.addAndGet(pair.getValue()); collector.emit(new Values(tupleId, pair)); }
public void handleCommit(Tuple tuple) { Object id = tuple.getValue(0); try { byte[] commitResult = ((ICommitter) delegate).commit((BatchId) id); collector.ack(tuple); updateToZk(id, commitResult); commited.put(id, commitResult); } catch (Exception e) { LOG.error("Failed to commit ", e); collector.fail(tuple); } }
@Override void updateRankingsWithTuple(Tuple tuple) { Rankings rankingsToBeMerged = (Rankings) tuple.getValue(0); super.getRankings().updateWith(rankingsToBeMerged); super.getRankings().pruneZeroCounts(); }