Search in sources :

Example 6 with TransactionManager

use of com.palantir.atlasdb.transaction.api.TransactionManager in project atlasdb by palantir.

the class TransactionManagerTest method shouldConflictIfImmutableTimestampLockExpiresEvenIfNoWritesOnThoroughSweptTable.

@Test
public void shouldConflictIfImmutableTimestampLockExpiresEvenIfNoWritesOnThoroughSweptTable() {
    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())));
    assertThatThrownBy(() -> txnManagerWithMocks.runTaskThrowOnConflict(txn -> {
        get(txn, TEST_TABLE_THOROUGH, "row1", "col1");
        return null;
    })).isInstanceOf(TransactionFailedRetriableException.class);
}
Also used : LockService(com.palantir.lock.LockService) TimelockService(com.palantir.lock.v2.TimelockService) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) Test(org.junit.Test)

Example 7 with TransactionManager

use of com.palantir.atlasdb.transaction.api.TransactionManager in project atlasdb by palantir.

the class TransactionManagersTest method timelockServiceStatusReturnsHealthyWithoutRequest.

@Test
public void timelockServiceStatusReturnsHealthyWithoutRequest() {
    TransactionManager tm = TransactionManagers.createInMemory(GenericTestSchema.getSchema());
    assertTrue(tm.getTimelockServiceStatus().isHealthy());
}
Also used : SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) Test(org.junit.Test)

Example 8 with TransactionManager

use of com.palantir.atlasdb.transaction.api.TransactionManager in project atlasdb by palantir.

the class TransactionManagersTest method timelockServiceStatusReturnsHealthyAfterSuccessfulRequests.

@Test
public void timelockServiceStatusReturnsHealthyAfterSuccessfulRequests() {
    TransactionManager tm = TransactionManagers.createInMemory(GenericTestSchema.getSchema());
    tm.getUnreadableTimestamp();
    assertTrue(tm.getTimelockServiceStatus().isHealthy());
}
Also used : SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) Test(org.junit.Test)

Example 9 with TransactionManager

use of com.palantir.atlasdb.transaction.api.TransactionManager in project atlasdb by palantir.

the class KeyValueServiceMigrator method cleanup.

/**
 * On success, delete the checkpoint table.
 */
public void cleanup() {
    TransactionManager txManager = toTransactionManager;
    GeneralTaskCheckpointer checkpointer = new GeneralTaskCheckpointer(checkpointTable, toKvs, txManager);
    processMessage("Deleting checkpoint table...", KvsMigrationMessageLevel.INFO);
    checkpointer.deleteCheckpoints();
    processMessage("Migration complete.", KvsMigrationMessageLevel.INFO);
}
Also used : TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager)

Example 10 with TransactionManager

use of com.palantir.atlasdb.transaction.api.TransactionManager in project atlasdb by palantir.

the class StreamStoreBenchmarks method loadLargeStream.

@Benchmark
@Threads(1)
@Warmup(time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(time = 30, timeUnit = TimeUnit.SECONDS)
public void loadLargeStream(StreamingTable table) throws IOException {
    long id = table.getLargeStreamId();
    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.getLargeStreamFirstBytes(), 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)

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