public class SegmentLocalCacheManager extends Object implements SegmentCacheManager
| Constructor and Description |
|---|
SegmentLocalCacheManager(List<StorageLocation> locations,
SegmentLoaderConfig config,
StorageLocationSelectorStrategy strategy,
com.fasterxml.jackson.databind.ObjectMapper mapper) |
SegmentLocalCacheManager(SegmentLoaderConfig config,
com.fasterxml.jackson.databind.ObjectMapper mapper)
creates instance with default storage location selector strategy
This ctor is mainly for test cases, including test cases in other modules
|
| Modifier and Type | Method and Description |
|---|---|
void |
cleanup(DataSegment segment)
Cleanup the cache space used by the segment.
|
List<StorageLocation> |
getLocations() |
File |
getSegmentFiles(DataSegment segment)
Make sure segments files in loc is intact, otherwise function like loadSegments will failed because of segment files is damaged.
|
ConcurrentHashMap<DataSegment,org.apache.druid.segment.loading.SegmentLocalCacheManager.ReferenceCountingLock> |
getSegmentLocks() |
boolean |
isSegmentCached(DataSegment segment)
Checks whether a segment is already cached.
|
void |
loadSegmentIntoPageCache(DataSegment segment,
ExecutorService exec)
Asyncly load segment into page cache.
|
boolean |
release(DataSegment segment)
Reverts the effects of
SegmentCacheManager.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.
|
@Inject public SegmentLocalCacheManager(List<StorageLocation> locations, SegmentLoaderConfig config, @Nonnull StorageLocationSelectorStrategy strategy, com.fasterxml.jackson.databind.ObjectMapper mapper)
public SegmentLocalCacheManager(SegmentLoaderConfig config, com.fasterxml.jackson.databind.ObjectMapper mapper)
public boolean isSegmentCached(DataSegment segment)
SegmentCacheManagerSegmentCacheManager.reserve(DataSegment)
has been successful for a segment but is not downloaded yet.isSegmentCached in interface SegmentCacheManagerpublic File getSegmentFiles(DataSegment segment) throws SegmentLoadingException
getSegmentFiles in interface SegmentCacheManagersegment - SegmentLoadingExceptionpublic boolean reserve(DataSegment segment)
SegmentCacheManagerSegmentCacheManager.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.reserve in interface SegmentCacheManagersegment - - Segment to reservepublic boolean release(DataSegment segment)
SegmentCacheManagerSegmentCacheManager.reserve(DataSegment) (DataSegment)} by releasing the location reserved for this segment.
Callers, that explicitly reserve the space via SegmentCacheManager.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 SegmentCacheManager.cleanup(DataSegment)release in interface SegmentCacheManagersegment - - Segment to release the location for.public void cleanup(DataSegment segment)
SegmentCacheManagerSegmentCacheManager.reserve(DataSegment)cleanup in interface SegmentCacheManagerpublic void loadSegmentIntoPageCache(DataSegment segment, ExecutorService exec)
SegmentCacheManagerloadSegmentIntoPageCache in interface SegmentCacheManagersegment - The segment to load its index files into page cacheexec - The thread pool to usepublic ConcurrentHashMap<DataSegment,org.apache.druid.segment.loading.SegmentLocalCacheManager.ReferenceCountingLock> getSegmentLocks()
public List<StorageLocation> getLocations()
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.