use of com.google.cloud.pubsublite.proto.SequencedMessage in project beam by apache.
the class UuidDeduplicationTransformTest method sameUuidsAfterGcOutsideWindowHasBoth.
@Test
public void sameUuidsAfterGcOutsideWindowHasBoth() {
SequencedMessage message1 = newMessage();
TestStream<SequencedMessage> messageStream = TestStream.create(ProtoCoder.of(SequencedMessage.class)).advanceWatermarkTo(START).addElements(message1).advanceWatermarkTo(START.plus(UuidDeduplicationOptions.DEFAULT_DEDUPLICATE_DURATION.plus(Duration.millis(1)))).addElements(message1).advanceWatermarkToInfinity();
PCollection<SequencedMessage> results = pipeline.apply(messageStream).apply(new UuidDeduplicationTransform(UuidDeduplicationOptions.newBuilder().build()));
PAssert.that(results).containsInAnyOrder(message1, message1);
pipeline.run();
}
use of com.google.cloud.pubsublite.proto.SequencedMessage in project beam by apache.
the class UuidDeduplicationTransformTest method sameUuidsWithinWindowOnlyOne.
@Test
public void sameUuidsWithinWindowOnlyOne() {
SequencedMessage message = newMessage();
TestStream<SequencedMessage> messageStream = TestStream.create(ProtoCoder.of(SequencedMessage.class)).advanceWatermarkTo(START).addElements(message).advanceWatermarkTo(START.plus(Deduplicate.DEFAULT_DURATION.dividedBy(2))).advanceWatermarkToInfinity();
PCollection<SequencedMessage> results = pipeline.apply(messageStream).apply(new UuidDeduplicationTransform(UuidDeduplicationOptions.newBuilder().build()));
PAssert.that(results).containsInAnyOrder(message);
pipeline.run();
}
use of com.google.cloud.pubsublite.proto.SequencedMessage in project beam by apache.
the class SubscriptionPartitionProcessorImpl method runFor.
@Override
@SuppressWarnings("argument.type.incompatible")
public ProcessContinuation runFor(Duration duration) {
Instant deadline = Instant.now().plus(duration);
start();
try (SubscriptionPartitionProcessorImpl closeThis = this) {
while (!completionFuture.isDone() && deadline.isAfterNow()) {
@Nullable List<SequencedMessage> messages = transfer.poll(10, TimeUnit.MILLISECONDS);
if (messages != null) {
handleMessages(messages);
}
}
} catch (Throwable t) {
throw ExtractStatus.toCanonical(t).underlying;
}
// Determine return code after shutdown.
if (completionFuture.isDone()) {
// Call get() to ensure there is no exception.
try {
completionFuture.get();
} catch (Throwable t) {
throw ExtractStatus.toCanonical(t).underlying;
}
// CompletionFuture set with null when tryClaim returned false.
return ProcessContinuation.stop();
}
return ProcessContinuation.resume();
}
Aggregations