lizhiboo commented on issue #2080: URL: https://github.com/apache/rocketmq/issues/2080#issuecomment-647503113
> source code class > https://github.com/apache/rocketmq/blob/master/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java > > **BUG REPORT** > > source code : > > ` @override > public String pickOneAtLeast() { > final Enumeration elements = this.faultItemTable.elements(); > List tmpList = new LinkedList(); > while (elements.hasMoreElements()) { > final FaultItem faultItem = elements.nextElement(); > tmpList.add(faultItem); > } > > ``` > if (!tmpList.isEmpty()) { > Collections.shuffle(tmpList); > > Collections.sort(tmpList); > > final int half = tmpList.size() / 2; > if (half <= 0) { > return tmpList.get(0).getName(); > } else { > final int i = this.whichItemWorst.getAndIncrement() % half; > return tmpList.get(i).getName(); > } > } > > return null; > } > ``` > > ` > > **FEATURE REQUEST** > > 在 pickOneAtLeast 方法里面,有代码片段如下: > > Collections.shuffle(tmpList); > > Collections.sort(tmpList); > > 对broker列表先打散,再排序,认为就失去了打散的作用,导致总是一个固有顺序,而出现压力都到了一个broker上 > > 认为改为 > > Collections.sort(tmpList); > > 去掉 > > Collections.shuffle(tmpList); 这行没起作用 I think it's a code mistake, it's no meaning call shuffle before sort. Can u submit a PR to fix it? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
