Class GenericWriteAheadSink<IN>
java.lang.Object
org.apache.flink.streaming.api.operators.AbstractStreamOperator<IN>
org.apache.flink.streaming.runtime.operators.GenericWriteAheadSink<IN>
- Type Parameters:
IN- Type of the elements emitted by this sink
- All Implemented Interfaces:
Serializable,org.apache.flink.api.common.state.CheckpointListener,org.apache.flink.streaming.api.operators.Input<IN>,org.apache.flink.streaming.api.operators.KeyContext,org.apache.flink.streaming.api.operators.KeyContextHandler,org.apache.flink.streaming.api.operators.OneInputStreamOperator<IN,,IN> org.apache.flink.streaming.api.operators.StreamOperator<IN>,org.apache.flink.streaming.api.operators.StreamOperatorStateHandler.CheckpointedStreamOperator,org.apache.flink.streaming.api.operators.YieldingOperator<IN>
public abstract class GenericWriteAheadSink<IN>
extends org.apache.flink.streaming.api.operators.AbstractStreamOperator<IN>
implements org.apache.flink.streaming.api.operators.OneInputStreamOperator<IN,IN>
Generic Sink that emits its input elements into an arbitrary backend. This sink is integrated
with Flink's checkpointing mechanism and can provide exactly-once guarantees; depending on the
storage backend and sink/committer implementation.
Incoming records are stored within a AbstractStateBackend, and only committed if a checkpoint is
completed.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.slf4j.Loggerprotected final org.apache.flink.api.common.typeutils.TypeSerializer<IN>Fields inherited from class org.apache.flink.streaming.api.operators.AbstractStreamOperator
combinedWatermark, config, lastRecordAttributes1, lastRecordAttributes2, latencyStats, metrics, output, processingTimeService, stateHandler, stateKeySelector1, stateKeySelector2, timeServiceManager -
Constructor Summary
ConstructorsConstructorDescriptionGenericWriteAheadSink(CheckpointCommitter committer, org.apache.flink.api.common.typeutils.TypeSerializer<IN> serializer, String jobID) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidinitializeState(org.apache.flink.runtime.state.StateInitializationContext context) voidnotifyCheckpointComplete(long checkpointId) voidopen()voidprocessElement(org.apache.flink.streaming.runtime.streamrecord.StreamRecord<IN> element) protected abstract booleansendValues(Iterable<IN> values, long checkpointId, long timestamp) Write the given element into the backend.voidsnapshotState(org.apache.flink.runtime.state.StateSnapshotContext context) Methods inherited from class org.apache.flink.streaming.api.operators.AbstractStreamOperator
beforeInitializeStateHandler, finish, getContainingTask, getCurrentKey, getExecutionConfig, getInternalTimerService, getKeyedStateBackend, getKeyedStateStore, getMetricGroup, getOperatorConfig, getOperatorID, getOperatorName, getOperatorStateBackend, getOrCreateKeyedState, getPartitionedState, getPartitionedState, getProcessingTimeService, getRuntimeContext, getStateKeySelector1, getStateKeySelector2, getTimeServiceManager, getUserCodeClassloader, hasKeyContext1, hasKeyContext2, initializeState, isAsyncStateProcessingEnabled, isUsingCustomRawKeyedState, notifyCheckpointAborted, prepareSnapshotPreBarrier, processLatencyMarker, processLatencyMarker1, processLatencyMarker2, processRecordAttributes, processRecordAttributes1, processRecordAttributes2, processWatermark, processWatermark, processWatermark1, processWatermark1, processWatermark2, processWatermark2, processWatermarkStatus, processWatermarkStatus, processWatermarkStatus1, processWatermarkStatus2, reportOrForwardLatencyMarker, setCurrentKey, setKeyContextElement1, setKeyContextElement2, setMailboxExecutor, setProcessingTimeService, setup, snapshotState, useSplittableTimersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.flink.api.common.state.CheckpointListener
notifyCheckpointAbortedMethods inherited from interface org.apache.flink.streaming.api.operators.Input
processLatencyMarker, processRecordAttributes, processWatermark, processWatermark, processWatermarkStatusMethods inherited from interface org.apache.flink.streaming.api.operators.KeyContext
getCurrentKey, setCurrentKeyMethods inherited from interface org.apache.flink.streaming.api.operators.KeyContextHandler
hasKeyContextMethods inherited from interface org.apache.flink.streaming.api.operators.OneInputStreamOperator
setKeyContextElementMethods inherited from interface org.apache.flink.streaming.api.operators.StreamOperator
finish, getMetricGroup, getOperatorAttributes, getOperatorID, initializeState, prepareSnapshotPreBarrier, setKeyContextElement1, setKeyContextElement2, snapshotState
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG -
serializer
-
-
Constructor Details
-
GenericWriteAheadSink
public GenericWriteAheadSink(CheckpointCommitter committer, org.apache.flink.api.common.typeutils.TypeSerializer<IN> serializer, String jobID) throws Exception - Throws:
Exception
-
-
Method Details
-
initializeState
public void initializeState(org.apache.flink.runtime.state.StateInitializationContext context) throws Exception -
open
-
close
-
snapshotState
public void snapshotState(org.apache.flink.runtime.state.StateSnapshotContext context) throws Exception -
notifyCheckpointComplete
-
sendValues
protected abstract boolean sendValues(Iterable<IN> values, long checkpointId, long timestamp) throws Exception Write the given element into the backend.- Parameters:
values- The values to be writtencheckpointId- The checkpoint ID of the checkpoint to be writtentimestamp- The wall-clock timestamp of the checkpoint- Returns:
- true, if the sending was successful, false otherwise
- Throws:
Exception
-
processElement
-