less stack traces when cancelling queries

This commit is contained in:
Xavier Léauté 2014-06-02 18:29:42 -07:00
parent d01f272a7a
commit 855c66c9ad
3 changed files with 28 additions and 5 deletions

View File

@ -136,6 +136,9 @@ public class ChainedExecutionQueryRunner<T> implements QueryRunner<T>
return retVal;
}
catch (QueryInterruptedException e) {
throw Throwables.propagate(e);
}
catch (Exception e) {
log.error(e, "Exception with one of the sequences!");
throw Throwables.propagate(e);
@ -166,11 +169,9 @@ public class ChainedExecutionQueryRunner<T> implements QueryRunner<T>
throw new QueryInterruptedException("Query interrupted");
}
catch(CancellationException e) {
log.warn(e, "Query cancelled, query id [%s]", query.getId());
throw new QueryInterruptedException("Query cancelled");
}
catch(TimeoutException e) {
log.warn(e, "Query timeout, query id [%s]", query.getId());
throw new QueryInterruptedException("Query timeout");
}
catch (ExecutionException e) {

View File

@ -333,7 +333,7 @@ public class DirectDruidClient<T> implements QueryRunner<T>
throw new RE(e, "Failure getting results from[%s]", url);
}
catch (CancellationException e) {
throw new QueryInterruptedException();
throw new QueryInterruptedException("Query cancelled");
}
}
}

View File

@ -125,7 +125,7 @@ public class QueryResource
final long start = System.currentTimeMillis();
Query query = null;
byte[] requestQuery = null;
String queryId;
String queryId = null;
final boolean isSmile = APPLICATION_SMILE.equals(req.getContentType());
@ -212,6 +212,28 @@ public class QueryResource
.build();
}
}
catch (QueryInterruptedException e) {
try {
log.info("%s [%s]", e.getMessage(), queryId);
requestLogger.log(
new RequestLogLine(
new DateTime(),
req.getRemoteAddr(),
query,
new QueryStats(ImmutableMap.<String, Object>of("success", false, "interrupted", true, "reason", e.toString()))
)
);
} catch (Exception e2) {
log.error(e2, "Unable to log query [%s]!", query);
}
return Response.serverError().entity(
jsonWriter.writeValueAsString(
ImmutableMap.of(
"error", e.getMessage()
)
)
).build();
}
catch (Exception e) {
final String queryString =
query == null
@ -243,7 +265,7 @@ public class QueryResource
return Response.serverError().entity(
jsonWriter.writeValueAsString(
ImmutableMap.of(
"error", (e.getMessage() == null) ? "null Exception" : e.getMessage()
"error", e.getMessage() == null ? "null exception" : e.getMessage()
)
)
).build();