/** * Write skipped late arriving element to SideOutput. * * @param element skipped late arriving element to side output */ protected void sideOutput(StreamRecord<IN> element){ output.collect(lateDataOutputTag, element); }
@Override protected void processAndCollect(T element) { lastRecordTime = this.timeService.getCurrentProcessingTime(); output.collect(reuse.replace(element, lastRecordTime)); // this is to avoid lock contention in the lockingObject by // sending the watermark before the firing of the watermark // emission task. if (lastRecordTime > nextWatermarkTime) { // in case we jumped some watermarks, recompute the next watermark time final long watermarkTime = lastRecordTime - (lastRecordTime % watermarkInterval); nextWatermarkTime = watermarkTime + watermarkInterval; output.emitWatermark(new Watermark(watermarkTime)); // we do not need to register another timer here // because the emitting task will do so. } }
@Override public void close() { for (Output<StreamRecord<T>> output : outputs) { output.close(); } } }
@Override public void emitWatermark(Watermark mark) { output.emitWatermark(mark); }
@Override public void emitLatencyMarker(LatencyMarker latencyMarker) { output.emitLatencyMarker(latencyMarker); }
@Override protected void processAndEmitWatermark(Watermark mark) { output.emitWatermark(mark); }
@Override public void emitLatencyMarker(LatencyMarker latencyMarker) { if (outputs.length <= 0) { // ignore } else if (outputs.length == 1) { outputs[0].emitLatencyMarker(latencyMarker); } else { // randomly select an output outputs[random.nextInt(outputs.length)].emitLatencyMarker(latencyMarker); } }
@Override public void collect(StreamRecord<T> record) { for (Output<StreamRecord<T>> output : outputs) { output.collect(record); } }
@Override public void processElement(StreamRecord<T> element) throws Exception { long newTimestamp = userFunction.extractTimestamp(element.getValue(), element.getTimestamp()); output.collect(element.replace(element.getValue(), newTimestamp)); long watermark = userFunction.extractWatermark(element.getValue(), newTimestamp); if (watermark > currentWatermark) { currentWatermark = watermark; output.emitWatermark(new Watermark(currentWatermark)); } }
/** This will only be called if allowWatermark returned {@code true}. */ @Override protected void processAndEmitWatermark(Watermark mark) { nextWatermarkTime = Long.MAX_VALUE; output.emitWatermark(mark); // we can shutdown the watermark timer now, no watermarks will be needed any more. // Note that this procedure actually doesn't need to be synchronized with the lock, // but since it's only a one-time thing, doesn't hurt either final ScheduledFuture<?> nextWatermarkTimer = this.nextWatermarkTimer; if (nextWatermarkTimer != null) { nextWatermarkTimer.cancel(true); } }
@Override public void close() { for (Output<StreamRecord<OUT>> out : allOutputs) { out.close(); } }
@Override public void emitLatencyMarker(LatencyMarker latencyMarker) { // randomly select an output allOutputs[random.nextInt(allOutputs.length)].emitLatencyMarker(latencyMarker); }
@Override public <X> void collect(OutputTag<X> outputTag, StreamRecord<X> record) { for (Output<StreamRecord<T>> output : outputs) { output.collect(outputTag, record); } }
@Override public void processElement(StreamRecord<T> element) throws Exception { final T value = element.getValue(); final long newTimestamp = userFunction.extractTimestamp(value, element.hasTimestamp() ? element.getTimestamp() : Long.MIN_VALUE); output.collect(element.replace(element.getValue(), newTimestamp)); final Watermark nextWatermark = userFunction.checkAndGetNextWatermark(value, newTimestamp); if (nextWatermark != null && nextWatermark.getTimestamp() > currentWatermark) { currentWatermark = nextWatermark.getTimestamp(); output.emitWatermark(nextWatermark); } }
public void processWatermark(Watermark mark) throws Exception { if (timeServiceManager != null) { timeServiceManager.advanceWatermark(mark); } output.emitWatermark(mark); }
@Override public void close() { output.close(); } }
protected void reportOrForwardLatencyMarker(LatencyMarker marker) { // all operators are tracking latencies this.latencyStats.reportLatency(marker); // everything except sinks forwards latency markers this.output.emitLatencyMarker(marker); }
@Override public void processElement(StreamRecord<IN> record) throws Exception { output.collect(record); }
@Override public void processElement(StreamRecord<T> element) throws Exception { long newTimestamp = userFunction.extractTimestamp(element.getValue(), element.getTimestamp()); output.collect(element.replace(element.getValue(), newTimestamp)); long watermark = userFunction.extractWatermark(element.getValue(), newTimestamp); if (watermark > currentWatermark) { currentWatermark = watermark; output.emitWatermark(new Watermark(currentWatermark)); } }
@Override public void processWatermark(Watermark mark) throws Exception { output.emitWatermark(mark); } }