Class AbstractPersistentCache
- java.lang.Object
-
- org.apache.jackrabbit.oak.segment.spi.persistence.persistentcache.AbstractPersistentCache
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,PersistentCache
- Direct Known Subclasses:
PersistentDiskCache
,PersistentRedisCache
public abstract class AbstractPersistentCache extends Object implements PersistentCache, Closeable
-
-
Field Summary
Fields Modifier and Type Field Description protected AtomicLong
cacheSize
protected ExecutorService
executor
protected PersistentCache
nextCache
protected SegmentCacheStats
segmentCacheStats
static int
THREADS
protected Set<String>
writesPending
-
Constructor Summary
Constructors Constructor Description AbstractPersistentCache()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
@NotNull AbstractCacheStats
getCacheStats()
int
getWritesPending()
PersistentCache
linkWith(AbstractPersistentCache nextCache)
Buffer
readSegment(long msb, long lsb, @NotNull 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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.jackrabbit.oak.segment.spi.persistence.persistentcache.PersistentCache
cleanUp, containsSegment, writeSegment
-
-
-
-
Field Detail
-
THREADS
public static final int THREADS
-
executor
protected ExecutorService executor
-
cacheSize
protected AtomicLong cacheSize
-
nextCache
protected PersistentCache nextCache
-
segmentCacheStats
protected SegmentCacheStats segmentCacheStats
-
-
Method Detail
-
linkWith
public PersistentCache linkWith(AbstractPersistentCache nextCache)
-
readSegment
public Buffer readSegment(long msb, long lsb, @NotNull @NotNull Callable<Buffer> loader)
Description copied from interface:PersistentCache
Reads the segment from cache.- Specified by:
readSegment
in interfacePersistentCache
- Parameters:
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, withloader.call()
missing element will be retrieved- Returns:
- byte buffer containing the segment data or null if the segment doesn't exist
-
readSegmentInternal
protected abstract Buffer readSegmentInternal(long msb, long lsb)
Reads the segment from the cache. If segment is not found, this method does not query next cache that was set withlinkWith(AbstractPersistentCache)
- Parameters:
msb
- the most significant bits of the identifier of the segmentlsb
- the least significant bits of the identifier of the segment- Returns:
- byte buffer containing the segment data or null if the segment doesn't exist
-
recordCacheLoadTimeInternal
protected final void recordCacheLoadTimeInternal(long loadTime, boolean successful)
Records time spent to load data from external source, after cache miss.- Parameters:
loadTime
- load time in nanosecondssuccessful
- indicates whether loading of the segment into cache was successful
-
getCacheStats
@NotNull public @NotNull AbstractCacheStats getCacheStats()
- Returns:
- Statistics for this cache.
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getWritesPending
public int getWritesPending()
-
-