use of com.palantir.atlasdb.timelock.api.ConjureStartTransactionsResponse in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method assertSanityAndStartTransactions.
private Map<Namespace, ConjureStartTransactionsResponse> assertSanityAndStartTransactions(TestableTimelockServer leader, List<String> expectedNamespaces) {
MultiClientConjureTimelockService multiClientConjureTimelockService = leader.multiClientService();
int numTransactions = 5;
Map<Namespace, ConjureStartTransactionsRequest> namespaceToRequestMap = defaultStartTransactionsRequests(expectedNamespaces, numTransactions);
Map<Namespace, ConjureStartTransactionsResponse> startedTransactions = multiClientConjureTimelockService.startTransactionsForClients(AUTH_HEADER, namespaceToRequestMap);
Set<String> namespaces = startedTransactions.keySet().stream().map(Namespace::get).collect(Collectors.toSet());
assertThat(namespaces).hasSameElementsAs(expectedNamespaces);
assertThat(startedTransactions.values().stream().map(ConjureStartTransactionsResponse::getTimestamps).mapToLong(partitionedTimestamps -> partitionedTimestamps.stream().count()).sum()).isEqualTo(namespaces.size() * numTransactions);
return startedTransactions;
}
use of com.palantir.atlasdb.timelock.api.ConjureStartTransactionsResponse in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method startTransactionHandlesInvalidatesCorrectly.
@Test
public void startTransactionHandlesInvalidatesCorrectly() {
ConjureStartTransactionsResponse responseBeforeInvalidation = client.namespacedConjureTimelockService().startTransactions(ConjureStartTransactionsRequest.builder().numTransactions(10).requestId(UUID.randomUUID()).requestorId(UUID.randomUUID()).build());
invalidateMainClientResources();
ConjureStartTransactionsResponse responseAfterInvalidation = client.namespacedConjureTimelockService().startTransactions(ConjureStartTransactionsRequest.builder().numTransactions(10).requestId(UUID.randomUUID()).requestorId(UUID.randomUUID()).build());
assertThat(responseBeforeInvalidation.getTimestamps().stream().max().orElseThrow()).as("timestamps must strictly increase").isLessThan(responseAfterInvalidation.getTimestamps().stream().min().orElseThrow());
assertThat(responseBeforeInvalidation.getLockWatchUpdate().logId()).as("lock watch log IDs must change following an invalidation").isNotEqualTo(responseAfterInvalidation.getLockWatchUpdate().logId());
}
use of com.palantir.atlasdb.timelock.api.ConjureStartTransactionsResponse in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method multiClientStartTransactionsReturnsCorrectStartTimestamps.
@Test
public void multiClientStartTransactionsReturnsCorrectStartTimestamps() {
TestableTimelockServer leader = cluster.currentLeaderFor(client.namespace());
// Multi client batched TimeLock endpoints do not support multi-leader mode on TimeLock
Assume.assumeFalse(leader.isMultiLeader());
Namespace delta = Namespace.of("delta");
Namespace gamma = Namespace.of("gamma");
NamespacedClients deltaClient = leader.client(delta.get()).throughWireMockProxy();
NamespacedClients gammaClient = leader.client(gamma.get()).throughWireMockProxy();
List<String> expectedNamespaces = ImmutableList.of(delta.get(), gamma.get());
int deltaFastForwardedTimestamp = 155_200_000;
int gammaFastForwardedTimestamp = 988_000_000;
deltaClient.timestampManagementService().fastForwardTimestamp(deltaFastForwardedTimestamp);
gammaClient.timestampManagementService().fastForwardTimestamp(gammaFastForwardedTimestamp);
Map<Namespace, ConjureStartTransactionsResponse> startedTransactions = assertSanityAndStartTransactions(leader, expectedNamespaces);
assertThat(startedTransactions.get(delta).getTimestamps().start()).isGreaterThanOrEqualTo(deltaFastForwardedTimestamp).isLessThan(gammaFastForwardedTimestamp);
assertThat(startedTransactions.get(gamma).getTimestamps().start()).isGreaterThanOrEqualTo(gammaFastForwardedTimestamp);
}
use of com.palantir.atlasdb.timelock.api.ConjureStartTransactionsResponse in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method sanityCheckMultiClientStartTransactionsAgainstConjureTimelockService.
@Test
public void sanityCheckMultiClientStartTransactionsAgainstConjureTimelockService() {
TestableTimelockServer leader = cluster.currentLeaderFor(client.namespace());
// Multi client batched TimeLock endpoints do not support multi-leader mode on TimeLock
Assume.assumeFalse(leader.isMultiLeader());
MultiClientConjureTimelockService multiClientConjureTimelockService = leader.multiClientService();
List<String> expectedNamespaces = ImmutableList.of("alpha", "beta");
int numTransactions = 7;
Map<Namespace, ConjureStartTransactionsRequest> namespaceToRequestMap = defaultStartTransactionsRequests(expectedNamespaces, numTransactions);
Map<Namespace, ConjureStartTransactionsResponse> startedTransactions = multiClientConjureTimelockService.startTransactionsForClients(AUTH_HEADER, namespaceToRequestMap);
// Whether we hit the multi client endpoint or conjureTimelockService endpoint, for a namespace, the underlying
// service to process the request is the same
startedTransactions.forEach((namespace, responseFromBatchedEndpoint) -> {
ConjureStartTransactionsResponse responseFromLegacyEndpoint = leader.client(namespace.get()).namespacedConjureTimelockService().startTransactions(namespaceToRequestMap.get(namespace));
assertThat(responseFromLegacyEndpoint.getLockWatchUpdate().logId()).isEqualTo(responseFromBatchedEndpoint.getLockWatchUpdate().logId());
PartitionedTimestamps batchedEndpointTimestamps = responseFromBatchedEndpoint.getTimestamps();
long lastTimestamp = batchedEndpointTimestamps.stream().max().orElseThrow(SafeIllegalStateException::new);
assertThat(responseFromLegacyEndpoint.getTimestamps().start()).isGreaterThan(lastTimestamp);
});
}
Aggregations