use of com.palantir.lock.v2.StartTransactionRequestV4 in project atlasdb by palantir.
the class AsyncTimelockResource method startTransactions.
/**
* Returns a {@link StartTransactionResponseV4} which has a single immutable ts, and a range of timestamps to
* be used as start timestamps.
*
* It is guaranteed to have at least one usable timestamp matching the partition criteria in the returned timestamp
* range, but there is no other guarantee given. (It can be less than number of requested timestamps)
*/
@POST
@Path("start-atlasdb-transaction-v4")
public void startTransactions(@Suspended final AsyncResponse response, StartTransactionRequestV4 request) {
ConjureStartTransactionsRequest conjureRequest = ConjureStartTransactionsRequest.builder().requestId(request.requestId()).requestorId(request.requestorId()).numTransactions(request.numTransactions()).build();
addJerseyCallback(Futures.transform(timelock.startTransactionsWithWatches(conjureRequest), newResponse -> ImmutableStartTransactionResponseV4.builder().timestamps(newResponse.getTimestamps()).immutableTimestamp(newResponse.getImmutableTimestamp()).lease(newResponse.getLease()).build(), MoreExecutors.directExecutor()), response);
}
use of com.palantir.lock.v2.StartTransactionRequestV4 in project atlasdb by palantir.
the class AsyncTimelockServiceImpl method startTransactions.
@Override
public StartTransactionResponseV4 startTransactions(StartTransactionRequestV4 request) {
Leased<LockImmutableTimestampResponse> leasedLockImmutableTimestampResponse = lockImmutableTimestampWithLease(request.requestId());
PartitionedTimestamps partitionedTimestamps = timestampService.getFreshTimestampsForClient(request.requestorId(), request.numTransactions());
return StartTransactionResponseV4.of(leasedLockImmutableTimestampResponse.value(), partitionedTimestamps, leasedLockImmutableTimestampResponse.lease());
}
Aggregations