public void execute(Tuple input) { Integer sourceId = input.getInteger(0); Long eventId = input.getLong(1); Long recentEvent = recentEventId.get(sourceId); if (null != recentEvent && eventId <= recentEvent) { String error = "Error: event id is not in strict order! event source Id: " + sourceId + ", last event Id: " + recentEvent + ", current event Id: " + eventId; _collector.emit(input, new Values(error)); } recentEventId.put(sourceId, eventId); _collector.ack(input); }
@Override public void execute(Tuple tuple) { Object obj = tuple.getValue(0); long count = tuple.getLong(1); int source = tuple.getSourceTask(); Map<Integer, Long> subCounts = counts.get(obj); if (subCounts == null) { subCounts = new HashMap<Integer, Long>(); counts.put(obj, subCounts); } //Update the current count for this object subCounts.put(source, count); //Output the sum of all the known counts so for this key long sum = 0; for (Long val : subCounts.values()) { sum += val; } collector.emit(new Values(obj, sum)); }
@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); LatencyReporter latencyReporter = new KafkaReporter(config.reporterTopic, config.brokerList); latencyReporter.report(tuple.getLong(1), System.currentTimeMillis()); }
@Override public void execute(TupleWindow inputWindow) { Map<String, Long[]> counts = new HashMap<String, Long[]>(); for (Tuple tuple : inputWindow.get()) { Long time = tuple.getLong(1); String ip = tuple.getString(0); Long[] timeAndCount = counts.get(ip); if (null == timeAndCount) { timeAndCount = new Long[2]; timeAndCount[0] = time; timeAndCount[1] = 0L; } timeAndCount[0] = Math.min(timeAndCount[0], time); timeAndCount[1]++; counts.put(ip, timeAndCount); } LatencyReporter latencyReporter = new KafkaReporter(config.reporterTopic, config.brokerList); for (Long[] timeAndCount : counts.values()) { for (int i = 0; i < timeAndCount[1]; i++) { latencyReporter.report(timeAndCount[0], System.currentTimeMillis()); } } }
public void execute(Tuple input) { Integer sourceId = input.getInteger(0); Long eventId = input.getLong(1); Long recentEvent = recentEventId.get(sourceId); if (null != recentEvent && eventId <= recentEvent) { String error = "Error: event id is not in strict order! event source Id: " + sourceId + ", last event Id: " + recentEvent + ", current event Id: " + eventId; _collector.emit(input, new Values(error)); } recentEventId.put(sourceId, eventId); _collector.ack(input); }
@Override public void execute(Tuple tuple) { Object obj = tuple.getValue(0); long count = tuple.getLong(1); int source = tuple.getSourceTask(); Map<Integer, Long> subCounts = counts.get(obj); if (subCounts == null) { subCounts = new HashMap<Integer, Long>(); counts.put(obj, subCounts); } //Update the current count for this object subCounts.put(source, count); //Output the sum of all the known counts so for this key long sum = 0; for (Long val: subCounts.values()) { sum += val; } collector.emit(new Values(obj, sum)); }