Class AcquireSegmentAction
- All Implemented Interfaces:
Closeable,AutoCloseable
Segment and then use it to do stuff, and finally
closing when done.
When an AcquireSegmentAction is created, segment cache implementations will create a
'hold' to ensure it cannot be removed from the cache until this action has been closed.
Calling getSegmentFuture() is what actually initiates the 'action', and will return a segment reference
provider if already cached, or attempt to download from deep storage to load into the cache if not. The
Segment returned by acquiring a reference from the ReferenceCountedObjectProvider returned by the
future places a separate hold on the cache until the segment itself is closed, and MUST be closed when the caller is
finished doing segment things with it.
The caller must also call close() on this object to clean up the hold that exists while possibly loading
the segment, and may do so as soon as the Segment is acquired (or can do so earlier to abort the load and
release the hold).
-
Constructor Summary
ConstructorsConstructorDescriptionAcquireSegmentAction(Supplier<com.google.common.util.concurrent.ListenableFuture<AcquireSegmentResult>> segmentFutureSupplier, Closeable loadCleanup) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()com.google.common.util.concurrent.ListenableFuture<AcquireSegmentResult>Get aReferenceCountedObjectProvider<Segment>to acquire a reference to an item that exists in the cache, or if necessary/possible, fetching it from deep storage.static AcquireSegmentAction
-
Constructor Details
-
AcquireSegmentAction
public AcquireSegmentAction(Supplier<com.google.common.util.concurrent.ListenableFuture<AcquireSegmentResult>> segmentFutureSupplier, @Nullable Closeable loadCleanup)
-
-
Method Details
-
missingSegment
-
getSegmentFuture
Get aReferenceCountedObjectProvider<Segment>to acquire a reference to an item that exists in the cache, or if necessary/possible, fetching it from deep storage. This is typicallyReferenceCountedSegmentProvider, either as an immediate future if the segment already exists in cache. The 'action' to fetch the segment and return the reference provider is not initiated until this method is called. -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-