use of org.apache.rya.streams.kafka.topology.TopologyBuilderFactory.TopologyBuilderException in project incubator-rya by apache.
the class SingleThreadKafkaStreamsFactory method make.
@Override
public KafkaStreams make(final String ryaInstance, final StreamsQuery query) throws KafkaStreamsFactoryException {
requireNonNull(ryaInstance);
requireNonNull(query);
// Setup the Kafka Stream program.
final Properties streamsProps = new Properties();
// Configure the Kafka servers that will be talked to.
streamsProps.setProperty(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServersConfig);
// Use the Query ID as the Application ID to ensure we resume where we left off the last time this command was run.
streamsProps.put(StreamsConfig.APPLICATION_ID_CONFIG, "RyaStreams-Query-" + query.getQueryId());
// Always start at the beginning of the input topic.
streamsProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
// Setup the topology that processes the Query.
final String statementsTopic = KafkaTopics.statementsTopic(ryaInstance);
final String resultsTopic = KafkaTopics.queryResultsTopic(ryaInstance, query.getQueryId());
try {
final TopologyBuilder topologyBuilder = topologyFactory.build(query.getSparql(), statementsTopic, resultsTopic, new RandomUUIDFactory());
return new KafkaStreams(topologyBuilder, new StreamsConfig(streamsProps));
} catch (final MalformedQueryException | TopologyBuilderException e) {
throw new KafkaStreamsFactoryException("Could not create a KafkaStreams processing topology for query " + query.getQueryId(), e);
}
}
Aggregations