SOLR-10104: BlockDirectoryCache release hooks do not work with multiple directories.

# Conflicts:
#	solr/CHANGES.txt
This commit is contained in:
markrmiller 2017-02-14 11:33:18 -05:00
parent a243befdbb
commit a1f114f70f
3 changed files with 9 additions and 5 deletions

View File

@ -157,6 +157,8 @@ Bug Fixes
* SOLR-10063: CoreContainer shutdown has race condition that can cause a hang on shutdown. (Mark Miller)
* SOLR-10104: BlockDirectoryCache release hooks do not work with multiple directories. (Mike Drob, Mark Miller)
Optimizations
----------------------

View File

@ -17,6 +17,8 @@
package org.apache.solr.store.blockcache;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import com.github.benmanes.caffeine.cache.Cache;
@ -38,8 +40,8 @@ public class BlockCache {
private final int numberOfBlocksPerBank;
private final int maxEntries;
private final Metrics metrics;
private volatile OnRelease onRelease;
private final List<OnRelease> onReleases = new CopyOnWriteArrayList<>();
public static interface OnRelease {
public void release(BlockCacheKey blockCacheKey);
}
@ -95,7 +97,7 @@ public class BlockCache {
location.setRemoved(true);
locks[bankId].clear(block);
lockCounters[bankId].decrementAndGet();
if (onRelease != null) {
for (OnRelease onRelease : onReleases) {
onRelease.release(blockCacheKey);
}
metrics.blockCacheEviction.incrementAndGet();
@ -239,6 +241,6 @@ public class BlockCache {
}
void setOnRelease(OnRelease onRelease) {
this.onRelease = onRelease;
this.onReleases.add(onRelease);
}
}

View File

@ -457,7 +457,7 @@ public class MiniSolrCloudCluster {
}
} finally {
executor.shutdown();
executor.awaitTermination(2, TimeUnit.SECONDS);
executor.awaitTermination(15, TimeUnit.SECONDS);
try {
if (!externalZkServer) {
zkServer.shutdown();