use of com.palantir.lock.v2.TimelockService in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method canCreateNewClientsDynamically.
@Test
public void canCreateNewClientsDynamically() {
for (int i = 0; i < 5; i++) {
String client = UUID.randomUUID().toString();
TimelockService timelock = CLUSTER.timelockServiceForClient(client);
timelock.getFreshTimestamp();
LockToken token = timelock.lock(LockRequest.of(LOCKS, DEFAULT_LOCK_TIMEOUT_MS)).getToken();
CLUSTER.unlock(token);
}
}
use of com.palantir.lock.v2.TimelockService in project atlasdb by palantir.
the class PaxosTimeLockServerIntegrationTest method asyncLockServiceShouldNotAllowUsToRefreshLocksFromDifferentNamespaces.
@Test
public void asyncLockServiceShouldNotAllowUsToRefreshLocksFromDifferentNamespaces() throws InterruptedException {
TimelockService lockService1 = getTimelockService(CLIENT_1);
TimelockService lockService2 = getTimelockService(CLIENT_2);
LockToken token = lockService1.lock(newLockV2Request(LOCK_1)).getToken();
assertThat(lockService1.refreshLockLeases(ImmutableSet.of(token))).isNotEmpty();
assertThat(lockService2.refreshLockLeases(ImmutableSet.of(token))).isEmpty();
lockService1.unlock(ImmutableSet.of(token));
}
use of com.palantir.lock.v2.TimelockService in project atlasdb by palantir.
the class PaxosTimeLockServerIntegrationTest method asyncLockServiceShouldAllowUsToTakeOutSameLockInDifferentNamespaces.
@Test
public void asyncLockServiceShouldAllowUsToTakeOutSameLockInDifferentNamespaces() throws InterruptedException {
TimelockService lockService1 = getTimelockService(CLIENT_1);
TimelockService lockService2 = getTimelockService(CLIENT_2);
LockToken token1 = lockService1.lock(newLockV2Request(LOCK_1)).getToken();
LockToken token2 = lockService2.lock(newLockV2Request(LOCK_1)).getToken();
lockService1.unlock(ImmutableSet.of(token1));
lockService2.unlock(ImmutableSet.of(token2));
}
use of com.palantir.lock.v2.TimelockService in project atlasdb by palantir.
the class TransactionManagerTest method shouldNotConflictIfImmutableTimestampLockExpiresIfNoReadsOrWrites.
@Test
public void shouldNotConflictIfImmutableTimestampLockExpiresIfNoReadsOrWrites() {
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 -> null);
}
use of com.palantir.lock.v2.TimelockService 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);
}
Aggregations