SOLR-8856: Do not cache merge or 'read once' contexts in the hdfs block cache.

This commit is contained in:
markrmiller 2016-03-22 23:05:13 -04:00
parent 99c3bb2371
commit 574da7667f
3 changed files with 36 additions and 1 deletions

View File

@ -64,9 +64,13 @@ Optimizations
----------------------
* SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation.
(Scott Blum via shalin)
* SOLR-8856: Do not cache merge or 'read once' contexts in the hdfs block cache. (Mark Miller)
* SOLR-8745: Deprecate costly ZkStateReader.updateClusterState(), replace with a narrow
forceUpdateCollection(collection) (Scott Blum via shalin)
* SOLR-8856: Do not cache merge or 'read once' contexts in the hdfs block cache. (Mark Miller, Mike Drob)
Other Changes
----------------------

View File

@ -90,12 +90,19 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory implements Sol
public static final String CONFIG_DIRECTORY = "solr.hdfs.confdir";
public static final String CACHE_MERGES = "solr.hdfs.blockcache.cachemerges";
public static final String CACHE_READONCE = "solr.hdfs.blockcache.cachereadonce";
private SolrParams params;
private String hdfsDataDir;
private String confDir;
private boolean cacheReadOnce;
private boolean cacheMerges;
private static BlockCache globalBlockCache;
public static Metrics metrics;
@ -144,6 +151,8 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory implements Sol
} else {
LOG.info(HDFS_HOME + "=" + this.hdfsDataDir);
}
cacheMerges = getConfig(CACHE_MERGES, false);
cacheReadOnce = getConfig(CACHE_READONCE, false);
boolean kerberosEnabled = getConfig(KERBEROS_ENABLED, false);
LOG.info("Solr Kerberos Authentication "
+ (kerberosEnabled ? "enabled" : "disabled"));
@ -215,7 +224,7 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory implements Sol
Cache cache = new BlockDirectoryCache(blockCache, path, metrics, blockCacheGlobal);
hdfsDir = new HdfsDirectory(new Path(path), lockFactory, conf);
dir = new BlockDirectory(path, hdfsDir, cache, null, blockCacheReadEnabled, false);
dir = new BlockDirectory(path, hdfsDir, cache, null, blockCacheReadEnabled, false, cacheMerges, cacheReadOnce);
} else {
hdfsDir = new HdfsDirectory(new Path(path), lockFactory, conf);
dir = hdfsDir;

View File

@ -92,10 +92,21 @@ public class BlockDirectory extends FilterDirectory implements ShutdownAwareDire
private final boolean blockCacheReadEnabled;
private final boolean blockCacheWriteEnabled;
private boolean cacheMerges;
private boolean cacheReadOnce;
public BlockDirectory(String dirName, Directory directory, Cache cache,
Set<String> blockCacheFileTypes, boolean blockCacheReadEnabled,
boolean blockCacheWriteEnabled) throws IOException {
this(dirName, directory, cache, blockCacheFileTypes, blockCacheReadEnabled, blockCacheWriteEnabled, true, true);
}
public BlockDirectory(String dirName, Directory directory, Cache cache,
Set<String> blockCacheFileTypes, boolean blockCacheReadEnabled,
boolean blockCacheWriteEnabled, boolean cacheMerges, boolean cacheReadOnce) throws IOException {
super(directory);
this.cacheMerges = cacheMerges;
this.cacheReadOnce = cacheReadOnce;
this.dirName = dirName;
blockSize = BLOCK_SIZE;
this.cache = cache;
@ -292,6 +303,17 @@ public class BlockDirectory extends FilterDirectory implements ShutdownAwareDire
return false;
}
switch (context.context) {
// depending on params, we don't cache on merges or when only reading once
case MERGE: {
return cacheMerges;
}
case READ: {
if (context.readOnce) {
return cacheReadOnce;
} else {
return true;
}
}
default: {
return true;
}