Java Code Examples for org.apache.flink.streaming.runtime.streamrecord.StreamElement#asRecord()

The following examples show how to use org.apache.flink.streaming.runtime.streamrecord.StreamElement#asRecord() . 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 vote down vote up
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 vote down vote up
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 vote down vote up
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");
	}
}