@Test void testEligibleMembersCorrectlyOrdered() { Collection<ConsistentHash.ConsistentHashMember> actual = testSubject.getEligibleMembers("someOtherKey"); assertEquals(asList("member2", "member1", "member3"), actual.stream().map(ConsistentHash.ConsistentHashMember::name).collect(Collectors.toList())); }
public Collection<ConsistentHashMember> getEligibleMembers(String routingKey) { String hash = hash(routingKey); Collection<ConsistentHashMember> tail = hashToMember.tailMap(hash).values(); Collection<ConsistentHashMember> head = hashToMember.headMap(hash).values(); LinkedHashSet<ConsistentHashMember> combined = new LinkedHashSet<>(tail); combined.addAll(head); return combined; }
ConsistentHash { public Collection<ConsistentHashMember> getEligibleMembers(String routingKey) { String hash = hash(routingKey); Collection<ConsistentHashMember> tail = hashToMember.tailMap(hash).values(); Collection<ConsistentHashMember> head = hashToMember.headMap(hash).values(); LinkedHashSet<ConsistentHashMember> combined = new LinkedHashSet<>(tail); combined.addAll(head); return combined; } }
ConsistentHash { public Collection<ConsistentHashMember> getEligibleMembers(String routingKey) { String hash = hash(routingKey); Collection<ConsistentHashMember> tail = hashToMember.tailMap(hash).values(); Collection<ConsistentHashMember> head = hashToMember.headMap(hash).values(); LinkedHashSet<ConsistentHashMember> combined = new LinkedHashSet<>(tail); combined.addAll(head); return combined; } ConsistentHash();  ConsistentHash(Function<String, String> hashFunction); private  ConsistentHash(Map<String, ConsistentHashMember> members,
                           Function<String, String> hashFunction, int modCount); }
ConsistentHash { public Collection<ConsistentHashMember> getEligibleMembers(String routingKey) { String hash = hash(routingKey); Collection<ConsistentHashMember> tail = hashToMember.tailMap(hash).values(); Collection<ConsistentHashMember> head = hashToMember.headMap(hash).values(); LinkedHashSet<ConsistentHashMember> combined = new LinkedHashSet<>(tail); combined.addAll(head); return combined; } ConsistentHash();  ConsistentHash(Function<String, String> hashFunction); private  ConsistentHash(Map<String, ConsistentHashMember> members,
                           Function<String, String> hashFunction, int modCount); Collection<ConsistentHashMember> getEligibleMembers(String routingKey); Optional<Member> getMember(String routingKey, CommandMessage<?> commandMessage); Set<Member> getMembers(); ConsistentHash with(Member member, int loadFactor, CommandMessageFilter commandFilter); ConsistentHash without(Member member); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); int version(); }
ConsistentHash { public Collection<ConsistentHashMember> getEligibleMembers(String routingKey) { String hash = hash(routingKey); Collection<ConsistentHashMember> tail = hashToMember.tailMap(hash).values(); Collection<ConsistentHashMember> head = hashToMember.headMap(hash).values(); LinkedHashSet<ConsistentHashMember> combined = new LinkedHashSet<>(tail); combined.addAll(head); return combined; } ConsistentHash();  ConsistentHash(Function<String, String> hashFunction); private  ConsistentHash(Map<String, ConsistentHashMember> members,
                           Function<String, String> hashFunction, int modCount); Collection<ConsistentHashMember> getEligibleMembers(String routingKey); Optional<Member> getMember(String routingKey, CommandMessage<?> commandMessage); Set<Member> getMembers(); ConsistentHash with(Member member, int loadFactor, CommandMessageFilter commandFilter); ConsistentHash without(Member member); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); int version();  }