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));
}
}
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));
}
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);
}
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);
}
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);
}
Aggregations