use of com.palantir.paxos.Client in project atlasdb by palantir.
the class BatchingPaxosLatestSequenceCacheTests method ifThereAreUpdatesWithCacheKeyWeAddToOurCache_unseenClient.
@Test
public void ifThereAreUpdatesWithCacheKeyWeAddToOurCache_unseenClient() throws InvalidAcceptorCacheKeyException {
BatchingPaxosLatestSequenceCache cache = initialCache();
Client client4 = Client.of("client-4");
AcceptorCacheDigest digest = digestWithUpdates(entry(client4, 150L));
when(remote.latestSequencesPreparedOrAccepted(any(Optional.class), eq(ImmutableSet.of(client4)))).thenReturn(digest);
assertThat(cache.apply(ImmutableSet.of(CLIENT_3, client4))).containsEntry(CLIENT_3, INITIAL_UPDATES.get(CLIENT_3)).containsEntry(client4, PaxosLong.of(150L));
}
use of com.palantir.paxos.Client in project atlasdb by palantir.
the class LearnedValuesCoalescingFunctionTests method canProcessBatch.
@Test
public void canProcessBatch() {
Set<WithSeq<Client>> remoteRequest = ImmutableSet.of(WithSeq.of(CLIENT_1, 10), WithSeq.of(CLIENT_1, 12), WithSeq.of(CLIENT_1, 15), WithSeq.of(CLIENT_2, 10), WithSeq.of(CLIENT_2, 15));
PaxosValue paxosValue1 = paxosValue(10);
PaxosValue paxosValue2 = paxosValue(12);
SetMultimap<Client, PaxosValue> remoteResponse = ImmutableSetMultimap.<Client, PaxosValue>builder().putAll(CLIENT_1, paxosValue1, paxosValue2).put(CLIENT_2, paxosValue1).build();
when(remote.getLearnedValues(remoteRequest)).thenReturn(remoteResponse);
LearnedValuesCoalescingFunction function = new LearnedValuesCoalescingFunction(remote);
Map<WithSeq<Client>, PaxosContainer<Optional<PaxosValue>>> results = function.apply(remoteRequest);
assertThat(results).containsOnly(entry(WithSeq.of(CLIENT_2, 10), asResult(paxosValue1)), entry(WithSeq.of(CLIENT_1, 12), asResult(paxosValue2)), entry(WithSeq.of(CLIENT_1, 10), asResult(paxosValue1)), entry(WithSeq.of(CLIENT_1, 15), EMPTY_RESULT), entry(WithSeq.of(CLIENT_2, 15), EMPTY_RESULT));
}
use of com.palantir.paxos.Client in project atlasdb by palantir.
the class TimeLockAgent method createInvalidatingTimeLockServices.
/**
* Creates timestamp and lock services for the given client. It is expected that for each client there should
* only be (up to) one active timestamp service, and one active lock service at any time.
* @param client Client namespace to create the services for
* @return Invalidating timestamp and lock services
*/
public TimeLockServices createInvalidatingTimeLockServices(String client) {
LeaderConfig leaderConfig = createLeaderConfig();
Client typedClient = Client.of(client);
Supplier<ManagedTimestampService> rawTimestampServiceSupplier = timestampStorage.timestampCreator().createTimestampService(typedClient, leaderConfig);
Supplier<LockService> rawLockServiceSupplier = lockCreator::createThreadPoolingLockService;
return timelockCreator.createTimeLockServices(typedClient, rawTimestampServiceSupplier, rawLockServiceSupplier);
}
use of com.palantir.paxos.Client in project atlasdb by palantir.
the class PaxosResourcesFactoryTest method individualTimestampServicesHaveDifferingProposers.
@Test
public void individualTimestampServicesHaveDifferingProposers() {
NetworkClientFactories.Factory<PaxosProposer> proposerFactory = PaxosResourcesFactory.getPaxosProposerFactory(TimelockPaxosMetrics.of(PaxosUseCase.TIMESTAMP, MetricsManagers.createForTests()), mock(NetworkClientFactories.class, Answers.RETURNS_DEEP_STUBS));
Client client = Client.of("client");
PaxosProposer proposer1 = proposerFactory.create(client);
PaxosProposer proposer2 = proposerFactory.create(client);
assertThat(proposer1.getUuid()).isNotEqualTo(proposer2.getUuid());
}
use of com.palantir.paxos.Client in project atlasdb by palantir.
the class PaxosStateLogMigrationIntegrationTest method noCrossClientPollution.
@Test
public void noCrossClientPollution() {
fileBasedLearnerLog.writeRound(LATEST_ROUND_BEFORE_MIGRATING, valueForRound(LATEST_ROUND_BEFORE_MIGRATING));
int otherRound = 200;
Client otherClient = Client.of("other");
PaxosStateLog<PaxosValue> otherFileBasedLog = createFileSystemLearnerLog(otherClient);
otherFileBasedLog.writeRound(otherRound, valueForRound(otherRound));
LocalPaxosComponents paxosComponents = createPaxosComponentsAndMaybeMigrate();
PaxosLearner learner = paxosComponents.learner(CLIENT);
PaxosLearner otherLearner = paxosComponents.learner(otherClient);
assertValueLearned(LATEST_ROUND_BEFORE_MIGRATING, learner);
assertValueNotLearned(otherRound, learner);
assertValueNotLearned(LATEST_ROUND_BEFORE_MIGRATING, otherLearner);
assertValueLearned(otherRound, otherLearner);
}
Aggregations