Search in sources :

Example 36 with KsqlEngine

use of io.confluent.ksql.engine.KsqlEngine in project ksql by confluentinc.

the class RequestHandler method executeStatement.

@SuppressWarnings("unchecked")
private <T extends Statement> Optional<KsqlEntity> executeStatement(final KsqlSecurityContext securityContext, final PreparedStatement<T> prepared, final SessionProperties sessionProperties, final KsqlEntityList entities) {
    final Class<? extends Statement> statementClass = prepared.getStatement().getClass();
    commandQueueSync.waitFor(new KsqlEntityList(entities), statementClass);
    final ConfiguredStatement<T> configured = ConfiguredStatement.of(prepared, SessionConfig.of(this.ksqlEngine.getKsqlConfig(), sessionProperties.getMutableScopedProperties()));
    FeatureFlagChecker.throwOnDisabledFeatures(configured);
    final StatementExecutor<T> executor = (StatementExecutor<T>) customExecutors.getOrDefault(statementClass, (stmt, props, ctx, svcCtx) -> distributor.execute(stmt, ctx, securityContext));
    final StatementExecutorResponse response = executor.execute(configured, sessionProperties, ksqlEngine, securityContext.getServiceContext());
    if (response.isHandled()) {
        return response.getEntity();
    } else {
        return distributor.execute(configured, ksqlEngine, securityContext).getEntity();
    }
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) SessionProperties(io.confluent.ksql.rest.SessionProperties) KsqlEngine(io.confluent.ksql.engine.KsqlEngine) KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) KsqlConfig(io.confluent.ksql.util.KsqlConfig) FeatureFlagChecker(io.confluent.ksql.rest.util.FeatureFlagChecker) KsqlSecurityContext(io.confluent.ksql.security.KsqlSecurityContext) DistributingExecutor(io.confluent.ksql.rest.server.computation.DistributingExecutor) SessionConfig(io.confluent.ksql.config.SessionConfig) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) Objects(java.util.Objects) List(java.util.List) Map(java.util.Map) ParsedStatement(io.confluent.ksql.parser.KsqlParser.ParsedStatement) Optional(java.util.Optional) Statement(io.confluent.ksql.parser.tree.Statement) Collections(java.util.Collections) PreparedStatement(io.confluent.ksql.parser.KsqlParser.PreparedStatement)

Example 37 with KsqlEngine

use of io.confluent.ksql.engine.KsqlEngine 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)

Example 38 with KsqlEngine

use of io.confluent.ksql.engine.KsqlEngine in project ksql by confluentinc.

the class ClientIntegrationTest method verifyNumActiveQueries.

private static void verifyNumActiveQueries(final int numQueries) {
    final KsqlEngine engine = (KsqlEngine) REST_APP.getEngine();
    assertThatEventually(engine::numberOfLiveQueries, is(numQueries));
}
Also used : KsqlEngine(io.confluent.ksql.engine.KsqlEngine)

Aggregations

KsqlEngine (io.confluent.ksql.engine.KsqlEngine)38 Test (org.junit.Test)25 ConfiguredStatement (io.confluent.ksql.statement.ConfiguredStatement)24 PersistentQueryMetadata (io.confluent.ksql.util.PersistentQueryMetadata)22 InternalFunctionRegistry (io.confluent.ksql.function.InternalFunctionRegistry)14 SequentialQueryIdGenerator (io.confluent.ksql.query.id.SequentialQueryIdGenerator)14 KsqlConfig (io.confluent.ksql.util.KsqlConfig)14 MetricCollectors (io.confluent.ksql.metrics.MetricCollectors)13 ServiceContext (io.confluent.ksql.services.ServiceContext)13 MutableFunctionRegistry (io.confluent.ksql.function.MutableFunctionRegistry)11 KsqlEntity (io.confluent.ksql.rest.entity.KsqlEntity)11 KsqlHostInfoEntity (io.confluent.ksql.rest.entity.KsqlHostInfoEntity)11 Queries (io.confluent.ksql.rest.entity.Queries)11 List (java.util.List)11 MetaStoreImpl (io.confluent.ksql.metastore.MetaStoreImpl)10 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)10 Matchers.is (org.hamcrest.Matchers.is)10 ImmutableList (com.google.common.collect.ImmutableList)9 SessionConfig (io.confluent.ksql.config.SessionConfig)9 KsqlEngineMetrics (io.confluent.ksql.internal.KsqlEngineMetrics)9