Search in sources :

Example 11 with TimelockService

use of com.palantir.lock.v2.TimelockService in project atlasdb by palantir.

the class TransactionManagers method withRequestBatchingTimestampService.

private static LockAndTimestampServices withRequestBatchingTimestampService(java.util.function.Supplier<TimestampClientConfig> timestampClientConfigSupplier, LockAndTimestampServices lockAndTimestampServices) {
    TimelockService timelockServiceWithBatching = DecoratedTimelockServices.createTimelockServiceWithTimestampBatching(lockAndTimestampServices.timelock(), timestampClientConfigSupplier);
    TimelockService instrumentedTimelockService = new InstrumentedTimelockService(timelockServiceWithBatching, AtlasDbMetrics.getMetricRegistry());
    return ImmutableLockAndTimestampServices.builder().from(lockAndTimestampServices).timestamp(new TimelockTimestampServiceAdapter(timelockServiceWithBatching)).timelock(instrumentedTimelockService).build();
}
Also used : TimelockTimestampServiceAdapter(com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter) LegacyTimelockService(com.palantir.lock.impl.LegacyTimelockService) TimelockService(com.palantir.lock.v2.TimelockService) InstrumentedTimelockService(com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService) InstrumentedTimelockService(com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService)

Example 12 with TimelockService

use of com.palantir.lock.v2.TimelockService in project atlasdb by palantir.

the class TransactionManagers method getLockAndTimestampServices.

private static LockAndTimestampServices getLockAndTimestampServices(Supplier<ServerListConfig> timelockServerListConfig, String userAgent) {
    LockService lockService = new ServiceCreator<>(LockService.class, userAgent).applyDynamic(timelockServerListConfig);
    TimelockService timelockService = new ServiceCreator<>(TimelockService.class, userAgent).applyDynamic(timelockServerListConfig);
    return ImmutableLockAndTimestampServices.builder().lock(lockService).timestamp(new TimelockTimestampServiceAdapter(timelockService)).timelock(timelockService).build();
}
Also used : TimelockTimestampServiceAdapter(com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter) NoOpPersistentLockService(com.palantir.atlasdb.persistentlock.NoOpPersistentLockService) KvsBackedPersistentLockService(com.palantir.atlasdb.persistentlock.KvsBackedPersistentLockService) LockService(com.palantir.lock.LockService) LockRefreshingLockService(com.palantir.lock.client.LockRefreshingLockService) PersistentLockService(com.palantir.atlasdb.persistentlock.PersistentLockService) LegacyTimelockService(com.palantir.lock.impl.LegacyTimelockService) TimelockService(com.palantir.lock.v2.TimelockService) InstrumentedTimelockService(com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService)

Example 13 with TimelockService

use of com.palantir.lock.v2.TimelockService 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)

Example 14 with TimelockService

use of com.palantir.lock.v2.TimelockService in project atlasdb by palantir.

the class LegacyTimeLockServicesCreator method createTimeLockServices.

@Override
public TimeLockServices createTimeLockServices(String client, Supplier<ManagedTimestampService> rawTimestampServiceSupplier, Supplier<LockService> rawLockServiceSupplier) {
    log.info("Creating legacy timelock service for client {}", client);
    ManagedTimestampService timestampService = instrumentInLeadershipProxy(ManagedTimestampService.class, rawTimestampServiceSupplier, client);
    LockService lockService = instrumentInLeadershipProxy(LockService.class, rawLockServiceSupplier, client);
    // The underlying primitives are already wrapped in a leadership proxy (and must be).
    // Wrapping this means that we will make 2 paxos checks per request, which is silly.
    TimelockService legacyTimelockService = instrument(TimelockService.class, createRawLegacyTimelockService(timestampService, lockService), client);
    return TimeLockServices.create(timestampService, lockService, AsyncOrLegacyTimelockService.createFromLegacyTimelock(legacyTimelockService), timestampService);
}
Also used : LockService(com.palantir.lock.LockService) LegacyTimelockService(com.palantir.lock.impl.LegacyTimelockService) TimelockService(com.palantir.lock.v2.TimelockService) AsyncOrLegacyTimelockService(com.palantir.atlasdb.timelock.util.AsyncOrLegacyTimelockService) ManagedTimestampService(com.palantir.atlasdb.timelock.paxos.ManagedTimestampService)

Example 15 with TimelockService

use of com.palantir.lock.v2.TimelockService in project atlasdb by palantir.

the class PaxosTimeLockServerIntegrationTest method asyncLockServiceShouldAllowUsToTakeOutLocks.

@Test
public void asyncLockServiceShouldAllowUsToTakeOutLocks() throws InterruptedException {
    TimelockService timelockService = getTimelockService(CLIENT_1);
    LockToken token = timelockService.lock(newLockV2Request(LOCK_1)).getToken();
    assertThat(timelockService.unlock(ImmutableSet.of(token))).contains(token);
}
Also used : TimelockService(com.palantir.lock.v2.TimelockService) LockToken(com.palantir.lock.v2.LockToken) Test(org.junit.Test)

Aggregations

TimelockService (com.palantir.lock.v2.TimelockService)15 Test (org.junit.Test)11 InstrumentedTimelockService (com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService)7 LockService (com.palantir.lock.LockService)5 LockToken (com.palantir.lock.v2.LockToken)4 TransactionManager (com.palantir.atlasdb.transaction.api.TransactionManager)3 LegacyTimelockService (com.palantir.lock.impl.LegacyTimelockService)3 TimelockTimestampServiceAdapter (com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter)2 KvsBackedPersistentLockService (com.palantir.atlasdb.persistentlock.KvsBackedPersistentLockService)1 NoOpPersistentLockService (com.palantir.atlasdb.persistentlock.NoOpPersistentLockService)1 PersistentLockService (com.palantir.atlasdb.persistentlock.PersistentLockService)1 ManagedTimestampService (com.palantir.atlasdb.timelock.paxos.ManagedTimestampService)1 AsyncOrLegacyTimelockService (com.palantir.atlasdb.timelock.util.AsyncOrLegacyTimelockService)1 LockRefreshingLockService (com.palantir.lock.client.LockRefreshingLockService)1