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)));
}
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);
}
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);
}
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);
}
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);
}
Aggregations