SortArrayMapConsistentHash extends AbstractConsistentHash { @Override public String getFirstNodeValue(String value) { long hash = super.hash(value); System.out.println("value=" + value + " hash = " + hash); return sortArrayMap.firstNodeValue(hash); }  @Override void add(long key, String value); @Override void sort(); @Override String getFirstNodeValue(String value);  }
@Test public void getFirstNodeValue() { AbstractConsistentHash map = new SortArrayMapConsistentHash() ; List<String> strings = new ArrayList<String>(); for (int i = 0; i < 10; i++) { strings.add("127.0.0." + i) ; } String process = map.process(strings,"zhangsan"); System.out.println(process); Assert.assertEquals("127.0.0.2",process); }