use of org.apache.samza.system.kafka.descriptors.KafkaSystemDescriptor in project samza by apache.
the class AsyncApplicationExample method describe.
@Override
public void describe(StreamApplicationDescriptor appDescriptor) {
KafkaSystemDescriptor trackingSystem = new KafkaSystemDescriptor("tracking");
KafkaInputDescriptor<AdClickEvent> inputStreamDescriptor = trackingSystem.getInputDescriptor("adClickEvent", new JsonSerdeV2<>(AdClickEvent.class));
KafkaOutputDescriptor<KV<String, EnrichedAdClickEvent>> outputStreamDescriptor = trackingSystem.getOutputDescriptor("enrichedAdClickEvent", KVSerde.of(new StringSerde(), new JsonSerdeV2<>(EnrichedAdClickEvent.class)));
MessageStream<AdClickEvent> adClickEventStream = appDescriptor.getInputStream(inputStreamDescriptor);
OutputStream<KV<String, EnrichedAdClickEvent>> enrichedAdClickStream = appDescriptor.getOutputStream(outputStreamDescriptor);
adClickEventStream.flatMapAsync(AsyncApplicationExample::enrichAdClickEvent).map(enrichedAdClickEvent -> KV.of(enrichedAdClickEvent.getCountry(), enrichedAdClickEvent)).sendTo(enrichedAdClickStream);
}
use of org.apache.samza.system.kafka.descriptors.KafkaSystemDescriptor in project samza by apache.
the class BroadcastAssertApp method describe.
@Override
public void describe(StreamApplicationDescriptor appDescriptor) {
Config config = appDescriptor.getConfig();
String inputTopic = config.get(INPUT_TOPIC_NAME_PROP);
final JsonSerdeV2<PageView> serde = new JsonSerdeV2<>(PageView.class);
KafkaSystemDescriptor ksd = new KafkaSystemDescriptor(SYSTEM);
KafkaInputDescriptor<PageView> isd = ksd.getInputDescriptor(inputTopic, serde);
final MessageStream<PageView> broadcastPageViews = appDescriptor.getInputStream(isd).broadcast(serde, "pv");
/**
* Each task will see all the pageview events
*/
MessageStreamAssert.that("Each task contains all broadcast PageView events", broadcastPageViews, serde).forEachTask().containsInAnyOrder(Arrays.asList(new PageView("v1", "p1", "u1"), new PageView("v2", "p2", "u1"), new PageView("v3", "p1", "u2"), new PageView("v4", "p3", "u2")));
}
use of org.apache.samza.system.kafka.descriptors.KafkaSystemDescriptor in project samza by apache.
the class TestStreamApplication method describe.
@Override
public void describe(StreamApplicationDescriptor appDescriptor) {
KafkaSystemDescriptor ksd = new KafkaSystemDescriptor(systemName);
KafkaOutputDescriptor<String> osd = ksd.getOutputDescriptor(outputTopic, new StringSerde());
OutputStream<String> outputStream = appDescriptor.getOutputStream(osd);
for (String inputTopic : inputTopics) {
KafkaInputDescriptor<String> isd = ksd.getInputDescriptor(inputTopic, new NoOpSerde<>());
MessageStream<String> inputStream = appDescriptor.getInputStream(isd);
inputStream.map(new TestMapFunction(appName, processorName)).sendTo(outputStream);
}
}
use of org.apache.samza.system.kafka.descriptors.KafkaSystemDescriptor in project samza by apache.
the class TestTaskApplication method describe.
@Override
public void describe(TaskApplicationDescriptor appDescriptor) {
KafkaSystemDescriptor ksd = new KafkaSystemDescriptor(systemName);
KafkaInputDescriptor<TestTableData.Profile> inputDescriptor = ksd.getInputDescriptor(inputTopic, new NoOpSerde<>());
KafkaOutputDescriptor<TestTableData.EnrichedPageView> outputDescriptor = ksd.getOutputDescriptor(outputTopic, new NoOpSerde<>());
appDescriptor.withInputStream(inputDescriptor).withOutputStream(outputDescriptor).withTaskFactory((AsyncStreamTaskFactory) () -> new TestTaskImpl());
}
Aggregations