Search in sources :

Example 1 with KsqlClient

use of io.confluent.ksql.rest.client.KsqlClient in project ksql by confluentinc.

the class InternalKsqlClientFactoryTest method shouldCreateClient.

@Test
public void shouldCreateClient() {
    // When:
    KsqlClient client = InternalKsqlClientFactory.createInternalClient(ImmutableMap.of(), SocketAddress::inetSocketAddress, vertx);
    // Then:
    assertThat(client, notNullValue());
}
Also used : KsqlClient(io.confluent.ksql.rest.client.KsqlClient) SocketAddress(io.vertx.core.net.SocketAddress) Test(org.junit.Test)

Example 2 with KsqlClient

use of io.confluent.ksql.rest.client.KsqlClient in project ksql by confluentinc.

the class InternalKsqlClientFactory method createInternalClient.

public static KsqlClient createInternalClient(final Map<String, String> clientProps, final BiFunction<Integer, String, SocketAddress> socketAddressFactory, final Vertx vertx) {
    final String internalClientAuth = clientProps.get(KsqlRestConfig.KSQL_INTERNAL_SSL_CLIENT_AUTHENTICATION_CONFIG);
    final boolean verifyHost = !Strings.isNullOrEmpty(internalClientAuth) && !KsqlRestConfig.SSL_CLIENT_AUTHENTICATION_NONE.equals(internalClientAuth);
    return new KsqlClient(Optional.empty(), new LocalProperties(ImmutableMap.of()), httpOptionsFactory(clientProps, verifyHost, InternalKsqlClientFactory::createClientOptions), httpOptionsFactory(clientProps, verifyHost, InternalKsqlClientFactory::createClientOptionsHttp2), socketAddressFactory, vertx);
}
Also used : KsqlClient(io.confluent.ksql.rest.client.KsqlClient) LocalProperties(io.confluent.ksql.properties.LocalProperties)

Example 3 with KsqlClient

use of io.confluent.ksql.rest.client.KsqlClient in project ksql by confluentinc.

the class InternalKsqlClientFactoryTest method shouldCreateClient_http2.

@Test
public void shouldCreateClient_http2() {
    // When:
    KsqlClient client = InternalKsqlClientFactory.createInternalClient(ImmutableMap.of(KsqlRestConfig.KSQL_INTERNAL_HTTP2_MAX_POOL_SIZE_CONFIG, "1234"), SocketAddress::inetSocketAddress, vertx);
    List<HttpClientOptions> optionsList = options.getAllValues();
    // Then:
    assertThat(client, notNullValue());
    assertThat(optionsList.size(), is(4));
    HttpClientOptions sslOptions = optionsList.get(2);
    assertThat(sslOptions.getHttp2MaxPoolSize(), is(1234));
}
Also used : KsqlClient(io.confluent.ksql.rest.client.KsqlClient) SocketAddress(io.vertx.core.net.SocketAddress) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Example 4 with KsqlClient

use of io.confluent.ksql.rest.client.KsqlClient in project ksql by confluentinc.

the class InternalKsqlClientFactoryTest method shouldCreateClient_http2_badPoolSize.

@Test
public void shouldCreateClient_http2_badPoolSize() {
    // When:
    KsqlClient client = InternalKsqlClientFactory.createInternalClient(ImmutableMap.of(KsqlRestConfig.KSQL_INTERNAL_HTTP2_MAX_POOL_SIZE_CONFIG, "abc"), SocketAddress::inetSocketAddress, vertx);
    List<HttpClientOptions> optionsList = options.getAllValues();
    // Then:
    assertThat(client, notNullValue());
    assertThat(optionsList.size(), is(4));
    HttpClientOptions sslOptions = optionsList.get(2);
    assertThat(sslOptions.getHttp2MaxPoolSize(), is(KsqlRestConfig.KSQL_INTERNAL_HTTP2_MAX_POOL_SIZE_DEFAULT));
}
Also used : KsqlClient(io.confluent.ksql.rest.client.KsqlClient) SocketAddress(io.vertx.core.net.SocketAddress) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Example 5 with KsqlClient

use of io.confluent.ksql.rest.client.KsqlClient 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

KsqlClient (io.confluent.ksql.rest.client.KsqlClient)5 SocketAddress (io.vertx.core.net.SocketAddress)4 Test (org.junit.Test)3 HttpClientOptions (io.vertx.core.http.HttpClientOptions)2 SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)1 LocalProperties (io.confluent.ksql.properties.LocalProperties)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