Search in sources :

Example 6 with PaxosLearner

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

the class LeaderRemotingTest method testLearn.

@Test
public void testLearn() throws IOException {
    PaxosValue value = new PaxosValue("asdfasdfsa", 0, new byte[] { 0, 1, 2 });
    PaxosLearner learn = AtlasDbFeignTargetFactory.createProxy(Optional.empty(), learner.baseUri().toString(), PaxosLearner.class, UserAgents.DEFAULT_USER_AGENT);
    learn.getGreatestLearnedValue();
    learn.getLearnedValuesSince(0);
    learn.learn(0, value);
    PaxosValue val = learn.getGreatestLearnedValue();
    learn.getLearnedValuesSince(0);
    learn.getLearnedValue(0);
}
Also used : PaxosLearner(com.palantir.paxos.PaxosLearner) PaxosValue(com.palantir.paxos.PaxosValue) Test(org.junit.Test)

Example 7 with PaxosLearner

use of com.palantir.paxos.PaxosLearner 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 8 with PaxosLearner

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

the class IsolatedPaxosTimeLockServerIntegrationTest method canParticipateInPaxosAsLearnerWithoutQuorum.

@Test
public void canParticipateInPaxosAsLearnerWithoutQuorum() {
    PaxosLearner learner = createProxyForInternalNamespacedTestService(PaxosLearner.class);
    learner.getGreatestLearnedValue();
}
Also used : PaxosLearner(com.palantir.paxos.PaxosLearner) Test(org.junit.Test)

Example 9 with PaxosLearner

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

the class PaxosSynchronizerTest method setUp.

@Before
public void setUp() throws IOException {
    for (int i = 0; i < NUM_NODES; i++) {
        AtomicBoolean failureController = new AtomicBoolean(false);
        PaxosLearner learner = PaxosLearnerImpl.newLearner(TEMPORARY_FOLDER.newFolder().getPath());
        learners.add(ToggleableExceptionProxy.newProxyInstance(PaxosLearner.class, learner, failureController, EXCEPTION));
        failureToggles.add(failureController);
    }
    ourLearner = learners.get(0);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) PaxosLearner(com.palantir.paxos.PaxosLearner) Before(org.junit.Before)

Example 10 with PaxosLearner

use of com.palantir.paxos.PaxosLearner 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

PaxosLearner (com.palantir.paxos.PaxosLearner)10 PaxosAcceptor (com.palantir.paxos.PaxosAcceptor)5 Test (org.junit.Test)4 PaxosValue (com.palantir.paxos.PaxosValue)3 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)2 PaxosProposer (com.palantir.paxos.PaxosProposer)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Before (org.junit.Before)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 PaxosUpdate (com.palantir.paxos.PaxosUpdate)1 UUID (java.util.UUID)1 ExecutorService (java.util.concurrent.ExecutorService)1 Nullable (javax.annotation.Nullable)1