[ 
https://issues.apache.org/jira/browse/RATIS-134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16243218#comment-16243218
 ] 

Tsz Wo Nicholas Sze commented on RATIS-134:
-------------------------------------------

Thanks for the update.  The patch looks good.  Need some more your help below:

# Let's rename PeerProxyMap.putIfAbsent to computeIfAbsent.
# Let's call PeerProxyMap.computeIfAbsent in addPeers.
# The resetProxy method also have a call to peers.put.  Could you also change 
it to call PeerProxyMap.computeIfAbsent?


> PeerProxyMap#addPeers should add peers only if it is not already present in 
> the proxymap
> ----------------------------------------------------------------------------------------
>
>                 Key: RATIS-134
>                 URL: https://issues.apache.org/jira/browse/RATIS-134
>             Project: Ratis
>          Issue Type: Bug
>            Reporter: Mukul Kumar Singh
>            Assignee: Mukul Kumar Singh
>         Attachments: RATIS-134.001.patch, RATIS-134.002.patch
>
>
> {{PeerProxyMap#addPeers}} currently adds peers to the proxyMap without 
> checkint the current state. This should be optimized to allow addition only 
> if the peer is not present in the proxyMap.
> {code}
>   public void addPeers(Iterable<RaftPeer> newPeers) {
>     for(RaftPeer p : newPeers) {
>       peers.put(p.getId(), new PeerAndProxy(p));
>     }
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to