use of com.palantir.lock.v2.LockResponseV2 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());
});
}
Aggregations