use of io.confluent.ksql.rest.server.services.ServerInternalKsqlClient in project ksql by confluentinc.
the class KsqlRestApplication method maybeCreateProcessingLogStream.
private static void maybeCreateProcessingLogStream(final ProcessingLogConfig processingLogConfig, final KsqlConfig ksqlConfig, final KsqlRestConfig restConfig, final KsqlResource ksqlResource, final ServiceContext serviceContext) {
if (!processingLogConfig.getBoolean(ProcessingLogConfig.STREAM_AUTO_CREATE)) {
return;
}
try {
final SimpleKsqlClient internalClient = new ServerInternalKsqlClient(ksqlResource, new KsqlSecurityContext(Optional.empty(), serviceContext));
final URI serverEndpoint = ServerUtil.getServerAddress(restConfig);
final String processingLogStreamName = processingLogConfig.getString(ProcessingLogConfig.STREAM_NAME);
if (!processingLogStreamExists(internalClient, serverEndpoint, processingLogStreamName)) {
final RestResponse<KsqlEntityList> response = internalClient.makeKsqlRequest(serverEndpoint, ProcessingLogServerUtils.processingLogStreamCreateStatement(processingLogConfig, ksqlConfig), ImmutableMap.of());
if (response.isSuccessful()) {
log.info("Successfully created processing log stream.");
}
}
} catch (final Exception e) {
log.error("Error while sending processing log CreateStream request to KsqlResource: ", e);
}
}
Aggregations