use of com.palantir.atlasdb.transaction.api.TransactionManager in project atlasdb by palantir.
the class StreamStoreBenchmarks method loadSmallStream.
@Benchmark
@Threads(1)
@Warmup(time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(time = 5, timeUnit = TimeUnit.SECONDS)
public void loadSmallStream(StreamingTable table) throws IOException {
long id = table.getSmallStreamId();
TransactionManager transactionManager = table.getTransactionManager();
StreamTestTableFactory tables = StreamTestTableFactory.of();
ValueStreamStore store = ValueStreamStore.of(transactionManager, tables);
try (InputStream inputStream = transactionManager.runTaskThrowOnConflict(txn -> store.loadStream(txn, id));
InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
BufferedReader bufferedReader = new BufferedReader(reader)) {
String line = bufferedReader.readLine();
assertThat(line, startsWith("bytes"));
}
}
use of com.palantir.atlasdb.transaction.api.TransactionManager in project atlasdb by palantir.
the class StreamStoreBenchmarks method loadVeryLargeStream.
@Benchmark
@Threads(1)
@Warmup(time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(time = 30, timeUnit = TimeUnit.SECONDS)
public void loadVeryLargeStream(StreamingTable table) throws IOException {
long id = table.getVeryLargeStreamId();
TransactionManager transactionManager = table.getTransactionManager();
StreamTestTableFactory tables = StreamTestTableFactory.of();
ValueStreamStore store = ValueStreamStore.of(transactionManager, tables);
try (InputStream inputStream = transactionManager.runTaskThrowOnConflict(txn -> store.loadStream(txn, id))) {
byte[] firstBytes = new byte[16];
int read = inputStream.read(firstBytes);
assertThat(read, is(16));
assertArrayEquals(table.getVeryLargeStreamFirstBytes(), firstBytes);
}
}
use of com.palantir.atlasdb.transaction.api.TransactionManager in project atlasdb by palantir.
the class TransactionManagerTest method shouldNotConflictIfImmutableTimestampLockExpiresEvenIfNoWritesOnNonThoroughSweptTable.
@Test
public void shouldNotConflictIfImmutableTimestampLockExpiresEvenIfNoWritesOnNonThoroughSweptTable() {
TimelockService timelock = mock(TimelockService.class);
LockService mockLockService = mock(LockService.class);
TransactionManager txnManagerWithMocks = new SerializableTransactionManager(keyValueService, timelock, mockLockService, transactionService, () -> AtlasDbConstraintCheckingMode.FULL_CONSTRAINT_CHECKING_THROWS_EXCEPTIONS, conflictDetectionManager, sweepStrategyManager, NoOpCleaner.INSTANCE, TimestampTrackerImpl.createNoOpTracker(), () -> AtlasDbConstants.DEFAULT_TIMESTAMP_CACHE_SIZE, false, () -> AtlasDbConstants.DEFAULT_TRANSACTION_LOCK_ACQUIRE_TIMEOUT_MS, AbstractTransactionTest.GET_RANGES_THREAD_POOL_SIZE, AbstractTransactionTest.DEFAULT_GET_RANGES_CONCURRENCY, MultiTableSweepQueueWriter.NO_OP);
when(timelock.getFreshTimestamp()).thenReturn(1L);
when(timelock.lockImmutableTimestamp(any())).thenReturn(LockImmutableTimestampResponse.of(2L, LockToken.of(UUID.randomUUID())));
txnManagerWithMocks.runTaskThrowOnConflict(txn -> {
get(txn, TEST_TABLE, "row1", "col1");
return null;
});
}
Aggregations