use of com.palantir.atlasdb.timelock.api.ConjureStartTransactionsResponse in project atlasdb by palantir.
the class TimestampCorroboratingTimelockServiceTest method startTransactionsBoundIncreasesWithLargeInterval.
@Test
public void startTransactionsBoundIncreasesWithLargeInterval() {
ConjureStartTransactionsResponse response = ConjureStartTransactionsResponse.builder().immutableTimestamp(LOCK_IMMUTABLE_TIMESTAMP_RESPONSE).lease(Lease.of(LeaderTime.of(LeadershipId.random(), NanoTime.now()), Duration.ZERO)).lockWatchUpdate(LOCK_WATCH_UPDATE).timestamps(ImmutablePartitionedTimestamps.builder().start(5L).count(100).interval(12).build()).build();
when(rawTimelockService.startTransactions(startTransactionsRequest)).thenReturn(response);
timelockService.startTransactions(startTransactionsRequest);
assertThat(timelockService.getTimestampBounds().boundFromTransactions().lowerBoundForNextRequest()).isEqualTo(5 + (99 * 12));
assertThat(timelockService.getTimestampBounds().boundFromTransactions().operationType()).isEqualTo(OperationType.TRANSACTION);
verifyNoInteractions(callback);
}
use of com.palantir.atlasdb.timelock.api.ConjureStartTransactionsResponse in project atlasdb by palantir.
the class TransactionStarterTest method shouldDeriveStartTransactionResponseFromBatchedResponse_singleTransaction.
@Test
public void shouldDeriveStartTransactionResponseFromBatchedResponse_singleTransaction() {
ConjureStartTransactionsResponse startTransactionResponse = StartTransactionsTestUtils.getStartTransactionResponse(12, 1);
when(lockLeaseService.startTransactionsWithWatches(version, 1)).thenReturn(startTransactionResponse);
StartIdentifiedAtlasDbTransactionResponse response = Iterables.getOnlyElement(transactionStarter.startIdentifiedAtlasDbTransactionBatch(1));
assertDerivableFromBatchedResponse(response, startTransactionResponse);
}
use of com.palantir.atlasdb.timelock.api.ConjureStartTransactionsResponse in project atlasdb by palantir.
the class BatchingIdentifiedAtlasDbTransactionStarter method getStartTransactionResponses.
private static List<StartIdentifiedAtlasDbTransactionResponse> getStartTransactionResponses(LockLeaseService lockLeaseService, LockWatchCache cache, int numberOfTransactions) {
List<StartIdentifiedAtlasDbTransactionResponse> result = new ArrayList<>();
while (result.size() < numberOfTransactions) {
try {
Optional<LockWatchVersion> requestedVersion = cache.getEventCache().lastKnownVersion();
ConjureStartTransactionsResponse response = lockLeaseService.startTransactionsWithWatches(requestedVersion, numberOfTransactions - result.size());
TransactionStarterHelper.updateCacheWithStartTransactionResponse(cache, response);
result.addAll(TransactionStarterHelper.split(response));
} catch (Throwable t) {
TransactionStarterHelper.cleanUpCaches(cache, result);
TransactionStarterHelper.unlock(result.stream().map(response -> response.immutableTimestamp().getLock()).collect(Collectors.toSet()), lockLeaseService);
throw Throwables.throwUncheckedException(t);
}
}
return result;
}
use of com.palantir.atlasdb.timelock.api.ConjureStartTransactionsResponse in project atlasdb by palantir.
the class MultiClientTransactionStarter method getProcessedStartTransactionResponses.
private static Map<Namespace, List<StartIdentifiedAtlasDbTransactionResponse>> getProcessedStartTransactionResponses(Map<Namespace, RequestParams> originalRequestMap, InternalMultiClientConjureTimelockService delegate, UUID requestorId) {
Map<Namespace, ConjureStartTransactionsRequest> requests = getConjureRequests(originalRequestMap, requestorId);
Map<Namespace, ConjureStartTransactionsResponse> responseMap = getResponseMap(delegate, requests);
Map<Namespace, List<StartIdentifiedAtlasDbTransactionResponse>> processedResult = new HashMap<>();
for (Map.Entry<Namespace, ConjureStartTransactionsResponse> entry : responseMap.entrySet()) {
Namespace namespace = entry.getKey();
ConjureStartTransactionsResponse response = entry.getValue();
TransactionStarterHelper.updateCacheWithStartTransactionResponse(originalRequestMap.get(namespace).cache(), response);
processedResult.put(namespace, TransactionStarterHelper.split(response));
}
return processedResult;
}
use of com.palantir.atlasdb.timelock.api.ConjureStartTransactionsResponse in project atlasdb by palantir.
the class LockDiagnosticConjureTimelockService method startTransactions.
@Override
public ConjureStartTransactionsResponse startTransactions(AuthHeader authHeader, String namespace, ConjureStartTransactionsRequest request) {
ConjureStartTransactionsResponse response = conjureDelegate.startTransactions(authHeader, namespace, request);
lockDiagnosticCollector.collect(response.getTimestamps().stream(), response.getImmutableTimestamp().getImmutableTimestamp(), request.getRequestId());
return response;
}
Aggregations