use of io.confluent.ksql.query.QueryError in project ksql by confluentinc.
the class QueryMetadataTest method shouldEvictBasedOnTime.
@Test
public void shouldEvictBasedOnTime() {
// Given:
final QueryMetadataImpl.TimeBoundedQueue queue = new QueryMetadataImpl.TimeBoundedQueue(Duration.ZERO, 1);
queue.add(new QueryError(System.currentTimeMillis(), "test", Type.SYSTEM));
// Then:
assertThat(queue.toImmutableList().size(), is(0));
}
use of io.confluent.ksql.query.QueryError in project ksql by confluentinc.
the class SharedKafkaStreamsRuntimeImpl method uncaughtHandler.
public StreamsUncaughtExceptionHandler.StreamThreadExceptionResponse uncaughtHandler(final Throwable e) {
QueryError.Type errorType = QueryError.Type.UNKNOWN;
try {
errorType = errorClassifier.classify(e);
if (e.getCause() != null && errorType == QueryError.Type.UNKNOWN) {
errorType = errorClassifier.classify(e.getCause());
}
} catch (final Exception classificationException) {
log.error("Error classifying unhandled exception", classificationException);
} finally {
// If error classification throws then we consider the error to be an UNKNOWN error.
// We notify listeners and add the error to the errors queue in the finally block to ensure
// all listeners and consumers of the error queue (eg the API) can see the error. Similarly,
// log in finally block to make sure that if there's ever an error in the classification
// we still get this in our logs.
final QueryError queryError = new QueryError(System.currentTimeMillis(), Throwables.getStackTraceAsString(e), errorType);
final BinPackedPersistentQueryMetadataImpl queryInError = parseException(e);
if (queryInError != null) {
queryInError.setQueryError(queryError);
log.error(String.format("Unhandled query exception caught in streams thread %s for query %s. (%s)", Thread.currentThread().getName(), queryInError.getQueryId(), errorType), e);
} else {
for (BinPackedPersistentQueryMetadataImpl query : collocatedQueries.values()) {
query.setQueryError(queryError);
}
log.error(String.format("Unhandled runtime exception caught in streams thread %s. (%s)", Thread.currentThread().getName(), errorType), e);
}
}
return StreamsUncaughtExceptionHandler.StreamThreadExceptionResponse.REPLACE_THREAD;
}
use of io.confluent.ksql.query.QueryError in project ksql by confluentinc.
the class SecureIntegrationTest method assertQueryFailsWithUserError.
private void assertQueryFailsWithUserError(final String query, final String errorMsg) {
final QueryMetadata queryMetadata = KsqlEngineTestUtil.execute(serviceContext, ksqlEngine, query, ksqlConfig, Collections.emptyMap()).get(0);
queryMetadata.start();
assertThatEventually("Wait for query to fail", () -> queryMetadata.getQueryErrors().size() > 0, is(true));
for (final QueryError error : queryMetadata.getQueryErrors()) {
assertThat(error.getType(), is(Type.USER));
assertThat(error.getErrorMessage().split("\n")[0], containsString(String.format(errorMsg, queryMetadata.getQueryId())));
}
}
use of io.confluent.ksql.query.QueryError in project ksql by confluentinc.
the class QueryStateMetricsReportingListenerTest method shouldGracefullyHandleErrorCallbackAfterDeregister.
@Test
public void shouldGracefullyHandleErrorCallbackAfterDeregister() {
// Given:
listener.onCreate(serviceContext, metaStore, query);
listener.onDeregister(query);
// When/Then(don't throw)
listener.onError(query, new QueryError(123, "foo", Type.USER));
}
use of io.confluent.ksql.query.QueryError in project ksql by confluentinc.
the class Console method printQueryError.
private void printQueryError(final QueryDescription query) {
writer().println();
final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss,SSS (z)");
for (final QueryError error : query.getQueryErrors()) {
final Instant ts = Instant.ofEpochMilli(error.getTimestamp());
final String errorDate = ts.atZone(ZoneId.systemDefault()).format(dateFormatter);
writer().println(String.format("%-20s : %s", "Error Date", errorDate));
writer().println(String.format("%-20s : %s", "Error Details", error.getErrorMessage()));
writer().println(String.format("%-20s : %s", "Error Type", error.getType()));
}
}
Aggregations