AHeise commented on a change in pull request #16701:
URL: https://github.com/apache/flink/pull/16701#discussion_r683293393
##########
File path:
flink-core/src/main/java/org/apache/flink/api/connector/sink/Sink.java
##########
@@ -48,41 +54,70 @@
public interface Sink<InputT, CommT, WriterStateT, GlobalCommT> extends
Serializable {
/**
- * Create a {@link SinkWriter}.
+ * Create a {@link SinkWriter}. If the application is resumed from a
checkpoint or savepoint and
+ * the sink is stateful, it will receive the corresponding state obtained
with {@link
+ * SinkWriter#snapshotState()} and serialized with {@link
#getWriterStateSerializer()}. If no
+ * state exists, the first existing, compatible state specified in {@link
+ * #getCompatibleStateNames()} will be loaded and passed.
*
* @param context the runtime context.
- * @param states the writer's state.
+ * @param states the writer's previous state.
* @return A sink writer.
- * @throws IOException if fail to create a writer.
+ * @throws IOException for any failure during creation.
+ * @see SinkWriter#snapshotState()
+ * @see #getWriterStateSerializer()
+ * @see #getCompatibleStateNames()
*/
SinkWriter<InputT, CommT, WriterStateT> createWriter(
InitContext context, List<WriterStateT> states) throws IOException;
/**
- * Creates a {@link Committer}.
+ * Any stateful sink needs to provide this state serializer and implement
{@link
+ * SinkWriter#snapshotState()} properly. The respective state is used in
{@link
+ * #createWriter(InitContext, List)} on recovery.
+ *
+ * @return the serializer of the writer's state type.
+ */
+ Optional<SimpleVersionedSerializer<WriterStateT>>
getWriterStateSerializer();
+
+ /**
+ * Creates a {@link Committer} which is part of a 2-phase-commit protocol.
The {@link
+ * SinkWriter} creates committables through {@link
SinkWriter#prepareCommit(boolean)} in the
+ * first phase. The committables are then passed to this committer and
persisted with {@link
+ * Committer#commit(List)}. If a committer is returned, the sink must also
return a {@link
+ * #getCommittableSerializer()}.
*
- * @return A committer.
- * @throws IOException if fail to create a committer.
+ * @return A committer for the 2-phase-commit protocol.
+ * @throws IOException for any failure during creation.
*/
Optional<Committer<CommT>> createCommitter() throws IOException;
/**
- * Creates a {@link GlobalCommitter}.
+ * Creates a {@link GlobalCommitter} which is part of a 2-phase-commit
protocol. The {@link
+ * SinkWriter} creates committables through {@link
SinkWriter#prepareCommit(boolean)} in the
+ * first phase. The committables are then passed to the Committer and
persisted with {@link
+ * Committer#commit(List)} which also can return an aggregated
committable. This aggregated
Review comment:
You are right. Thanks for double-checking!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]