[
https://issues.apache.org/jira/browse/BOOKKEEPER-304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13439326#comment-13439326
]
Rakesh R commented on BOOKKEEPER-304:
-------------------------------------
@Ivan
Thanks for the comments.
Point-1) yeah, I agree to use Collections.synchronizedSet() and will do the
necessary changes.
Point-2) But having doubt whether to use ConcurrentHashMap or not?
Here bookie2ledgersMap.put(bookie, ledgers); is getting called inside
synchronized block as follows, I couldn't see any necessity of
concurrentHashMap. I'm missing anything?
I'm having double check to avoid two guys are seeing null simultaneously. Even
if I'm having ConcurrentHashMap, say if two guys has come and invoked map#get()
method. Both will see null one after another and continue for creating their
own separate HasSet. Isn't it?
{code}
Set<Long> ledgers = bookie2ledgersMap.get(bookie);
// creates an empty list and add to bookie for keeping its ledgers
if (ledgers == null) {
synchronized (bookie2ledgersMap) {
// double check whether the ledgerset exists or not
ledgers = bookie2ledgersMap.get(bookie);
if (ledgers == null) {
edgers = new HashSet<Long>();
bookie2ledgersMap.put(bookie, ledgers);
}
}
}
{code}
Could you please give your thoughts?
Thanks
Rakesh
> Prepare bookie vs ledgers cache and will be used by the Auditor
> ---------------------------------------------------------------
>
> Key: BOOKKEEPER-304
> URL: https://issues.apache.org/jira/browse/BOOKKEEPER-304
> Project: Bookkeeper
> Issue Type: Sub-task
> Components: bookkeeper-server
> Reporter: Rakesh R
> Assignee: Rakesh R
> Fix For: 4.2.0
>
> Attachments: BOOKKEEPER-304.1.patch, BOOKKEEPER-304.2.patch,
> BOOKKEEPER-304.2.patch, BOOKKEEPER-304.3.patch
>
>
> This JIRA discusses how to build bookie -> ledgers cache and this will be
> used by the Auditor to publish the suspected ledgers of failed bookies.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira