use of java.util.concurrent.ConcurrentLinkedQueue in project flink by apache.
the class CoProcessOperatorTest method testTimestampAndWatermarkQuerying.
@Test
public void testTimestampAndWatermarkQuerying() throws Exception {
CoProcessOperator<Integer, String, String> operator = new CoProcessOperator<>(new WatermarkQueryingProcessFunction());
TwoInputStreamOperatorTestHarness<Integer, String, String> testHarness = new TwoInputStreamOperatorTestHarness<>(operator);
testHarness.setup();
testHarness.open();
testHarness.processWatermark1(new Watermark(17));
testHarness.processWatermark2(new Watermark(17));
testHarness.processElement1(new StreamRecord<>(5, 12L));
testHarness.processWatermark1(new Watermark(42));
testHarness.processWatermark2(new Watermark(42));
testHarness.processElement2(new StreamRecord<>("6", 13L));
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
expectedOutput.add(new Watermark(17L));
expectedOutput.add(new StreamRecord<>("5WM:17 TS:12", 12L));
expectedOutput.add(new Watermark(42L));
expectedOutput.add(new StreamRecord<>("6WM:42 TS:13", 13L));
TestHarnessUtil.assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
testHarness.close();
}
use of java.util.concurrent.ConcurrentLinkedQueue in project flink by apache.
the class CoStreamMapTest method testCoMap.
@Test
public void testCoMap() throws Exception {
CoStreamMap<Double, Integer, String> operator = new CoStreamMap<Double, Integer, String>(new MyCoMap());
TwoInputStreamOperatorTestHarness<Double, Integer, String> testHarness = new TwoInputStreamOperatorTestHarness<Double, Integer, String>(operator);
long initialTime = 0L;
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<Object>();
testHarness.open();
testHarness.processElement1(new StreamRecord<Double>(1.1d, initialTime + 1));
testHarness.processElement1(new StreamRecord<Double>(1.2d, initialTime + 2));
testHarness.processElement1(new StreamRecord<Double>(1.3d, initialTime + 3));
testHarness.processWatermark1(new Watermark(initialTime + 3));
testHarness.processElement1(new StreamRecord<Double>(1.4d, initialTime + 4));
testHarness.processElement1(new StreamRecord<Double>(1.5d, initialTime + 5));
testHarness.processElement2(new StreamRecord<Integer>(1, initialTime + 1));
testHarness.processElement2(new StreamRecord<Integer>(2, initialTime + 2));
testHarness.processWatermark2(new Watermark(initialTime + 2));
testHarness.processElement2(new StreamRecord<Integer>(3, initialTime + 3));
testHarness.processElement2(new StreamRecord<Integer>(4, initialTime + 4));
testHarness.processElement2(new StreamRecord<Integer>(5, initialTime + 5));
expectedOutput.add(new StreamRecord<String>("1.1", initialTime + 1));
expectedOutput.add(new StreamRecord<String>("1.2", initialTime + 2));
expectedOutput.add(new StreamRecord<String>("1.3", initialTime + 3));
expectedOutput.add(new StreamRecord<String>("1.4", initialTime + 4));
expectedOutput.add(new StreamRecord<String>("1.5", initialTime + 5));
expectedOutput.add(new StreamRecord<String>("1", initialTime + 1));
expectedOutput.add(new StreamRecord<String>("2", initialTime + 2));
expectedOutput.add(new Watermark(initialTime + 2));
expectedOutput.add(new StreamRecord<String>("3", initialTime + 3));
expectedOutput.add(new StreamRecord<String>("4", initialTime + 4));
expectedOutput.add(new StreamRecord<String>("5", initialTime + 5));
TestHarnessUtil.assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
}
use of java.util.concurrent.ConcurrentLinkedQueue in project flink by apache.
the class KeyedCoProcessOperatorTest method testEventTimeTimerWithState.
/**
* Verifies that we don't have leakage between different keys.
*/
@Test
public void testEventTimeTimerWithState() throws Exception {
KeyedCoProcessOperator<String, Integer, String, String> operator = new KeyedCoProcessOperator<>(new EventTimeTriggeringStatefulProcessFunction());
TwoInputStreamOperatorTestHarness<Integer, String, String> testHarness = new KeyedTwoInputStreamOperatorTestHarness<>(operator, new IntToStringKeySelector<>(), new IdentityKeySelector<String>(), BasicTypeInfo.STRING_TYPE_INFO);
testHarness.setup();
testHarness.open();
testHarness.processWatermark1(new Watermark(1));
testHarness.processWatermark2(new Watermark(1));
// should set timer for 6
testHarness.processElement1(new StreamRecord<>(17, 0L));
testHarness.processWatermark1(new Watermark(2));
testHarness.processWatermark2(new Watermark(2));
// should set timer for 7
testHarness.processElement2(new StreamRecord<>("42", 1L));
testHarness.processWatermark1(new Watermark(6));
testHarness.processWatermark2(new Watermark(6));
testHarness.processWatermark1(new Watermark(7));
testHarness.processWatermark2(new Watermark(7));
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
expectedOutput.add(new Watermark(1L));
expectedOutput.add(new StreamRecord<>("INPUT1:17", 0L));
expectedOutput.add(new Watermark(2L));
expectedOutput.add(new StreamRecord<>("INPUT2:42", 1L));
expectedOutput.add(new StreamRecord<>("STATE:17", 6L));
expectedOutput.add(new Watermark(6L));
expectedOutput.add(new StreamRecord<>("STATE:42", 7L));
expectedOutput.add(new Watermark(7L));
TestHarnessUtil.assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
testHarness.close();
}
use of java.util.concurrent.ConcurrentLinkedQueue in project flink by apache.
the class KeyedCoProcessOperatorTest method testTimestampAndWatermarkQuerying.
@Test
public void testTimestampAndWatermarkQuerying() throws Exception {
KeyedCoProcessOperator<String, Integer, String, String> operator = new KeyedCoProcessOperator<>(new WatermarkQueryingProcessFunction());
TwoInputStreamOperatorTestHarness<Integer, String, String> testHarness = new KeyedTwoInputStreamOperatorTestHarness<>(operator, new IntToStringKeySelector<>(), new IdentityKeySelector<String>(), BasicTypeInfo.STRING_TYPE_INFO);
testHarness.setup();
testHarness.open();
testHarness.processWatermark1(new Watermark(17));
testHarness.processWatermark2(new Watermark(17));
testHarness.processElement1(new StreamRecord<>(5, 12L));
testHarness.processWatermark1(new Watermark(42));
testHarness.processWatermark2(new Watermark(42));
testHarness.processElement2(new StreamRecord<>("6", 13L));
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
expectedOutput.add(new Watermark(17L));
expectedOutput.add(new StreamRecord<>("5WM:17 TS:12", 12L));
expectedOutput.add(new Watermark(42L));
expectedOutput.add(new StreamRecord<>("6WM:42 TS:13", 13L));
TestHarnessUtil.assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
testHarness.close();
}
use of java.util.concurrent.ConcurrentLinkedQueue in project flink by apache.
the class KeyedProcessOperatorTest method testTimestampAndWatermarkQuerying.
@Test
public void testTimestampAndWatermarkQuerying() throws Exception {
KeyedProcessOperator<Integer, Integer, String> operator = new KeyedProcessOperator<>(new QueryingFlatMapFunction(TimeDomain.EVENT_TIME));
OneInputStreamOperatorTestHarness<Integer, String> testHarness = new KeyedOneInputStreamOperatorTestHarness<>(operator, new IdentityKeySelector<Integer>(), BasicTypeInfo.INT_TYPE_INFO);
testHarness.setup();
testHarness.open();
testHarness.processWatermark(new Watermark(17));
testHarness.processElement(new StreamRecord<>(5, 12L));
testHarness.processWatermark(new Watermark(42));
testHarness.processElement(new StreamRecord<>(6, 13L));
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
expectedOutput.add(new Watermark(17L));
expectedOutput.add(new StreamRecord<>("5TIME:17 TS:12", 12L));
expectedOutput.add(new Watermark(42L));
expectedOutput.add(new StreamRecord<>("6TIME:42 TS:13", 13L));
TestHarnessUtil.assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
testHarness.close();
}
Aggregations