Skip to content

Commit

Permalink
simplify markShardAsEvictedInCache
Browse files Browse the repository at this point in the history
  • Loading branch information
tlrx committed Dec 10, 2020
1 parent 082e0c8 commit 393deaf
Showing 1 changed file with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.SortedSet;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;
Expand Down Expand Up @@ -298,14 +293,8 @@ public void removeFromCache(final CacheKey cacheKey) {
* @param shardId the {@link SnapshotId}
*/
public void markShardAsEvictedInCache(SnapshotId snapshotId, IndexId indexId, ShardId shardId) {
boolean markedAsEvicted = false;
final ShardEviction shardEviction = new ShardEviction(snapshotId, indexId, shardId);
try (Releasable ignored = shardsEvictionLock.acquire(shardEviction)) {
if (evictedShards.add(shardEviction)) {
markedAsEvicted = true;
}
}
if (markedAsEvicted) {
if (evictedShards.add(shardEviction)) {
threadPool.generic().submit(new AbstractRunnable() {
@Override
protected void doRun() {
Expand All @@ -325,7 +314,6 @@ protected void doRun() {
assert e instanceof IOException : e;
logger.warn(() -> new ParameterizedMessage("failed to evict cache file {}", cacheFile.getKey()), e);
}

}
}
});
Expand Down

0 comments on commit 393deaf

Please sign in to comment.