Search in sources :

Example 16 with WriterMark

use of io.pravega.controller.store.stream.records.WriterMark in project pravega by pravega.

the class StreamTestBase method testTransactionMark.

@Test(timeout = 30000L)
public void testTransactionMark() {
    PersistentStreamBase streamObj = createStream("txnMark", "txnMark", System.currentTimeMillis(), 3, 0);
    UUID txnId = new UUID(0L, 0L);
    OperationContext context = getContext();
    VersionedTransactionData tx01 = streamObj.createTransaction(txnId, 100, 100, context).join();
    String writer1 = "writer1";
    long time = 1L;
    streamObj.sealTransaction(txnId, true, Optional.of(tx01.getVersion()), writer1, time, context).join();
    streamObj.startCommittingTransactions(100, context).join();
    TxnWriterMark writerMarks = new TxnWriterMark(time, Collections.singletonMap(0L, 1L), txnId);
    Map<String, TxnWriterMark> marksForWriters = Collections.singletonMap(writer1, writerMarks);
    streamObj.generateMarksForTransactions(context, marksForWriters).join();
    // verify that writer mark is created in the store
    WriterMark mark = streamObj.getWriterMark(writer1, context).join();
    assertEquals(mark.getTimestamp(), time);
    // idempotent call to generateMarksForTransactions
    streamObj.generateMarksForTransactions(context, marksForWriters).join();
    mark = streamObj.getWriterMark(writer1, context).join();
    assertEquals(mark.getTimestamp(), time);
    // complete txn commit explicitly such that activeTxnRecord no longer exists and then invoke generateMark
    streamObj.commitTransaction(txnId, context).join();
    AssertExtensions.assertFutureThrows("", streamObj.getActiveTx(0, txnId, context), e -> Exceptions.unwrap(e) instanceof StoreException.DataNotFoundException);
    streamObj.generateMarksForTransactions(context, marksForWriters).join();
    mark = streamObj.getWriterMark(writer1, context).join();
    assertEquals(mark.getTimestamp(), time);
}
Also used : TestOperationContext(io.pravega.controller.store.TestOperationContext) WriterMark(io.pravega.controller.store.stream.records.WriterMark) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

WriterMark (io.pravega.controller.store.stream.records.WriterMark)16 Test (org.junit.Test)9 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)7 ImmutableMap (com.google.common.collect.ImmutableMap)6 HashMap (java.util.HashMap)6 VisibleForTesting (com.google.common.annotations.VisibleForTesting)5 SynchronizerClientFactory (io.pravega.client.SynchronizerClientFactory)5 Exceptions (io.pravega.common.Exceptions)5 Futures (io.pravega.common.concurrent.Futures)5 TagLogger (io.pravega.common.tracing.TagLogger)5 EpochRecord (io.pravega.controller.store.stream.records.EpochRecord)5 Watermark (io.pravega.shared.watermarks.Watermark)5 ArrayList (java.util.ArrayList)5 Collections (java.util.Collections)5 List (java.util.List)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 Stream (io.pravega.client.stream.Stream)4 RequestTracker (io.pravega.common.tracing.RequestTracker)4 Map (java.util.Map)4 UUID (java.util.UUID)4