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();
}
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();
}
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;
});
}
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);
}
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);
}
Aggregations