[
https://issues.apache.org/jira/browse/BOOKKEEPER-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13448270#comment-13448270
]
Sijie Guo commented on BOOKKEEPER-392:
--------------------------------------
@Stu, the changes looks good.
But I had a question about storeTopic2HostMapping
{code}
+ if (topic2Host.putIfAbsent(pubSubData.topic, host) == null) {
+ if (logger.isDebugEnabled())
+ logger.debug("Stored info for topic: " +
pubSubData.topic.toStringUtf8() + ", old host: "
+ + existingHost + ", new host: " + host);
+ }
+ ConcurrentLinkedQueue<ByteString> topicsForHost =
host2Topics.get(host);
+ if (topicsForHost == null) {
+ ConcurrentLinkedQueue<ByteString> newTopicsList = new
ConcurrentLinkedQueue<ByteString>();
+ topicsForHost = host2Topics.putIfAbsent(host, newTopicsList);
+ if (topicsForHost == null) {
+ topicsForHost = newTopicsList;
+ }
}
+ topicsForHost.add(pubSubData.topic);
}
{code}
if we failed to put host into topic2Host, I don't think we need to put it into
host2Topics. And seems that you had assumption that there is not entry for the
given host in topic2Host, which is a bit strict.
I had a different change when working for BOOKKEEPER-70.
https://github.com/sijie/bookkeeper/commit/5ac124f2013f4f1d39559c908320dd91184f806c#L6R452
(my changes for clearAllTopicsForHost has a bit problem. It should use
conditional remove #remove(key, oldvalue) to remove from concurrent map in my
changes)
Could you take a look at it? How is your opinion?
> Racey ConcurrentMap usage in java hedwig-client
> -----------------------------------------------
>
> Key: BOOKKEEPER-392
> URL: https://issues.apache.org/jira/browse/BOOKKEEPER-392
> Project: Bookkeeper
> Issue Type: Bug
> Components: hedwig-client
> Reporter: Stu Hood
> Attachments: 392.diff
>
>
> The java hedwig-client misuses ConcurrentMap in various ways.
--
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