Search in sources :

Example 1 with ServerInternalKsqlClient

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);
    }
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) KsqlSecurityContext(io.confluent.ksql.security.KsqlSecurityContext) SimpleKsqlClient(io.confluent.ksql.services.SimpleKsqlClient) ServerInternalKsqlClient(io.confluent.ksql.rest.server.services.ServerInternalKsqlClient) URI(java.net.URI) KsqlException(io.confluent.ksql.util.KsqlException) ExecutionException(java.util.concurrent.ExecutionException) KsqlServerException(io.confluent.ksql.util.KsqlServerException) MalformedURLException(java.net.MalformedURLException)

Aggregations

KsqlEntityList (io.confluent.ksql.rest.entity.KsqlEntityList)1 ServerInternalKsqlClient (io.confluent.ksql.rest.server.services.ServerInternalKsqlClient)1 KsqlSecurityContext (io.confluent.ksql.security.KsqlSecurityContext)1 SimpleKsqlClient (io.confluent.ksql.services.SimpleKsqlClient)1 KsqlException (io.confluent.ksql.util.KsqlException)1 KsqlServerException (io.confluent.ksql.util.KsqlServerException)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 ExecutionException (java.util.concurrent.ExecutionException)1