Class SegmentLocalCacheManager

    • Constructor Detail

      • SegmentLocalCacheManager

        public 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
    • Method Detail

      • getSegmentFiles

        public File getSegmentFiles​(org.apache.druid.timeline.DataSegment segment)
                             throws org.apache.druid.segment.loading.SegmentLoadingException
        Make sure segments files in loc is intact, otherwise function like loadSegments will failed because of segment files is damaged.
        Specified by:
        getSegmentFiles in interface SegmentCacheManager
        Parameters:
        segment -
        Returns:
        Throws:
        org.apache.druid.segment.loading.SegmentLoadingException
      • reserve

        public boolean reserve​(org.apache.druid.timeline.DataSegment segment)
        Description copied from interface: SegmentCacheManager
        Tries to reserve the space for a segment on any location. When the space has been reserved, SegmentCacheManager.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.
        Specified by:
        reserve in interface SegmentCacheManager
        Parameters:
        segment - - Segment to reserve
        Returns:
        True if enough space found to store the segment, false otherwise
      • loadSegmentIntoPageCache

        public void loadSegmentIntoPageCache​(org.apache.druid.timeline.DataSegment segment,
                                             ExecutorService exec)
        Description copied from interface: SegmentCacheManager
        Asyncly load segment into page cache. Equivalent to `cat segment_files > /dev/null` to force loading the segment index files into page cache so that later when the segment is queried, they are already in page cache and only a minor page fault needs to be triggered instead of a major page fault to make the query latency more consistent.
        Specified by:
        loadSegmentIntoPageCache in interface SegmentCacheManager
        Parameters:
        segment - The segment to load its index files into page cache
        exec - The thread pool to use
      • getSegmentLocks

        public ConcurrentHashMap<org.apache.druid.timeline.DataSegment,​org.apache.druid.segment.loading.SegmentLocalCacheManager.ReferenceCountingLock> getSegmentLocks()