Search in sources :

Example 6 with MetricCollectors

use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.

the class KsqlResourceTest method shouldDescribeTables.

@Test
public void shouldDescribeTables() {
    // Given:
    final LogicalSchema schema = LogicalSchema.builder().keyColumn(SystemColumns.ROWKEY_NAME, SqlTypes.STRING).valueColumn(ColumnName.of("FIELD1"), SqlTypes.BOOLEAN).valueColumn(ColumnName.of("FIELD2"), SqlTypes.STRING).build();
    givenSource(DataSourceType.KTABLE, "new_table", "new_topic", schema, ImmutableSet.of(SourceName.of("TEST_TABLE")));
    // When:
    final SourceDescriptionList descriptionList = makeSingleRequest("DESCRIBE TABLES;", SourceDescriptionList.class);
    // Then:
    assertThat(descriptionList.getSourceDescriptions(), containsInAnyOrder(SourceDescriptionFactory.create(ksqlEngine.getMetaStore().getSource(SourceName.of("TEST_TABLE")), false, Collections.emptyList(), Collections.emptyList(), Optional.of(kafkaTopicClient.describeTopic("KAFKA_TOPIC_1")), Collections.emptyList(), ImmutableList.of("new_table"), new MetricCollectors()), SourceDescriptionFactory.create(ksqlEngine.getMetaStore().getSource(SourceName.of("new_table")), false, Collections.emptyList(), Collections.emptyList(), Optional.of(kafkaTopicClient.describeTopic("new_topic")), Collections.emptyList(), Collections.emptyList(), new MetricCollectors())));
}
Also used : SourceDescriptionList(io.confluent.ksql.rest.entity.SourceDescriptionList) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) Test(org.junit.Test)

Example 7 with MetricCollectors

use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.

the class KsqlResourceTest method shouldDescribeStreams.

@Test
public void shouldDescribeStreams() {
    // Given:
    final LogicalSchema schema = LogicalSchema.builder().keyColumn(SystemColumns.ROWKEY_NAME, SqlTypes.STRING).valueColumn(ColumnName.of("FIELD1"), SqlTypes.BOOLEAN).valueColumn(ColumnName.of("FIELD2"), SqlTypes.STRING).build();
    givenSource(DataSourceType.KSTREAM, "new_stream", "new_topic", schema);
    // When:
    final SourceDescriptionList descriptionList = makeSingleRequest("DESCRIBE STREAMS;", SourceDescriptionList.class);
    // Then:
    assertThat(descriptionList.getSourceDescriptions(), containsInAnyOrder(SourceDescriptionFactory.create(ksqlEngine.getMetaStore().getSource(SourceName.of("TEST_STREAM")), false, Collections.emptyList(), Collections.emptyList(), Optional.of(kafkaTopicClient.describeTopic("KAFKA_TOPIC_2")), Collections.emptyList(), Collections.emptyList(), new MetricCollectors()), SourceDescriptionFactory.create(ksqlEngine.getMetaStore().getSource(SourceName.of("new_stream")), false, Collections.emptyList(), Collections.emptyList(), Optional.of(kafkaTopicClient.describeTopic("new_topic")), Collections.emptyList(), Collections.emptyList(), new MetricCollectors())));
}
Also used : SourceDescriptionList(io.confluent.ksql.rest.entity.SourceDescriptionList) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) Test(org.junit.Test)

Example 8 with MetricCollectors

use of io.confluent.ksql.metrics.MetricCollectors 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 9 with MetricCollectors

use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.

the class KsqlTesterTest method setUp.

@Before
public void setUp() {
    final MockSchemaRegistryClient srClient = new MockSchemaRegistryClient();
    this.topicClient = new FakeKafkaTopicClient();
    this.serviceContext = TestServiceContext.create(topicClient, () -> srClient);
    this.config = new KsqlConfig(BASE_CONFIG);
    this.formatInjector = new DefaultFormatInjector();
    final MetaStoreImpl metaStore = new MetaStoreImpl(TestFunctionRegistry.INSTANCE.get());
    final MetricCollectors metricCollectors = new MetricCollectors();
    this.engine = new KsqlEngine(serviceContext, NoopProcessingLogContext.INSTANCE, metaStore, ServiceInfo.create(config), new SequentialQueryIdGenerator(), this.config, Collections.singletonList(new QueryEventListener() {

        @Override
        public void onDeregister(QueryMetadata query) {
            final DriverAndProperties driverAndProperties = drivers.get(query.getQueryId());
            closeDriver(driverAndProperties.driver, driverAndProperties.properties, false);
        }
    }), metricCollectors);
    this.expectedException = null;
    this.expectedMessage = null;
    this.overrides = new HashMap<>();
    this.driverPipeline = new TestDriverPipeline();
}
Also used : KsqlEngine(io.confluent.ksql.engine.KsqlEngine) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata) QueryMetadata(io.confluent.ksql.util.QueryMetadata) MockSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient) MetaStoreImpl(io.confluent.ksql.metastore.MetaStoreImpl) FakeKafkaTopicClient(io.confluent.ksql.services.FakeKafkaTopicClient) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) KsqlConfig(io.confluent.ksql.util.KsqlConfig) DefaultFormatInjector(io.confluent.ksql.format.DefaultFormatInjector) QueryEventListener(io.confluent.ksql.engine.QueryEventListener) SequentialQueryIdGenerator(io.confluent.ksql.query.id.SequentialQueryIdGenerator) Before(org.junit.Before)

Example 10 with MetricCollectors

use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.

the class TestExecutor method getKsqlEngine.

static KsqlEngine getKsqlEngine(final ServiceContext serviceContext, final Optional<String> extensionDir) {
    final FunctionRegistry functionRegistry;
    if (extensionDir.isPresent()) {
        final MutableFunctionRegistry mutable = new InternalFunctionRegistry();
        UdfLoaderUtil.load(mutable, extensionDir.get());
        functionRegistry = mutable;
    } else {
        functionRegistry = TestFunctionRegistry.INSTANCE.get();
    }
    final MutableMetaStore metaStore = new MetaStoreImpl(functionRegistry);
    final MetricCollectors metricCollectors = new MetricCollectors();
    return new KsqlEngine(serviceContext, ProcessingLogContext.create(), "test_instance_", metaStore, (engine) -> new KsqlEngineMetrics("", engine, Collections.emptyMap(), Optional.empty(), metricCollectors), new SequentialQueryIdGenerator(), KsqlConfig.empty(), Collections.emptyList(), metricCollectors);
}
Also used : KsqlEngineMetrics(io.confluent.ksql.internal.KsqlEngineMetrics) InternalFunctionRegistry(io.confluent.ksql.function.InternalFunctionRegistry) FunctionRegistry(io.confluent.ksql.function.FunctionRegistry) MutableFunctionRegistry(io.confluent.ksql.function.MutableFunctionRegistry) KsqlEngine(io.confluent.ksql.engine.KsqlEngine) MutableFunctionRegistry(io.confluent.ksql.function.MutableFunctionRegistry) MetaStoreImpl(io.confluent.ksql.metastore.MetaStoreImpl) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) MutableMetaStore(io.confluent.ksql.metastore.MutableMetaStore) SequentialQueryIdGenerator(io.confluent.ksql.query.id.SequentialQueryIdGenerator) InternalFunctionRegistry(io.confluent.ksql.function.InternalFunctionRegistry)

Aggregations

MetricCollectors (io.confluent.ksql.metrics.MetricCollectors)46 Test (org.junit.Test)29 KsqlConfig (io.confluent.ksql.util.KsqlConfig)15 SourceDescriptionList (io.confluent.ksql.rest.entity.SourceDescriptionList)13 Before (org.junit.Before)13 InternalFunctionRegistry (io.confluent.ksql.function.InternalFunctionRegistry)12 MetaStoreImpl (io.confluent.ksql.metastore.MetaStoreImpl)10 DataSource (io.confluent.ksql.metastore.model.DataSource)10 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)10 KsqlEngine (io.confluent.ksql.engine.KsqlEngine)9 ServiceContext (io.confluent.ksql.services.ServiceContext)9 SequentialQueryIdGenerator (io.confluent.ksql.query.id.SequentialQueryIdGenerator)8 ConfiguredStatement (io.confluent.ksql.statement.ConfiguredStatement)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 SourceDescriptionEntity (io.confluent.ksql.rest.entity.SourceDescriptionEntity)7 TestServiceContext (io.confluent.ksql.services.TestServiceContext)7 Collections (java.util.Collections)7 Map (java.util.Map)7 Optional (java.util.Optional)7