use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method sanityCheckMultiClientGetCommitTimestamps.
@Test
public void sanityCheckMultiClientGetCommitTimestamps() {
TestableTimelockServer leader = cluster.currentLeaderFor(client.namespace());
// Multi client batched TimeLock endpoints do not support multi-leader mode on TimeLock
Assume.assumeFalse(leader.isMultiLeader());
MultiClientConjureTimelockService service = leader.multiClientService();
Set<String> expectedNamespaces = ImmutableSet.of("cli-1", "cli-2");
Map<Namespace, GetCommitTimestampsResponse> multiClientResponses = service.getCommitTimestampsForClients(AUTH_HEADER, defaultGetCommitTimestampsRequests(expectedNamespaces));
assertSanityOfNamespacesServed(expectedNamespaces, multiClientResponses);
Set<UUID> leadershipIds = multiClientResponses.values().stream().map(GetCommitTimestampsResponse::getLockWatchUpdate).map(LockWatchStateUpdate::logId).collect(Collectors.toSet());
assertThat(leadershipIds).hasSameSizeAs(expectedNamespaces);
}
use of com.palantir.atlasdb.timelock.api.Namespace 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.Namespace 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