ctubbsii commented on code in PR #5423:
URL: https://github.com/apache/accumulo/pull/5423#discussion_r2011086233


##########
core/src/main/java/org/apache/accumulo/core/clientImpl/ClientTabletCacheImpl.java:
##########
@@ -479,57 +445,44 @@ public List<Range> findTablets(ClientContext context, 
List<Range> ranges,
 
   @Override
   public void invalidateCache(KeyExtent failedExtent) {
-    wLock.lock();
-    try {
-      badExtents.add(failedExtent);
-    } finally {
-      wLock.unlock();
-    }
+    removeOverlapping(metaCache, failedExtent);
     if (log.isTraceEnabled()) {
       log.trace("Invalidated extent={}", failedExtent);
     }
   }
 
   @Override
   public void invalidateCache(Collection<KeyExtent> keySet) {
-    wLock.lock();
-    try {
-      badExtents.addAll(keySet);
-    } finally {
-      wLock.unlock();
-    }
+    keySet.forEach(extent -> removeOverlapping(metaCache, extent));
     if (log.isTraceEnabled()) {
       log.trace("Invalidated {} cache entries for table {}", keySet.size(), 
tableId);
     }
   }
 
   @Override
   public void invalidateCache(ClientContext context, String server) {
-
-    wLock.lock();
-    try {
-      badServers.add(server);
-    } finally {
-      wLock.unlock();
+    var iter = metaCache.values().iterator();
+    int removed = 0;
+    while (iter.hasNext()) {
+      var cachedTablet = iter.next();
+      if (cachedTablet.getTserverLocation().isPresent()
+          && cachedTablet.getTserverLocation().orElseThrow().equals(server)) {
+        iter.remove();
+        removed++;
+      }
     }

Review Comment:
   I tried to make this more succinct, and came up with this:
   
   ```suggestion
       var removed = new AtomicInteger();
       metaCache.values()
           .removeIf(tablet -> 
tablet.getTserverLocation().filter(server::equals).isPresent()
               && removed.incrementAndGet() > 0);
   ```
   
   This would be simpler if we weren't trying to keep track of the removed 
count:
   
   ```suggestion
       metaCache.values()
           .removeIf(tablet -> 
tablet.getTserverLocation().filter(server::equals).isPresent());
   ```
   
   Do we really need to track the count of those removed? It's a lot simpler 
code if not. It doesn't look like the old code kept the size per-table. Or, can 
we just compare the before/after size to log the count?



##########
core/src/main/java/org/apache/accumulo/core/clientImpl/ClientTabletCacheImpl.java:
##########
@@ -95,27 +96,20 @@ public class ClientTabletCacheImpl extends 
ClientTabletCache {
 
   protected final TableId tableId;
   protected final ClientTabletCache parent;
-  protected final TreeMap<Text,CachedTablet> metaCache = new 
TreeMap<>(END_ROW_COMPARATOR);
+  protected final ConcurrentSkipListMap<Text,CachedTablet> metaCache =
+      new ConcurrentSkipListMap<>(END_ROW_COMPARATOR);
   protected final CachedTabletObtainer tabletObtainer;
   private final TabletServerLockChecker lockChecker;
   protected final Text lastTabletRow;
 
-  private final TreeSet<KeyExtent> badExtents = new TreeSet<>();
-  private final HashSet<String> badServers = new HashSet<>();
   private final ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();

Review Comment:
   This is no longer used, and should be deleted too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to