Package org.apache.druid.server
Class ServerManager
java.lang.Object
org.apache.druid.server.ServerManager
- All Implemented Interfaces:
QuerySegmentWalker
Query handler for Historical processes (see CliHistorical).
In tests, this class's behavior is partially mimicked by TestClusterQuerySegmentWalker.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classclassQueryRunnerthat on run builds a set ofQueryRunnerfor a set ofSegmentDescriptorand merges them using theQueryToolChest. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionServerManager(QueryRunnerFactoryConglomerate conglomerate, ServiceEmitter emitter, QueryProcessingPool queryProcessingPool, CachePopulator cachePopulator, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Cache cache, CacheConfig cacheConfig, SegmentManager segmentManager, ServerConfig serverConfig, PolicyEnforcer policyEnforcer) -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> QueryRunner<T>buildQueryRunnerForSegment(SegmentDescriptor segmentDescriptor, Segment segment, QueryRunnerFactory<T, Query<T>> factory, QueryToolChest<T, Query<T>> toolChest, AtomicLong cpuTimeAccumulator, Optional<byte[]> cacheKeyPrefix) protected ArrayList<SegmentReference>getOrLoadBundleSegments(QueryPlus<?> queryPlus, LeafSegmentsBundle segmentsBundle, SegmentMapFunction segmentMapFunction) CombinesLeafSegmentsBundle.cachedSegmentswithLeafSegmentsBundle.loadableSegments, loading the latter set into the cacheprotected ServerManager.LoadSegmentsResultgetOrLoadSegmentReferences(List<DataSegmentAndDescriptor> segmentsToMap, SegmentMapFunction segmentMapFunction, long timeout) Given a list ofDataSegmentAndDescriptor, usesSegmentManager.acquireSegment(DataSegment)for each to obtain a 'reference' to segments in the cache (or load from deep storage if necessary/supported by the storage layer).protected <T> QueryRunnerFactory<T,Query<T>> getQueryRunnerFactory(Query<T> query) <T> QueryRunner<T>getQueryRunnerForIntervals(Query<T> query, Iterable<org.joda.time.Interval> intervals) <T> QueryRunner<T>getQueryRunnerForSegments(Query<T> query, Iterable<SegmentDescriptor> specs) protected <T> FunctionalIterable<QueryRunner<T>>getQueryRunnersForSegments(Query<T> query, QueryRunnerFactory<T, Query<T>> factory, QueryToolChest<T, Query<T>> toolChest, List<SegmentReference> segmentReferences, AtomicLong cpuTimeAccumulator, Optional<byte[]> cacheKeyPrefix) protected static <T> QueryToolChest<T,Query<T>> getQueryToolChest(Query<T> query, QueryRunnerFactory<T, Query<T>> factory) protected LeafSegmentsBundlegetSegmentsBundle(VersionedIntervalTimeline<String, DataSegment> timeline, Iterable<SegmentDescriptor> segments, SegmentMapFunction segmentMapFunction) For eachSegmentDescriptor, we try to obtain aDataSegmentfrom the suppliedVersionedIntervalTimelineto create aLeafSegmentsBundlewhich contains the partitioned segments into 3 groups: those which are already present in the cache, those which can be loaded on demand, and those which were missing from theVersionedIntervalTimeline.
-
Field Details
-
segmentManager
-
-
Constructor Details
-
ServerManager
@Inject public ServerManager(QueryRunnerFactoryConglomerate conglomerate, ServiceEmitter emitter, QueryProcessingPool queryProcessingPool, CachePopulator cachePopulator, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Cache cache, CacheConfig cacheConfig, SegmentManager segmentManager, ServerConfig serverConfig, PolicyEnforcer policyEnforcer)
-
-
Method Details
-
getQueryRunnerForIntervals
public <T> QueryRunner<T> getQueryRunnerForIntervals(Query<T> query, Iterable<org.joda.time.Interval> intervals) - Specified by:
getQueryRunnerForIntervalsin interfaceQuerySegmentWalker
-
getQueryRunnerForSegments
public <T> QueryRunner<T> getQueryRunnerForSegments(Query<T> query, Iterable<SegmentDescriptor> specs) - Specified by:
getQueryRunnerForSegmentsin interfaceQuerySegmentWalker
-
getSegmentsBundle
protected LeafSegmentsBundle getSegmentsBundle(VersionedIntervalTimeline<String, DataSegment> timeline, Iterable<SegmentDescriptor> segments, SegmentMapFunction segmentMapFunction) For eachSegmentDescriptor, we try to obtain aDataSegmentfrom the suppliedVersionedIntervalTimelineto create aLeafSegmentsBundlewhich contains the partitioned segments into 3 groups: those which are already present in the cache, those which can be loaded on demand, and those which were missing from theVersionedIntervalTimeline. -
getOrLoadBundleSegments
protected ArrayList<SegmentReference> getOrLoadBundleSegments(QueryPlus<?> queryPlus, LeafSegmentsBundle segmentsBundle, SegmentMapFunction segmentMapFunction) CombinesLeafSegmentsBundle.cachedSegmentswithLeafSegmentsBundle.loadableSegments, loading the latter set into the cache -
getOrLoadSegmentReferences
protected ServerManager.LoadSegmentsResult getOrLoadSegmentReferences(List<DataSegmentAndDescriptor> segmentsToMap, SegmentMapFunction segmentMapFunction, long timeout) Given a list ofDataSegmentAndDescriptor, usesSegmentManager.acquireSegment(DataSegment)for each to obtain a 'reference' to segments in the cache (or load from deep storage if necessary/supported by the storage layer).For each of these segments, we then apply a
SegmentMapFunctionto prepare for processing. The returnedSegmentReferenceMUST BE CLOSED to release the reference. -
getQueryRunnersForSegments
protected <T> FunctionalIterable<QueryRunner<T>> getQueryRunnersForSegments(Query<T> query, QueryRunnerFactory<T, Query<T>> factory, QueryToolChest<T, Query<T>> toolChest, List<SegmentReference> segmentReferences, AtomicLong cpuTimeAccumulator, Optional<byte[]> cacheKeyPrefix) -
buildQueryRunnerForSegment
protected <T> QueryRunner<T> buildQueryRunnerForSegment(SegmentDescriptor segmentDescriptor, Segment segment, QueryRunnerFactory<T, Query<T>> factory, QueryToolChest<T, Query<T>> toolChest, AtomicLong cpuTimeAccumulator, Optional<byte[]> cacheKeyPrefix) -
getQueryRunnerFactory
-
getQueryToolChest
protected static <T> QueryToolChest<T,Query<T>> getQueryToolChest(Query<T> query, QueryRunnerFactory<T, Query<T>> factory)
-