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

Jason Lowe commented on YARN-573:
---------------------------------

bq. I thought about it earlier but we are using iterator internally and we are 
modifying list using that iterator which won't be thread safe. Let me know if 
we should use Collections.synchronizedList or should synchronize on list?

It's OK to iterate over a SynchronizedList as long as one explicitly 
synchronizes the list while iterating.  This is called out in the javadocs for 
SynchronizedList.  Synchronizing on the list will effectively block all other 
threads attempting to access the list until the iteration completes, because 
SynchronizedList methods end up using {{this}} as a mutex.

bq. Yes you are right we should change the constructor to use ConcurrentMap. I 
will fix it together with above question/comment.

I was not so much thinking the constructor should take a ConcurrentMap so much 
as thinking that particular constructor should simply be removed.  It's not 
called by anything else other than the simpler constructor form, and we can 
just have that constructor create the ConcurrentMap directly when it 
initializes the {{pending}} field.
                
> Shared data structures in Public Localizer and Private Localizer are not 
> Thread safe.
> -------------------------------------------------------------------------------------
>
>                 Key: YARN-573
>                 URL: https://issues.apache.org/jira/browse/YARN-573
>             Project: Hadoop YARN
>          Issue Type: Sub-task
>            Reporter: Omkar Vinit Joshi
>            Assignee: Omkar Vinit Joshi
>            Priority: Critical
>         Attachments: YARN-573-20130730.1.patch
>
>
> PublicLocalizer
> 1) pending accessed by addResource (part of event handling) and run method 
> (as a part of PublicLocalizer.run() ).
> PrivateLocalizer
> 1) pending accessed by addResource (part of event handling) and 
> findNextResource (i.remove()). Also update method should be fixed. It too is 
> sharing pending list.

--
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