@Test void testNoMemberReturnedWhenNoEligibleMembers() { Optional<Member> actual = testSubject.getMember("routingKey", new GenericCommandMessage<>(new GenericMessage<>("test"), "unknown")); assertFalse(actual.isPresent()); }
public Optional<Member> getMember(String routingKey, CommandMessage<?> commandMessage) { String hash = hash(routingKey); Optional<Member> foundMember = findSuitableMember(commandMessage, hashToMember.tailMap(hash).values()); if (!foundMember.isPresent()) { foundMember = findSuitableMember(commandMessage, hashToMember.headMap(hash).values()); } return foundMember; }
ConsistentHash { public Optional<Member> getMember(String routingKey, CommandMessage<?> commandMessage) { String hash = hash(routingKey); Optional<Member> foundMember = findSuitableMember(commandMessage, hashToMember.tailMap(hash).values()); if (!foundMember.isPresent()) { foundMember = findSuitableMember(commandMessage, hashToMember.headMap(hash).values()); } return foundMember; } }
ConsistentHash { public Optional<Member> getMember(String routingKey, CommandMessage<?> commandMessage) { String hash = hash(routingKey); Optional<Member> foundMember = findSuitableMember(commandMessage, hashToMember.tailMap(hash).values()); if (!foundMember.isPresent()) { foundMember = findSuitableMember(commandMessage, hashToMember.headMap(hash).values()); } return foundMember; } ConsistentHash();  ConsistentHash(Function<String, String> hashFunction); private  ConsistentHash(Map<String, ConsistentHashMember> members,
                           Function<String, String> hashFunction, int modCount); }
ConsistentHash { public Optional<Member> getMember(String routingKey, CommandMessage<?> commandMessage) { String hash = hash(routingKey); Optional<Member> foundMember = findSuitableMember(commandMessage, hashToMember.tailMap(hash).values()); if (!foundMember.isPresent()) { foundMember = findSuitableMember(commandMessage, hashToMember.headMap(hash).values()); } return foundMember; } 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 Optional<Member> getMember(String routingKey, CommandMessage<?> commandMessage) { String hash = hash(routingKey); Optional<Member> foundMember = findSuitableMember(commandMessage, hashToMember.tailMap(hash).values()); if (!foundMember.isPresent()) { foundMember = findSuitableMember(commandMessage, hashToMember.headMap(hash).values()); } return foundMember; } 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();  }