use of io.confluent.ksql.util.KsqlRequestConfig in project ksql by confluentinc.
the class KsqlResource method handleKsqlStatements.
public EndpointResponse handleKsqlStatements(final KsqlSecurityContext securityContext, final KsqlRequest request) {
LOG.info("Received: " + request);
throwIfNotConfigured();
activenessRegistrar.updateLastRequestTime();
try {
CommandStoreUtil.httpWaitForCommandSequenceNumber(commandRunner.getCommandQueue(), request, distributedCmdResponseTimeout);
final Map<String, Object> configProperties = request.getConfigOverrides();
denyListPropertyValidator.validateAll(configProperties);
final KsqlRequestConfig requestConfig = new KsqlRequestConfig(request.getRequestProperties());
final List<ParsedStatement> statements = ksqlEngine.parse(request.getKsql());
validator.validate(SandboxedServiceContext.create(securityContext.getServiceContext()), statements, new SessionProperties(configProperties, localHost, localUrl, requestConfig.getBoolean(KsqlRequestConfig.KSQL_REQUEST_INTERNAL_REQUEST), request.getSessionVariables()), request.getKsql());
// log validated statements for query anonymization
statements.forEach(s -> {
if (s.getStatementText().toLowerCase().contains("terminate") || s.getStatementText().toLowerCase().contains("drop")) {
QueryLogger.info("Query terminated", s.getStatementText());
} else {
QueryLogger.info("Query created", s.getStatementText());
}
});
final KsqlEntityList entities = handler.execute(securityContext, statements, new SessionProperties(configProperties, localHost, localUrl, requestConfig.getBoolean(KsqlRequestConfig.KSQL_REQUEST_INTERNAL_REQUEST), request.getSessionVariables()));
LOG.info("Processed successfully: " + request);
addCommandRunnerWarning(entities, commandRunnerWarning);
return EndpointResponse.ok(entities);
} catch (final KsqlRestException e) {
LOG.info("Processed unsuccessfully: " + request + ", reason: ", e);
throw e;
} catch (final KsqlStatementException e) {
LOG.info("Processed unsuccessfully: " + request + ", reason: ", e);
return Errors.badStatement(e.getRawMessage(), e.getSqlStatement());
} catch (final KsqlException e) {
LOG.info("Processed unsuccessfully: " + request + ", reason: ", e);
return errorHandler.generateResponse(e, Errors.badRequest(e));
} catch (final Exception e) {
LOG.info("Processed unsuccessfully: " + request + ", reason: ", e);
return errorHandler.generateResponse(e, Errors.serverErrorForStatement(e, request.getKsql()));
}
}
Aggregations