Search in sources :

Example 1 with LeaderTimes

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);
}
Also used : LeaderTime(com.palantir.lock.v2.LeaderTime) LeaderTimes(com.palantir.atlasdb.timelock.api.LeaderTimes) UUID(java.util.UUID) Namespace(com.palantir.atlasdb.timelock.api.Namespace) Test(org.junit.Test)

Example 2 with LeaderTimes

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;
}
Also used : MultiClientConjureTimelockService(com.palantir.atlasdb.timelock.api.MultiClientConjureTimelockService) LeaderTimes(com.palantir.atlasdb.timelock.api.LeaderTimes) Namespace(com.palantir.atlasdb.timelock.api.Namespace)

Example 3 with 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);
}
Also used : LeaderTime(com.palantir.lock.v2.LeaderTime) LeaderTimes(com.palantir.atlasdb.timelock.api.LeaderTimes) UUID(java.util.UUID) Namespace(com.palantir.atlasdb.timelock.api.Namespace) Test(org.junit.Test)

Example 4 with LeaderTimes

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());
    });
}
Also used : LeaderTime(com.palantir.lock.v2.LeaderTime) LeaderTimes(com.palantir.atlasdb.timelock.api.LeaderTimes) Namespace(com.palantir.atlasdb.timelock.api.Namespace) Test(org.junit.Test)

Aggregations

LeaderTimes (com.palantir.atlasdb.timelock.api.LeaderTimes)4 Namespace (com.palantir.atlasdb.timelock.api.Namespace)4 LeaderTime (com.palantir.lock.v2.LeaderTime)3 Test (org.junit.Test)3 UUID (java.util.UUID)2 MultiClientConjureTimelockService (com.palantir.atlasdb.timelock.api.MultiClientConjureTimelockService)1