@Test public void testWeightedHostsWithNonZeroWeights() { Map<InetSocketAddress, CassandraClientPoolingContainer> pools = ImmutableMap.of( new InetSocketAddress(0), createMockClientPoolingContainerWithUtilization(5), new InetSocketAddress(1), createMockClientPoolingContainerWithUtilization(10), new InetSocketAddress(2), createMockClientPoolingContainerWithUtilization(15)); NavigableMap<Integer, InetSocketAddress> result = WeightedHosts.create(pools).hosts; int prevKey = 0; for (Map.Entry<Integer, InetSocketAddress> entry : result.entrySet()) { int currWeight = entry.getKey() - prevKey; assertThat(currWeight, Matchers.greaterThan(0)); prevKey = entry.getKey(); } }
public static WeightedHosts create(Map<InetSocketAddress, CassandraClientPoolingContainer> pools) { Preconditions.checkArgument(!pools.isEmpty(), "pools should be non-empty"); return new WeightedHosts(buildHostsWeightedByActiveConnections(pools)); }
WeightedHosts { public static WeightedHosts create(Map<InetSocketAddress, CassandraClientPoolingContainer> pools) { Preconditions.checkArgument(!pools.isEmpty(), "pools should be non-empty"); return new WeightedHosts(buildHostsWeightedByActiveConnections(pools)); } }
WeightedHosts { public static WeightedHosts create(Map<InetSocketAddress, CassandraClientPoolingContainer> pools) { Preconditions.checkArgument(!pools.isEmpty(), "pools should be non-empty"); return new WeightedHosts(buildHostsWeightedByActiveConnections(pools)); } private  WeightedHosts(NavigableMap<Integer, InetSocketAddress> hosts); }
WeightedHosts { public static WeightedHosts create(Map<InetSocketAddress, CassandraClientPoolingContainer> pools) { Preconditions.checkArgument(!pools.isEmpty(), "pools should be non-empty"); return new WeightedHosts(buildHostsWeightedByActiveConnections(pools)); } private  WeightedHosts(NavigableMap<Integer, InetSocketAddress> hosts); static WeightedHosts create(Map<InetSocketAddress, CassandraClientPoolingContainer> pools); InetSocketAddress getRandomHost(); }
WeightedHosts { public static WeightedHosts create(Map<InetSocketAddress, CassandraClientPoolingContainer> pools) { Preconditions.checkArgument(!pools.isEmpty(), "pools should be non-empty"); return new WeightedHosts(buildHostsWeightedByActiveConnections(pools)); } private  WeightedHosts(NavigableMap<Integer, InetSocketAddress> hosts); static WeightedHosts create(Map<InetSocketAddress, CassandraClientPoolingContainer> pools); InetSocketAddress getRandomHost();  }