Search in sources :

Example 16 with EventStreamWriter

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());
}
Also used : StreamCut(io.pravega.client.stream.StreamCut) EventStreamWriter(io.pravega.client.stream.EventStreamWriter) AssertExtensions(io.pravega.test.common.AssertExtensions) ReaderGroupManagerImpl(io.pravega.client.admin.impl.ReaderGroupManagerImpl) Cleanup(lombok.Cleanup) JavaSerializer(io.pravega.client.stream.impl.JavaSerializer) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) EventRead(io.pravega.client.stream.EventRead) ClientFactoryImpl(io.pravega.client.stream.impl.ClientFactoryImpl) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ReaderGroupManager(io.pravega.client.admin.ReaderGroupManager) Stream(io.pravega.client.stream.Stream) Duration(java.time.Duration) Map(java.util.Map) TimeWindow(io.pravega.client.stream.TimeWindow) ClassRule(org.junit.ClassRule) Transaction(io.pravega.client.stream.Transaction) ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) WatermarkSerializer(io.pravega.client.watermark.WatermarkSerializer) CompletionException(java.util.concurrent.CompletionException) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Collectors(java.util.stream.Collectors) ControllerImplConfig(io.pravega.client.control.impl.ControllerImplConfig) Slf4j(lombok.extern.slf4j.Slf4j) ThreadPooledTestSuite(io.pravega.test.common.ThreadPooledTestSuite) Controller(io.pravega.client.control.impl.Controller) Futures(io.pravega.common.concurrent.Futures) Segment(io.pravega.client.segment.impl.Segment) ConnectionFactory(io.pravega.client.connection.impl.ConnectionFactory) StreamManager(io.pravega.client.admin.StreamManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) AtomicReference(java.util.concurrent.atomic.AtomicReference) StreamCutImpl(io.pravega.client.stream.impl.StreamCutImpl) EventStreamClientFactory(io.pravega.client.EventStreamClientFactory) RevisionedStreamClient(io.pravega.client.state.RevisionedStreamClient) SynchronizerConfig(io.pravega.client.state.SynchronizerConfig) SocketConnectionFactoryImpl(io.pravega.client.connection.impl.SocketConnectionFactoryImpl) TransactionalEventStreamWriter(io.pravega.client.stream.TransactionalEventStreamWriter) EventWriterConfig(io.pravega.client.stream.EventWriterConfig) NameUtils(io.pravega.shared.NameUtils) Iterator(java.util.Iterator) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) EventStreamReader(io.pravega.client.stream.EventStreamReader) Test(org.junit.Test) Watermark(io.pravega.shared.watermarks.Watermark) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) Assert.assertNull(org.junit.Assert.assertNull) SynchronizerClientFactory(io.pravega.client.SynchronizerClientFactory) ControllerImpl(io.pravega.client.control.impl.ControllerImpl) Revision(io.pravega.client.state.Revision) ReaderConfig(io.pravega.client.stream.ReaderConfig) TxnFailedException(io.pravega.client.stream.TxnFailedException) Collections(java.util.Collections) ScalingPolicy(io.pravega.client.stream.ScalingPolicy) Assert.assertEquals(org.junit.Assert.assertEquals) ClientConfig(io.pravega.client.ClientConfig) AtomicLong(java.util.concurrent.atomic.AtomicLong) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Aggregations

EventStreamWriter (io.pravega.client.stream.EventStreamWriter)16 ClientConfig (io.pravega.client.ClientConfig)15 Cleanup (lombok.Cleanup)15 EventWriterConfig (io.pravega.client.stream.EventWriterConfig)14 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)14 Test (org.junit.Test)14 ScalingPolicy (io.pravega.client.stream.ScalingPolicy)13 Map (java.util.Map)13 Assert.assertTrue (org.junit.Assert.assertTrue)13 SocketConnectionFactoryImpl (io.pravega.client.connection.impl.SocketConnectionFactoryImpl)12 Stream (io.pravega.client.stream.Stream)12 ClientFactoryImpl (io.pravega.client.stream.impl.ClientFactoryImpl)12 JavaSerializer (io.pravega.client.stream.impl.JavaSerializer)12 ReaderGroupManager (io.pravega.client.admin.ReaderGroupManager)11 ConnectionFactory (io.pravega.client.connection.impl.ConnectionFactory)11 ReaderGroupConfig (io.pravega.client.stream.ReaderGroupConfig)11 AssertExtensions (io.pravega.test.common.AssertExtensions)11 Slf4j (lombok.extern.slf4j.Slf4j)11 EventRead (io.pravega.client.stream.EventRead)10 EventStreamReader (io.pravega.client.stream.EventStreamReader)10