Search in sources :

Example 1 with PrecommittingSinkWriter

use of org.apache.flink.api.connector.sink2.TwoPhaseCommittingSink.PrecommittingSinkWriter in project flink by apache.

the class SinkWriterOperator method emitCommittables.

private void emitCommittables(Long checkpointId) throws IOException, InterruptedException {
    if (!emitDownstream) {
        // although no committables are forwarded
        if (sinkWriter instanceof PrecommittingSinkWriter) {
            ((PrecommittingSinkWriter<?, ?>) sinkWriter).prepareCommit();
        }
        return;
    }
    Collection<CommT> committables = ((PrecommittingSinkWriter<?, CommT>) sinkWriter).prepareCommit();
    StreamingRuntimeContext runtimeContext = getRuntimeContext();
    int indexOfThisSubtask = runtimeContext.getIndexOfThisSubtask();
    output.collect(new StreamRecord<>(new CommittableSummary<>(indexOfThisSubtask, runtimeContext.getNumberOfParallelSubtasks(), checkpointId, committables.size(), committables.size(), 0)));
    for (CommT committable : committables) {
        output.collect(new StreamRecord<>(new CommittableWithLineage<>(committable, checkpointId, indexOfThisSubtask)));
    }
}
Also used : PrecommittingSinkWriter(org.apache.flink.api.connector.sink2.TwoPhaseCommittingSink.PrecommittingSinkWriter) CommittableSummary(org.apache.flink.streaming.api.connector.sink2.CommittableSummary) CommittableWithLineage(org.apache.flink.streaming.api.connector.sink2.CommittableWithLineage) StreamingRuntimeContext(org.apache.flink.streaming.api.operators.StreamingRuntimeContext)

Aggregations

PrecommittingSinkWriter (org.apache.flink.api.connector.sink2.TwoPhaseCommittingSink.PrecommittingSinkWriter)1 CommittableSummary (org.apache.flink.streaming.api.connector.sink2.CommittableSummary)1 CommittableWithLineage (org.apache.flink.streaming.api.connector.sink2.CommittableWithLineage)1 StreamingRuntimeContext (org.apache.flink.streaming.api.operators.StreamingRuntimeContext)1