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