Class AheadOfTimeBlobDownloaderThrottler
- java.lang.Object
-
- org.apache.jackrabbit.oak.index.indexer.document.flatfile.AheadOfTimeBlobDownloaderThrottler
-
public class AheadOfTimeBlobDownloaderThrottler extends Object
Tracks a prefetch window for the AOT downloader. This class keeps a window from {startPosition, endPosition} together with an estimation of the data that was downloaded inside this window. It exposes two operations:-
reserveSpaceForBlob(long, long)- Reserves space to download blob at the given position and size, blocking until enough space is available. -
advanceIndexer(long)- Advances the window until the given position, removing from the window any positions lower or equal than the new index.
-
-
-
Constructor Summary
Constructors Constructor Description AheadOfTimeBlobDownloaderThrottler(int maxWindowSizeNumberOfBlobs, long maxWindowSizeBytes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadvanceIndexer(long indexerPosition)Advances the indexer to the given position.StringformatStats()longgetAvailableWindowBytes()longgetAvailableWindowSize()booleanreserveSpaceForBlob(long position, long length)Reserves space for a blob to be downloaded.
-
-
-
Constructor Detail
-
AheadOfTimeBlobDownloaderThrottler
public AheadOfTimeBlobDownloaderThrottler(int maxWindowSizeNumberOfBlobs, long maxWindowSizeBytes)- Parameters:
maxWindowSizeBytes- How many bytes can be downloaded ahead of the indexer.maxWindowSizeNumberOfBlobs- How many blobs can be downloaded ahead of the indexer.
-
-
Method Detail
-
reserveSpaceForBlob
public boolean reserveSpaceForBlob(long position, long length) throws InterruptedExceptionReserves space for a blob to be downloaded. This method blocks until there is enough space in the prefetch window. If the position of the reservation is lower or equal to the indexer position, the reservation is ignored.- Parameters:
position- The position of the blob to be downloaded.length- The length of the blob to be downloaded.- Returns:
- true if space was reserved, false if the indexer is already ahead of the position of the blob.
- Throws:
InterruptedException
-
getAvailableWindowSize
public long getAvailableWindowSize()
-
getAvailableWindowBytes
public long getAvailableWindowBytes()
-
advanceIndexer
public void advanceIndexer(long indexerPosition)
Advances the indexer to the given position.- Parameters:
indexerPosition- The new position of the indexer.
-
formatStats
public String formatStats()
-
-