Search in sources :

Example 41 with MetricCollectors

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

the class EmbeddedKsql method main.

public static void main(final String[] args) {
    final KsqlContext ksqlContext = KsqlContext.create(new KsqlConfig(Collections.emptyMap()), ProcessingLogContext.create(), new MetricCollectors());
    ksqlContext.sql("REGISTER TOPIC orders_topic WITH (format = 'json', " + "kafka_topic='orders_topic_json');");
    ksqlContext.sql("CREATE STREAM orders (orderid bigint KEY, ordertime bigint, itemid varchar, " + "orderunits double, arraycol array<double>, mapcol map<varchar, double>) " + "WITH (topicname = 'orders_topic' );\n");
    ksqlContext.sql("CREATE STREAM BIGORDERS AS SELECT * FROM ORDERS WHERE ORDERUNITS > 5;");
    ksqlContext.sql("SELECT * FROM ORDERS;");
    ksqlContext.sql("CREATE TABLE ORDERSUMS AS select itemid, sum(orderunits) from orders window " + "TUMBLING ( size 30 second) group by itemid;");
    System.out.println("Queries are running!");
}
Also used : MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) KsqlConfig(io.confluent.ksql.util.KsqlConfig)

Example 42 with MetricCollectors

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

the class KsqlAuthorizationValidatorImplTest method setUp.

@Before
public void setUp() {
    metaStore = new MetaStoreImpl(new InternalFunctionRegistry());
    ksqlEngine = KsqlEngineTestUtil.createKsqlEngine(serviceContext, metaStore, new MetricCollectors());
    authorizationValidator = new KsqlAuthorizationValidatorImpl(accessValidator);
    securityContext = new KsqlSecurityContext(Optional.empty(), serviceContext);
    givenStreamWithTopic(KAFKA_STREAM_TOPIC, KAFKA_KSQL_TOPIC);
    givenStreamWithTopic(AVRO_STREAM_TOPIC, AVRO_KSQL_TOPIC);
}
Also used : MetaStoreImpl(io.confluent.ksql.metastore.MetaStoreImpl) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) InternalFunctionRegistry(io.confluent.ksql.function.InternalFunctionRegistry) Before(org.junit.Before)

Example 43 with MetricCollectors

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

the class StandaloneExecutorFactory method create.

public static StandaloneExecutor create(final Map<String, String> properties, final String queriesFile, final String installDir, final MetricCollectors metricCollectors) {
    final KsqlConfig tempConfig = new KsqlConfig(properties);
    final Function<KsqlConfig, ServiceContext> serviceContextFactory = config -> ServiceContextFactory.create(config, DisabledKsqlClient::instance);
    final ServiceContext tempServiceContext = serviceContextFactory.apply(tempConfig);
    final String kafkaClusterId = KafkaClusterUtil.getKafkaClusterId(tempServiceContext);
    final String ksqlServerId = tempConfig.getString(KsqlConfig.KSQL_SERVICE_ID_CONFIG);
    final Map<String, Object> updatedProperties = tempConfig.originals();
    updatedProperties.putAll(metricCollectors.addConfluentMetricsContextConfigs(ksqlServerId, kafkaClusterId));
    return create(updatedProperties, queriesFile, installDir, serviceContextFactory, KafkaConfigStore::new, KsqlVersionCheckerAgent::new, StandaloneExecutor::new, metricCollectors);
}
Also used : InternalFunctionRegistry(io.confluent.ksql.function.InternalFunctionRegistry) SequentialQueryIdGenerator(io.confluent.ksql.query.id.SequentialQueryIdGenerator) BiFunction(java.util.function.BiFunction) ServiceContext(io.confluent.ksql.services.ServiceContext) ProcessingLogContext(io.confluent.ksql.logging.processing.ProcessingLogContext) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) ReservedInternalTopics(io.confluent.ksql.util.ReservedInternalTopics) Function(java.util.function.Function) Supplier(java.util.function.Supplier) KafkaConfigStore(io.confluent.ksql.rest.server.computation.KafkaConfigStore) Injector(io.confluent.ksql.statement.Injector) Map(java.util.Map) UserFunctionLoader(io.confluent.ksql.function.UserFunctionLoader) KafkaClusterUtil(io.confluent.ksql.services.KafkaClusterUtil) KsqlVersionCheckerAgent(io.confluent.ksql.version.metrics.KsqlVersionCheckerAgent) KsqlEngine(io.confluent.ksql.engine.KsqlEngine) MutableFunctionRegistry(io.confluent.ksql.function.MutableFunctionRegistry) KsqlInternalTopicUtils(io.confluent.ksql.rest.util.KsqlInternalTopicUtils) ServiceInfo(io.confluent.ksql.ServiceInfo) KsqlConfig(io.confluent.ksql.util.KsqlConfig) ServiceContextFactory(io.confluent.ksql.services.ServiceContextFactory) DisabledKsqlClient(io.confluent.ksql.services.DisabledKsqlClient) VersionCheckerAgent(io.confluent.ksql.version.metrics.VersionCheckerAgent) KsqlExecutionContext(io.confluent.ksql.KsqlExecutionContext) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ConfigStore(io.confluent.ksql.rest.server.computation.ConfigStore) Collections(java.util.Collections) ProcessingLogConfig(io.confluent.ksql.logging.processing.ProcessingLogConfig) Injectors(io.confluent.ksql.statement.Injectors) DisabledKsqlClient(io.confluent.ksql.services.DisabledKsqlClient) KafkaConfigStore(io.confluent.ksql.rest.server.computation.KafkaConfigStore) ServiceContext(io.confluent.ksql.services.ServiceContext) KsqlConfig(io.confluent.ksql.util.KsqlConfig) KsqlVersionCheckerAgent(io.confluent.ksql.version.metrics.KsqlVersionCheckerAgent)

Example 44 with MetricCollectors

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

the class KsqlEngineMetricsTest method setUp.

@Before
public void setUp() {
    when(ksqlEngine.getServiceId()).thenReturn(KSQL_SERVICE_ID);
    metricCollectors = new MetricCollectors();
    engineMetrics = new KsqlEngineMetrics(METRIC_GROUP, ksqlEngine, metricCollectors, CUSTOM_TAGS, Optional.of(new TestKsqlMetricsExtension()));
}
Also used : MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) Before(org.junit.Before)

Example 45 with MetricCollectors

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

the class SecureIntegrationTest method givenTestSetupWithConfig.

private void givenTestSetupWithConfig(final Map<String, Object> ksqlConfigs) {
    ksqlConfig = new KsqlConfig(ksqlConfigs);
    serviceContext = ServiceContextFactory.create(ksqlConfig, DisabledKsqlClient::instance);
    ksqlEngine = new KsqlEngine(serviceContext, ProcessingLogContext.create(), new InternalFunctionRegistry(), ServiceInfo.create(ksqlConfig), new SequentialQueryIdGenerator(), ksqlConfig, Collections.emptyList(), new MetricCollectors());
    execInitCreateStreamQueries();
}
Also used : KsqlEngine(io.confluent.ksql.engine.KsqlEngine) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) KsqlConfig(io.confluent.ksql.util.KsqlConfig) 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