Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,12 @@ public Dataflow create(PipelineOptions options) {

/** The max amount of time an UnboundedReader is consumed before checkpointing. */
@Description(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mentioning that the representation can be in fractions of seconds is probably a good call-out here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. added additional comment.

"The max amount of time before an UnboundedReader is consumed before checkpointing, in seconds.")
@Default.Integer(10)
Integer getUnboundedReaderMaxReadTimeSec();
"The max amount of time before an UnboundedReader is consumed before checkpointing, "
+ "in seconds. Duration can be set to fractions of seconds. ")
@Default.Double(10.0)
double getUnboundedReaderMaxReadTimeSec();

void setUnboundedReaderMaxReadTimeSec(Integer value);
void setUnboundedReaderMaxReadTimeSec(double value);

/** The max elements read from an UnboundedReader before checkpointing. */
@Description("The max elements read from an UnboundedReader before checkpointing. ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,9 @@ private UnboundedReaderIterator(
DataflowPipelineDebugOptions debugOptions = options.as(DataflowPipelineDebugOptions.class);
this.endTime =
Instant.now()
.plus(Duration.standardSeconds(debugOptions.getUnboundedReaderMaxReadTimeSec()));
.plus(
Duration.millis(
(long) (debugOptions.getUnboundedReaderMaxReadTimeSec() * 1000L)));
this.maxElems = debugOptions.getUnboundedReaderMaxElements();
this.backoffFactory =
FluentBackoff.DEFAULT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ public void testReadUnboundedReader() throws Exception {
int maxElements = 10;
DataflowPipelineDebugOptions debugOptions = options.as(DataflowPipelineDebugOptions.class);
debugOptions.setUnboundedReaderMaxElements(maxElements);
debugOptions.setUnboundedReaderMaxReadTimeSec(10);

ByteString state = ByteString.EMPTY;
for (int i = 0; i < 10 * maxElements;
Expand Down Expand Up @@ -645,10 +646,10 @@ public void testReadUnboundedReader() throws Exception {
numReadOnThisIteration++;
}
Instant afterReading = Instant.now();
long maxReadSec = debugOptions.getUnboundedReaderMaxReadTimeSec();
double maxReadSec = debugOptions.getUnboundedReaderMaxReadTimeSec();
assertThat(
new Duration(beforeReading, afterReading).getStandardSeconds(),
lessThanOrEqualTo(maxReadSec + 1));
new Duration(beforeReading, afterReading).getMillis(),
lessThanOrEqualTo((long) ((maxReadSec + 1) * 1000L)));
assertThat(
numReadOnThisIteration, lessThanOrEqualTo(debugOptions.getUnboundedReaderMaxElements()));

Expand Down