Class ChannelStateWriterImpl
java.lang.Object
org.apache.flink.runtime.checkpoint.channel.ChannelStateWriterImpl
- All Implemented Interfaces:
Closeable,AutoCloseable,ChannelStateWriter
@Internal
@ThreadSafe
public class ChannelStateWriterImpl
extends Object
implements ChannelStateWriter
ChannelStateWriter implemented using CheckpointStateOutputStreams. Internally, it has by default
- one stream per checkpoint; having multiple streams would mean more files written and more connections opened (and more latency on restore)
- one thread; having multiple threads means more connections, couples with the implementation and increases complexity
Thread-safety: this class is thread-safe when used with a thread-safe executor (e.g. default ChannelStateWriteRequestExecutorImpl.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter
ChannelStateWriter.ChannelStateWriteResult, ChannelStateWriter.NoOpChannelStateWriter -
Field Summary
Fields inherited from interface org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter
NO_OP, SEQUENCE_NUMBER_RESTORED, SEQUENCE_NUMBER_UNKNOWN -
Constructor Summary
ConstructorsConstructorDescriptionChannelStateWriterImpl(JobVertexID jobVertexID, String taskName, int subtaskIndex, org.apache.flink.util.function.SupplierWithException<CheckpointStorageWorkerView, ? extends IOException> checkpointStorageWorkerViewSupplier, ChannelStateWriteRequestExecutorFactory channelStateExecutorFactory, int maxSubtasksPerChannelStateFile) -
Method Summary
Modifier and TypeMethodDescriptionvoidAborts the checkpoint and fails pending result for this checkpoint.voidaddInputData(long checkpointId, InputChannelInfo info, int startSeqNum, org.apache.flink.util.CloseableIterator<Buffer> iterator) Add in-flight buffers from theInputChannel.voidaddOutputData(long checkpointId, ResultSubpartitionInfo info, int startSeqNum, Buffer... data) Add in-flight buffers from theResultSubpartition.voidaddOutputDataFuture(long checkpointId, ResultSubpartitionInfo info, int startSeqNum, CompletableFuture<List<Buffer>> dataFuture) Add in-flight bufferFuture from theResultSubpartition.voidclose()voidfinishInput(long checkpointId) Finalize write of channel state data for the given checkpoint id.voidfinishOutput(long checkpointId) Finalize write of channel state data for the given checkpoint id.getAndRemoveWriteResult(long checkpointId) Must be called afterChannelStateWriter.start(long, CheckpointOptions)once.getWriteResult(long checkpointId) voidstart(long checkpointId, CheckpointOptions checkpointOptions) Initiate write of channel state for the given checkpoint id.
-
Constructor Details
-
ChannelStateWriterImpl
public ChannelStateWriterImpl(JobVertexID jobVertexID, String taskName, int subtaskIndex, org.apache.flink.util.function.SupplierWithException<CheckpointStorageWorkerView, ? extends IOException> checkpointStorageWorkerViewSupplier, ChannelStateWriteRequestExecutorFactory channelStateExecutorFactory, int maxSubtasksPerChannelStateFile)
-
-
Method Details
-
start
Description copied from interface:ChannelStateWriterInitiate write of channel state for the given checkpoint id.- Specified by:
startin interfaceChannelStateWriter
-
addInputData
public void addInputData(long checkpointId, InputChannelInfo info, int startSeqNum, org.apache.flink.util.CloseableIterator<Buffer> iterator) Description copied from interface:ChannelStateWriterAdd in-flight buffers from theInputChannel. Must be called afterChannelStateWriter.start(long,CheckpointOptions)and beforeChannelStateWriter.finishInput(long). Buffers are recycled after they are written or exception occurs.- Specified by:
addInputDatain interfaceChannelStateWriterstartSeqNum- sequence number of the 1st passed buffer. It is intended to use for incremental snapshots. If no data is passed it is ignored.iterator- zero or more data buffers ordered by their sequence numbers- See Also:
-
addOutputData
public void addOutputData(long checkpointId, ResultSubpartitionInfo info, int startSeqNum, Buffer... data) Description copied from interface:ChannelStateWriterAdd in-flight buffers from theResultSubpartition. Must be called afterChannelStateWriter.start(long, org.apache.flink.runtime.checkpoint.CheckpointOptions)and beforeChannelStateWriter.finishOutput(long). Buffers are recycled after they are written or exception occurs.- Specified by:
addOutputDatain interfaceChannelStateWriterstartSeqNum- sequence number of the 1st passed buffer. It is intended to use for incremental snapshots. If no data is passed it is ignored.data- zero or more data buffers ordered by their sequence numbers- See Also:
-
addOutputDataFuture
public void addOutputDataFuture(long checkpointId, ResultSubpartitionInfo info, int startSeqNum, CompletableFuture<List<Buffer>> dataFuture) throws IllegalArgumentException Description copied from interface:ChannelStateWriterAdd in-flight bufferFuture from theResultSubpartition. Must be called afterChannelStateWriter.start(long, org.apache.flink.runtime.checkpoint.CheckpointOptions)and beforeChannelStateWriter.finishOutput(long). Buffers are recycled after they are written or exception occurs.The method will be called when the unaligned checkpoint is enabled and received an aligned barrier.
- Specified by:
addOutputDataFuturein interfaceChannelStateWriter- Throws:
IllegalArgumentException
-
finishInput
public void finishInput(long checkpointId) Description copied from interface:ChannelStateWriterFinalize write of channel state data for the given checkpoint id. Must be called afterChannelStateWriter.start(long, CheckpointOptions)and all of the input data of the given checkpoint added. When bothChannelStateWriter.finishInput(long)andChannelStateWriter.finishOutput(long)were called the results can be (eventually) obtained usingChannelStateWriter.getAndRemoveWriteResult(long)- Specified by:
finishInputin interfaceChannelStateWriter
-
finishOutput
public void finishOutput(long checkpointId) Description copied from interface:ChannelStateWriterFinalize write of channel state data for the given checkpoint id. Must be called afterChannelStateWriter.start(long, CheckpointOptions)and all of the output data of the given checkpoint added. When bothChannelStateWriter.finishInput(long)andChannelStateWriter.finishOutput(long)were called the results can be (eventually) obtained usingChannelStateWriter.getAndRemoveWriteResult(long)- Specified by:
finishOutputin interfaceChannelStateWriter
-
abort
Description copied from interface:ChannelStateWriterAborts the checkpoint and fails pending result for this checkpoint.- Specified by:
abortin interfaceChannelStateWritercleanup- true ifChannelStateWriter.getAndRemoveWriteResult(long)is not supposed to be called afterwards.
-
getAndRemoveWriteResult
Description copied from interface:ChannelStateWriterMust be called afterChannelStateWriter.start(long, CheckpointOptions)once.- Specified by:
getAndRemoveWriteResultin interfaceChannelStateWriter
-
getWriteResult
@VisibleForTesting public ChannelStateWriter.ChannelStateWriteResult getWriteResult(long checkpointId) -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-