Search in sources :

Example 1 with PaxosAcceptor

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

the class IsolatedPaxosTimeLockServerIntegrationTest method canParticipateInPaxosAsAcceptorWithoutQuorum.

@Test
public void canParticipateInPaxosAsAcceptorWithoutQuorum() {
    PaxosAcceptor acceptor = createProxyForInternalNamespacedTestService(PaxosAcceptor.class);
    acceptor.getLatestSequencePreparedOrAccepted();
}
Also used : PaxosAcceptor(com.palantir.paxos.PaxosAcceptor) Test(org.junit.Test)

Example 2 with PaxosAcceptor

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

the class Leaders method createInstrumentedLocalServices.

public static LocalPaxosServices createInstrumentedLocalServices(LeaderConfig config, Supplier<LeaderRuntimeConfig> runtime, RemotePaxosServerSpec remotePaxosServerSpec, String userAgent) {
    UUID leaderUuid = UUID.randomUUID();
    PaxosLeadershipEventRecorder leadershipEventRecorder = PaxosLeadershipEventRecorder.create(AtlasDbMetrics.getMetricRegistry(), leaderUuid.toString());
    PaxosAcceptor ourAcceptor = AtlasDbMetrics.instrument(PaxosAcceptor.class, PaxosAcceptorImpl.newAcceptor(config.acceptorLogDir().getPath()));
    PaxosLearner ourLearner = AtlasDbMetrics.instrument(PaxosLearner.class, PaxosLearnerImpl.newLearner(config.learnerLogDir().getPath(), leadershipEventRecorder));
    Optional<SSLSocketFactory> sslSocketFactory = ServiceCreator.createSslSocketFactory(config.sslConfiguration());
    List<PaxosLearner> learners = createProxyAndLocalList(ourLearner, remotePaxosServerSpec.remoteLearnerUris(), sslSocketFactory, PaxosLearner.class, userAgent);
    List<PaxosAcceptor> acceptors = createProxyAndLocalList(ourAcceptor, remotePaxosServerSpec.remoteAcceptorUris(), sslSocketFactory, PaxosAcceptor.class, userAgent);
    Map<PingableLeader, HostAndPort> otherLeaders = generatePingables(remotePaxosServerSpec.remoteLeaderUris(), sslSocketFactory, userAgent);
    InstrumentedExecutorService proposerExecutorService = new InstrumentedExecutorService(PTExecutors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("atlas-proposer-%d").setDaemon(true).build()), AtlasDbMetrics.getMetricRegistry(), MetricRegistry.name(PaxosProposer.class, "executor"));
    PaxosProposer proposer = AtlasDbMetrics.instrument(PaxosProposer.class, PaxosProposerImpl.newProposer(ourLearner, acceptors, learners, config.quorumSize(), leaderUuid, proposerExecutorService));
    InstrumentedExecutorService leaderElectionExecutor = new InstrumentedExecutorService(PTExecutors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("atlas-leaders-election-%d").setDaemon(true).build()), AtlasDbMetrics.getMetricRegistry(), MetricRegistry.name(PaxosLeaderElectionService.class, "executor"));
    PaxosLeaderElectionService paxosLeaderElectionService = new PaxosLeaderElectionServiceBuilder().proposer(proposer).knowledge(ourLearner).potentialLeadersToHosts(otherLeaders).acceptors(acceptors).learners(learners).executor(leaderElectionExecutor).pingRateMs(config.pingRateMs()).randomWaitBeforeProposingLeadershipMs(config.randomWaitBeforeProposingLeadershipMs()).leaderPingResponseWaitMs(config.leaderPingResponseWaitMs()).eventRecorder(leadershipEventRecorder).onlyLogOnQuorumFailure(JavaSuppliers.compose(LeaderRuntimeConfig::onlyLogOnQuorumFailure, runtime)).build();
    LeaderElectionService leaderElectionService = AtlasDbMetrics.instrument(LeaderElectionService.class, paxosLeaderElectionService);
    PingableLeader pingableLeader = AtlasDbMetrics.instrument(PingableLeader.class, paxosLeaderElectionService);
    return ImmutableLocalPaxosServices.builder().ourAcceptor(ourAcceptor).ourLearner(ourLearner).leaderElectionService(leaderElectionService).pingableLeader(pingableLeader).build();
}
Also used : PaxosAcceptor(com.palantir.paxos.PaxosAcceptor) InstrumentedExecutorService(com.codahale.metrics.InstrumentedExecutorService) PaxosProposer(com.palantir.paxos.PaxosProposer) PaxosLearner(com.palantir.paxos.PaxosLearner) HostAndPort(com.google.common.net.HostAndPort) PingableLeader(com.palantir.leader.PingableLeader) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) PaxosLeaderElectionService(com.palantir.leader.PaxosLeaderElectionService) PaxosLeaderElectionService(com.palantir.leader.PaxosLeaderElectionService) LeaderElectionService(com.palantir.leader.LeaderElectionService) PaxosLeadershipEventRecorder(com.palantir.leader.PaxosLeadershipEventRecorder) UUID(java.util.UUID) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) PaxosLeaderElectionServiceBuilder(com.palantir.leader.PaxosLeaderElectionServiceBuilder) LeaderRuntimeConfig(com.palantir.atlasdb.config.LeaderRuntimeConfig)

Example 3 with PaxosAcceptor

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

the class LeaderRemotingTest method testAccept.

@Test
public void testAccept() throws IOException {
    PaxosProposalId id = new PaxosProposalId(123123, UUID.randomUUID().toString());
    PaxosProposal paxosProposal = new PaxosProposal(id, new PaxosValue(id.getProposerUUID(), 0, new byte[] { 0, 1, 2, 4, 1 }));
    PaxosAcceptor accept = AtlasDbFeignTargetFactory.createProxy(Optional.empty(), acceptor.baseUri().toString(), PaxosAcceptor.class, UserAgents.DEFAULT_USER_AGENT);
    accept.accept(0, paxosProposal);
    accept.getLatestSequencePreparedOrAccepted();
    accept.prepare(0, id);
    accept.prepare(1, id);
}
Also used : PaxosAcceptor(com.palantir.paxos.PaxosAcceptor) PaxosProposal(com.palantir.paxos.PaxosProposal) PaxosProposalId(com.palantir.paxos.PaxosProposalId) PaxosValue(com.palantir.paxos.PaxosValue) Test(org.junit.Test)

Example 4 with PaxosAcceptor

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

the class PaxosResourceTest method newClientCanBeCreated.

@Test
public void newClientCanBeCreated() {
    PaxosLearner learner = paxosResource.getPaxosLearner(CLIENT_1);
    learner.learn(PAXOS_ROUND_ONE, PAXOS_VALUE);
    assertThat(learner.getGreatestLearnedValue()).isNotNull();
    assertThat(learner.getGreatestLearnedValue().getLeaderUUID()).isEqualTo(PAXOS_UUID);
    assertThat(learner.getGreatestLearnedValue().getData()).isEqualTo(PAXOS_DATA);
    PaxosAcceptor acceptor = paxosResource.getPaxosAcceptor(CLIENT_1);
    acceptor.accept(PAXOS_ROUND_TWO, PAXOS_PROPOSAL);
    assertThat(acceptor.getLatestSequencePreparedOrAccepted()).isEqualTo(PAXOS_ROUND_TWO);
}
Also used : PaxosAcceptor(com.palantir.paxos.PaxosAcceptor) PaxosLearner(com.palantir.paxos.PaxosLearner) Test(org.junit.Test)

Example 5 with PaxosAcceptor

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

the class PaxosResource method createInstrumentedComponents.

public PaxosComponents createInstrumentedComponents(String client) {
    String learnerLogDir = Paths.get(logDirectory, client, PaxosTimeLockConstants.LEARNER_SUBDIRECTORY_PATH).toString();
    PaxosLearner learner = instrument(PaxosLearner.class, PaxosLearnerImpl.newLearner(learnerLogDir), client);
    String acceptorLogDir = Paths.get(logDirectory, client, PaxosTimeLockConstants.ACCEPTOR_SUBDIRECTORY_PATH).toString();
    PaxosAcceptor acceptor = instrument(PaxosAcceptor.class, PaxosAcceptorImpl.newAcceptor(acceptorLogDir), client);
    return ImmutablePaxosComponents.builder().acceptor(acceptor).learner(learner).build();
}
Also used : PaxosAcceptor(com.palantir.paxos.PaxosAcceptor) PaxosLearner(com.palantir.paxos.PaxosLearner)

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