@Test public void roundRobinTest() { RpcClientConnectionPoolStub pool = new RpcClientConnectionPoolStub(); RpcSenderStub connection1 = new RpcSenderStub(); RpcSenderStub connection2 = new RpcSenderStub(); RpcSenderStub connection3 = new RpcSenderStub(); RpcSenderStub connection4 = new RpcSenderStub(); RpcSenderStub connection5 = new RpcSenderStub(); pool.put(ADDRESS_1, connection1); pool.put(ADDRESS_2, connection2); pool.put(ADDRESS_3, connection3); pool.put(ADDRESS_4, connection4); pool.put(ADDRESS_5, connection5); int iterations = 100; RpcStrategy strategy = roundRobin(servers(ADDRESS_1, ADDRESS_2, ADDRESS_3, ADDRESS_4, ADDRESS_5)); RpcSender sender = strategy.createSender(pool); for (int i = 0; i < iterations; i++) { sender.sendRequest(new Object(), 50, ignore()); } List<RpcSenderStub> connections = asList(connection1, connection2, connection3, connection4, connection5); for (int i = 0; i < 5; i++) { assertEquals(iterations / 5, connections.get(i).getRequests()); } }
public static RpcStrategyRoundRobin roundRobin(RpcStrategy... senders) { return roundRobin(asList(senders)); }
RpcStrategies { public static RpcStrategyRoundRobin roundRobin(RpcStrategy... senders) { return roundRobin(asList(senders)); } }
RpcStrategies { public static RpcStrategyRoundRobin roundRobin(RpcStrategy... senders) { return roundRobin(asList(senders)); }  }
RpcStrategies { public static RpcStrategyRoundRobin roundRobin(RpcStrategy... senders) { return roundRobin(asList(senders)); }  static RpcStrategySingleServer server(@NotNull InetSocketAddress address); static RpcStrategyList servers(InetSocketAddress... addresses); static RpcStrategyList servers(List<InetSocketAddress> addresses); static RpcStrategyFirstAvailable firstAvailable(RpcStrategy... senders); static RpcStrategyFirstAvailable firstAvailable(List<RpcStrategy> strategies); static RpcStrategyFirstAvailable firstAvailable(RpcStrategyList list); static RpcStrategyFirstValidResult firstValidResult(RpcStrategy... senders); static RpcStrategyFirstValidResult firstValidResult(List<RpcStrategy> senders); static RpcStrategyFirstValidResult firstValidResult(RpcStrategyList list); static RpcStrategyRoundRobin roundRobin(RpcStrategy... senders); static RpcStrategyRoundRobin roundRobin(List<RpcStrategy> senders); static RpcStrategyRoundRobin roundRobin(RpcStrategyList list); static RpcStrategySharding sharding(ShardingFunction<?> hashFunction,
			RpcStrategy... senders); static RpcStrategySharding sharding(@NotNull ShardingFunction<?> hashFunction,
			@NotNull List<RpcStrategy> senders); static RpcStrategySharding sharding(@NotNull ShardingFunction<?> hashFunction,
			@NotNull RpcStrategyList list); static RpcStrategyRendezvousHashing rendezvousHashing(@NotNull HashFunction<?> hashFunction); static RpcStrategyTypeDispatching typeDispatching(); static RpcStrategyRandomSampling randomSampling(); }
RpcStrategies { public static RpcStrategyRoundRobin roundRobin(RpcStrategy... senders) { return roundRobin(asList(senders)); }  static RpcStrategySingleServer server(@NotNull InetSocketAddress address); static RpcStrategyList servers(InetSocketAddress... addresses); static RpcStrategyList servers(List<InetSocketAddress> addresses); static RpcStrategyFirstAvailable firstAvailable(RpcStrategy... senders); static RpcStrategyFirstAvailable firstAvailable(List<RpcStrategy> strategies); static RpcStrategyFirstAvailable firstAvailable(RpcStrategyList list); static RpcStrategyFirstValidResult firstValidResult(RpcStrategy... senders); static RpcStrategyFirstValidResult firstValidResult(List<RpcStrategy> senders); static RpcStrategyFirstValidResult firstValidResult(RpcStrategyList list); static RpcStrategyRoundRobin roundRobin(RpcStrategy... senders); static RpcStrategyRoundRobin roundRobin(List<RpcStrategy> senders); static RpcStrategyRoundRobin roundRobin(RpcStrategyList list); static RpcStrategySharding sharding(ShardingFunction<?> hashFunction,
			RpcStrategy... senders); static RpcStrategySharding sharding(@NotNull ShardingFunction<?> hashFunction,
			@NotNull List<RpcStrategy> senders); static RpcStrategySharding sharding(@NotNull ShardingFunction<?> hashFunction,
			@NotNull RpcStrategyList list); static RpcStrategyRendezvousHashing rendezvousHashing(@NotNull HashFunction<?> hashFunction); static RpcStrategyTypeDispatching typeDispatching(); static RpcStrategyRandomSampling randomSampling();  }