use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class TestDriverPipelineTest method shouldDetectLoops.
@Test
public void shouldDetectLoops() {
// Given:
final TopologyTestDriver driver1 = mock(TopologyTestDriver.class);
final TopologyTestDriver driver2 = mock(TopologyTestDriver.class);
final TestInputTopic<GenericKey, GenericRow> inA = givenInput(driver1, "a");
givenOutput(driver1, "b");
final TestInputTopic<GenericKey, GenericRow> inB = givenInput(driver2, "b");
givenOutput(driver2, "a");
givenPipe(inA, "b");
givenPipe(inB, "a");
pipeline.addDriver(driver1, ImmutableList.of(inf("a")), inf("b"));
pipeline.addDriver(driver2, ImmutableList.of(inf("b")), inf("a"));
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> pipeline.pipeInput("a", KEY, ROW1, 1));
// Then:
assertThat(e.getMessage(), containsString("Detected illegal cycle in topology: a->b->a"));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class TestDriverPipelineTest method shouldHandleLinearChainTopology.
@Test
public void shouldHandleLinearChainTopology() {
// Given (a topology that pipes a directly to b, and from b to c):
final TopologyTestDriver driver = mock(TopologyTestDriver.class);
final TestInputTopic<GenericKey, GenericRow> inA = givenInput(driver, "a");
givenOutput(driver, "b");
final TestInputTopic<GenericKey, GenericRow> inB = givenInput(driver, "b");
givenOutput(driver, "c");
givenPipe(inA, "b");
givenPipe(inB, "c");
pipeline.addDriver(driver, ImmutableList.of(inf("a")), inf("b"));
pipeline.addDriver(driver, ImmutableList.of(inf("b")), inf("c"));
// When:
pipeline.pipeInput("a", KEY, ROW1, 1);
// Then:
assertThat(pipeline.getAllRecordsForTopic("b"), is(ImmutableList.of(new TestRecord<>(KEY, ROW1, Instant.ofEpochMilli(1)))));
assertThat(pipeline.getAllRecordsForTopic("c"), is(ImmutableList.of(new TestRecord<>(KEY, ROW1, Instant.ofEpochMilli(1)))));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class TestDriverPipelineTest method shouldHandleSingleTopology.
@Test
public void shouldHandleSingleTopology() {
// Given (a topology that pipes a directly to b):
final TopologyTestDriver driver = mock(TopologyTestDriver.class);
final TestInputTopic<GenericKey, GenericRow> inA = givenInput(driver, "a");
givenOutput(driver, "b");
givenPipe(inA, "b");
pipeline.addDriver(driver, ImmutableList.of(inf("a")), inf("b"));
// When:
pipeline.pipeInput("a", KEY, ROW1, 1);
// Then:
assertThat(pipeline.getAllRecordsForTopic("b"), is(ImmutableList.of(new TestRecord<>(KEY, ROW1, Instant.ofEpochMilli(1)))));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class SourceBuilderBase method buildTable.
KTableHolder<GenericKey> buildTable(final RuntimeBuildContext buildContext, final SourceStep<KTableHolder<GenericKey>> source, final ConsumedFactory consumedFactory, final MaterializedFactory materializedFactory, final PlanInfo planInfo) {
final PhysicalSchema physicalSchema = getPhysicalSchema(source);
final Serde<GenericRow> valueSerde = getValueSerde(buildContext, source, physicalSchema);
final Serde<GenericKey> keySerde = getKeySerde(source, physicalSchema, buildContext);
final Consumed<GenericKey, GenericRow> consumed = buildSourceConsumed(source, keySerde, valueSerde, AutoOffsetReset.EARLIEST, buildContext, consumedFactory);
final String stateStoreName = tableChangeLogOpName(source.getProperties());
final Materialized<GenericKey, GenericRow, KeyValueStore<Bytes, byte[]>> materialized = buildTableMaterialized(source, buildContext, materializedFactory, keySerde, valueSerde, stateStoreName);
final KTable<GenericKey, GenericRow> ktable = buildKTable(source, buildContext, consumed, GenericKey::values, materialized, valueSerde, stateStoreName, planInfo);
final LogicalSchema stateStoreSchema = source.getSourceSchema().withPseudoColumnsToMaterialize(source.getPseudoColumnVersion());
return KTableHolder.materialized(ktable, buildSchema(source, false), ExecutionKeyFactory.unwindowed(buildContext), MaterializationInfo.builder(stateStoreName, stateStoreSchema));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class SourceBuilderV1 method buildStream.
public KStreamHolder<GenericKey> buildStream(final RuntimeBuildContext buildContext, final StreamSource source, final ConsumedFactory consumedFactory) {
final PhysicalSchema physicalSchema = getPhysicalSchema(source);
final Serde<GenericRow> valueSerde = getValueSerde(buildContext, source, physicalSchema);
final Serde<GenericKey> keySerde = getKeySerde(source, physicalSchema, buildContext);
final Consumed<GenericKey, GenericRow> consumed = buildSourceConsumed(source, keySerde, valueSerde, AutoOffsetReset.LATEST, buildContext, consumedFactory);
final KStream<GenericKey, GenericRow> kstream = buildKStream(source, buildContext, consumed, nonWindowedKeyGenerator(source.getSourceSchema()));
return new KStreamHolder<>(kstream, buildSchema(source, false), ExecutionKeyFactory.unwindowed(buildContext));
}
Aggregations