use of com.palantir.paxos.PaxosAcceptor in project atlasdb by palantir.
the class LeadersTest method createProxyAndLocalListThrowsIfNullClassProvided.
@Test(expected = NullPointerException.class)
public void createProxyAndLocalListThrowsIfNullClassProvided() {
PaxosAcceptor localAcceptor = mock(PaxosAcceptor.class);
Leaders.createProxyAndLocalList(localAcceptor, REMOTE_SERVICE_ADDRESSES, Optional.empty(), null);
}
use of com.palantir.paxos.PaxosAcceptor in project atlasdb by palantir.
the class LeadersTest method canCreateProxyAndLocalListOfPaxosAcceptors.
@Test
public void canCreateProxyAndLocalListOfPaxosAcceptors() {
PaxosAcceptor localAcceptor = mock(PaxosAcceptor.class);
when(localAcceptor.getLatestSequencePreparedOrAccepted()).thenReturn(1L);
List<PaxosAcceptor> paxosAcceptors = Leaders.createProxyAndLocalList(localAcceptor, REMOTE_SERVICE_ADDRESSES, Optional.empty(), PaxosAcceptor.class);
MatcherAssert.assertThat(paxosAcceptors.size(), is(REMOTE_SERVICE_ADDRESSES.size() + 1));
paxosAcceptors.forEach(object -> MatcherAssert.assertThat(object, not(nullValue())));
MatcherAssert.assertThat(Iterables.getLast(paxosAcceptors).getLatestSequencePreparedOrAccepted(), is(1L));
verify(localAcceptor).getLatestSequencePreparedOrAccepted();
verifyNoMoreInteractions(localAcceptor);
}
use of com.palantir.paxos.PaxosAcceptor in project atlasdb by palantir.
the class LeadersTest method createProxyAndLocalListCreatesSingletonListIfNoRemoteAddressesProvided.
@Test
public void createProxyAndLocalListCreatesSingletonListIfNoRemoteAddressesProvided() {
PaxosAcceptor localAcceptor = mock(PaxosAcceptor.class);
when(localAcceptor.getLatestSequencePreparedOrAccepted()).thenReturn(1L);
List<PaxosAcceptor> paxosAcceptors = Leaders.createProxyAndLocalList(localAcceptor, ImmutableSet.of(), Optional.empty(), PaxosAcceptor.class);
MatcherAssert.assertThat(paxosAcceptors.size(), is(1));
MatcherAssert.assertThat(Iterables.getLast(paxosAcceptors).getLatestSequencePreparedOrAccepted(), is(1L));
verify(localAcceptor).getLatestSequencePreparedOrAccepted();
verifyNoMoreInteractions(localAcceptor);
}
use of com.palantir.paxos.PaxosAcceptor in project atlasdb by palantir.
the class PaxosTimestampCreator method createTimestampService.
@Override
public Supplier<ManagedTimestampService> createTimestampService(String client, LeaderConfig unused) {
ExecutorService executor = PTExecutors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("atlas-consensus-" + client + "-%d").setDaemon(true).build());
Set<String> namespacedUris = PaxosTimeLockUriUtils.getClientPaxosUris(remoteServers, client);
List<PaxosAcceptor> acceptors = Leaders.createProxyAndLocalList(paxosResource.getPaxosAcceptor(client), namespacedUris, optionalSecurity, PaxosAcceptor.class, "timestamp-bound-store." + client);
PaxosLearner ourLearner = paxosResource.getPaxosLearner(client);
List<PaxosLearner> learners = Leaders.createProxyAndLocalList(ourLearner, namespacedUris, optionalSecurity, PaxosLearner.class, "timestamp-bound-store." + client);
PaxosProposer proposer = instrument(PaxosProposer.class, PaxosProposerImpl.newProposer(ourLearner, ImmutableList.copyOf(acceptors), ImmutableList.copyOf(learners), PaxosRemotingUtils.getQuorumSize(acceptors), UUID.randomUUID(), executor), client);
PaxosSynchronizer.synchronizeLearner(ourLearner, learners);
return () -> createManagedPaxosTimestampService(proposer, client, acceptors, learners);
}
use of com.palantir.paxos.PaxosAcceptor in project atlasdb by palantir.
the class PaxosTimestampBoundStoreTest method setUp.
@Before
public void setUp() {
for (int i = 0; i < NUM_NODES; i++) {
AtomicBoolean failureController = new AtomicBoolean(false);
PaxosAcceptor acceptor = PaxosAcceptorImpl.newAcceptor(ACCEPTOR_DIR_PREFIX + i);
acceptors.add(ToggleableExceptionProxy.newProxyInstance(PaxosAcceptor.class, acceptor, failureController, EXCEPTION));
PaxosLearner learner = PaxosLearnerImpl.newLearner(LEARNER_DIR_PREFIX + i);
learners.add(ToggleableExceptionProxy.newProxyInstance(PaxosLearner.class, learner, failureController, EXCEPTION));
failureToggles.add(failureController);
}
store = createPaxosTimestampBoundStore(0);
}
Aggregations