Source:
<code>public final void updateEquivalences(ImmutableSet<EquivalenceGraph> graphs) throws WriteException { metricRegistry.meter(updateEquivalences + METER_CALLED).mark(); ImmutableMap<EquivalenceGraph, ListenableFuture<Resolved<Content>>> graphsContent = graphs .stream() .distinct() .collect(MoreCollectors.toImmutableMap( graph -> graph, graph -> contentStore.resolveIds(graph.getEquivalenceSet()) )); ImmutableList.Builder<ResultSetFuture> futureBuilder = ImmutableList.builder(); for (Map.Entry<EquivalenceGraph, ListenableFuture<Resolved<Content>>> entry : graphsContent.entrySet()) { EquivalenceGraph graph = entry.getKey(); ImmutableList<Item> graphItems = get(entry.getValue()) .getResources() .filter(Item.class) .toList(); for (Item item : graphItems) { ImmutableList<Broadcast> broadcasts = item.getBroadcasts() .stream() .filter(Broadcast::isActivelyPublished) .collect(MoreCollectors.toImmutableList()); for (Broadcast broadcast : broadcasts) { Item copy = item.copy(); copy.setBroadcasts(ImmutableSet.of(broadcast)); futureBuilder.addAll(updateEquivalentContent( item.getSource(), broadcast, graph, equivItems(copy, broadcast, graphItems) )); } } } ImmutableList<ResultSetFuture> futures = futureBuilder.build(); metricRegistry.histogram(updateEquivalences + "histogram.parallelWrites") .update(futures.size()); try { <START> for (ResultSetFuture future : futures) { <END> future.get(); } } catch (Exception e) { metricRegistry.meter(updateEquivalences + METER_FAILURE).mark(); throw new WriteException(e); } }</code><technical_language>ListenableFutures, able Futures.allAsList().get() For future -- driver Guava heavily, of future stuff is Listenable* Guava's executors, etc</technical_language>

Target:
public final void updateEquivalences(ImmutableSet<EquivalenceGraph> graphs) throws WriteException { metricRegistry.meter(updateEquivalences + METER_CALLED).mark(); ImmutableMap<EquivalenceGraph, ListenableFuture<Resolved<Content>>> graphsContent = graphs .stream() .distinct() .collect(MoreCollectors.toImmutableMap( graph -> graph, graph -> contentStore.resolveIds(graph.getEquivalenceSet()) )); ImmutableList.Builder<ResultSetFuture> futureBuilder = ImmutableList.builder(); for (Map.Entry<EquivalenceGraph, ListenableFuture<Resolved<Content>>> entry : graphsContent.entrySet()) { EquivalenceGraph graph = entry.getKey(); ImmutableList<Item> graphItems = get(entry.getValue()) .getResources() .filter(Item.class) .toList(); for (Item item : graphItems) { ImmutableList<Broadcast> broadcasts = item.getBroadcasts() .stream() .filter(Broadcast::isActivelyPublished) .collect(MoreCollectors.toImmutableList()); for (Broadcast broadcast : broadcasts) { Item copy = item.copy(); copy.setBroadcasts(ImmutableSet.of(broadcast)); futureBuilder.addAll(updateEquivalentContent( item.getSource(), broadcast, graph, equivItems(copy, broadcast, graphItems) )); } } } ImmutableList<ResultSetFuture> futures = futureBuilder.build(); metricRegistry.histogram(updateEquivalences + "histogram.parallelWrites") .update(futures.size()); try { Futures.allAsList(futures).get(); } catch (Exception e) { metricRegistry.meter(updateEquivalences + METER_FAILURE).mark(); throw new WriteException(e); } }