sanpwc commented on code in PR #3423:
URL: https://github.com/apache/ignite-3/pull/3423#discussion_r1527962536
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/impl/core/AppendEntriesRequestProcessor.java:
##########
@@ -322,41 +322,19 @@ void sendSequenceResponse(final String groupId, final
PeerPair pair, final int s
}
}
- PeerRequestContext getOrCreatePeerRequestContext(final String groupId,
final PeerPair pair,
- NodeManager nodeManager) {
- ConcurrentMap<PeerPair, PeerRequestContext> groupContexts =
this.peerRequestContexts.get(groupId);
- if (groupContexts == null) {
- groupContexts = new ConcurrentHashMap<>();
- final ConcurrentMap<PeerPair, PeerRequestContext> existsCtxs =
this.peerRequestContexts.putIfAbsent(
- groupId, groupContexts);
- if (existsCtxs != null) {
- groupContexts = existsCtxs;
- }
- }
+ PeerRequestContext getOrCreatePeerRequestContext(final String groupId,
final PeerPair pair, Node node) {
+ ConcurrentMap<PeerPair, PeerRequestContext> groupContexts =
+ this.peerRequestContexts.computeIfAbsent(groupId, s -> new
ConcurrentHashMap<>());
- PeerRequestContext peerCtx = groupContexts.get(pair);
- if (peerCtx == null) {
- synchronized (Utils.withLockObject(groupContexts)) {
- peerCtx = groupContexts.get(pair);
- // double check in lock
- if (peerCtx == null) {
- // only one thread to process append entries for every
jraft node
- final PeerId peer = new PeerId();
- final boolean parsed = peer.parse(pair.local);
- assert (parsed);
- final Node node = nodeManager.get(groupId, peer);
- assert (node != null);
- peerCtx = new PeerRequestContext(groupId, pair,
node.getRaftOptions().getMaxReplicatorInflightMsgs());
-
- peerCtx.executor =
node.getOptions().getStripedExecutor().next();
-
- groupContexts.put(pair, peerCtx);
- }
- }
- }
+ return groupContexts.computeIfAbsent(pair, peerPair -> {
Review Comment:
In original code we've parsed the peer. Seems that given code is missing in
proposed solution. Why?
--
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]