use of org.apache.kafka.streams.TopologyDescription.Processor in project ksql by confluentinc.
the class KsLocator method findSubtopologySourceTopicSuffixes.
/**
* For the particular state store, this finds the subtopology which contains that store, and
* then finds the input topics for the subtopology by finding the source nodes. These topics are
* then used for checking against all the metadata for the state store and used to find the
* active and standby hosts for the topics. Without doing this check, incorrect assignments could
* be chosen since different subtopologies can be run by different hosts.
*/
private Set<String> findSubtopologySourceTopicSuffixes() {
for (final Subtopology subtopology : topology.describe().subtopologies()) {
boolean containsStateStore = false;
for (final TopologyDescription.Node node : subtopology.nodes()) {
if (node instanceof Processor) {
final Processor processor = (Processor) node;
if (processor.stores().contains(storeName)) {
containsStateStore = true;
}
}
}
if (!containsStateStore) {
continue;
}
for (final TopologyDescription.Node node : subtopology.nodes()) {
if (node instanceof Source) {
final Source source = (Source) node;
Preconditions.checkNotNull(source.topicSet(), "Expecting topic set, not regex");
return source.topicSet();
}
}
throw new IllegalStateException("Failed to find source with topics");
}
throw new IllegalStateException("Failed to find state store " + storeName);
}
Aggregations