use of com.palantir.paxos.LeaderPinger in project atlasdb by palantir.
the class SinglePingableLeaderTest method fallbackOnPingWhenPingV2ThrowsEvenWhenPingV2Exists.
@Test
public void fallbackOnPingWhenPingV2ThrowsEvenWhenPingV2Exists() {
availableServer.stubFor(PING_V2_MAPPING.willReturn(WireMock.aResponse().withStatus(500)));
LeaderPinger pinger = getDefaultLeaderPinger();
pingMultipleTimes(pinger, 5);
assertPingV2RequestsMadeAreLessThan(5);
assertLegacyPingRequestsMade(5);
}
use of com.palantir.paxos.LeaderPinger in project atlasdb by palantir.
the class SinglePingableLeaderTest method fallbackOnPingWhenPingV2DoesNotExist.
@Test
public void fallbackOnPingWhenPingV2DoesNotExist() {
availableServer.stubFor(PING_V2_MAPPING.willReturn(WireMock.aResponse().withStatus(404)));
LeaderPinger pinger = getDefaultLeaderPinger();
pingMultipleTimes(pinger, 5);
assertPingV2RequestsMadeAreLessThan(5);
assertLegacyPingRequestsMade(5);
}
use of com.palantir.paxos.LeaderPinger in project atlasdb by palantir.
the class AutobatchingPingableLeaderFactoryTests method unknownUuidReturnsFalse.
@Test
public void unknownUuidReturnsFalse() {
LeaderPingerContext<BatchPingableLeader> rpc = batchPingableLeader(HOST_AND_PORT, CLIENT_1, CLIENT_2);
try (AutobatchingPingableLeaderFactory factory = factoryForPingables(rpc)) {
LeaderPinger client1Pinger = factory.leaderPingerFor(CLIENT_1);
LeaderPinger client2Pinger = factory.leaderPingerFor(CLIENT_2);
assertThat(client1Pinger.pingLeaderWithUuid(UUID.randomUUID())).isEqualTo(LeaderPingResults.pingReturnedFalse());
assertThat(client2Pinger.pingLeaderWithUuid(UUID.randomUUID())).isEqualTo(LeaderPingResults.pingReturnedFalse());
}
}
use of com.palantir.paxos.LeaderPinger in project atlasdb by palantir.
the class AutobatchingPingableLeaderFactoryTests method twoDifferentLeaders.
@Test
public void twoDifferentLeaders() {
HostAndPort leader1 = HostAndPort.fromParts("timelock-1", 8080);
HostAndPort leader2 = HostAndPort.fromParts("timelock-2", 8080);
LeaderPingerContext<BatchPingableLeader> client1Leader = batchPingableLeader(leader1, CLIENT_1);
LeaderPingerContext<BatchPingableLeader> client2Leader = batchPingableLeader(leader2, CLIENT_2);
try (AutobatchingPingableLeaderFactory factory = factoryForPingables(client1Leader, client2Leader)) {
LeaderPinger client1Pinger = factory.leaderPingerFor(CLIENT_1);
LeaderPinger client2Pinger = factory.leaderPingerFor(CLIENT_2);
assertThat(client1Pinger.pingLeaderWithUuid(client1Leader.pinger().uuid())).isEqualTo(LeaderPingResults.pingReturnedTrue(client1Leader.pinger().uuid(), leader1));
assertThat(client2Pinger.pingLeaderWithUuid(client2Leader.pinger().uuid())).isEqualTo(LeaderPingResults.pingReturnedTrue(client2Leader.pinger().uuid(), leader2));
}
}
use of com.palantir.paxos.LeaderPinger in project atlasdb by palantir.
the class Leaders method createInstrumentedLocalServices.
public static LocalPaxosServices createInstrumentedLocalServices(MetricsManager metricsManager, LeaderConfig config, RemotePaxosServerSpec remotePaxosServerSpec, Supplier<RemotingClientConfig> remotingClientConfig, UserAgent userAgent, LeadershipObserver leadershipObserver) {
UUID leaderUuid = UUID.randomUUID();
PaxosLeadershipEventRecorder leadershipEventRecorder = PaxosLeadershipEventRecorder.create(metricsManager.getTaggedRegistry(), leaderUuid.toString(), leadershipObserver, ImmutableList.of());
PaxosAcceptor ourAcceptor = AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), PaxosAcceptor.class, PaxosAcceptorImpl.newAcceptor(config.acceptorLogDir().getPath()));
PaxosLearner ourLearner = AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), PaxosLearner.class, PaxosLearnerImpl.newLearner(config.learnerLogDir().getPath(), leadershipEventRecorder));
Optional<TrustContext> trustContext = ServiceCreator.createTrustContext(config.sslConfiguration());
List<PaxosLearner> learners = createProxyAndLocalList(ourLearner, remotePaxosServerSpec.remoteLearnerUris(), remotingClientConfig, trustContext, PaxosLearner.class, userAgent);
List<PaxosLearner> remoteLearners = learners.stream().filter(learner -> !learner.equals(ourLearner)).collect(ImmutableList.toImmutableList());
PaxosLearnerNetworkClient learnerNetworkClient = SingleLeaderLearnerNetworkClient.createLegacy(ourLearner, remoteLearners, config.quorumSize(), createExecutorsForService(metricsManager, learners, "knowledge-update"), PaxosConstants.CANCEL_REMAINING_CALLS);
List<PaxosAcceptor> acceptors = createProxyAndLocalList(ourAcceptor, remotePaxosServerSpec.remoteAcceptorUris(), remotingClientConfig, trustContext, PaxosAcceptor.class, userAgent);
PaxosAcceptorNetworkClient acceptorNetworkClient = SingleLeaderAcceptorNetworkClient.createLegacy(acceptors, config.quorumSize(), createExecutorsForService(metricsManager, acceptors, "latest-round-verifier"), PaxosConstants.CANCEL_REMAINING_CALLS);
List<LeaderPingerContext<PingableLeader>> otherLeaders = generatePingables(remotePaxosServerSpec.remoteLeaderUris(), remotingClientConfig, trustContext, userAgent);
LeaderPinger leaderPinger = SingleLeaderPinger.createLegacy(createExecutorsForService(metricsManager, otherLeaders, "leader-ping"), config.leaderPingResponseWait(), leaderUuid, PaxosConstants.CANCEL_REMAINING_CALLS);
LeaderElectionService uninstrumentedLeaderElectionService = new LeaderElectionServiceBuilder().leaderUuid(leaderUuid).knowledge(ourLearner).eventRecorder(leadershipEventRecorder).randomWaitBeforeProposingLeadership(config.randomWaitBeforeProposingLeadership()).pingRate(config.pingRate()).leaderPinger(leaderPinger).acceptorClient(acceptorNetworkClient).learnerClient(learnerNetworkClient).decorateProposer(proposer -> AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), PaxosProposer.class, proposer)).leaderAddressCacheTtl(config.leaderAddressCacheTtl()).build();
LeaderElectionService leaderElectionService = AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), LeaderElectionService.class, uninstrumentedLeaderElectionService);
PingableLeader pingableLeader = AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), PingableLeader.class, new LocalPingableLeader(ourLearner, leaderUuid));
List<PingableLeader> remotePingableLeaders = otherLeaders.stream().map(LeaderPingerContext::pinger).collect(Collectors.toList());
BatchingLeaderElectionService batchingLeaderElectionService = new BatchingLeaderElectionService(leaderElectionService);
return ImmutableLocalPaxosServices.builder().ourAcceptor(ourAcceptor).ourLearner(ourLearner).leaderElectionService(batchingLeaderElectionService).leadershipCoordinator(LeadershipCoordinator.create(batchingLeaderElectionService)).localPingableLeader(pingableLeader).remotePingableLeaders(remotePingableLeaders).build();
}
Aggregations