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

Aniruddha commented on BOOKKEEPER-407:
--------------------------------------

Strictly speaking, the synchronized block is not needed. So, if we want 
performance, we can remove the synchronized block altogether. host2Topics is a 
cached structure and it is used only while clearing all topics so even if we 
end up in an inconsistent state, what we will do is not remove a topic2Host 
mapping, but because we are using a put()/replace() this will be remedied the 
next time we try to do any operation. Usage of either is fine. The only reason 
I suggested a put() was to avoid the CAS. 

remove() on a ConcurrentLinkedQueue() will be an O(n) operation AFAIK. In a 
HashedSet, it will be O(1). add() will be O(1) in both. The usage of HashedSet 
makes remove() faster and hence clearTopicForHost() faster. Having multiple 
values of the same topic in host2Topics is alright because it is used only to 
remove the topic2Host mapping. 
                
> Hedwig client doesn't remove old topic2Host mapping in case of redirect
> -----------------------------------------------------------------------
>
>                 Key: BOOKKEEPER-407
>                 URL: https://issues.apache.org/jira/browse/BOOKKEEPER-407
>             Project: Bookkeeper
>          Issue Type: Bug
>    Affects Versions: 4.2.0
>            Reporter: Aniruddha
>             Fix For: 4.2.0
>
>         Attachments: BK-407.patch
>
>
> In the storeTopic2HostMapping function, there is a topic2Host.putIfAbsent(). 
> This doesn't seem correct as we should always update the mapping in case of a 
> redirect. 
> Reviewboard : https://reviews.apache.org/r/7139/

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to