Java Code Examples for org.apache.flink.streaming.runtime.streamrecord.StreamElement#isRecord()
The following examples show how to use
org.apache.flink.streaming.runtime.streamrecord.StreamElement#isRecord() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamOneInputProcessor.java From flink with Apache License 2.0 | 6 votes |
private void processElement(StreamElement recordOrMark, int channel) throws Exception { if (recordOrMark.isRecord()) { // now we can do the actual processing StreamRecord<IN> record = recordOrMark.asRecord(); synchronized (lock) { numRecordsIn.inc(); streamOperator.setKeyContextElement1(record); streamOperator.processElement(record); } } else if (recordOrMark.isWatermark()) { // handle watermark statusWatermarkValve.inputWatermark(recordOrMark.asWatermark(), channel); } else if (recordOrMark.isStreamStatus()) { // handle stream status statusWatermarkValve.inputStreamStatus(recordOrMark.asStreamStatus(), channel); } else if (recordOrMark.isLatencyMarker()) { // handle latency marker synchronized (lock) { streamOperator.processLatencyMarker(recordOrMark.asLatencyMarker()); } } else { throw new UnsupportedOperationException("Unknown type of StreamElement"); } }
Example 2
Source File: StreamTwoInputSelectableProcessor.java From flink with Apache License 2.0 | 6 votes |
private void processElement1(StreamElement recordOrMark, int channel) throws Exception { if (recordOrMark.isRecord()) { StreamRecord<IN1> record = recordOrMark.asRecord(); synchronized (lock) { numRecordsIn.inc(); streamOperator.setKeyContextElement1(record); streamOperator.processElement1(record); inputSelection = inputSelector.nextSelection(); } } else if (recordOrMark.isWatermark()) { statusWatermarkValve1.inputWatermark(recordOrMark.asWatermark(), channel); } else if (recordOrMark.isStreamStatus()) { statusWatermarkValve1.inputStreamStatus(recordOrMark.asStreamStatus(), channel); } else if (recordOrMark.isLatencyMarker()) { synchronized (lock) { streamOperator.processLatencyMarker1(recordOrMark.asLatencyMarker()); } } else { throw new UnsupportedOperationException("Unknown type of StreamElement on input1"); } }
Example 3
Source File: StreamTwoInputSelectableProcessor.java From flink with Apache License 2.0 | 6 votes |
private void processElement2(StreamElement recordOrMark, int channel) throws Exception { if (recordOrMark.isRecord()) { StreamRecord<IN2> record = recordOrMark.asRecord(); synchronized (lock) { numRecordsIn.inc(); streamOperator.setKeyContextElement2(record); streamOperator.processElement2(record); inputSelection = inputSelector.nextSelection(); } } else if (recordOrMark.isWatermark()) { statusWatermarkValve2.inputWatermark(recordOrMark.asWatermark(), channel); } else if (recordOrMark.isStreamStatus()) { statusWatermarkValve2.inputStreamStatus(recordOrMark.asStreamStatus(), channel); } else if (recordOrMark.isLatencyMarker()) { synchronized (lock) { streamOperator.processLatencyMarker2(recordOrMark.asLatencyMarker()); } } else { throw new UnsupportedOperationException("Unknown type of StreamElement on input2"); } }
Example 4
Source File: AsyncWaitOperator.java From flink with Apache License 2.0 | 6 votes |
@Override public void open() throws Exception { super.open(); if (recoveredStreamElements != null) { for (StreamElement element : recoveredStreamElements.get()) { if (element.isRecord()) { processElement(element.<IN>asRecord()); } else if (element.isWatermark()) { processWatermark(element.asWatermark()); } else if (element.isLatencyMarker()) { processLatencyMarker(element.asLatencyMarker()); } else { throw new IllegalStateException("Unknown record type " + element.getClass() + " encountered while opening the operator."); } } recoveredStreamElements = null; } }
Example 5
Source File: UnorderedStreamElementQueue.java From flink with Apache License 2.0 | 6 votes |
@Override public Optional<ResultFuture<OUT>> tryPut(StreamElement streamElement) { if (size() < capacity) { StreamElementQueueEntry<OUT> queueEntry; if (streamElement.isRecord()) { queueEntry = addRecord((StreamRecord<?>) streamElement); } else if (streamElement.isWatermark()) { queueEntry = addWatermark((Watermark) streamElement); } else { throw new UnsupportedOperationException("Cannot enqueue " + streamElement); } numberOfEntries++; LOG.debug("Put element into unordered stream element queue. New filling degree " + "({}/{}).", size(), capacity); return Optional.of(queueEntry); } else { LOG.debug("Failed to put element into unordered stream element queue because it " + "was full ({}/{}).", size(), capacity); return Optional.empty(); } }
Example 6
Source File: AsyncWaitOperator.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void open() throws Exception { super.open(); // create the emitter this.emitter = new Emitter<>(checkpointingLock, output, queue, this); // start the emitter thread this.emitterThread = new Thread(emitter, "AsyncIO-Emitter-Thread (" + getOperatorName() + ')'); emitterThread.setDaemon(true); emitterThread.start(); // process stream elements from state, since the Emit thread will start as soon as all // elements from previous state are in the StreamElementQueue, we have to make sure that the // order to open all operators in the operator chain proceeds from the tail operator to the // head operator. if (recoveredStreamElements != null) { for (StreamElement element : recoveredStreamElements.get()) { if (element.isRecord()) { processElement(element.<IN>asRecord()); } else if (element.isWatermark()) { processWatermark(element.asWatermark()); } else if (element.isLatencyMarker()) { processLatencyMarker(element.asLatencyMarker()); } else { throw new IllegalStateException("Unknown record type " + element.getClass() + " encountered while opening the operator."); } } recoveredStreamElements = null; } }
Example 7
Source File: AsyncWaitOperator.java From flink with Apache License 2.0 | 5 votes |
@Override public void open() throws Exception { super.open(); // create the emitter this.emitter = new Emitter<>(checkpointingLock, output, queue, this); // start the emitter thread this.emitterThread = new Thread(emitter, "AsyncIO-Emitter-Thread (" + getOperatorName() + ')'); emitterThread.setDaemon(true); emitterThread.start(); // process stream elements from state, since the Emit thread will start as soon as all // elements from previous state are in the StreamElementQueue, we have to make sure that the // order to open all operators in the operator chain proceeds from the tail operator to the // head operator. if (recoveredStreamElements != null) { for (StreamElement element : recoveredStreamElements.get()) { if (element.isRecord()) { processElement(element.<IN>asRecord()); } else if (element.isWatermark()) { processWatermark(element.asWatermark()); } else if (element.isLatencyMarker()) { processLatencyMarker(element.asLatencyMarker()); } else { throw new IllegalStateException("Unknown record type " + element.getClass() + " encountered while opening the operator."); } } recoveredStreamElements = null; } }
Example 8
Source File: OrderedStreamElementQueue.java From flink with Apache License 2.0 | 5 votes |
private StreamElementQueueEntry<OUT> createEntry(StreamElement streamElement) { if (streamElement.isRecord()) { return new StreamRecordQueueEntry<>((StreamRecord<?>) streamElement); } if (streamElement.isWatermark()) { return new WatermarkQueueEntry<>((Watermark) streamElement); } throw new UnsupportedOperationException("Cannot enqueue " + streamElement); }
Example 9
Source File: StreamTaskNetworkInput.java From flink with Apache License 2.0 | 5 votes |
private void processElement(StreamElement recordOrMark, DataOutput<T> output) throws Exception { if (recordOrMark.isRecord()){ output.emitRecord(recordOrMark.asRecord()); } else if (recordOrMark.isWatermark()) { statusWatermarkValve.inputWatermark(recordOrMark.asWatermark(), lastChannel); } else if (recordOrMark.isLatencyMarker()) { output.emitLatencyMarker(recordOrMark.asLatencyMarker()); } else if (recordOrMark.isStreamStatus()) { statusWatermarkValve.inputStreamStatus(recordOrMark.asStreamStatus(), lastChannel); } else { throw new UnsupportedOperationException("Unknown type of StreamElement"); } }