ns-shua commented on code in PR #17169:
URL: https://github.com/apache/beam/pull/17169#discussion_r1433239877
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsublite/internal/SubscriptionPartitionProcessorImpl.java:
##########
@@ -59,42 +52,24 @@ class SubscriptionPartitionProcessorImpl implements
SubscriptionPartitionProcess
}
@Override
- @SuppressWarnings("argument.type.incompatible")
- public ProcessContinuation runFor(Duration duration) {
- Instant maxReadTime = Instant.now().plus(duration);
- while (subscriber.isRunning()) {
- // Read any available data.
- for (Optional<SequencedMessage> next = subscriber.peek();
- next.isPresent();
- next = subscriber.peek()) {
- SequencedMessage message = next.get();
- Offset messageOffset = Offset.of(message.getCursor().getOffset());
- if (tracker.tryClaim(OffsetByteProgress.of(messageOffset,
message.getSizeBytes()))) {
- subscriber.pop();
- lastClaimedOffset = Optional.of(messageOffset);
- receiver.outputWithTimestamp(
- message, new
Instant(Timestamps.toMillis(message.getPublishTime())));
- } else {
- // Our claim failed, return stop()
- return ProcessContinuation.stop();
- }
- }
- // Try waiting for new data.
- try {
- Duration readTime = new Duration(Instant.now(), maxReadTime);
- Future<Void> onData = subscriber.onData();
- checkArgumentNotNull(onData);
- onData.get(readTime.getMillis(), TimeUnit.MILLISECONDS);
- } catch (TimeoutException e) {
- // Read timed out without us being cut off, yield to the runtime.
- return ProcessContinuation.resume();
- } catch (InterruptedException | ExecutionException e2) {
- // We should never be interrupted by beam, and onData should never
return an error.
- throw new RuntimeException(e2);
+ public ProcessContinuation run() {
+ // Read any available data.
+ for (Optional<SequencedMessage> next = subscriber.peek();
+ next.isPresent();
+ next = subscriber.peek()) {
+ SequencedMessage message = next.get();
+ Offset messageOffset = Offset.of(message.getCursor().getOffset());
+ if (tracker.tryClaim(OffsetByteProgress.of(messageOffset,
message.getSizeBytes()))) {
+ subscriber.pop();
+ lastClaimedOffset = Optional.of(messageOffset);
+ receiver.outputWithTimestamp(
+ message, new
Instant(Timestamps.toMillis(message.getPublishTime())));
Review Comment:
Why can't user define the timestamp fn?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]