Search in sources :

Example 1 with ThresholdBasedQueryPrioritizationStrategy

use of org.apache.druid.server.scheduling.ThresholdBasedQueryPrioritizationStrategy in project druid by druid-io.

the class QueryResourceTest method testTooManyQueryInLaneImplicitFromDurationThreshold.

@Test(timeout = 10_000L)
public void testTooManyQueryInLaneImplicitFromDurationThreshold() throws InterruptedException {
    expectPermissiveHappyPathAuth();
    final CountDownLatch waitTwoStarted = new CountDownLatch(2);
    final CountDownLatch waitOneScheduled = new CountDownLatch(1);
    final CountDownLatch waitAllFinished = new CountDownLatch(3);
    final QueryScheduler scheduler = new QueryScheduler(40, new ThresholdBasedQueryPrioritizationStrategy(null, "P90D", null, null), new HiLoQueryLaningStrategy(1), new ServerConfig());
    createScheduledQueryResource(scheduler, ImmutableList.of(waitTwoStarted), ImmutableList.of(waitOneScheduled));
    assertResponseAndCountdownOrBlockForever(SIMPLE_TIMESERIES_QUERY, waitAllFinished, response -> Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()));
    waitOneScheduled.await();
    assertResponseAndCountdownOrBlockForever(SIMPLE_TIMESERIES_QUERY, waitAllFinished, response -> {
        Assert.assertEquals(QueryCapacityExceededException.STATUS_CODE, response.getStatus());
        QueryCapacityExceededException ex;
        try {
            ex = jsonMapper.readValue((byte[]) response.getEntity(), QueryCapacityExceededException.class);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        Assert.assertEquals(QueryCapacityExceededException.makeLaneErrorMessage(HiLoQueryLaningStrategy.LOW, 1), ex.getMessage());
        Assert.assertEquals(QueryCapacityExceededException.ERROR_CODE, ex.getErrorCode());
    });
    waitTwoStarted.await();
    assertResponseAndCountdownOrBlockForever(SIMPLE_TIMESERIES_QUERY_SMALLISH_INTERVAL, waitAllFinished, response -> Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()));
    waitAllFinished.await();
}
Also used : ServerConfig(org.apache.druid.server.initialization.ServerConfig) QueryCapacityExceededException(org.apache.druid.query.QueryCapacityExceededException) ThresholdBasedQueryPrioritizationStrategy(org.apache.druid.server.scheduling.ThresholdBasedQueryPrioritizationStrategy) HiLoQueryLaningStrategy(org.apache.druid.server.scheduling.HiLoQueryLaningStrategy) IOException(java.io.IOException) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 QueryCapacityExceededException (org.apache.druid.query.QueryCapacityExceededException)1 ServerConfig (org.apache.druid.server.initialization.ServerConfig)1 HiLoQueryLaningStrategy (org.apache.druid.server.scheduling.HiLoQueryLaningStrategy)1 ThresholdBasedQueryPrioritizationStrategy (org.apache.druid.server.scheduling.ThresholdBasedQueryPrioritizationStrategy)1 Test (org.junit.Test)1