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

Sangjin Lee commented on YARN-2180:
-----------------------------------

bq. Synchronization is missing from the InMemoryStore operations? You are using 
a ConcurrentHashMap but to insert correctly (multiple apps adding a cache-entry 
to the same path) you'll need to use putIfAbsent? Surprised the test is 
presumably passing.

I can answer this question as I wrote the in-memory store. :)

Actually all operations (both access and mutation) on {{map}} are synchronized 
on the interned key. Since keys are unique, there can be no concurrent 
operations operating on the same key when synchronized on the key. Therefore, 
{{putIfAbsent()}} is not necessary (as it is needed if there are concurrent 
operations on the same key).

There can be concurrent operations on the map on *different* keys, and that 
thread-safety is addressed by the {{ConcurrentHashMap}}.

There are a couple of exceptions, and those are {{bootstrap()}} and 
{{clearCache()}}. The {{bootstrap()}} method is an exception because it 
operates on the map before it accepts any reads/writes. The {{clearCache()}} 
method is provided only for test purposes.

Hope this helps.

> In-memory backing store for cache manager
> -----------------------------------------
>
>                 Key: YARN-2180
>                 URL: https://issues.apache.org/jira/browse/YARN-2180
>             Project: Hadoop YARN
>          Issue Type: Sub-task
>            Reporter: Chris Trezzo
>            Assignee: Chris Trezzo
>         Attachments: YARN-2180-trunk-v1.patch, YARN-2180-trunk-v2.patch, 
> YARN-2180-trunk-v3.patch
>
>
> Implement an in-memory backing store for the cache manager.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to