use of org.apache.kafka.streams.errors.TopologyException in project apache-kafka-on-k8s by banzaicloud.
the class KStreamsFineGrainedAutoResetIntegrationTest method shouldThrowExceptionOverlappingPattern.
@Test
public void shouldThrowExceptionOverlappingPattern() throws Exception {
final KStreamBuilder builder = new KStreamBuilder();
// NOTE this would realistically get caught when building topology, the test is for completeness
builder.stream(KStreamBuilder.AutoOffsetReset.EARLIEST, Pattern.compile("topic-[A-D]_1"));
builder.stream(KStreamBuilder.AutoOffsetReset.LATEST, Pattern.compile("topic-[A-D]_1"));
// instead of at runtime. See KAFKA-5660
try {
builder.earliestResetTopicsPattern();
fail("Should have thrown TopologyException");
} catch (final TopologyException expected) {
// do nothing
}
}
use of org.apache.kafka.streams.errors.TopologyException in project apache-kafka-on-k8s by banzaicloud.
the class KStreamsFineGrainedAutoResetIntegrationTest method shouldThrowExceptionOverlappingTopic.
@Test
public void shouldThrowExceptionOverlappingTopic() throws Exception {
final StreamsBuilder builder = new StreamsBuilder();
// NOTE this would realistically get caught when building topology, the test is for completeness
builder.stream(Pattern.compile("topic-[A-D]_1"), Consumed.with(Topology.AutoOffsetReset.EARLIEST));
try {
builder.stream(Arrays.asList(TOPIC_A_1, TOPIC_Z_1), Consumed.with(Topology.AutoOffsetReset.LATEST));
fail("Should have thrown TopologyException");
} catch (final TopologyException expected) {
// do nothing
}
}
use of org.apache.kafka.streams.errors.TopologyException in project apache-kafka-on-k8s by banzaicloud.
the class TopologyTest method shouldNotAllowToAddProcessorWithSameName.
@Test
public void shouldNotAllowToAddProcessorWithSameName() {
topology.addSource("source", "topic-1");
topology.addProcessor("processor", new MockProcessorSupplier(), "source");
try {
topology.addProcessor("processor", new MockProcessorSupplier(), "source");
fail("Should throw TopologyException for duplicate processor name");
} catch (TopologyException expected) {
}
}
use of org.apache.kafka.streams.errors.TopologyException in project apache-kafka-on-k8s by banzaicloud.
the class KTableImpl method writeAsText.
/**
* @throws TopologyException if file is not found
*/
@SuppressWarnings({ "unchecked", "deprecation" })
@Override
public void writeAsText(final String filePath, final String label, final Serde<K> keySerde, final Serde<V> valSerde) {
Objects.requireNonNull(filePath, "filePath can't be null");
Objects.requireNonNull(label, "label can't be null");
if (filePath.trim().isEmpty()) {
throw new TopologyException("filePath can't be an empty string");
}
final String name = builder.newProcessorName(PRINTING_NAME);
try {
builder.internalTopologyBuilder.addProcessor(name, new KStreamPrint<>(new PrintForeachAction<>(new FileOutputStream(filePath), defaultKeyValueMapper, label)), this.name);
} catch (final FileNotFoundException e) {
throw new TopologyException(String.format("Unable to write stream to file at [%s] %s", filePath, e.getMessage()));
}
}
use of org.apache.kafka.streams.errors.TopologyException in project apache-kafka-on-k8s by banzaicloud.
the class InternalTopologyBuilderTest method testAddStateStoreWithSource.
@Test
public void testAddStateStoreWithSource() {
builder.addSource(null, "source-1", null, null, null, "topic-1");
try {
builder.addStateStore(new MockStateStoreSupplier("store", false), "source-1");
fail("Should throw TopologyException with store cannot be added to source");
} catch (final TopologyException expected) {
/* ok */
}
}
Aggregations