@Override public Iterable<ServiceEndPoint> filter(Iterable<ServiceEndPoint> endPoints, PartitionContext partitionContext) { HashCode partitionHash = getPartitionHash(partitionContext); if (partitionHash == null) { return endPoints; // No partition hash means any server can handle the request. } // The choose() method is synchronized. Do any prep work we can up front before calling into it. Map<String, ServiceEndPoint> endPointsById = indexById(endPoints); ServiceEndPoint endPoint = choose(endPointsById, partitionHash); return Collections.singleton(endPoint); }
@Override public Iterable<ServiceEndPoint> filter(Iterable<ServiceEndPoint> endPoints, PartitionContext partitionContext) { HashCode partitionHash = getPartitionHash(partitionContext); if (partitionHash == null) { return endPoints; // No partition hash means any server can handle the request. } // The choose() method is synchronized. Do any prep work we can up front before calling into it. Map<String, ServiceEndPoint> endPointsById = indexById(endPoints); ServiceEndPoint endPoint = choose(endPointsById, partitionHash); return Collections.singleton(endPoint); }