sunhaibotb commented on a change in pull request #8731: [FLINK-11878][runtime]
Implement the runtime handling of BoundedOneInput and BoundedMultiInput
URL: https://github.com/apache/flink/pull/8731#discussion_r295255945
##########
File path:
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/TwoInputStreamTaskTest.java
##########
@@ -671,5 +737,100 @@ public InputSelection nextSelection() {
return InputSelection.ALL;
}
}
+
+ /**
+ * Uses to test handling the EndOfInput notification.
+ */
+ private static class TestBoundedTwoInputOperator extends
AbstractStreamOperator<String>
+ implements TwoInputStreamOperator<String, String, String>,
BoundedMultiInput {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String name;
+
+ private volatile int outputRecords1;
+ private volatile int outputRecords2;
+
+ private static final CompletableFuture<Void> success =
CompletableFuture.completedFuture(null);
+ private static final CompletableFuture<Void> failure =
FutureUtils.completedExceptionally(
+ new Exception("Not in line with expectations."));
+
+ public TestBoundedTwoInputOperator(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public void processElement1(StreamRecord<String> element) {
+ output.collect(element.replace("[" + name + "-1]: " +
element.getValue()));
+ outputRecords1++;
+
+ synchronized (this) {
+ this.notifyAll();
+ }
+ }
+
+ @Override
+ public void processElement2(StreamRecord<String> element) {
+ output.collect(element.replace("[" + name + "-2]: " +
element.getValue()));
+ outputRecords2++;
+
+ synchronized (this) {
+ this.notifyAll();
+ }
+ }
+
+ @Override
+ public void endInput(int inputId) {
+ output.collect(new StreamRecord<>("[" + name + "-" +
inputId + "]: Bye"));
+
+ if (inputId == 1) {
+ outputRecords1++;
+ } else {
+ outputRecords2++;
+ }
+
+ synchronized (this) {
+ this.notifyAll();
+ }
+ }
+
+ public void waitOutputRecords(int inputId, int expectedRecords)
throws Exception {
Review comment:
I was misled by its name before. `testHarness.waitForInputProcessing` can
work well.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services