use of org.apache.distributedlog.util.Transaction in project bookkeeper by apache.
the class TestZKLogSegmentMetadataStore method testStoreMaxTxnId.
@Test(timeout = 60000)
public void testStoreMaxTxnId() throws Exception {
Transaction<Object> updateTxn = lsmStore.transaction();
Versioned<Long> value = new Versioned<Long>(999L, new LongVersion(0));
final CompletableFuture<Version> result = new CompletableFuture<Version>();
LogMetadataForWriter metadata = mock(LogMetadataForWriter.class);
when(metadata.getMaxTxIdPath()).thenReturn(rootZkPath);
lsmStore.storeMaxTxnId(updateTxn, metadata, value, new Transaction.OpListener<Version>() {
@Override
public void onCommit(Version r) {
result.complete(r);
}
@Override
public void onAbort(Throwable t) {
result.completeExceptionally(t);
}
});
Utils.ioResult(updateTxn.execute());
assertEquals(1L, ((LongVersion) Utils.ioResult(result)).getLongVersion());
Stat stat = new Stat();
byte[] data = zkc.get().getData(rootZkPath, false, stat);
assertEquals(999L, DLUtils.deserializeTransactionId(data));
assertEquals(1, stat.getVersion());
}
Aggregations