Search in sources :

Example 6 with QueryCapacityExceededException

use of org.apache.druid.query.QueryCapacityExceededException 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

QueryCapacityExceededException (org.apache.druid.query.QueryCapacityExceededException)6 IOException (java.io.IOException)5 CountDownLatch (java.util.concurrent.CountDownLatch)3 ServerConfig (org.apache.druid.server.initialization.ServerConfig)3 Test (org.junit.Test)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 CountingOutputStream (com.google.common.io.CountingOutputStream)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Produces (javax.ws.rs.Produces)2 Response (javax.ws.rs.core.Response)2 StreamingOutput (javax.ws.rs.core.StreamingOutput)2 BadQueryException (org.apache.druid.query.BadQueryException)2 QueryInterruptedException (org.apache.druid.query.QueryInterruptedException)2 QueryTimeoutException (org.apache.druid.query.QueryTimeoutException)2 QueryUnsupportedException (org.apache.druid.query.QueryUnsupportedException)2 ResourceLimitExceededException (org.apache.druid.query.ResourceLimitExceededException)2 HiLoQueryLaningStrategy (org.apache.druid.server.scheduling.HiLoQueryLaningStrategy)2 ForbiddenException (org.apache.druid.server.security.ForbiddenException)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1