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,Input<IN>,KeyContext,KeyContextHandler,OneInputStreamOperator<IN,IN>,SetupableStreamOperator<IN>,StreamOperator<IN>,StreamOperatorStateHandler.CheckpointedStreamOperator
public abstract class GenericWriteAheadSink<IN> extends AbstractStreamOperator<IN> implements 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.LoggerLOGprotected org.apache.flink.api.common.typeutils.TypeSerializer<IN>serializer-
Fields inherited from class org.apache.flink.streaming.api.operators.AbstractStreamOperator
chainingStrategy, config, latencyStats, metrics, output, processingTimeService
-
-
Constructor Summary
Constructors Constructor Description GenericWriteAheadSink(CheckpointCommitter committer, org.apache.flink.api.common.typeutils.TypeSerializer<IN> serializer, String jobID)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()This method is called at the very end of the operator's life, both in the case of a successful completion of the operation, and in the case of a failure and canceling.voidinitializeState(org.apache.flink.runtime.state.StateInitializationContext context)Stream operators with state which can be restored need to override this hook method.voidnotifyCheckpointComplete(long checkpointId)voidopen()This method is called immediately before any elements are processed, it should contain the operator's initialization logic, e.g. state initialization.voidprocessElement(StreamRecord<IN> element)Processes one element that arrived on this input of theMultipleInputStreamOperator.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)Stream operators with state, which want to participate in a snapshot need to override this hook method.-
Methods inherited from class org.apache.flink.streaming.api.operators.AbstractStreamOperator
finish, getChainingStrategy, getContainingTask, getCurrentKey, getExecutionConfig, getInternalTimerService, getKeyedStateBackend, getKeyedStateStore, getMetricGroup, getOperatorConfig, getOperatorID, getOperatorName, getOperatorStateBackend, getOrCreateKeyedState, getPartitionedState, getPartitionedState, getProcessingTimeService, getRuntimeContext, getTimeServiceManager, getUserCodeClassloader, hasKeyContext1, hasKeyContext2, initializeState, isUsingCustomRawKeyedState, notifyCheckpointAborted, prepareSnapshotPreBarrier, processLatencyMarker, processLatencyMarker1, processLatencyMarker2, processWatermark, processWatermark1, processWatermark2, processWatermarkStatus, processWatermarkStatus1, processWatermarkStatus2, reportOrForwardLatencyMarker, setChainingStrategy, setCurrentKey, setKeyContextElement1, setKeyContextElement2, setProcessingTimeService, setup, snapshotState
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.api.common.state.CheckpointListener
notifyCheckpointAborted
-
Methods inherited from interface org.apache.flink.streaming.api.operators.Input
processLatencyMarker, processWatermark, processWatermarkStatus
-
Methods inherited from interface org.apache.flink.streaming.api.operators.KeyContext
getCurrentKey, setCurrentKey
-
Methods inherited from interface org.apache.flink.streaming.api.operators.KeyContextHandler
hasKeyContext
-
Methods inherited from interface org.apache.flink.streaming.api.operators.OneInputStreamOperator
setKeyContextElement
-
Methods inherited from interface org.apache.flink.streaming.api.operators.StreamOperator
finish, getMetricGroup, getOperatorID, initializeState, prepareSnapshotPreBarrier, setKeyContextElement1, setKeyContextElement2, snapshotState
-
-
-
-
Field Detail
-
LOG
protected static final org.slf4j.Logger LOG
-
serializer
protected final org.apache.flink.api.common.typeutils.TypeSerializer<IN> serializer
-
-
Constructor Detail
-
GenericWriteAheadSink
public GenericWriteAheadSink(CheckpointCommitter committer, org.apache.flink.api.common.typeutils.TypeSerializer<IN> serializer, String jobID) throws Exception
- Throws:
Exception
-
-
Method Detail
-
initializeState
public void initializeState(org.apache.flink.runtime.state.StateInitializationContext context) throws ExceptionDescription copied from class:AbstractStreamOperatorStream operators with state which can be restored need to override this hook method.- Specified by:
initializeStatein interfaceStreamOperatorStateHandler.CheckpointedStreamOperator- Overrides:
initializeStatein classAbstractStreamOperator<IN>- Parameters:
context- context that allows to register different states.- Throws:
Exception
-
open
public void open() throws ExceptionDescription copied from class:AbstractStreamOperatorThis method is called immediately before any elements are processed, it should contain the operator's initialization logic, e.g. state initialization.The default implementation does nothing.
- Specified by:
openin interfaceStreamOperator<IN>- Overrides:
openin classAbstractStreamOperator<IN>- Throws:
Exception- An exception in this method causes the operator to fail.
-
close
public void close() throws ExceptionDescription copied from interface:StreamOperatorThis method is called at the very end of the operator's life, both in the case of a successful completion of the operation, and in the case of a failure and canceling.This method is expected to make a thorough effort to release all resources that the operator has acquired.
NOTE:It can not emit any records! If you need to emit records at the end of processing, do so in the
StreamOperator.finish()method.- Specified by:
closein interfaceStreamOperator<IN>- Overrides:
closein classAbstractStreamOperator<IN>- Throws:
Exception
-
snapshotState
public void snapshotState(org.apache.flink.runtime.state.StateSnapshotContext context) throws ExceptionDescription copied from class:AbstractStreamOperatorStream operators with state, which want to participate in a snapshot need to override this hook method.- Specified by:
snapshotStatein interfaceStreamOperatorStateHandler.CheckpointedStreamOperator- Overrides:
snapshotStatein classAbstractStreamOperator<IN>- Parameters:
context- context that provides information and means required for taking a snapshot- Throws:
Exception
-
notifyCheckpointComplete
public void notifyCheckpointComplete(long checkpointId) throws Exception- Specified by:
notifyCheckpointCompletein interfaceorg.apache.flink.api.common.state.CheckpointListener- Overrides:
notifyCheckpointCompletein classAbstractStreamOperator<IN>- Throws:
Exception
-
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
public void processElement(StreamRecord<IN> element) throws Exception
Description copied from interface:InputProcesses one element that arrived on this input of theMultipleInputStreamOperator. This method is guaranteed to not be called concurrently with other methods of the operator.- Specified by:
processElementin interfaceInput<IN>- Throws:
Exception
-
-