Search in sources :

Example 11 with Client

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));
}
Also used : Optional(java.util.Optional) Client(com.palantir.paxos.Client) Test(org.junit.Test)

Example 12 with Client

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));
}
Also used : PaxosContainer(com.palantir.atlasdb.timelock.paxos.PaxosQuorumCheckingCoalescingFunction.PaxosContainer) Client(com.palantir.paxos.Client) PaxosValue(com.palantir.paxos.PaxosValue) Test(org.junit.Test)

Example 13 with Client

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);
}
Also used : LeaderConfig(com.palantir.atlasdb.config.LeaderConfig) ImmutableLeaderConfig(com.palantir.atlasdb.config.ImmutableLeaderConfig) LockService(com.palantir.lock.LockService) ManagedTimestampService(com.palantir.timestamp.ManagedTimestampService) Client(com.palantir.paxos.Client)

Example 14 with Client

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());
}
Also used : PaxosProposer(com.palantir.paxos.PaxosProposer) Client(com.palantir.paxos.Client) Test(org.junit.Test)

Example 15 with Client

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);
}
Also used : Client(com.palantir.paxos.Client) PaxosLearner(com.palantir.paxos.PaxosLearner) PaxosValue(com.palantir.paxos.PaxosValue) Test(org.junit.Test)

Aggregations

Client (com.palantir.paxos.Client)19 Test (org.junit.Test)14 PaxosValue (com.palantir.paxos.PaxosValue)8 PaxosLearner (com.palantir.paxos.PaxosLearner)2 PaxosProposal (com.palantir.paxos.PaxosProposal)2 PaxosProposer (com.palantir.paxos.PaxosProposer)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ImmutableList (com.google.common.collect.ImmutableList)1 Maps (com.google.common.collect.Maps)1 Closer (com.google.common.io.Closer)1 ImmutableLeaderConfig (com.palantir.atlasdb.config.ImmutableLeaderConfig)1 LeaderConfig (com.palantir.atlasdb.config.LeaderConfig)1 DiskNamespaceLoader (com.palantir.atlasdb.timelock.management.DiskNamespaceLoader)1 PersistentNamespaceLoader (com.palantir.atlasdb.timelock.management.PersistentNamespaceLoader)1 PaxosContainer (com.palantir.atlasdb.timelock.paxos.PaxosQuorumCheckingCoalescingFunction.PaxosContainer)1 MetricsManagers (com.palantir.atlasdb.util.MetricsManagers)1 CheckedRejectionExecutorService (com.palantir.common.concurrent.CheckedRejectionExecutorService)1 PTExecutors (com.palantir.common.concurrent.PTExecutors)1 ServiceNotAvailableException (com.palantir.common.remoting.ServiceNotAvailableException)1 KeyedStream (com.palantir.common.streams.KeyedStream)1