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());
}
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);
}
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));
}
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));
}
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);
}
Aggregations