Search in sources :

Example 1 with EnrichedAdClickEvent

use of org.apache.samza.example.models.EnrichedAdClickEvent 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);
}
Also used : CommandLine(org.apache.samza.util.CommandLine) Random(java.util.Random) CompletableFuture(java.util.concurrent.CompletableFuture) StringSerde(org.apache.samza.serializers.StringSerde) AdClickEvent(org.apache.samza.example.models.AdClickEvent) KafkaOutputDescriptor(org.apache.samza.system.kafka.descriptors.KafkaOutputDescriptor) ImmutableList(com.google.common.collect.ImmutableList) EnrichedAdClickEvent(org.apache.samza.example.models.EnrichedAdClickEvent) ApplicationRunners(org.apache.samza.runtime.ApplicationRunners) KV(org.apache.samza.operators.KV) MessageStream(org.apache.samza.operators.MessageStream) ApplicationRunner(org.apache.samza.runtime.ApplicationRunner) KafkaInputDescriptor(org.apache.samza.system.kafka.descriptors.KafkaInputDescriptor) Collection(java.util.Collection) Member(org.apache.samza.example.models.Member) KafkaSystemDescriptor(org.apache.samza.system.kafka.descriptors.KafkaSystemDescriptor) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) StreamApplicationDescriptor(org.apache.samza.application.descriptors.StreamApplicationDescriptor) Config(org.apache.samza.config.Config) JsonSerdeV2(org.apache.samza.serializers.JsonSerdeV2) KVSerde(org.apache.samza.serializers.KVSerde) StreamApplication(org.apache.samza.application.StreamApplication) Collections(java.util.Collections) OutputStream(org.apache.samza.operators.OutputStream) AdClickEvent(org.apache.samza.example.models.AdClickEvent) EnrichedAdClickEvent(org.apache.samza.example.models.EnrichedAdClickEvent) StringSerde(org.apache.samza.serializers.StringSerde) KV(org.apache.samza.operators.KV) KafkaSystemDescriptor(org.apache.samza.system.kafka.descriptors.KafkaSystemDescriptor) JsonSerdeV2(org.apache.samza.serializers.JsonSerdeV2)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Random (java.util.Random)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletionStage (java.util.concurrent.CompletionStage)1 StreamApplication (org.apache.samza.application.StreamApplication)1 StreamApplicationDescriptor (org.apache.samza.application.descriptors.StreamApplicationDescriptor)1 Config (org.apache.samza.config.Config)1 AdClickEvent (org.apache.samza.example.models.AdClickEvent)1 EnrichedAdClickEvent (org.apache.samza.example.models.EnrichedAdClickEvent)1 Member (org.apache.samza.example.models.Member)1 KV (org.apache.samza.operators.KV)1 MessageStream (org.apache.samza.operators.MessageStream)1 OutputStream (org.apache.samza.operators.OutputStream)1 ApplicationRunner (org.apache.samza.runtime.ApplicationRunner)1 ApplicationRunners (org.apache.samza.runtime.ApplicationRunners)1 JsonSerdeV2 (org.apache.samza.serializers.JsonSerdeV2)1 KVSerde (org.apache.samza.serializers.KVSerde)1