public interface SegmentCacheManager
| Modifier and Type | Method and Description |
|---|---|
void |
cleanup(DataSegment segment)
Cleanup the cache space used by the segment.
|
File |
getSegmentFiles(DataSegment segment)
This method fetches the files for the given segment if the segment is not downloaded already.
|
boolean |
isSegmentCached(DataSegment segment)
Checks whether a segment is already cached.
|
boolean |
release(DataSegment segment)
Reverts the effects of
reserve(DataSegment) (DataSegment)} by releasing the location reserved for this segment. |
boolean |
reserve(DataSegment segment)
Tries to reserve the space for a segment on any location.
|
boolean isSegmentCached(DataSegment segment)
reserve(DataSegment)
has been successful for a segment but is not downloaded yet.File getSegmentFiles(DataSegment segment) throws SegmentLoadingException
reserve(DataSegment) before calling this method. If caller has not reserved
the space explicitly via reserve(DataSegment), the implementation should reserve space on caller's
behalf.
If the space has been explicitly reserved already
- implementation should use only the reserved space to store segment files.
- implementation should not release the location in case of download erros and leave it to the caller.SegmentLoadingException - if there is an error in downloading filesboolean reserve(DataSegment segment)
getSegmentFiles(DataSegment) should download the segment on the reserved location or
fail otherwise.
This function is useful for custom extensions. Extensions can try to reserve the space first and
if not successful, make some space by cleaning up other segments, etc. There is also improved
concurrency for extensions with this function. Since reserve is a cheaper operation to invoke
till the space has been reserved. Hence it can be put inside a lock if required by the extensions. getSegment
can't be put inside a lock since it is a time-consuming operation, on account of downloading the files.segment - - Segment to reserveboolean release(DataSegment segment)
reserve(DataSegment) (DataSegment)} by releasing the location reserved for this segment.
Callers, that explicitly reserve the space via reserve(DataSegment), should use this method to release the space.
Implementation can throw error if the space is being released but there is data present. Callers
are supposed to ensure that any data is removed via cleanup(DataSegment)segment - - Segment to release the location for.void cleanup(DataSegment segment)
reserve(DataSegment)Copyright © 2011–2021 The Apache Software Foundation. All rights reserved.