Search in sources :

Example 21 with LockService

use of com.palantir.lock.LockService in project atlasdb by palantir.

the class PaxosTimeLockServerIntegrationTest method lockServiceShouldAllowUsToTakeOutSameLockInDifferentNamespaces.

@Test
public void lockServiceShouldAllowUsToTakeOutSameLockInDifferentNamespaces() throws InterruptedException {
    LockService lockService1 = getLockService(CLIENT_1);
    LockService lockService2 = getLockService(CLIENT_2);
    LockRefreshToken token1 = lockService1.lock(LOCK_CLIENT_NAME, com.palantir.lock.LockRequest.builder(LOCK_MAP).doNotBlock().build());
    LockRefreshToken token2 = lockService2.lock(LOCK_CLIENT_NAME, com.palantir.lock.LockRequest.builder(LOCK_MAP).doNotBlock().build());
    assertThat(token1).isNotNull();
    assertThat(token2).isNotNull();
    lockService1.unlock(token1);
    lockService2.unlock(token2);
}
Also used : LockService(com.palantir.lock.LockService) LockRefreshToken(com.palantir.lock.LockRefreshToken) Test(org.junit.Test)

Example 22 with LockService

use of com.palantir.lock.LockService in project atlasdb by palantir.

the class PaxosTimeLockServerIntegrationTest method lockServiceShouldDisallowGettingMinLockedInVersionId.

@Test
public void lockServiceShouldDisallowGettingMinLockedInVersionId() {
    LockService lockService = getLockService(CLIENT_1);
    assertThatThrownBy(() -> lockService.getMinLockedInVersionId(CLIENT_1)).isInstanceOf(AtlasDbRemoteException.class).satisfies(remoteException -> {
        AtlasDbRemoteException atlasDbRemoteException = (AtlasDbRemoteException) remoteException;
        assertThat(atlasDbRemoteException.getErrorName()).isEqualTo(BadRequestException.class.getCanonicalName());
        assertThat(atlasDbRemoteException.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400);
    });
}
Also used : LockService(com.palantir.lock.LockService) BadRequestException(javax.ws.rs.BadRequestException) AtlasDbRemoteException(com.palantir.atlasdb.http.errors.AtlasDbRemoteException) Test(org.junit.Test)

Aggregations

LockService (com.palantir.lock.LockService)22 Test (org.junit.Test)11 LockRefreshToken (com.palantir.lock.LockRefreshToken)7 LegacyTimelockService (com.palantir.lock.impl.LegacyTimelockService)7 TimestampService (com.palantir.timestamp.TimestampService)6 KvsBackedPersistentLockService (com.palantir.atlasdb.persistentlock.KvsBackedPersistentLockService)5 NoOpPersistentLockService (com.palantir.atlasdb.persistentlock.NoOpPersistentLockService)5 PersistentLockService (com.palantir.atlasdb.persistentlock.PersistentLockService)5 LockRefreshingLockService (com.palantir.lock.client.LockRefreshingLockService)5 TimelockService (com.palantir.lock.v2.TimelockService)5 LockClient (com.palantir.lock.LockClient)4 LockRequest (com.palantir.lock.LockRequest)4 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)3 TransactionManager (com.palantir.atlasdb.transaction.api.TransactionManager)3 Cleaner (com.palantir.atlasdb.cleaner.Cleaner)2 NoOpCleaner (com.palantir.atlasdb.cleaner.NoOpCleaner)2 Cell (com.palantir.atlasdb.keyvalue.api.Cell)2 ForwardingKeyValueService (com.palantir.atlasdb.keyvalue.impl.ForwardingKeyValueService)2 TrackingKeyValueService (com.palantir.atlasdb.keyvalue.impl.TrackingKeyValueService)2 ManagedTimestampService (com.palantir.atlasdb.timelock.paxos.ManagedTimestampService)2