SAMZA-1268: Javadoc cleanup for public APIs for 0.13 release
[samza.git] / samza-api / src / main / java / org / apache / samza / operators / StreamGraph.java
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.samza.operators;
20
21 import org.apache.samza.annotation.InterfaceStability;
22
23 import java.util.function.BiFunction;
24 import java.util.function.Function;
25
26 /**
27 * Provides access to {@link MessageStream}s and {@link OutputStream}s used to describe the processing logic.
28 */
29 @InterfaceStability.Unstable
30 public interface StreamGraph {
31
32 /**
33 * Gets the input {@link MessageStream} corresponding to the {@code streamId}.
34 * <p>
35 * Multiple invocations of this method with the same {@code streamId} will throw an {@link IllegalStateException}.
36 *
37 * @param streamId the unique ID for the stream
38 * @param msgBuilder the {@link BiFunction} to convert the incoming key and message to a message
39 * in the input {@link MessageStream}
40 * @param <K> the type of key in the incoming message
41 * @param <V> the type of message in the incoming message
42 * @param <M> the type of message in the input {@link MessageStream}
43 * @return the input {@link MessageStream}
44 * @throws IllegalStateException when invoked multiple times with the same {@code streamId}
45 */
46 <K, V, M> MessageStream<M> getInputStream(String streamId, BiFunction<? super K, ? super V, ? extends M> msgBuilder);
47
48 /**
49 * Gets the {@link OutputStream} corresponding to the {@code streamId}.
50 * <p>
51 * Multiple invocations of this method with the same {@code streamId} will throw an {@link IllegalStateException}.
52 *
53 * @param streamId the unique ID for the stream
54 * @param keyExtractor the {@link Function} to extract the outgoing key from the output message
55 * @param msgExtractor the {@link Function} to extract the outgoing message from the output message
56 * @param <K> the type of key in the outgoing message
57 * @param <V> the type of message in the outgoing message
58 * @param <M> the type of message in the {@link OutputStream}
59 * @return the output {@link MessageStream}
60 * @throws IllegalStateException when invoked multiple times with the same {@code streamId}
61 */
62 <K, V, M> OutputStream<K, V, M> getOutputStream(String streamId,
63 Function<? super M, ? extends K> keyExtractor, Function<? super M, ? extends V> msgExtractor);
64
65 /**
66 * Sets the {@link ContextManager} for this {@link StreamGraph}.
67 * <p>
68 * The provided {@link ContextManager} can be used to setup shared context between the operator functions
69 * within a task instance
70 *
71 * @param contextManager the {@link ContextManager} to use for the {@link StreamGraph}
72 * @return the {@link StreamGraph} with {@code contextManager} set as its {@link ContextManager}
73 */
74 StreamGraph withContextManager(ContextManager contextManager);
75
76 }