@Test public void testTokenAware() throws Exception { TreeMap<HostToken, HostConnectionPool<Integer>> pools = new TreeMap<HostToken, HostConnectionPool<Integer>>(new Comparator<HostToken>() { @Override public int compare(HostToken o1, HostToken o2) { return o1.getHost().getHostAddress().compareTo(o2.getHost().getHostAddress()); } }); pools.put(h1, getMockHostConnectionPool(h1)); pools.put(h2, getMockHostConnectionPool(h2)); pools.put(h3, getMockHostConnectionPool(h3)); pools.put(h4, getMockHostConnectionPool(h4)); TokenAwareSelection<Integer> tokenAwareSelector = new TokenAwareSelection<Integer>(); tokenAwareSelector.initWithHosts(pools); Map<String, Integer> result = new HashMap<String, Integer>(); runTest(0L, 100000L, result, tokenAwareSelector); System.out.println("Token distribution: " + result); verifyTokenDistribution(result.values()); }
@Override public void initWithHosts(Map<HostToken, HostConnectionPool<CL>> hPools) { tokenPools.putAll(CollectionUtils.transformMapKeys(hPools, new Transform<HostToken, Long>() { @Override public Long get(HostToken x) { return x.getToken(); } })); this.tokenMapper.initSearchMechanism(hPools.keySet()); }
TokenAwareSelection implements HostSelectionStrategy<CL> { @Override public void initWithHosts(Map<HostToken, HostConnectionPool<CL>> hPools) { tokenPools.putAll(CollectionUtils.transformMapKeys(hPools, new Transform<HostToken, Long>() { @Override public Long get(HostToken x) { return x.getToken(); } })); this.tokenMapper.initSearchMechanism(hPools.keySet()); } }
TokenAwareSelection implements HostSelectionStrategy<CL> { @Override public void initWithHosts(Map<HostToken, HostConnectionPool<CL>> hPools) { tokenPools.putAll(CollectionUtils.transformMapKeys(hPools, new Transform<HostToken, Long>() { @Override public Long get(HostToken x) { return x.getToken(); } })); this.tokenMapper.initSearchMechanism(hPools.keySet()); } TokenAwareSelection();  TokenAwareSelection(HashPartitioner hashPartitioner); }
TokenAwareSelection implements HostSelectionStrategy<CL> { @Override public void initWithHosts(Map<HostToken, HostConnectionPool<CL>> hPools) { tokenPools.putAll(CollectionUtils.transformMapKeys(hPools, new Transform<HostToken, Long>() { @Override public Long get(HostToken x) { return x.getToken(); } })); this.tokenMapper.initSearchMechanism(hPools.keySet()); } TokenAwareSelection();  TokenAwareSelection(HashPartitioner hashPartitioner); @Override void initWithHosts(Map<HostToken, HostConnectionPool<CL>> hPools); @Override HostConnectionPool<CL> getPoolForOperation(BaseOperation<CL, ?> op, String hashtag); @Override Map<HostConnectionPool<CL>, BaseOperation<CL, ?>> getPoolsForOperationBatch(
            Collection<BaseOperation<CL, ?>> ops); @Override List<HostConnectionPool<CL>> getOrderedHostPools(); @Override HostConnectionPool<CL> getPoolForToken(Long token); List<HostConnectionPool<CL>> getPoolsForTokens(Long start, Long end); @Override HostToken getTokenForKey(String key); @Override HostToken getTokenForKey(byte[] key); @Override boolean addHostPool(HostToken hostToken, HostConnectionPool<CL> hostPool); @Override boolean removeHostPool(HostToken hostToken); @Override boolean isTokenAware(); @Override boolean isEmpty(); Long getKeyHash(String key); @Override String toString(); }
TokenAwareSelection implements HostSelectionStrategy<CL> { @Override public void initWithHosts(Map<HostToken, HostConnectionPool<CL>> hPools) { tokenPools.putAll(CollectionUtils.transformMapKeys(hPools, new Transform<HostToken, Long>() { @Override public Long get(HostToken x) { return x.getToken(); } })); this.tokenMapper.initSearchMechanism(hPools.keySet()); } TokenAwareSelection();  TokenAwareSelection(HashPartitioner hashPartitioner); @Override void initWithHosts(Map<HostToken, HostConnectionPool<CL>> hPools); @Override HostConnectionPool<CL> getPoolForOperation(BaseOperation<CL, ?> op, String hashtag); @Override Map<HostConnectionPool<CL>, BaseOperation<CL, ?>> getPoolsForOperationBatch(
            Collection<BaseOperation<CL, ?>> ops); @Override List<HostConnectionPool<CL>> getOrderedHostPools(); @Override HostConnectionPool<CL> getPoolForToken(Long token); List<HostConnectionPool<CL>> getPoolsForTokens(Long start, Long end); @Override HostToken getTokenForKey(String key); @Override HostToken getTokenForKey(byte[] key); @Override boolean addHostPool(HostToken hostToken, HostConnectionPool<CL> hostPool); @Override boolean removeHostPool(HostToken hostToken); @Override boolean isTokenAware(); @Override boolean isEmpty(); Long getKeyHash(String key); @Override String toString();  }