Search in sources :

Example 1 with LazyServiceContext

use of io.confluent.ksql.services.LazyServiceContext in project ksql by confluentinc.

the class KsqlRestApplication method buildApplication.

public static KsqlRestApplication buildApplication(final KsqlRestConfig restConfig, final MetricCollectors metricCollectors) {
    final Map<String, Object> updatedRestProps = restConfig.getOriginals();
    final KsqlConfig ksqlConfig = new KsqlConfig(restConfig.getKsqlConfigProperties());
    final Vertx vertx = Vertx.vertx(new VertxOptions().setMaxWorkerExecuteTimeUnit(TimeUnit.MILLISECONDS).setMaxWorkerExecuteTime(Long.MAX_VALUE).setMetricsOptions(setUpHttpMetrics(ksqlConfig)));
    vertx.exceptionHandler(t -> log.error("Unhandled exception in Vert.x", t));
    final KsqlClient sharedClient = InternalKsqlClientFactory.createInternalClient(PropertiesUtil.toMapStrings(ksqlConfig.originals()), SocketAddress::inetSocketAddress, vertx);
    final Supplier<SchemaRegistryClient> schemaRegistryClientFactory = new KsqlSchemaRegistryClientFactory(ksqlConfig, Collections.emptyMap())::get;
    final ConnectClientFactory connectClientFactory = new DefaultConnectClientFactory(ksqlConfig);
    final ServiceContext tempServiceContext = new LazyServiceContext(() -> RestServiceContextFactory.create(ksqlConfig, Optional.empty(), schemaRegistryClientFactory, connectClientFactory, sharedClient, Collections.emptyList(), Optional.empty()));
    final String kafkaClusterId = KafkaClusterUtil.getKafkaClusterId(tempServiceContext);
    final String ksqlServerId = ksqlConfig.getString(KsqlConfig.KSQL_SERVICE_ID_CONFIG);
    updatedRestProps.putAll(metricCollectors.addConfluentMetricsContextConfigs(ksqlServerId, kafkaClusterId));
    final KsqlRestConfig updatedRestConfig = new KsqlRestConfig(updatedRestProps);
    final ServiceContext serviceContext = new LazyServiceContext(() -> RestServiceContextFactory.create(new KsqlConfig(updatedRestConfig.getKsqlConfigProperties()), Optional.empty(), schemaRegistryClientFactory, connectClientFactory, sharedClient, Collections.emptyList(), Optional.empty()));
    return buildApplication("", updatedRestConfig, KsqlVersionCheckerAgent::new, Integer.MAX_VALUE, serviceContext, schemaRegistryClientFactory, connectClientFactory, vertx, sharedClient, RestServiceContextFactory::create, RestServiceContextFactory::create, metricCollectors);
}
Also used : ServiceContext(io.confluent.ksql.services.ServiceContext) LazyServiceContext(io.confluent.ksql.services.LazyServiceContext) KsqlConfig(io.confluent.ksql.util.KsqlConfig) KsqlSchemaRegistryClientFactory(io.confluent.ksql.schema.registry.KsqlSchemaRegistryClientFactory) RestServiceContextFactory(io.confluent.ksql.rest.server.services.RestServiceContextFactory) Vertx(io.vertx.core.Vertx) LazyServiceContext(io.confluent.ksql.services.LazyServiceContext) KsqlVersionCheckerAgent(io.confluent.ksql.version.metrics.KsqlVersionCheckerAgent) DefaultConnectClientFactory(io.confluent.ksql.services.DefaultConnectClientFactory) ConnectClientFactory(io.confluent.ksql.services.ConnectClientFactory) DefaultConnectClientFactory(io.confluent.ksql.services.DefaultConnectClientFactory) ServerInternalKsqlClient(io.confluent.ksql.rest.server.services.ServerInternalKsqlClient) KsqlClient(io.confluent.ksql.rest.client.KsqlClient) SimpleKsqlClient(io.confluent.ksql.services.SimpleKsqlClient) SocketAddress(io.vertx.core.net.SocketAddress) VertxOptions(io.vertx.core.VertxOptions) SchemaRegistryClient(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)

Aggregations

SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)1 KsqlClient (io.confluent.ksql.rest.client.KsqlClient)1 RestServiceContextFactory (io.confluent.ksql.rest.server.services.RestServiceContextFactory)1 ServerInternalKsqlClient (io.confluent.ksql.rest.server.services.ServerInternalKsqlClient)1 KsqlSchemaRegistryClientFactory (io.confluent.ksql.schema.registry.KsqlSchemaRegistryClientFactory)1 ConnectClientFactory (io.confluent.ksql.services.ConnectClientFactory)1 DefaultConnectClientFactory (io.confluent.ksql.services.DefaultConnectClientFactory)1 LazyServiceContext (io.confluent.ksql.services.LazyServiceContext)1 ServiceContext (io.confluent.ksql.services.ServiceContext)1 SimpleKsqlClient (io.confluent.ksql.services.SimpleKsqlClient)1 KsqlConfig (io.confluent.ksql.util.KsqlConfig)1 KsqlVersionCheckerAgent (io.confluent.ksql.version.metrics.KsqlVersionCheckerAgent)1 Vertx (io.vertx.core.Vertx)1 VertxOptions (io.vertx.core.VertxOptions)1 SocketAddress (io.vertx.core.net.SocketAddress)1