use of org.apache.flink.streaming.api.graph.StreamConfig in project flink by apache.
the class StreamingRuntimeContextTest method createDescriptorCapturingMockOp.
@SuppressWarnings("unchecked")
private static AbstractStreamOperator<?> createDescriptorCapturingMockOp(final AtomicReference<Object> ref, final ExecutionConfig config, Environment environment) throws Exception {
AbstractStreamOperator<?> operator = new AbstractStreamOperator<Object>() {
@Override
public void setup(StreamTask<?, ?> containingTask, StreamConfig config, Output<StreamRecord<Object>> output) {
super.setup(containingTask, config, output);
}
};
StreamConfig streamConfig = new StreamConfig(new Configuration());
streamConfig.setOperatorID(new OperatorID());
operator.setup(new MockStreamTaskBuilder(environment).setExecutionConfig(config).build(), streamConfig, new CollectorOutput<>(new ArrayList<>()));
StreamTaskStateInitializer streamTaskStateManager = new StreamTaskStateInitializerImpl(environment, new MemoryStateBackend());
KeyedStateBackend keyedStateBackend = mock(KeyedStateBackend.class);
DefaultKeyedStateStore keyedStateStore = new DefaultKeyedStateStore(keyedStateBackend, config);
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
ref.set(invocationOnMock.getArguments()[2]);
return null;
}
}).when(keyedStateBackend).getPartitionedState(Matchers.any(), any(TypeSerializer.class), any(StateDescriptor.class));
operator.initializeState(streamTaskStateManager);
operator.getRuntimeContext().setKeyedStateStore(keyedStateStore);
return operator;
}
use of org.apache.flink.streaming.api.graph.StreamConfig in project flink by apache.
the class MultipleInputStreamOperatorBase method createStreamConfig.
protected StreamConfig createStreamConfig(StreamOperatorParameters<RowData> multipleInputOperatorParameters, TableOperatorWrapper<?> wrapper) {
final ExecutionConfig executionConfig = getExecutionConfig();
final StreamConfig streamConfig = new StreamConfig(multipleInputOperatorParameters.getStreamConfig().getConfiguration().clone());
streamConfig.setOperatorName(wrapper.getOperatorName());
streamConfig.setNumberOfNetworkInputs(wrapper.getAllInputTypes().size());
streamConfig.setNumberOfOutputs(wrapper.getOutputEdges().size());
streamConfig.setupNetworkInputs(wrapper.getAllInputTypes().stream().map(t -> t.createSerializer(executionConfig)).toArray(TypeSerializer[]::new));
streamConfig.setTypeSerializerOut(wrapper.getOutputType().createSerializer(executionConfig));
return streamConfig;
}
use of org.apache.flink.streaming.api.graph.StreamConfig in project flink by apache.
the class NonBufferOverWindowOperatorTest method test.
private void test(boolean[] resetAccumulators, GenericRowData[] expect) throws Exception {
operator = new NonBufferOverWindowOperator(functions, comparator, resetAccumulators) {
{
output = new ConsumerOutput(new Consumer<RowData>() {
@Override
public void accept(RowData r) {
collect.add(GenericRowData.of(r.getInt(0), r.getLong(1), r.getLong(2), r.getLong(3), r.getLong(4)));
}
});
}
@Override
public ClassLoader getUserCodeClassloader() {
return Thread.currentThread().getContextClassLoader();
}
@Override
public StreamConfig getOperatorConfig() {
StreamConfig conf = mock(StreamConfig.class);
when(conf.<RowData>getTypeSerializerIn1(getUserCodeClassloader())).thenReturn(inputSer);
return conf;
}
@Override
public StreamingRuntimeContext getRuntimeContext() {
return mock(StreamingRuntimeContext.class);
}
};
operator.setProcessingTimeService(new TestProcessingTimeService());
operator.open();
addRow(0, 1L, 4L);
addRow(0, 1L, 1L);
addRow(1, 5L, 2L);
addRow(2, 5L, 4L);
addRow(2, 6L, 2L);
GenericRowData[] outputs = this.collect.toArray(new GenericRowData[0]);
Assert.assertArrayEquals(expect, outputs);
}
Aggregations