Class SegmentPreloader
- java.lang.Object
-
- org.apache.jackrabbit.oak.segment.spi.persistence.persistentcache.DelegatingPersistentCache
-
- org.apache.jackrabbit.oak.segment.file.preloader.SegmentPreloader
-
- All Implemented Interfaces:
Closeable,AutoCloseable,PersistentCache
public class SegmentPreloader extends DelegatingPersistentCache implements Closeable
APersistentCachedecorator that preloads segments into the cache by asynchronously preloading segments referenced by a segment that is being read from the cache.- See Also:
PersistentCachePreloadingConfiguration
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static @NotNull PersistentCachedecorate(@NotNull PersistentCache delegate, @NotNull PersistentCachePreloadingConfiguration config, @NotNull Supplier<TarFiles> tarFiles)Factory method that decorates the givenPersistentCachewith aSegmentPreloaderif the given configuration requires preloading.protected PersistentCachedelegate()@Nullable BufferreadSegment(long msb, long lsb, @NotNull Callable<Buffer> loader)Reads the segment from cache.-
Methods inherited from class org.apache.jackrabbit.oak.segment.spi.persistence.persistentcache.DelegatingPersistentCache
cleanUp, containsSegment, writeSegment
-
-
-
-
Method Detail
-
decorate
@NotNull public static @NotNull PersistentCache decorate(@NotNull @NotNull PersistentCache delegate, @NotNull @NotNull PersistentCachePreloadingConfiguration config, @NotNull @NotNull Supplier<TarFiles> tarFiles)
Factory method that decorates the givenPersistentCachewith aSegmentPreloaderif the given configuration requires preloading. Otherwise, the givendelegateis returned as-is.- Parameters:
delegate- the cache to decorateconfig- the preloading configurationtarFiles- a supplier of theTarFilesinstance used to read segments and segment graphs- Returns:
- the decorated cache or the given
delegateif no preloading is configured
-
delegate
protected PersistentCache delegate()
- Specified by:
delegatein classDelegatingPersistentCache
-
readSegment
@Nullable public @Nullable Buffer readSegment(long msb, long lsb, @NotNull @NotNull Callable<Buffer> loader)
Description copied from interface:PersistentCacheReads the segment from cache.- Specified by:
readSegmentin interfacePersistentCache- Overrides:
readSegmentin classDelegatingPersistentCache- 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
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-