use of org.apache.flink.streaming.util.MockStreamingRuntimeContext in project flink by apache.
the class RMQSinkTest method createRMQSinkWithOptionsAndReturnHandler.
private RMQSink<String> createRMQSinkWithOptionsAndReturnHandler(boolean mandatory, boolean immediate) throws Exception {
publishOptions = new DummyPublishOptions(mandatory, immediate);
returnListener = new DummyReturnHandler();
RMQSink<String> rmqSink = new RMQSink<>(rmqConnectionConfig, serializationSchema, publishOptions, returnListener);
rmqSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
rmqSink.open(new Configuration());
return rmqSink;
}
use of org.apache.flink.streaming.util.MockStreamingRuntimeContext in project flink by apache.
the class RMQSinkTest method createRMQSinkWithOptions.
private RMQSink<String> createRMQSinkWithOptions(boolean mandatory, boolean immediate) throws Exception {
publishOptions = new DummyPublishOptions(mandatory, immediate);
RMQSink<String> rmqSink = new RMQSink<>(rmqConnectionConfig, serializationSchema, publishOptions);
rmqSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
rmqSink.open(new Configuration());
return rmqSink;
}
use of org.apache.flink.streaming.util.MockStreamingRuntimeContext in project flink by apache.
the class PubSubConsumingTest method createSourceThread.
private Thread createSourceThread(PubSubSource<String> pubSubSource, Object lock, ConcurrentLinkedQueue<String> results) {
return new Thread(() -> {
try {
pubSubSource.setRuntimeContext(new MockStreamingRuntimeContext(true, 1, 0));
pubSubSource.open(new Configuration());
pubSubSource.run(new CollectingSourceContext<>(lock, results));
} catch (InterruptedException e) {
// expected on cancel
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}
use of org.apache.flink.streaming.util.MockStreamingRuntimeContext in project flink by apache.
the class OracleTableSinkITCase method testFlushBufferWhenCheckpoint.
@Test
public void testFlushBufferWhenCheckpoint() throws Exception {
Map<String, String> options = new HashMap<>();
options.put("connector", "jdbc");
options.put("url", containerUrl);
options.put("table-name", OUTPUT_TABLE5);
options.put("sink.buffer-flush.interval", "0");
ResolvedSchema schema = ResolvedSchema.of(Column.physical("id", DataTypes.BIGINT().notNull()));
DynamicTableSink tableSink = createTableSink(schema, options);
SinkRuntimeProviderContext context = new SinkRuntimeProviderContext(false);
SinkFunctionProvider sinkProvider = (SinkFunctionProvider) tableSink.getSinkRuntimeProvider(context);
GenericJdbcSinkFunction<RowData> sinkFunction = (GenericJdbcSinkFunction<RowData>) sinkProvider.createSinkFunction();
sinkFunction.setRuntimeContext(new MockStreamingRuntimeContext(true, 1, 0));
sinkFunction.open(new Configuration());
sinkFunction.invoke(GenericRowData.of(1L), SinkContextUtil.forTimestamp(1));
sinkFunction.invoke(GenericRowData.of(2L), SinkContextUtil.forTimestamp(1));
check(new Row[] {}, containerUrl, OUTPUT_TABLE5, new String[] { "id" });
sinkFunction.snapshotState(new StateSnapshotContextSynchronousImpl(1, 1));
check(new Row[] { Row.of(1L), Row.of(2L) }, containerUrl, OUTPUT_TABLE5, new String[] { "id" });
sinkFunction.close();
}
use of org.apache.flink.streaming.util.MockStreamingRuntimeContext in project flink by apache.
the class FlinkKafkaConsumerBaseTest method setupConsumer.
@SuppressWarnings("unchecked")
private static <T, S> void setupConsumer(FlinkKafkaConsumerBase<T> consumer, boolean isRestored, ListState<S> restoredListState, boolean isCheckpointingEnabled, int subtaskIndex, int totalNumSubtasks) throws Exception {
// run setup procedure in operator life cycle
consumer.setRuntimeContext(new MockStreamingRuntimeContext(isCheckpointingEnabled, totalNumSubtasks, subtaskIndex));
consumer.initializeState(new MockFunctionInitializationContext(isRestored, new MockOperatorStateStore(restoredListState)));
consumer.open(new Configuration());
}
Aggregations