Search in sources :

Example 6 with Client

use of com.palantir.paxos.Client in project atlasdb by palantir.

the class LocalBatchPaxosAcceptorTests method weProxyAcceptRequests.

@Test
public void weProxyAcceptRequests() {
    PaxosProposal proposal1 = proposal(PROPOSAL_ID_1, 1);
    PaxosProposal proposal2 = proposal(PROPOSAL_ID_2, 2);
    when(components.acceptor(CLIENT_1).accept(1, proposal1)).thenReturn(success());
    when(components.acceptor(CLIENT_2).accept(1, proposal1)).thenReturn(success());
    when(components.acceptor(CLIENT_2).accept(2, proposal2)).thenReturn(success());
    when(components.acceptor(CLIENT_1).getLatestSequencePreparedOrAccepted()).thenReturn(1L);
    when(components.acceptor(CLIENT_2).getLatestSequencePreparedOrAccepted()).thenReturn(2L);
    SetMultimap<Client, PaxosProposal> request = ImmutableSetMultimap.<Client, PaxosProposal>builder().put(CLIENT_1, proposal1).put(CLIENT_2, proposal1).put(CLIENT_2, proposal2).build();
    SetMultimap<Client, WithSeq<BooleanPaxosResponse>> expected = ImmutableSetMultimap.<Client, WithSeq<BooleanPaxosResponse>>builder().put(CLIENT_1, WithSeq.of(success(), 1)).put(CLIENT_2, WithSeq.of(success(), 1)).put(CLIENT_2, WithSeq.of(success(), 2)).build();
    assertThat(resource.accept(request)).isEqualTo(expected);
    verify(cache).updateSequenceNumbers(ImmutableSet.of(WithSeq.of(CLIENT_1, 1), WithSeq.of(CLIENT_2, 2)));
}
Also used : PaxosProposal(com.palantir.paxos.PaxosProposal) Client(com.palantir.paxos.Client) Test(org.junit.Test)

Example 7 with Client

use of com.palantir.paxos.Client in project atlasdb by palantir.

the class LocalBatchPaxosLearnerTests method weProxyGetLearnedValuesSince.

@Test
public void weProxyGetLearnedValuesSince() {
    PaxosValue paxosValue1 = paxosValue(1);
    PaxosValue paxosValue2 = paxosValue(2);
    when(paxosComponents.learner(CLIENT_1).getLearnedValuesSince(1)).thenReturn(ImmutableSet.of(paxosValue1));
    when(paxosComponents.learner(CLIENT_2).getLearnedValuesSince(2)).thenReturn(ImmutableSet.of(paxosValue2));
    Map<Client, Long> request = ImmutableMap.<Client, Long>builder().put(CLIENT_1, 1L).put(CLIENT_2, 2L).build();
    SetMultimap<Client, PaxosValue> expected = ImmutableSetMultimap.<Client, PaxosValue>builder().putAll(CLIENT_1, paxosValue1).putAll(CLIENT_2, paxosValue2).build();
    assertThat(resource.getLearnedValuesSince(request)).isEqualTo(expected);
}
Also used : Client(com.palantir.paxos.Client) PaxosValue(com.palantir.paxos.PaxosValue) Test(org.junit.Test)

Example 8 with Client

use of com.palantir.paxos.Client in project atlasdb by palantir.

the class LocalBatchPaxosLearnerTests method weProxyGetLearnedValuesThrough.

@Test
public void weProxyGetLearnedValuesThrough() {
    PaxosValue paxosValue1 = paxosValue(1);
    PaxosValue paxosValue2 = paxosValue(2);
    when(paxosComponents.learner(CLIENT_1).getLearnedValue(1)).thenReturn(Optional.of(paxosValue1));
    when(paxosComponents.learner(CLIENT_1).getLearnedValue(2)).thenReturn(Optional.empty());
    when(paxosComponents.learner(CLIENT_2).getLearnedValue(1)).thenReturn(Optional.of(paxosValue1));
    when(paxosComponents.learner(CLIENT_2).getLearnedValue(2)).thenReturn(Optional.of(paxosValue2));
    SetMultimap<Client, PaxosValue> expected = ImmutableSetMultimap.<Client, PaxosValue>builder().putAll(CLIENT_1, paxosValue1).putAll(CLIENT_2, paxosValue1, paxosValue2).build();
    Set<WithSeq<Client>> request = ImmutableSet.of(WithSeq.of(CLIENT_1, 1), WithSeq.of(CLIENT_1, 2), WithSeq.of(CLIENT_2, 1), WithSeq.of(CLIENT_2, 2));
    assertThat(resource.getLearnedValues(request)).isEqualTo(expected);
}
Also used : Client(com.palantir.paxos.Client) PaxosValue(com.palantir.paxos.PaxosValue) Test(org.junit.Test)

Example 9 with Client

use of com.palantir.paxos.Client in project atlasdb by palantir.

the class LocalBatchPaxosLearnerTests method weProxyLearnRequestsThrough.

@Test
public void weProxyLearnRequestsThrough() {
    PaxosValue paxosValue1 = paxosValue(1);
    PaxosValue paxosValue2 = paxosValue(2);
    SetMultimap<Client, PaxosValue> learnData = ImmutableSetMultimap.<Client, PaxosValue>builder().putAll(CLIENT_1, paxosValue1).putAll(CLIENT_2, paxosValue1, paxosValue2).build();
    resource.learn(learnData);
    verify(paxosComponents.learner(CLIENT_1)).learn(1, paxosValue1);
    verify(paxosComponents.learner(CLIENT_2)).learn(1, paxosValue1);
    verify(paxosComponents.learner(CLIENT_2)).learn(2, paxosValue2);
}
Also used : Client(com.palantir.paxos.Client) PaxosValue(com.palantir.paxos.PaxosValue) Test(org.junit.Test)

Example 10 with Client

use of com.palantir.paxos.Client in project atlasdb by palantir.

the class BatchPingableLeaderResourceTests method filtersOutClientsWhereNothingHasBeenLearnt.

@Test
public void filtersOutClientsWhereNothingHasBeenLearnt() {
    Client clientWhereNothingHasBeenLearnt = Client.of("client-where-nothing-has-been-learnt");
    when(components.learner(CLIENT_1).getGreatestLearnedValue()).thenReturn(paxosValue(LEADER_UUID));
    when(components.learner(clientWhereNothingHasBeenLearnt).getGreatestLearnedValue()).thenReturn(Optional.empty());
    assertThat(resource.ping(ImmutableSet.of(CLIENT_1, clientWhereNothingHasBeenLearnt))).containsOnly(CLIENT_1);
}
Also used : Client(com.palantir.paxos.Client) Test(org.junit.Test)

Aggregations

Client (com.palantir.paxos.Client)19 Test (org.junit.Test)14 PaxosValue (com.palantir.paxos.PaxosValue)8 PaxosLearner (com.palantir.paxos.PaxosLearner)2 PaxosProposal (com.palantir.paxos.PaxosProposal)2 PaxosProposer (com.palantir.paxos.PaxosProposer)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ImmutableList (com.google.common.collect.ImmutableList)1 Maps (com.google.common.collect.Maps)1 Closer (com.google.common.io.Closer)1 ImmutableLeaderConfig (com.palantir.atlasdb.config.ImmutableLeaderConfig)1 LeaderConfig (com.palantir.atlasdb.config.LeaderConfig)1 DiskNamespaceLoader (com.palantir.atlasdb.timelock.management.DiskNamespaceLoader)1 PersistentNamespaceLoader (com.palantir.atlasdb.timelock.management.PersistentNamespaceLoader)1 PaxosContainer (com.palantir.atlasdb.timelock.paxos.PaxosQuorumCheckingCoalescingFunction.PaxosContainer)1 MetricsManagers (com.palantir.atlasdb.util.MetricsManagers)1 CheckedRejectionExecutorService (com.palantir.common.concurrent.CheckedRejectionExecutorService)1 PTExecutors (com.palantir.common.concurrent.PTExecutors)1 ServiceNotAvailableException (com.palantir.common.remoting.ServiceNotAvailableException)1 KeyedStream (com.palantir.common.streams.KeyedStream)1