use of com.palantir.atlasdb.timelock.api.LeaderTimes in project atlasdb by palantir.
the class MultiClientConjureTimelockResourceTest method canGetLeaderTimesForMultipleClients.
@Test
public void canGetLeaderTimesForMultipleClients() {
Namespace client1 = Namespace.of("client1");
Namespace client2 = Namespace.of("client2");
Set<Namespace> namespaces = ImmutableSet.of(client1, client2);
LeaderTimes leaderTimesResponse = Futures.getUnchecked(resource.leaderTimes(AUTH_HEADER, namespaces));
Map<Namespace, LeaderTime> leaderTimes = leaderTimesResponse.getLeaderTimes();
// leaderTimes for namespaces are computed by their respective underlying AsyncTimelockService instances
leaderTimes.forEach((namespace, leaderTime) -> {
assertThat(leaderTime.id()).isEqualTo(namespaceToLeaderMap.get(namespace.get()));
});
// there should be as many leaders as there are distinct clients
Set<UUID> leaders = leaderTimes.values().stream().map(LeaderTime::id).map(LeadershipId::id).collect(Collectors.toSet());
assertThat(leaders).hasSameSizeAs(namespaces);
}
use of com.palantir.atlasdb.timelock.api.LeaderTimes in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method assertSanityAndGetLeaderTimes.
private LeaderTimes assertSanityAndGetLeaderTimes(TestableTimelockServer leader, Set<Namespace> expectedNamespaces) {
MultiClientConjureTimelockService multiClientConjureTimelockService = leader.multiClientService();
LeaderTimes leaderTimes = multiClientConjureTimelockService.leaderTimes(AUTH_HEADER, expectedNamespaces);
Set<Namespace> namespaces = leaderTimes.getLeaderTimes().keySet();
assertThat(namespaces).hasSameElementsAs(expectedNamespaces);
return leaderTimes;
}
use of com.palantir.atlasdb.timelock.api.LeaderTimes in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method sanityCheckMultiClientLeaderTime.
@Test
public void sanityCheckMultiClientLeaderTime() {
TestableTimelockServer leader = cluster.currentLeaderFor(client.namespace());
// Multi client batched TimeLock endpoints do not support multi-leader mode on TimeLock
Assume.assumeFalse(leader.isMultiLeader());
Set<Namespace> expectedNamespaces = ImmutableSet.of(Namespace.of("client1"), Namespace.of("client2"));
LeaderTimes leaderTimes = assertSanityAndGetLeaderTimes(leader, expectedNamespaces);
// leaderTimes for namespaces are computed by their respective underlying AsyncTimelockService instances
Set<UUID> leadershipIds = leaderTimes.getLeaderTimes().values().stream().map(LeaderTime::id).map(LeadershipId::id).collect(Collectors.toSet());
assertThat(leadershipIds).hasSameSizeAs(expectedNamespaces);
}
use of com.palantir.atlasdb.timelock.api.LeaderTimes in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method sanityCheckMultiClientLeaderTimeAgainstConjureTimelockService.
@Test
public void sanityCheckMultiClientLeaderTimeAgainstConjureTimelockService() {
TestableTimelockServer leader = cluster.currentLeaderFor(client.namespace());
// Multi client batched TimeLock endpoints do not support multi-leader mode on TimeLock
Assume.assumeFalse(leader.isMultiLeader());
Set<Namespace> expectedNamespaces = ImmutableSet.of(Namespace.of("alpha"), Namespace.of("beta"));
LeaderTimes leaderTimes = assertSanityAndGetLeaderTimes(leader, expectedNamespaces);
// Whether we hit the multi client endpoint or conjureTimelockService endpoint(services one client in one
// call), for a namespace, the underlying service to process the request is the same
leaderTimes.getLeaderTimes().forEach((namespace, leaderTime) -> {
LeaderTime conjureTimelockServiceLeaderTime = leader.client(namespace.get()).namespacedConjureTimelockService().leaderTime();
assertThat(conjureTimelockServiceLeaderTime.id()).isEqualTo(leaderTime.id());
});
}
Aggregations