use of io.pravega.client.stream.EventStreamWriter in project pravega by pravega.
the class WatermarkingTest method writeEvents.
private CompletableFuture<Void> writeEvents(EventStreamWriter<Long> writer, AtomicBoolean stopFlag) {
AtomicInteger count = new AtomicInteger(0);
AtomicLong currentTime = new AtomicLong();
return Futures.loop(() -> !stopFlag.get(), () -> Futures.delayedFuture(() -> {
currentTime.set(timer.incrementAndGet());
return writer.writeEvent(count.toString(), currentTime.get()).thenAccept(v -> {
if (count.incrementAndGet() % 3 == 0) {
writer.noteTime(currentTime.get());
}
});
}, 1000L, executorService()), executorService());
}
Aggregations