Search in sources :

Example 1 with ImmutableStartTransactionResponseV4

use of com.palantir.lock.v2.ImmutableStartTransactionResponseV4 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);
}
Also used : LockResponseV2(com.palantir.lock.v2.LockResponseV2) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) StartIdentifiedAtlasDbTransactionRequest(com.palantir.lock.v2.StartIdentifiedAtlasDbTransactionRequest) StartAtlasDbTransactionResponseV3(com.palantir.lock.v2.StartAtlasDbTransactionResponseV3) StartTransactionRequestV4(com.palantir.lock.v2.StartTransactionRequestV4) Path(javax.ws.rs.Path) LockImmutableTimestampResponse(com.palantir.lock.v2.LockImmutableTimestampResponse) StartTransactionResponseV4(com.palantir.lock.v2.StartTransactionResponseV4) ConjureStartTransactionsRequest(com.palantir.atlasdb.timelock.api.ConjureStartTransactionsRequest) MediaType(javax.ws.rs.core.MediaType) QueryParam(javax.ws.rs.QueryParam) PTExecutors(com.palantir.common.concurrent.PTExecutors) Consumes(javax.ws.rs.Consumes) IdentifiedLockRequest(com.palantir.lock.client.IdentifiedLockRequest) RefreshLockResponseV2(com.palantir.lock.v2.RefreshLockResponseV2) ExecutorService(java.util.concurrent.ExecutorService) LockResponse(com.palantir.lock.v2.LockResponse) StartAtlasDbTransactionResponse(com.palantir.lock.v2.StartAtlasDbTransactionResponse) POST(javax.ws.rs.POST) LockToken(com.palantir.lock.v2.LockToken) AsyncResponse(javax.ws.rs.container.AsyncResponse) LockDiagnosticInfo(com.palantir.atlasdb.debug.LockDiagnosticInfo) Set(java.util.Set) UUID(java.util.UUID) Suspended(javax.ws.rs.container.Suspended) FutureCallback(com.google.common.util.concurrent.FutureCallback) ImmutableStartTransactionResponseV4(com.palantir.lock.v2.ImmutableStartTransactionResponseV4) Futures(com.google.common.util.concurrent.Futures) Safe(com.palantir.logsafe.Safe) LockLog(com.palantir.atlasdb.timelock.lock.LockLog) TimestampRange(com.palantir.timestamp.TimestampRange) StartIdentifiedAtlasDbTransactionResponse(com.palantir.lock.v2.StartIdentifiedAtlasDbTransactionResponse) Optional(java.util.Optional) IdentifiedTimeLockRequest(com.palantir.lock.v2.IdentifiedTimeLockRequest) WaitForLocksRequest(com.palantir.lock.v2.WaitForLocksRequest) ConjureStartTransactionsRequest(com.palantir.atlasdb.timelock.api.ConjureStartTransactionsRequest) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 LockDiagnosticInfo (com.palantir.atlasdb.debug.LockDiagnosticInfo)1 ConjureStartTransactionsRequest (com.palantir.atlasdb.timelock.api.ConjureStartTransactionsRequest)1 LockLog (com.palantir.atlasdb.timelock.lock.LockLog)1 PTExecutors (com.palantir.common.concurrent.PTExecutors)1 IdentifiedLockRequest (com.palantir.lock.client.IdentifiedLockRequest)1 IdentifiedTimeLockRequest (com.palantir.lock.v2.IdentifiedTimeLockRequest)1 ImmutableStartTransactionResponseV4 (com.palantir.lock.v2.ImmutableStartTransactionResponseV4)1 LockImmutableTimestampResponse (com.palantir.lock.v2.LockImmutableTimestampResponse)1 LockResponse (com.palantir.lock.v2.LockResponse)1 LockResponseV2 (com.palantir.lock.v2.LockResponseV2)1 LockToken (com.palantir.lock.v2.LockToken)1 RefreshLockResponseV2 (com.palantir.lock.v2.RefreshLockResponseV2)1 StartAtlasDbTransactionResponse (com.palantir.lock.v2.StartAtlasDbTransactionResponse)1 StartAtlasDbTransactionResponseV3 (com.palantir.lock.v2.StartAtlasDbTransactionResponseV3)1 StartIdentifiedAtlasDbTransactionRequest (com.palantir.lock.v2.StartIdentifiedAtlasDbTransactionRequest)1 StartIdentifiedAtlasDbTransactionResponse (com.palantir.lock.v2.StartIdentifiedAtlasDbTransactionResponse)1