mirror of https://github.com/apache/cassandra
Merge 6be8b3e330 into 2ddb92091c
This commit is contained in:
commit
73ea791b43
|
|
@ -28,6 +28,7 @@ public class InstrumentingCache<K, V>
|
|||
{
|
||||
private final ICache<K, V> map;
|
||||
private final String type;
|
||||
private volatile boolean enabled;
|
||||
|
||||
private CacheMetrics metrics;
|
||||
|
||||
|
|
@ -35,6 +36,7 @@ public class InstrumentingCache<K, V>
|
|||
{
|
||||
this.map = map;
|
||||
this.type = type;
|
||||
enabled = !(map instanceof NopCacheProvider.NopCache) && map.capacity() > 0;
|
||||
this.metrics = new CacheMetrics(type, map);
|
||||
}
|
||||
|
||||
|
|
@ -82,6 +84,12 @@ public class InstrumentingCache<K, V>
|
|||
public void setCapacity(long capacity)
|
||||
{
|
||||
map.setCapacity(capacity);
|
||||
enabled = capacity > 0;
|
||||
}
|
||||
|
||||
public boolean enabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public int size()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class NopCacheProvider implements CacheProvider<RowCacheKey, IRowCacheEnt
|
|||
return new NopCache();
|
||||
}
|
||||
|
||||
private static class NopCache implements ICache<RowCacheKey, IRowCacheEntry>
|
||||
static class NopCache implements ICache<RowCacheKey, IRowCacheEntry>
|
||||
{
|
||||
public long capacity()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -519,7 +519,7 @@ public abstract class SSTableReader extends SSTable implements UnfilteredSource,
|
|||
if (validate)
|
||||
sstable.validate();
|
||||
|
||||
if (sstable.getKeyCache() != null)
|
||||
if (logger.isTraceEnabled() && sstable.getKeyCache() != null && sstable.getKeyCache().enabled())
|
||||
logger.trace("key cache contains {}/{} keys", sstable.getKeyCache().size(), sstable.getKeyCache().getCapacity());
|
||||
|
||||
return sstable;
|
||||
|
|
@ -717,7 +717,7 @@ public abstract class SSTableReader extends SSTable implements UnfilteredSource,
|
|||
// e.g. by BulkLoader, which does not initialize the cache. As a kludge, we set up the cache
|
||||
// here when we know we're being wired into the rest of the server infrastructure.
|
||||
InstrumentingCache<KeyCacheKey, RowIndexEntry> maybeKeyCache = CacheService.instance.keyCache;
|
||||
if (maybeKeyCache.getCapacity() > 0)
|
||||
if (maybeKeyCache.enabled())
|
||||
keyCache = maybeKeyCache;
|
||||
|
||||
final ColumnFamilyStore cfs = Schema.instance.getColumnFamilyStoreInstance(metadata().id);
|
||||
|
|
@ -1333,7 +1333,7 @@ public abstract class SSTableReader extends SSTable implements UnfilteredSource,
|
|||
{
|
||||
CachingParams caching = metadata().params.caching;
|
||||
|
||||
if (!caching.cacheKeys() || keyCache == null || keyCache.getCapacity() == 0)
|
||||
if (!caching.cacheKeys() || keyCache == null || !keyCache.enabled())
|
||||
return;
|
||||
|
||||
KeyCacheKey cacheKey = new KeyCacheKey(metadata(), descriptor, key.getKey());
|
||||
|
|
|
|||
Loading…
Reference in New Issue