Package org.apache.druid.server
Class QueryScheduler
java.lang.Object
org.apache.druid.server.QueryScheduler
- All Implemented Interfaces:
QueryWatcher
QueryScheduler (potentially) assigns any
Query that is to be executed to a 'query lane' using the
QueryLaningStrategy that is defined in QuerySchedulerConfig.
As a QueryWatcher, it also provides cancellation facilities to brokers, historicals, and realtime tasks.
This class is shared by all requests on the HTTP theadpool and must be thread safe.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionQueryScheduler(int totalNumThreads, QueryPrioritizationStrategy prioritizationStrategy, QueryLaningStrategy laningStrategy, ServerConfig serverConfig) Keeping the old constructor as many test classes are dependent on thisQueryScheduler(int totalNumThreads, QueryPrioritizationStrategy prioritizationStrategy, QueryLaningStrategy laningStrategy, ServerConfig serverConfig, ServiceEmitter emitter) -
Method Summary
Modifier and TypeMethodDescriptionbooleancancelQuery(String id) Forcibly cancel all futures that have been registered to a specific query idgetQueryDatasources(String queryId) Get aSetof datasource names for aQueryid, used byQueryResource.cancelQuery(java.lang.String, javax.servlet.http.HttpServletRequest)to authorize that a user may callcancelQuery(java.lang.String)for the given id and datasources<T> Query<T>prioritizeAndLaneQuery(QueryPlus<T> queryPlus, Set<SegmentServerSelector> segments) Assign a query a priority and lane (if not set)voidregisterQueryFuture(Query<?> query, com.google.common.util.concurrent.ListenableFuture<?> future) <T> Sequence<T>Run a query with the scheduler, attempting to acquire a semaphore from the total and lane specific query capacities Note thatcancelQuery(java.lang.String)should not interrupt the thread that calls run, in all current usages it only cancels anyListenableFuturecreated downstream.<T> QueryRunner<T>wrapQueryRunner(QueryRunner<T> baseRunner)
-
Field Details
-
UNAVAILABLE
public static final int UNAVAILABLE- See Also:
-
TOTAL
- See Also:
-
-
Constructor Details
-
QueryScheduler
public QueryScheduler(int totalNumThreads, QueryPrioritizationStrategy prioritizationStrategy, QueryLaningStrategy laningStrategy, ServerConfig serverConfig, ServiceEmitter emitter) -
QueryScheduler
public QueryScheduler(int totalNumThreads, QueryPrioritizationStrategy prioritizationStrategy, QueryLaningStrategy laningStrategy, ServerConfig serverConfig) Keeping the old constructor as many test classes are dependent on this
-
-
Method Details
-
registerQueryFuture
public void registerQueryFuture(Query<?> query, com.google.common.util.concurrent.ListenableFuture<?> future) - Specified by:
registerQueryFuturein interfaceQueryWatcher
-
prioritizeAndLaneQuery
public <T> Query<T> prioritizeAndLaneQuery(QueryPlus<T> queryPlus, Set<SegmentServerSelector> segments) Assign a query a priority and lane (if not set) -
run
Run a query with the scheduler, attempting to acquire a semaphore from the total and lane specific query capacities Note thatcancelQuery(java.lang.String)should not interrupt the thread that calls run, in all current usages it only cancels anyListenableFuturecreated downstream. If this ever commonly changes, we should add synchronization betweencancelQuery(java.lang.String)and the acquisition of theBulkheadto continue to ensure that anything acquired is also released. In the meantime, if aListenableFutureis registered for the query that calls this method, it MUST handle this synchronization itself to ensure that noBulkheadis acquired without releasing it. -
wrapQueryRunner
-
cancelQuery
Forcibly cancel all futures that have been registered to a specific query id -
getQueryDatasources
Get aSetof datasource names for aQueryid, used byQueryResource.cancelQuery(java.lang.String, javax.servlet.http.HttpServletRequest)to authorize that a user may callcancelQuery(java.lang.String)for the given id and datasources
-