Search in sources :

Example 11 with QueryInterruptedException

use of org.apache.druid.query.QueryInterruptedException in project druid by druid-io.

the class DirectDruidClientTest method testQueryInterruptionExceptionLogMessage.

@Test
public void testQueryInterruptionExceptionLogMessage() {
    SettableFuture<Object> interruptionFuture = SettableFuture.create();
    Capture<Request> capturedRequest = EasyMock.newCapture();
    final String hostName = "localhost:8080";
    EasyMock.expect(httpClient.go(EasyMock.capture(capturedRequest), EasyMock.<HttpResponseHandler>anyObject(), EasyMock.anyObject(Duration.class))).andReturn(interruptionFuture).anyTimes();
    EasyMock.replay(httpClient);
    // test error
    TimeBoundaryQuery query = Druids.newTimeBoundaryQueryBuilder().dataSource("test").build();
    query = query.withOverriddenContext(ImmutableMap.of(DirectDruidClient.QUERY_FAIL_TIME, Long.MAX_VALUE));
    interruptionFuture.set(new ByteArrayInputStream(StringUtils.toUtf8("{\"error\":\"testing1\",\"errorMessage\":\"testing2\"}")));
    Sequence results = client.run(QueryPlus.wrap(query));
    QueryInterruptedException actualException = null;
    try {
        results.toList();
    } catch (QueryInterruptedException e) {
        actualException = e;
    }
    Assert.assertNotNull(actualException);
    Assert.assertEquals("testing1", actualException.getErrorCode());
    Assert.assertEquals("testing2", actualException.getMessage());
    Assert.assertEquals(hostName, actualException.getHost());
    EasyMock.verify(httpClient);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Request(org.apache.druid.java.util.http.client.Request) TimeBoundaryQuery(org.apache.druid.query.timeboundary.TimeBoundaryQuery) Sequence(org.apache.druid.java.util.common.guava.Sequence) HttpResponseHandler(org.apache.druid.java.util.http.client.response.HttpResponseHandler) QueryInterruptedException(org.apache.druid.query.QueryInterruptedException) Test(org.junit.Test)

Example 12 with QueryInterruptedException

use of org.apache.druid.query.QueryInterruptedException in project druid by druid-io.

the class ErrorHandlerTest method testErrorHandlerDefaultErrorResponseTransformStrategySanitizesErrorAsExpected.

@Test
public void testErrorHandlerDefaultErrorResponseTransformStrategySanitizesErrorAsExpected() {
    ServerConfig serverConfig = new ServerConfig();
    ErrorHandler errorHandler = new ErrorHandler(serverConfig);
    QueryInterruptedException input = new QueryInterruptedException("error", "error messagez", "error class", "host");
    RuntimeException output = errorHandler.sanitize(input);
    Assert.assertEquals("error messagez", output.getMessage());
}
Also used : ServerConfig(org.apache.druid.server.initialization.ServerConfig) QueryInterruptedException(org.apache.druid.query.QueryInterruptedException) Test(org.junit.Test)

Aggregations

QueryInterruptedException (org.apache.druid.query.QueryInterruptedException)12 QueryTimeoutException (org.apache.druid.query.QueryTimeoutException)5 Test (org.junit.Test)4 CancellationException (java.util.concurrent.CancellationException)3 ExecutionException (java.util.concurrent.ExecutionException)3 TimeoutException (java.util.concurrent.TimeoutException)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ImmutableList (com.google.common.collect.ImmutableList)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 OutputStream (java.io.OutputStream)2 ByteBuffer (java.nio.ByteBuffer)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Response (javax.ws.rs.core.Response)2 ReferenceCountingResourceHolder (org.apache.druid.collections.ReferenceCountingResourceHolder)2 ISE (org.apache.druid.java.util.common.ISE)2 Sequence (org.apache.druid.java.util.common.guava.Sequence)2 ResourceLimitExceededException (org.apache.druid.query.ResourceLimitExceededException)2 TruncatedResponseContextException (org.apache.druid.query.TruncatedResponseContextException)2