modify variable name whichItemWorst to randomItem to resolve ambiguity (#5436)

This commit is contained in:
jasonjavaYY
2022-11-07 15:22:31 +08:00
committed by GitHub
parent 08bcd80681
commit 0d44ea183e
@@ -27,7 +27,7 @@ import org.apache.rocketmq.client.common.ThreadLocalIndex;
public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String> {
private final ConcurrentHashMap<String, FaultItem> faultItemTable = new ConcurrentHashMap<>(16);
private final ThreadLocalIndex whichItemWorst = new ThreadLocalIndex();
private final ThreadLocalIndex randomItem = new ThreadLocalIndex();
@Override
public void updateFaultItem(final String name, final long currentLatency, final long notAvailableDuration) {
@@ -76,7 +76,7 @@ public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String>
if (half <= 0) {
return tmpList.get(0).getName();
} else {
final int i = this.whichItemWorst.incrementAndGet() % half;
final int i = this.randomItem.incrementAndGet() % half;
return tmpList.get(i).getName();
}
}
@@ -87,7 +87,7 @@ public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String>
public String toString() {
return "LatencyFaultToleranceImpl{" +
"faultItemTable=" + faultItemTable +
", whichItemWorst=" + whichItemWorst +
", whichItemWorst=" + randomItem +
'}';
}