public class QueryScheduler extends Object implements QueryWatcher
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.| Modifier and Type | Field and Description |
|---|---|
static String |
TOTAL |
static int |
UNAVAILABLE |
| Constructor and Description |
|---|
QueryScheduler(int totalNumThreads,
QueryPrioritizationStrategy prioritizationStrategy,
QueryLaningStrategy laningStrategy,
ServerConfig serverConfig) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancelQuery(String id)
Forcibly cancel all futures that have been registered to a specific query id
|
Set<String> |
getQueryDatasources(String queryId)
Get a
Set of datasource names for a Query id, used by QueryResource.cancelQuery(java.lang.String, javax.servlet.http.HttpServletRequest) to
authorize that a user may call cancelQuery(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)
|
void |
registerQueryFuture(Query<?> query,
com.google.common.util.concurrent.ListenableFuture<?> future) |
<T> Sequence<T> |
run(Query<?> query,
Sequence<T> resultSequence)
Run a query with the scheduler, attempting to acquire a semaphore from the total and lane specific query capacities
Note that
cancelQuery(java.lang.String) should not interrupt the thread that calls run, in all current usages it only
cancels any ListenableFuture created downstream. |
<T> QueryRunner<T> |
wrapQueryRunner(QueryRunner<T> baseRunner)
|
public static final int UNAVAILABLE
public static final String TOTAL
public QueryScheduler(int totalNumThreads,
QueryPrioritizationStrategy prioritizationStrategy,
QueryLaningStrategy laningStrategy,
ServerConfig serverConfig)
public void registerQueryFuture(Query<?> query, com.google.common.util.concurrent.ListenableFuture<?> future)
registerQueryFuture in interface QueryWatcherpublic <T> Query<T> prioritizeAndLaneQuery(QueryPlus<T> queryPlus, Set<SegmentServerSelector> segments)
public <T> Sequence<T> run(Query<?> query, Sequence<T> resultSequence)
cancelQuery(java.lang.String) should not interrupt the thread that calls run, in all current usages it only
cancels any ListenableFuture created downstream. If this ever commonly changes, we should add
synchronization between cancelQuery(java.lang.String) and the acquisition of the Bulkhead to continue to ensure that
anything acquired is also released.
In the meantime, if a ListenableFuture is registered for the query that calls this method, it MUST handle
this synchronization itself to ensure that no Bulkhead is acquired without releasing it.public <T> QueryRunner<T> wrapQueryRunner(QueryRunner<T> baseRunner)
public boolean cancelQuery(String id)
public Set<String> getQueryDatasources(String queryId)
Set of datasource names for a Query id, used by QueryResource.cancelQuery(java.lang.String, javax.servlet.http.HttpServletRequest) to
authorize that a user may call cancelQuery(java.lang.String) for the given id and datasourcesCopyright © 2011–2020 The Apache Software Foundation. All rights reserved.