Search in sources :

Example 11 with TransactionManager

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"));
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) StreamTestTableFactory(com.palantir.atlasdb.performance.schema.generated.StreamTestTableFactory) ValueStreamStore(com.palantir.atlasdb.performance.schema.generated.ValueStreamStore) Threads(org.openjdk.jmh.annotations.Threads) Measurement(org.openjdk.jmh.annotations.Measurement) Warmup(org.openjdk.jmh.annotations.Warmup) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 12 with TransactionManager

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);
    }
}
Also used : TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) InputStream(java.io.InputStream) StreamTestTableFactory(com.palantir.atlasdb.performance.schema.generated.StreamTestTableFactory) ValueStreamStore(com.palantir.atlasdb.performance.schema.generated.ValueStreamStore) Threads(org.openjdk.jmh.annotations.Threads) Measurement(org.openjdk.jmh.annotations.Measurement) Warmup(org.openjdk.jmh.annotations.Warmup) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 13 with TransactionManager

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;
    });
}
Also used : LockService(com.palantir.lock.LockService) TimelockService(com.palantir.lock.v2.TimelockService) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) Test(org.junit.Test)

Aggregations

TransactionManager (com.palantir.atlasdb.transaction.api.TransactionManager)13 Test (org.junit.Test)6 LockService (com.palantir.lock.LockService)4 StreamTestTableFactory (com.palantir.atlasdb.performance.schema.generated.StreamTestTableFactory)3 ValueStreamStore (com.palantir.atlasdb.performance.schema.generated.ValueStreamStore)3 TimelockService (com.palantir.lock.v2.TimelockService)3 InputStream (java.io.InputStream)3 Benchmark (org.openjdk.jmh.annotations.Benchmark)3 Measurement (org.openjdk.jmh.annotations.Measurement)3 Threads (org.openjdk.jmh.annotations.Threads)3 Warmup (org.openjdk.jmh.annotations.Warmup)3 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)2 SerializableTransactionManager (com.palantir.atlasdb.transaction.impl.SerializableTransactionManager)2 ExecutorService (java.util.concurrent.ExecutorService)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Supplier (com.google.common.base.Supplier)1 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 HashMultimap (com.google.common.collect.HashMultimap)1 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)1 Builder (com.google.common.collect.ImmutableMultimap.Builder)1