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);
}
Aggregations