accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhutchis <...@git.apache.org>
Subject [GitHub] accumulo pull request: ACCUMULO-4229 BatchWriter Locator cache out...
Date Thu, 28 Apr 2016 19:24:05 GMT
Github user dhutchis commented on the pull request:

    https://github.com/apache/accumulo/pull/96#issuecomment-215535249
  
    > An alternative solution to introducing SyncingTabletLocator could be to change the
implementation of clearLocators to the following. This clears all of the caches while still
maintaining the references to in uses locators.
    > 
    >      public static synchronized void clearLocators() {
    >         for(TabletLocator tl : locators.values()) {
    >           tl.invalidateCache();
    >         }
    >      }
    > If worried about empty tablet location caches being left around in the locators map,
that could possible be changed to a weak hash map.
    
    You could be on to something @keith-turner if we give it more thought.  The original reason
why the `locators` cache is cleared every hour is to remove TabletLocators that refer to tablets
that don't exist or are rarely accessed, ya?
    
    A WeakHashMap wouldn't work because it uses weak references for the keys. This would mean
that the gc could reclaim keys as soon as the `getLocator` method returns, which is inefficient
for a cache and has correctness issues if the static `invalidate` methods are called.
    
    What do you think of switching locators to a [Guava cache](https://github.com/google/guava/wiki/CachesExplained)
with a 1 hour timeout on entries since their last access?
    
    I think this would let us remove the `synchronized` from `getLocator` because Guava caches
are thread-safe and designed for concurrency.  It would eliminate the need for any `clearLocators`
call (and `SyncingTabletLocator`).  


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message