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