Search in sources :

Example 1 with DefaultConnectClientFactory

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

the class KsqlContextTestUtil method create.

public static KsqlContext create(final KsqlConfig ksqlConfig, final SchemaRegistryClient schemaRegistryClient, final FunctionRegistry functionRegistry) {
    final KafkaClientSupplier clientSupplier = new DefaultKafkaClientSupplier();
    final Admin adminClient = clientSupplier.getAdmin(ksqlConfig.getKsqlAdminClientConfigProps());
    final KafkaTopicClient kafkaTopicClient = new KafkaTopicClientImpl(() -> adminClient);
    final ServiceContext serviceContext = TestServiceContext.create(clientSupplier, adminClient, kafkaTopicClient, () -> schemaRegistryClient, new DefaultConnectClientFactory(ksqlConfig).get(Optional.empty(), Collections.emptyList(), Optional.empty()));
    final String metricsPrefix = "instance-" + COUNTER.getAndIncrement() + "-";
    final KsqlEngine engine = new KsqlEngine(serviceContext, ProcessingLogContext.create(), functionRegistry, ServiceInfo.create(ksqlConfig, metricsPrefix), new SequentialQueryIdGenerator(), ksqlConfig, Collections.emptyList(), new MetricCollectors());
    return new KsqlContext(serviceContext, ksqlConfig, engine, Injectors.DEFAULT);
}
Also used : DefaultConnectClientFactory(io.confluent.ksql.services.DefaultConnectClientFactory) KsqlEngine(io.confluent.ksql.engine.KsqlEngine) KafkaTopicClient(io.confluent.ksql.services.KafkaTopicClient) DefaultKafkaClientSupplier(org.apache.kafka.streams.processor.internals.DefaultKafkaClientSupplier) DefaultKafkaClientSupplier(org.apache.kafka.streams.processor.internals.DefaultKafkaClientSupplier) KafkaClientSupplier(org.apache.kafka.streams.KafkaClientSupplier) ServiceContext(io.confluent.ksql.services.ServiceContext) TestServiceContext(io.confluent.ksql.services.TestServiceContext) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) SequentialQueryIdGenerator(io.confluent.ksql.query.id.SequentialQueryIdGenerator) Admin(org.apache.kafka.clients.admin.Admin) KafkaTopicClientImpl(io.confluent.ksql.services.KafkaTopicClientImpl)

Example 2 with DefaultConnectClientFactory

use of io.confluent.ksql.services.DefaultConnectClientFactory 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

DefaultConnectClientFactory (io.confluent.ksql.services.DefaultConnectClientFactory)2 ServiceContext (io.confluent.ksql.services.ServiceContext)2 SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)1 KsqlEngine (io.confluent.ksql.engine.KsqlEngine)1 MetricCollectors (io.confluent.ksql.metrics.MetricCollectors)1 SequentialQueryIdGenerator (io.confluent.ksql.query.id.SequentialQueryIdGenerator)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 KafkaTopicClient (io.confluent.ksql.services.KafkaTopicClient)1 KafkaTopicClientImpl (io.confluent.ksql.services.KafkaTopicClientImpl)1 LazyServiceContext (io.confluent.ksql.services.LazyServiceContext)1 SimpleKsqlClient (io.confluent.ksql.services.SimpleKsqlClient)1 TestServiceContext (io.confluent.ksql.services.TestServiceContext)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