业务上需要一个服务,调用5个第三方,但是调用的次数是按照权重配比去分配的。
配置:
Map<Integer,Integer> flowAllot=new HashMap<>();
flowAllot.put("0", "10");flowAllot.put("1", "20");flowAllot.put("2", "30");
说明:
0出现的概率是 10/60, 1出现的概率是20/60 ,2出现的概率是 30/60
网上搜了大神的,参考链接在最下面。计算最大公约数的时候发现有个问题。
如果配置为 {"1":"0","2":"10"},就会进入死循环。
参考:
原文链接:https://blog.csdn.net/lizhitao/article/details/25412567
求最大公约数:
https://blog.csdn.net/weixin_44221079/article/details/104079250
https://blog.csdn.net/shencomd/article/details/97260065
网友评论