mxsm commented on code in PR #6291:
URL: https://github.com/apache/rocketmq/pull/6291#discussion_r1130334151
##########
client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java:
##########
@@ -22,27 +22,18 @@
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
+
import org.apache.rocketmq.client.common.ThreadLocalIndex;
public class LatencyFaultToleranceImpl implements
LatencyFaultTolerance<String> {
- private final ConcurrentHashMap<String, FaultItem> faultItemTable = new
ConcurrentHashMap<>(16);
+ private final ConcurrentHashMap<String/*broker name*/, FaultItem>
faultItemTable = new ConcurrentHashMap<>(16);
private final ThreadLocalIndex randomItem = new ThreadLocalIndex();
@Override
public void updateFaultItem(final String name, final long currentLatency,
final long notAvailableDuration) {
- FaultItem old = this.faultItemTable.get(name);
- if (null == old) {
- final FaultItem faultItem = new FaultItem(name);
- faultItem.setCurrentLatency(currentLatency);
- faultItem.setStartTimestamp(System.currentTimeMillis() +
notAvailableDuration);
-
- old = this.faultItemTable.putIfAbsent(name, faultItem);
- if (old != null) {
- old.setCurrentLatency(currentLatency);
- old.setStartTimestamp(System.currentTimeMillis() +
notAvailableDuration);
- }
- } else {
+ FaultItem old = this.faultItemTable.putIfAbsent(name, new
FaultItem(name, currentLatency, System.currentTimeMillis() +
notAvailableDuration));
Review Comment:
@drpmma thanks for you suggestion. I will fix it and resubmit later
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]