Search in sources :

Example 21 with KsqlConfig

use of io.confluent.ksql.util.KsqlConfig in project ksql by confluentinc.

the class KsqlContext method create.

public static KsqlContext create(KsqlConfig ksqlConfig, SchemaRegistryClient schemaRegistryClient) {
    if (ksqlConfig == null) {
        ksqlConfig = new KsqlConfig(Collections.emptyMap());
    }
    Map<String, Object> streamsProperties = ksqlConfig.getKsqlStreamConfigProps();
    if (!streamsProperties.containsKey(StreamsConfig.APPLICATION_ID_CONFIG)) {
        streamsProperties.put(StreamsConfig.APPLICATION_ID_CONFIG, APPLICATION_ID_OPTION_DEFAULT);
    }
    if (!streamsProperties.containsKey(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG)) {
        streamsProperties.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, KAFKA_BOOTSTRAP_SERVER_OPTION_DEFAULT);
    }
    AdminClient adminClient = AdminClient.create(ksqlConfig.getKsqlAdminClientConfigProps());
    KafkaTopicClient topicClient = new KafkaTopicClientImpl(adminClient);
    if (schemaRegistryClient == null) {
        return new KsqlContext(adminClient, topicClient, new KsqlEngine(ksqlConfig, topicClient));
    } else {
        return new KsqlContext(adminClient, topicClient, new KsqlEngine(ksqlConfig, topicClient, schemaRegistryClient, new MetaStoreImpl()));
    }
}
Also used : KafkaTopicClient(io.confluent.ksql.util.KafkaTopicClient) MetaStoreImpl(io.confluent.ksql.metastore.MetaStoreImpl) KsqlConfig(io.confluent.ksql.util.KsqlConfig) KafkaTopicClientImpl(io.confluent.ksql.util.KafkaTopicClientImpl) AdminClient(org.apache.kafka.clients.admin.AdminClient)

Example 22 with KsqlConfig

use of io.confluent.ksql.util.KsqlConfig in project ksql by confluentinc.

the class EndToEndIntegrationTest method before.

@Before
public void before() throws Exception {
    testHarness = new IntegrationTestHarness();
    testHarness.start();
    Map<String, Object> streamsConfig = testHarness.ksqlConfig.getKsqlStreamConfigProps();
    streamsConfig.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
    KsqlConfig ksqlconfig = new KsqlConfig(streamsConfig);
    AdminClient adminClient = AdminClient.create(ksqlconfig.getKsqlAdminClientConfigProps());
    KafkaTopicClient topicClient = new KafkaTopicClientImpl(adminClient);
    ksqlEngine = new KsqlEngine(ksqlconfig, topicClient);
    testHarness.createTopic(pageViewTopic);
    testHarness.createTopic(usersTopic);
    pageViewDataProvider = new PageViewDataProvider();
    testHarness.publishTestData(usersTopic, new UserDataProvider(), System.currentTimeMillis() - 10000);
    testHarness.publishTestData(pageViewTopic, pageViewDataProvider, System.currentTimeMillis());
    ksqlEngine.buildMultipleQueries(format("CREATE TABLE %s (registertime bigint, gender varchar, regionid varchar, " + "userid varchar) WITH (kafka_topic='%s', value_format='JSON', key = 'userid');", userTable, usersTopic), Collections.emptyMap());
    ksqlEngine.buildMultipleQueries(format("CREATE STREAM %s (viewtime bigint, userid varchar, pageid varchar) " + "WITH (kafka_topic='%s', value_format='JSON');", pageViewStream, pageViewTopic), Collections.emptyMap());
}
Also used : KsqlEngine(io.confluent.ksql.KsqlEngine) UserDataProvider(io.confluent.ksql.util.UserDataProvider) KafkaTopicClient(io.confluent.ksql.util.KafkaTopicClient) PageViewDataProvider(io.confluent.ksql.util.PageViewDataProvider) KsqlConfig(io.confluent.ksql.util.KsqlConfig) KafkaTopicClientImpl(io.confluent.ksql.util.KafkaTopicClientImpl) AdminClient(org.apache.kafka.clients.admin.AdminClient) Before(org.junit.Before)

Example 23 with KsqlConfig

use of io.confluent.ksql.util.KsqlConfig in project ksql by confluentinc.

the class SecureIntegrationTest method givenTestSetupWithConfig.

private void givenTestSetupWithConfig(final Map<String, Object> ksqlConfigs) throws Exception {
    final KsqlConfig ksqlConfig = new KsqlConfig(ksqlConfigs);
    ksqlEngine = new KsqlEngine(ksqlConfig, new KafkaTopicClientImpl(AdminClient.create(ksqlConfig.getKsqlAdminClientConfigProps())));
    execInitCreateStreamQueries();
}
Also used : KsqlEngine(io.confluent.ksql.KsqlEngine) KsqlConfig(io.confluent.ksql.util.KsqlConfig) KafkaTopicClientImpl(io.confluent.ksql.util.KafkaTopicClientImpl)

Example 24 with KsqlConfig

use of io.confluent.ksql.util.KsqlConfig in project ksql by confluentinc.

the class PhysicalPlanBuilderTest method buildPhysicalPlanBuilder.

private PhysicalPlanBuilder buildPhysicalPlanBuilder(Map<String, Object> overrideProperties) {
    final StreamsBuilder streamsBuilder = new StreamsBuilder();
    final FunctionRegistry functionRegistry = new FunctionRegistry();
    Map<String, Object> configMap = new HashMap<>();
    configMap.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
    configMap.put("application.id", "KSQL");
    configMap.put("commit.interval.ms", 0);
    configMap.put("cache.max.bytes.buffering", 0);
    configMap.put("auto.offset.reset", "earliest");
    return new PhysicalPlanBuilder(streamsBuilder, new KsqlConfig(configMap), new FakeKafkaTopicClient(), functionRegistry, overrideProperties, false, metaStore, new MockSchemaRegistryClient(), testKafkaStreamsBuilder);
}
Also used : StreamsBuilder(org.apache.kafka.streams.StreamsBuilder) FunctionRegistry(io.confluent.ksql.function.FunctionRegistry) HashMap(java.util.HashMap) MockSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient) FakeKafkaTopicClient(io.confluent.ksql.util.FakeKafkaTopicClient) KsqlConfig(io.confluent.ksql.util.KsqlConfig)

Example 25 with KsqlConfig

use of io.confluent.ksql.util.KsqlConfig in project ksql by confluentinc.

the class KsqlResourceTest method setUp.

@Before
public void setUp() throws IOException, RestClientException {
    SchemaRegistryClient schemaRegistryClient = new MockSchemaRegistryClient();
    registerSchema(schemaRegistryClient);
    ksqlRestConfig = new KsqlRestConfig(TestKsqlResourceUtil.getDefaultKsqlConfig());
    KsqlConfig ksqlConfig = new KsqlConfig(ksqlRestConfig.getKsqlConfigProperties());
    ksqlEngine = new KsqlEngine(ksqlConfig, new MockKafkaTopicClient(), schemaRegistryClient, new MetaStoreImpl());
}
Also used : KsqlEngine(io.confluent.ksql.KsqlEngine) MockSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient) KsqlRestConfig(io.confluent.ksql.rest.server.KsqlRestConfig) MockKafkaTopicClient(io.confluent.ksql.rest.server.mock.MockKafkaTopicClient) MetaStoreImpl(io.confluent.ksql.metastore.MetaStoreImpl) KsqlConfig(io.confluent.ksql.util.KsqlConfig) SchemaRegistryClient(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient) MockSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient) Before(org.junit.Before)

Aggregations

KsqlConfig (io.confluent.ksql.util.KsqlConfig)29 HashMap (java.util.HashMap)13 MockSchemaRegistryClient (io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient)11 SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)9 Before (org.junit.Before)9 Test (org.junit.Test)9 KafkaTopicClientImpl (io.confluent.ksql.util.KafkaTopicClientImpl)8 KsqlEngine (io.confluent.ksql.KsqlEngine)7 FunctionRegistry (io.confluent.ksql.function.FunctionRegistry)6 List (java.util.List)5 StreamsBuilder (org.apache.kafka.streams.StreamsBuilder)5 GenericRow (io.confluent.ksql.GenericRow)4 KafkaTopicClient (io.confluent.ksql.util.KafkaTopicClient)4 Map (java.util.Map)4 KafkaAvroDeserializer (io.confluent.kafka.serializers.KafkaAvroDeserializer)2 KsqlTopic (io.confluent.ksql.metastore.KsqlTopic)2 MetaStoreImpl (io.confluent.ksql.metastore.MetaStoreImpl)2 MockKafkaTopicClient (io.confluent.ksql.rest.server.mock.MockKafkaTopicClient)2 KsqlException (io.confluent.ksql.util.KsqlException)2 GenericData (org.apache.avro.generic.GenericData)2