public abstract class AbstractPersistentCache extends java.lang.Object implements PersistentCache, java.io.Closeable
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.atomic.AtomicLong |
cacheSize |
protected java.util.concurrent.ExecutorService |
executor |
protected PersistentCache |
nextCache |
protected SegmentCacheStats |
segmentCacheStats |
static int |
THREADS |
protected java.util.Set<java.lang.String> |
writesPending |
Constructor and Description |
---|
AbstractPersistentCache() |
Modifier and Type | Method and Description |
---|---|
void |
close() |
@NotNull AbstractCacheStats |
getCacheStats() |
int |
getWritesPending() |
PersistentCache |
linkWith(AbstractPersistentCache nextCache) |
Buffer |
readSegment(long msb,
long lsb,
@NotNull java.util.concurrent.Callable<Buffer> loader)
Reads the segment from cache.
|
protected abstract Buffer |
readSegmentInternal(long msb,
long lsb)
Reads the segment from the cache.
|
protected void |
recordCacheLoadTimeInternal(long loadTime,
boolean successful)
Records time spent to load data from external source, after cache miss.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cleanUp, containsSegment, writeSegment
public static final int THREADS
protected java.util.concurrent.ExecutorService executor
protected java.util.concurrent.atomic.AtomicLong cacheSize
protected PersistentCache nextCache
protected final java.util.Set<java.lang.String> writesPending
protected SegmentCacheStats segmentCacheStats
public PersistentCache linkWith(AbstractPersistentCache nextCache)
public Buffer readSegment(long msb, long lsb, @NotNull @NotNull java.util.concurrent.Callable<Buffer> loader)
PersistentCache
readSegment
in interface PersistentCache
msb
- the most significant bits of the identifier of the segmentlsb
- the least significant bits of the identifier of the segmentloader
- in case of cache miss, with loader.call()
missing element will be retrievedprotected abstract Buffer readSegmentInternal(long msb, long lsb)
linkWith(AbstractPersistentCache)
msb
- the most significant bits of the identifier of the segmentlsb
- the least significant bits of the identifier of the segmentprotected final void recordCacheLoadTimeInternal(long loadTime, boolean successful)
loadTime
- load time in nanosecondssuccessful
- indicates whether loading of the segment into cache was successful@NotNull public @NotNull AbstractCacheStats getCacheStats()
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public int getWritesPending()
Copyright © 2012–2022 The Apache Software Foundation. All rights reserved.