@Test public void testRelevantPartitionContext() { ConsistentHashPartitionFilter filter = new ConsistentHashPartitionFilter("cluster", "ensemble", "group"); List<ServiceEndPoint> endPoints = ImmutableList.of(FOO, BAR); assertEquals(singleton(FOO), filter.filter(endPoints, PartitionContextBuilder.of("ensemble", "aaa"))); }
@Override public Iterable<ServiceEndPoint> filter(Iterable<ServiceEndPoint> endPoints, PartitionContext partitionContext) { HashCode partitionHash = getPartitionHash(partitionContext); if (partitionHash == null) { return endPoints; } Map<String, ServiceEndPoint> endPointsById = indexById(endPoints); ServiceEndPoint endPoint = choose(endPointsById, partitionHash); return Collections.singleton(endPoint); }
ConsistentHashPartitionFilter implements PartitionFilter { @Override public Iterable<ServiceEndPoint> filter(Iterable<ServiceEndPoint> endPoints, PartitionContext partitionContext) { HashCode partitionHash = getPartitionHash(partitionContext); if (partitionHash == null) { return endPoints; } Map<String, ServiceEndPoint> endPointsById = indexById(endPoints); ServiceEndPoint endPoint = choose(endPointsById, partitionHash); return Collections.singleton(endPoint); } }
ConsistentHashPartitionFilter implements PartitionFilter { @Override public Iterable<ServiceEndPoint> filter(Iterable<ServiceEndPoint> endPoints, PartitionContext partitionContext) { HashCode partitionHash = getPartitionHash(partitionContext); if (partitionHash == null) { return endPoints; } Map<String, ServiceEndPoint> endPointsById = indexById(endPoints); ServiceEndPoint endPoint = choose(endPointsById, partitionHash); return Collections.singleton(endPoint); } ConsistentHashPartitionFilter();  ConsistentHashPartitionFilter(String... partitionKeys);  ConsistentHashPartitionFilter(List<String> partitionKeys); private  ConsistentHashPartitionFilter(List<String> partitionKeys, int entriesPerEndPoint); }
ConsistentHashPartitionFilter implements PartitionFilter { @Override public Iterable<ServiceEndPoint> filter(Iterable<ServiceEndPoint> endPoints, PartitionContext partitionContext) { HashCode partitionHash = getPartitionHash(partitionContext); if (partitionHash == null) { return endPoints; } Map<String, ServiceEndPoint> endPointsById = indexById(endPoints); ServiceEndPoint endPoint = choose(endPointsById, partitionHash); return Collections.singleton(endPoint); } ConsistentHashPartitionFilter();  ConsistentHashPartitionFilter(String... partitionKeys);  ConsistentHashPartitionFilter(List<String> partitionKeys); private  ConsistentHashPartitionFilter(List<String> partitionKeys, int entriesPerEndPoint); @Override Iterable<ServiceEndPoint> filter(Iterable<ServiceEndPoint> endPoints, PartitionContext partitionContext); }
ConsistentHashPartitionFilter implements PartitionFilter { @Override public Iterable<ServiceEndPoint> filter(Iterable<ServiceEndPoint> endPoints, PartitionContext partitionContext) { HashCode partitionHash = getPartitionHash(partitionContext); if (partitionHash == null) { return endPoints; } Map<String, ServiceEndPoint> endPointsById = indexById(endPoints); ServiceEndPoint endPoint = choose(endPointsById, partitionHash); return Collections.singleton(endPoint); } ConsistentHashPartitionFilter();  ConsistentHashPartitionFilter(String... partitionKeys);  ConsistentHashPartitionFilter(List<String> partitionKeys); private  ConsistentHashPartitionFilter(List<String> partitionKeys, int entriesPerEndPoint); @Override Iterable<ServiceEndPoint> filter(Iterable<ServiceEndPoint> endPoints, PartitionContext partitionContext);  }