@Test public void testServiceIdConflict() { ConsistentHashPartitionFilter filter = new ConsistentHashPartitionFilter(); assertEquals(singleton(FOO), filter.filter(ImmutableList.of(FOO, BAR), PartitionContextBuilder.of("a"))); assertEquals(singleton(FOO), filter.filter(ImmutableList.of(FOO2, FOO, BAR), PartitionContextBuilder.of("a"))); assertEquals(singleton(FOO2), filter.filter(ImmutableList.of(FOO2, BAR), PartitionContextBuilder.of("a"))); }
@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);  }