use of com.google.common.collect.Iterables.filter in project cassandra by apache.
the class HintsService method writeForAllReplicas.
/**
* Write a hint for all replicas. Used to re-dispatch hints whose destination is either missing or no longer correct.
*/
void writeForAllReplicas(Hint hint) {
String keyspaceName = hint.mutation.getKeyspaceName();
Token token = hint.mutation.key().getToken();
EndpointsForToken replicas = ReplicaLayout.forTokenWriteLiveAndDown(Keyspace.open(keyspaceName), token).all();
// judicious use of streams: eagerly materializing probably cheaper
// than performing filters / translations 2x extra via Iterables.filter/transform
List<UUID> hostIds = replicas.stream().filter(replica -> StorageProxy.shouldHint(replica, false)).map(replica -> StorageService.instance.getHostIdForEndpoint(replica.endpoint())).collect(Collectors.toList());
write(hostIds, hint);
}
Aggregations