Search in sources :

Example 1 with IdentifiedLockRequest

use of com.palantir.lock.client.IdentifiedLockRequest in project atlasdb by palantir.

the class ConjureTimelockResource method lock.

@Override
public ListenableFuture<ConjureLockResponse> lock(AuthHeader authHeader, String namespace, ConjureLockRequest request) {
    return handleExceptions(() -> {
        IdentifiedLockRequest lockRequest = ImmutableIdentifiedLockRequest.builder().lockDescriptors(fromConjureLockDescriptors(request.getLockDescriptors())).clientDescription(request.getClientDescription()).requestId(request.getRequestId()).acquireTimeoutMs(request.getAcquireTimeoutMs()).build();
        ListenableFuture<LockResponseV2> tokenFuture = forNamespace(namespace).lock(lockRequest);
        return Futures.transform(tokenFuture, token -> token.accept(Visitor.of(success -> ConjureLockResponse.successful(SuccessfulLockResponse.of(ConjureLockToken.of(success.getToken().getRequestId()), success.getLease())), failure -> ConjureLockResponse.unsuccessful(UnsuccessfulLockResponse.of()))), MoreExecutors.directExecutor());
    });
}
Also used : IdentifiedLockRequest(com.palantir.lock.client.IdentifiedLockRequest) ImmutableIdentifiedLockRequest(com.palantir.lock.client.ImmutableIdentifiedLockRequest) LockResponseV2(com.palantir.lock.v2.LockResponseV2)

Aggregations

IdentifiedLockRequest (com.palantir.lock.client.IdentifiedLockRequest)1 ImmutableIdentifiedLockRequest (com.palantir.lock.client.ImmutableIdentifiedLockRequest)1 LockResponseV2 (com.palantir.lock.v2.LockResponseV2)1