JingsongLi commented on a change in pull request #13010:
URL: https://github.com/apache/flink/pull/13010#discussion_r468305915



##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/source/datagen/DataGeneratorSource.java
##########
@@ -77,8 +102,11 @@ public void run(SourceContext<T> ctx) throws Exception {
 
                while (isRunning) {
                        for (int i = 0; i < taskRowsPerSecond; i++) {
-                               if (isRunning && generator.hasNext()) {
+                               if (isRunning && generator.hasNext() && 
(numberOfRows == null || outputSoFar < toOutput)) {
                                        synchronized (ctx.getCheckpointLock()) {
+                                               if (numberOfRows != null) {
+                                                       outputSoFar++;

Review comment:
       I have an idea: print `outputSoFar` in `close`. It is good for debugging.

##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/source/datagen/DataGeneratorSource.java
##########
@@ -77,8 +102,11 @@ public void run(SourceContext<T> ctx) throws Exception {
 
                while (isRunning) {
                        for (int i = 0; i < taskRowsPerSecond; i++) {
-                               if (isRunning && generator.hasNext()) {
+                               if (isRunning && generator.hasNext() && 
(numberOfRows == null || outputSoFar < toOutput)) {
                                        synchronized (ctx.getCheckpointLock()) {
+                                               if (numberOfRows != null) {

Review comment:
       Remove this if?




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to