Search in sources :

Example 6 with SessionConfig

use of io.confluent.ksql.config.SessionConfig in project ksql by confluentinc.

the class KafkaStreamsQueryValidator method validateCacheBytesUsage.

private void validateCacheBytesUsage(final Collection<QueryMetadata> running, final SessionConfig config, final long limit) {
    if (limit < 0) {
        return;
    }
    final long configured = getCacheMaxBytesBuffering(config);
    final long usedByRunning = running.stream().mapToLong(r -> new StreamsConfig(r.getStreamsProperties()).getLong(StreamsConfig.CACHE_MAX_BYTES_BUFFERING_CONFIG)).sum();
    if (configured + usedByRunning > limit) {
        throw new KsqlException(String.format("Configured cache usage (cache.max.bytes.buffering=%d) would put usage over the " + "configured limit (%d). Current usage is %d", configured, usedByRunning, limit));
    }
}
Also used : SessionConfig(io.confluent.ksql.config.SessionConfig) QueryMetadata(io.confluent.ksql.util.QueryMetadata) TransientQueryMetadata(io.confluent.ksql.util.TransientQueryMetadata) StreamsConfig(org.apache.kafka.streams.StreamsConfig) PhysicalPlan(io.confluent.ksql.physical.PhysicalPlan) Collection(java.util.Collection) Map(java.util.Map) KsqlException(io.confluent.ksql.util.KsqlException) HashMap(java.util.HashMap) KsqlConfig(io.confluent.ksql.util.KsqlConfig) Collectors(java.util.stream.Collectors) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata) KsqlException(io.confluent.ksql.util.KsqlException) StreamsConfig(org.apache.kafka.streams.StreamsConfig)

Example 7 with SessionConfig

use of io.confluent.ksql.config.SessionConfig in project ksql by confluentinc.

the class KafkaStreamsQueryValidatorTest method shouldLimitBufferCacheLimitForTransientQueries.

@Test
public void shouldLimitBufferCacheLimitForTransientQueries() {
    // Given:
    final SessionConfig config = configWithLimitsTransient(5, OptionalLong.of(30));
    // When/Then:
    assertThrows(KsqlException.class, () -> queryValidator.validateTransientQuery(config, plan, queries));
}
Also used : SessionConfig(io.confluent.ksql.config.SessionConfig) Test(org.junit.Test)

Example 8 with SessionConfig

use of io.confluent.ksql.config.SessionConfig in project ksql by confluentinc.

the class KafkaStreamsQueryValidatorTest method shouldNotThrowIfUnderLimit.

@Test
public void shouldNotThrowIfUnderLimit() {
    // Given:
    final SessionConfig config = configWithLimits(5, OptionalLong.of(40));
    // When/Then (no throw)
    queryValidator.validateQuery(config, plan, queries);
}
Also used : SessionConfig(io.confluent.ksql.config.SessionConfig) Test(org.junit.Test)

Example 9 with SessionConfig

use of io.confluent.ksql.config.SessionConfig in project ksql by confluentinc.

the class KafkaStreamsQueryValidatorTest method shouldIgnoreBufferCacheLimitIfNotSet.

@Test
public void shouldIgnoreBufferCacheLimitIfNotSet() {
    // Given:
    final SessionConfig config = configWithLimits(100000000000L, OptionalLong.empty());
    // When/Then (no throw)
    queryValidator.validateQuery(config, plan, queries);
}
Also used : SessionConfig(io.confluent.ksql.config.SessionConfig) Test(org.junit.Test)

Example 10 with SessionConfig

use of io.confluent.ksql.config.SessionConfig in project ksql by confluentinc.

the class KafkaStreamsQueryValidatorTest method shouldIgnoreBufferCacheLimitIfNotSetForTransientQueries.

@Test
public void shouldIgnoreBufferCacheLimitIfNotSetForTransientQueries() {
    // Given:
    final SessionConfig config = configWithLimits(100000000000L, OptionalLong.empty());
    // When/Then (no throw)
    queryValidator.validateTransientQuery(config, plan, queries);
}
Also used : SessionConfig(io.confluent.ksql.config.SessionConfig) Test(org.junit.Test)

Aggregations

SessionConfig (io.confluent.ksql.config.SessionConfig)12 Test (org.junit.Test)6 KsqlConfig (io.confluent.ksql.util.KsqlConfig)4 ImmutableAnalysis (io.confluent.ksql.analyzer.ImmutableAnalysis)3 DataSource (io.confluent.ksql.metastore.model.DataSource)3 Query (io.confluent.ksql.parser.tree.Query)3 KsqlStatementException (io.confluent.ksql.util.KsqlStatementException)3 Throwables (com.google.common.base.Throwables)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Iterables (com.google.common.collect.Iterables)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 ExecuteResult (io.confluent.ksql.KsqlExecutionContext.ExecuteResult)2 CreateTableCommand (io.confluent.ksql.execution.ddl.commands.CreateTableCommand)2 DdlCommand (io.confluent.ksql.execution.ddl.commands.DdlCommand)2 KsqlTopic (io.confluent.ksql.execution.ddl.commands.KsqlTopic)2 UnqualifiedColumnReferenceExp (io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp)2 ExecutionStep (io.confluent.ksql.execution.plan.ExecutionStep)2 Formats (io.confluent.ksql.execution.plan.Formats)2 PlanInfo (io.confluent.ksql.execution.plan.PlanInfo)2