Search in sources :

Example 6 with PaxosAcceptor

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);
}
Also used : PaxosAcceptor(com.palantir.paxos.PaxosAcceptor) Test(org.junit.Test)

Example 7 with PaxosAcceptor

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);
}
Also used : PaxosAcceptor(com.palantir.paxos.PaxosAcceptor) Test(org.junit.Test)

Example 8 with PaxosAcceptor

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);
}
Also used : PaxosAcceptor(com.palantir.paxos.PaxosAcceptor) Test(org.junit.Test)

Example 9 with PaxosAcceptor

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);
}
Also used : PaxosAcceptor(com.palantir.paxos.PaxosAcceptor) PaxosProposer(com.palantir.paxos.PaxosProposer) ExecutorService(java.util.concurrent.ExecutorService) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) PaxosLearner(com.palantir.paxos.PaxosLearner)

Example 10 with PaxosAcceptor

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);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) PaxosAcceptor(com.palantir.paxos.PaxosAcceptor) PaxosLearner(com.palantir.paxos.PaxosLearner) Before(org.junit.Before)

Aggregations

PaxosAcceptor (com.palantir.paxos.PaxosAcceptor)10 Test (org.junit.Test)6 PaxosLearner (com.palantir.paxos.PaxosLearner)5 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)2 PaxosProposer (com.palantir.paxos.PaxosProposer)2 InstrumentedExecutorService (com.codahale.metrics.InstrumentedExecutorService)1 HostAndPort (com.google.common.net.HostAndPort)1 LeaderRuntimeConfig (com.palantir.atlasdb.config.LeaderRuntimeConfig)1 LeaderElectionService (com.palantir.leader.LeaderElectionService)1 PaxosLeaderElectionService (com.palantir.leader.PaxosLeaderElectionService)1 PaxosLeaderElectionServiceBuilder (com.palantir.leader.PaxosLeaderElectionServiceBuilder)1 PaxosLeadershipEventRecorder (com.palantir.leader.PaxosLeadershipEventRecorder)1 PingableLeader (com.palantir.leader.PingableLeader)1 PaxosProposal (com.palantir.paxos.PaxosProposal)1 PaxosProposalId (com.palantir.paxos.PaxosProposalId)1 PaxosValue (com.palantir.paxos.PaxosValue)1 UUID (java.util.UUID)1 ExecutorService (java.util.concurrent.ExecutorService)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1