Java Code Examples for org.apache.flink.streaming.util.OneInputStreamOperatorTestHarness#prepareSnapshotPreBarrier()

The following examples show how to use org.apache.flink.streaming.util.OneInputStreamOperatorTestHarness#prepareSnapshotPreBarrier() . These examples are extracted from open source projects. 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
@Test
public void testWatermarkProcessedOnFinishBundle() throws Exception {
	Configuration conf = new Configuration();
	conf.setInteger(PythonOptions.MAX_BUNDLE_SIZE, 10);
	OneInputStreamOperatorTestHarness<IN, OUT> testHarness = getTestHarness(conf);
	long initialTime = 0L;
	ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();

	testHarness.open();

	testHarness.processElement(new StreamRecord<>(newRow(true, "c1", "c2", 0L), initialTime + 1));
	testHarness.processWatermark(initialTime + 2);
	assertOutputEquals("Watermark has been processed", expectedOutput, testHarness.getOutput());

	// checkpoint trigger finishBundle
	testHarness.prepareSnapshotPreBarrier(0L);

	expectedOutput.add(new StreamRecord<>(newRow(true, "c1", "c2", 0L)));
	expectedOutput.add(new Watermark(initialTime + 2));

	assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());

	testHarness.close();
}
 
Example 2
@Test
public void testFinishBundleTriggeredOnCheckpoint() throws Exception {
	Configuration conf = new Configuration();
	conf.setInteger(PythonOptions.MAX_BUNDLE_SIZE, 10);
	OneInputStreamOperatorTestHarness<IN, OUT> testHarness = getTestHarness(conf, JoinRelType.INNER);

	long initialTime = 0L;
	ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();

	testHarness.open();

	testHarness.processElement(new StreamRecord<>(newRow(true, "c1", "c2", 0L), initialTime + 1));

	// checkpoint trigger finishBundle
	testHarness.prepareSnapshotPreBarrier(0L);

	expectedOutput.add(new StreamRecord<>(newRow(true, "c1", "c2", 0L, 0L)));

	assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());

	testHarness.close();
}
 
Example 3
@Test
public void testFinishBundleTriggeredOnCheckpoint() throws Exception {
	Configuration conf = new Configuration();
	conf.setInteger(PythonOptions.MAX_BUNDLE_SIZE, 10);
	OneInputStreamOperatorTestHarness<IN, OUT> testHarness = getTestHarness(conf);

	long initialTime = 0L;
	ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();

	testHarness.open();

	testHarness.processElement(new StreamRecord<>(newRow(true, "c1", "c2", 0L), initialTime + 1));

	// checkpoint trigger finishBundle
	testHarness.prepareSnapshotPreBarrier(0L);

	expectedOutput.add(new StreamRecord<>(newRow(true, "c1", "c2", 0L)));

	assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());

	testHarness.close();
}