From 372be0ece71313a8bf64ee923a6ea3468bcb325e Mon Sep 17 00:00:00 2001 From: Aiolos <antfinaiolos@IT-C02V266KG8WN.local> Date: Mon, 15 Jul 2019 16:24:59 +0800 Subject: [PATCH] weight hash version --- .../main/java/com/aliware/tianchi/UserLoadBalance.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/workspace-gateway/src/main/java/com/aliware/tianchi/UserLoadBalance.java b/workspace-gateway/src/main/java/com/aliware/tianchi/UserLoadBalance.java index 401a080..a184f07 100644 --- a/workspace-gateway/src/main/java/com/aliware/tianchi/UserLoadBalance.java +++ b/workspace-gateway/src/main/java/com/aliware/tianchi/UserLoadBalance.java @@ -21,9 +21,9 @@ public class UserLoadBalance implements LoadBalance { @Override public <T> Invoker<T> select(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException { - //int[] invoker_list = {0, 1, 1, 2, 2, 2}; - //int id = ThreadLocalRandom.current().nextInt(invoker_list.length); - //return invokers.get(invoker_list[id]); - return invokers.get(0); + int[] invoker_list = {0, 1, 1, 2, 2, 2}; + int id = ThreadLocalRandom.current().nextInt(6); + //System.out.println("Send one request to " + invoker_list[id]); + return invokers.get(invoker_list[id]); } } -- GitLab