org.apache.flink.streaming.runtime.streamstatus.StreamStatusProvider Java Examples

The following examples show how to use org.apache.flink.streaming.runtime.streamstatus.StreamStatusProvider. 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: RecordWriterOutput.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public RecordWriterOutput(
		RecordWriter<SerializationDelegate<StreamRecord<OUT>>> recordWriter,
		TypeSerializer<OUT> outSerializer,
		OutputTag outputTag,
		StreamStatusProvider streamStatusProvider) {

	checkNotNull(recordWriter);
	this.outputTag = outputTag;
	// generic hack: cast the writer to generic Object type so we can use it
	// with multiplexed records and watermarks
	this.recordWriter = (RecordWriter<SerializationDelegate<StreamElement>>)
			(RecordWriter<?>) recordWriter;

	TypeSerializer<StreamElement> outRecordSerializer =
			new StreamElementSerializer<>(outSerializer);

	if (outSerializer != null) {
		serializationDelegate = new SerializationDelegate<StreamElement>(outRecordSerializer);
	}

	this.streamStatusProvider = checkNotNull(streamStatusProvider);
}
 
Example #2
Source File: RecordWriterOutput.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public RecordWriterOutput(
		RecordWriter<SerializationDelegate<StreamRecord<OUT>>> recordWriter,
		TypeSerializer<OUT> outSerializer,
		OutputTag outputTag,
		StreamStatusProvider streamStatusProvider) {

	checkNotNull(recordWriter);
	this.outputTag = outputTag;
	// generic hack: cast the writer to generic Object type so we can use it
	// with multiplexed records and watermarks
	this.recordWriter = (RecordWriter<SerializationDelegate<StreamElement>>)
			(RecordWriter<?>) recordWriter;

	TypeSerializer<StreamElement> outRecordSerializer =
			new StreamElementSerializer<>(outSerializer);

	if (outSerializer != null) {
		serializationDelegate = new SerializationDelegate<StreamElement>(outRecordSerializer);
	}

	this.streamStatusProvider = checkNotNull(streamStatusProvider);
}
 
Example #3
Source File: RecordWriterOutput.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public RecordWriterOutput(
		RecordWriter<SerializationDelegate<StreamRecord<OUT>>> recordWriter,
		TypeSerializer<OUT> outSerializer,
		OutputTag outputTag,
		StreamStatusProvider streamStatusProvider) {

	checkNotNull(recordWriter);
	this.outputTag = outputTag;
	// generic hack: cast the writer to generic Object type so we can use it
	// with multiplexed records and watermarks
	this.recordWriter = (RecordWriter<SerializationDelegate<StreamElement>>)
			(RecordWriter<?>) recordWriter;

	TypeSerializer<StreamElement> outRecordSerializer =
			new StreamElementSerializer<>(outSerializer);

	if (outSerializer != null) {
		serializationDelegate = new SerializationDelegate<StreamElement>(outRecordSerializer);
	}

	this.streamStatusProvider = checkNotNull(streamStatusProvider);
}
 
Example #4
Source File: OperatorChain.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public CopyingChainingOutput(
		OneInputStreamOperator<T, ?> operator,
		TypeSerializer<T> serializer,
		OutputTag<T> outputTag,
		StreamStatusProvider streamStatusProvider) {
	super(operator, streamStatusProvider, outputTag);
	this.serializer = serializer;
}
 
Example #5
Source File: OperatorChainTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@SafeVarargs
private static <T, OP extends StreamOperator<T>> OperatorChain<T, OP> setupOperatorChain(
		OneInputStreamOperator<T, T>... operators) {

	checkNotNull(operators);
	checkArgument(operators.length > 0);

	try (MockEnvironment env = MockEnvironment.builder().build()) {

	final StreamTask<?, ?> containingTask = new OneInputStreamTask<T, OneInputStreamOperator<T, T>>(env);

		final StreamStatusProvider statusProvider = mock(StreamStatusProvider.class);
		final StreamConfig cfg = new StreamConfig(new Configuration());

		final StreamOperator<?>[] ops = new StreamOperator<?>[operators.length];

		// initial output goes to nowhere
		@SuppressWarnings({"unchecked", "rawtypes"})
		WatermarkGaugeExposingOutput<StreamRecord<T>> lastWriter = new BroadcastingOutputCollector<>(
				new Output[0], statusProvider);

		// build the reverse operators array
		for (int i = 0; i < ops.length; i++) {
			OneInputStreamOperator<T, T> op = operators[ops.length - i - 1];
			op.setup(containingTask, cfg, lastWriter);
			lastWriter = new ChainingOutput<>(op, statusProvider, null);
			ops[i] = op;
		}

		@SuppressWarnings("unchecked")
		final OP head = (OP) operators[0];

		return new OperatorChain<>(
				ops,
				new RecordWriterOutput<?>[0],
				lastWriter,
				head);
	}
}
 
Example #6
Source File: OperatorChain.java    From flink with Apache License 2.0 5 votes vote down vote up
public CopyingChainingOutput(
		OneInputStreamOperator<T, ?> operator,
		TypeSerializer<T> serializer,
		OutputTag<T> outputTag,
		StreamStatusProvider streamStatusProvider) {
	super(operator, streamStatusProvider, outputTag);
	this.serializer = serializer;
}
 
Example #7
Source File: OperatorChain.java    From flink with Apache License 2.0 5 votes vote down vote up
public CopyingChainingOutput(
		OneInputStreamOperator<T, ?> operator,
		TypeSerializer<T> serializer,
		OutputTag<T> outputTag,
		StreamStatusProvider streamStatusProvider) {
	super(operator, streamStatusProvider, outputTag);
	this.serializer = serializer;
}
 
Example #8
Source File: OperatorChain.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public BroadcastingOutputCollector(
		Output<StreamRecord<T>>[] outputs,
		StreamStatusProvider streamStatusProvider) {
	this.outputs = outputs;
	this.streamStatusProvider = streamStatusProvider;
}
 
Example #9
Source File: OperatorChain.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public CopyingBroadcastingOutputCollector(
		Output<StreamRecord<T>>[] outputs,
		StreamStatusProvider streamStatusProvider) {
	super(outputs, streamStatusProvider);
}
 
Example #10
Source File: OperatorChain.java    From flink with Apache License 2.0 4 votes vote down vote up
public BroadcastingOutputCollector(
		Output<StreamRecord<T>>[] outputs,
		StreamStatusProvider streamStatusProvider) {
	this.outputs = outputs;
	this.streamStatusProvider = streamStatusProvider;
}
 
Example #11
Source File: OperatorChain.java    From flink with Apache License 2.0 4 votes vote down vote up
public CopyingBroadcastingOutputCollector(
		Output<StreamRecord<T>>[] outputs,
		StreamStatusProvider streamStatusProvider) {
	super(outputs, streamStatusProvider);
}
 
Example #12
Source File: OperatorChainTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@SafeVarargs
private static <T, OP extends StreamOperator<T>> OperatorChain<T, OP> setupOperatorChain(
		OneInputStreamOperator<T, T>... operators) throws Exception {

	checkNotNull(operators);
	checkArgument(operators.length > 0);

	try (MockEnvironment env = MockEnvironment.builder().build()) {

	final StreamTask<?, ?> containingTask = new OneInputStreamTask<T, OneInputStreamOperator<T, T>>(env);

		final StreamStatusProvider statusProvider = mock(StreamStatusProvider.class);
		final StreamConfig cfg = new StreamConfig(new Configuration());

		final StreamOperator<?>[] ops = new StreamOperator<?>[operators.length];

		// initial output goes to nowhere
		@SuppressWarnings({"unchecked", "rawtypes"})
		WatermarkGaugeExposingOutput<StreamRecord<T>> lastWriter = new BroadcastingOutputCollector<>(
				new Output[0], statusProvider);

		// build the reverse operators array
		for (int i = 0; i < ops.length; i++) {
			OneInputStreamOperator<T, T> op = operators[ops.length - i - 1];
			if (op instanceof SetupableStreamOperator) {
				((SetupableStreamOperator) op).setup(containingTask, cfg, lastWriter);
			}
			lastWriter = new ChainingOutput<>(op, statusProvider, null);
			ops[i] = op;
		}

		@SuppressWarnings("unchecked")
		final OP head = (OP) operators[0];

		return new OperatorChain<>(
				ops,
				new RecordWriterOutput<?>[0],
				lastWriter,
				head);
	}
}
 
Example #13
Source File: OperatorChain.java    From flink with Apache License 2.0 4 votes vote down vote up
public BroadcastingOutputCollector(
		Output<StreamRecord<T>>[] outputs,
		StreamStatusProvider streamStatusProvider) {
	this.outputs = outputs;
	this.streamStatusProvider = streamStatusProvider;
}
 
Example #14
Source File: OperatorChain.java    From flink with Apache License 2.0 4 votes vote down vote up
public CopyingBroadcastingOutputCollector(
		Output<StreamRecord<T>>[] outputs,
		StreamStatusProvider streamStatusProvider) {
	super(outputs, streamStatusProvider);
}
 
Example #15
Source File: OperatorChainTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@SafeVarargs
public static <T, OP extends StreamOperator<T>> OperatorChain<T, OP> setupOperatorChain(
		OneInputStreamOperator<T, T>... operators) throws Exception {

	checkNotNull(operators);
	checkArgument(operators.length > 0);

	try (MockEnvironment env = MockEnvironment.builder().build()) {
		final StreamTask<?, ?> containingTask = new MockStreamTaskBuilder(env).build();

		final StreamStatusProvider statusProvider = mock(StreamStatusProvider.class);
		final StreamConfig cfg = new StreamConfig(new Configuration());

		final List<StreamOperatorWrapper<?, ?>> operatorWrappers = new ArrayList<>();

		// initial output goes to nowhere
		@SuppressWarnings({"unchecked", "rawtypes"})
		WatermarkGaugeExposingOutput<StreamRecord<T>> lastWriter = new BroadcastingOutputCollector<>(
				new Output[0], statusProvider);

		// build the reverse operators array
		for (int i = 0; i < operators.length; i++) {
			OneInputStreamOperator<T, T> op = operators[operators.length - i - 1];
			if (op instanceof SetupableStreamOperator) {
				((SetupableStreamOperator) op).setup(containingTask, cfg, lastWriter);
			}
			lastWriter = new ChainingOutput<>(op, statusProvider, null);

			ProcessingTimeService processingTimeService = null;
			if (op instanceof AbstractStreamOperator) {
				processingTimeService = ((AbstractStreamOperator) op).getProcessingTimeService();
			}
			operatorWrappers.add(new StreamOperatorWrapper<>(
				op,
				Optional.ofNullable(processingTimeService),
				containingTask.getMailboxExecutorFactory().createExecutor(i)));
		}

		@SuppressWarnings("unchecked")
		final StreamOperatorWrapper<T, OP> headOperatorWrapper = (StreamOperatorWrapper<T, OP>) operatorWrappers.get(operatorWrappers.size() - 1);

		return new OperatorChain<>(
			operatorWrappers,
			new RecordWriterOutput<?>[0],
			lastWriter,
			headOperatorWrapper);
	}
}