Search in sources :

Example 1 with KeyedStream

use of com.palantir.common.streams.KeyedStream in project atlasdb by palantir.

the class TestableTimelockCluster method currentLeaders.

SetMultimap<String, TestableTimelockServer> currentLeaders(Iterable<String> namespaces) {
    Set<String> namespacesIterable = ImmutableSet.copyOf(namespaces);
    KeyedStream<TestableTimelockServer, PaxosContainer<Set<String>>> responses = PaxosQuorumChecker.collectUntil(ImmutableList.copyOf(servers), server -> PaxosContainer.of(server.pinger().ping(namespaces)), Maps.toMap(servers, unused -> new CheckedRejectionExecutorService(executorService)), Duration.ofSeconds(2), untilAllNamespacesAreSeen(namespacesIterable), true).stream();
    return responses.filter(PaxosContainer::isSuccessful).map(PaxosContainer::get).flatMap(Collection::stream).mapEntries((server, namespace) -> Maps.immutableEntry(namespace, server)).collectToSetMultimap();
}
Also used : Statement(org.junit.runners.model.Statement) Iterables(com.google.common.collect.Iterables) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) TestRule(org.junit.rules.TestRule) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) PaxosContainer(com.palantir.atlasdb.timelock.paxos.PaxosQuorumCheckingCoalescingFunction.PaxosContainer) Hashing(com.google.common.hash.Hashing) Random(java.util.Random) Multimap(com.google.common.collect.Multimap) ProxyMode(com.palantir.atlasdb.timelock.util.TestProxies.ProxyMode) ImmutableList(com.google.common.collect.ImmutableList) Duration(java.time.Duration) Map(java.util.Map) StreamSupport(java.util.stream.StreamSupport) PaxosQuorumChecker(com.palantir.paxos.PaxosQuorumChecker) NoSuchElementException(java.util.NoSuchElementException) ExecutorService(java.util.concurrent.ExecutorService) ImmutableSet(com.google.common.collect.ImmutableSet) KeyedStream(com.palantir.common.streams.KeyedStream) Predicate(java.util.function.Predicate) CheckedRejectionExecutorService(com.palantir.common.concurrent.CheckedRejectionExecutorService) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TestProxies(com.palantir.atlasdb.timelock.util.TestProxies) Set(java.util.Set) Description(org.junit.runner.Description) UUID(java.util.UUID) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) SetMultimap(com.google.common.collect.SetMultimap) Sets(com.google.common.collect.Sets) Executors(java.util.concurrent.Executors) InProgressResponseState(com.palantir.paxos.InProgressResponseState) ExecutionException(java.util.concurrent.ExecutionException) RuleChain(org.junit.rules.RuleChain) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) Awaitility(org.awaitility.Awaitility) TemporaryFolder(org.junit.rules.TemporaryFolder) PaxosContainer(com.palantir.atlasdb.timelock.paxos.PaxosQuorumCheckingCoalescingFunction.PaxosContainer) CheckedRejectionExecutorService(com.palantir.common.concurrent.CheckedRejectionExecutorService) Collection(java.util.Collection)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 Maps (com.google.common.collect.Maps)1 Multimap (com.google.common.collect.Multimap)1 SetMultimap (com.google.common.collect.SetMultimap)1 Sets (com.google.common.collect.Sets)1 Hashing (com.google.common.hash.Hashing)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 PaxosContainer (com.palantir.atlasdb.timelock.paxos.PaxosQuorumCheckingCoalescingFunction.PaxosContainer)1 TestProxies (com.palantir.atlasdb.timelock.util.TestProxies)1 ProxyMode (com.palantir.atlasdb.timelock.util.TestProxies.ProxyMode)1 CheckedRejectionExecutorService (com.palantir.common.concurrent.CheckedRejectionExecutorService)1 KeyedStream (com.palantir.common.streams.KeyedStream)1 InProgressResponseState (com.palantir.paxos.InProgressResponseState)1 PaxosQuorumChecker (com.palantir.paxos.PaxosQuorumChecker)1 Duration (java.time.Duration)1 Collection (java.util.Collection)1 List (java.util.List)1