Class RecordWriter<T extends org.apache.flink.core.io.IOReadableWritable>
- java.lang.Object
-
- org.apache.flink.runtime.io.network.api.writer.RecordWriter<T>
-
- Type Parameters:
T- the type of the record that can be emitted with this record writer
- All Implemented Interfaces:
AvailabilityProvider
- Direct Known Subclasses:
BroadcastRecordWriter,ChannelSelectorRecordWriter
public abstract class RecordWriter<T extends org.apache.flink.core.io.IOReadableWritable> extends Object implements AvailabilityProvider
An abstract record-oriented runtime result writer.The RecordWriter wraps the runtime's
ResultPartitionWriterand takes care of channel selection and serializing records into bytes.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AvailabilityProvider.AvailabilityHelper
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_OUTPUT_FLUSH_THREAD_NAMEDefault name for the output flush thread, if no name with a task reference is given.protected booleanflushAlwaysprotected intnumberOfChannelsprotected Randomrngprotected org.apache.flink.core.memory.DataOutputSerializerserializerprotected ResultPartitionWritertargetPartition-
Fields inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AVAILABLE
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidabortCheckpoint(long checkpointId, CheckpointException cause)voidalignedBarrierTimeout(long checkpointId)abstract voidbroadcastEmit(T record)This is used to broadcast streaming Watermarks in-band with records.voidbroadcastEvent(AbstractEvent event)voidbroadcastEvent(AbstractEvent event, boolean isPriorityEvent)protected voidcheckErroneous()voidclose()Closes the writer.abstract voidemit(T record)This is used to send regular records.protected voidemit(T record, int targetSubpartition)voidflushAll()CompletableFuture<?>getAvailableFuture()voidrandomEmit(T record)This is used to send LatencyMarks to a random target channel.static ByteBufferserializeRecord(org.apache.flink.core.memory.DataOutputSerializer serializer, org.apache.flink.core.io.IOReadableWritable record)voidsetMaxOverdraftBuffersPerGate(int maxOverdraftBuffersPerGate)Sets the max overdraft buffer size of per gate.voidsetMetricGroup(TaskIOMetricGroup metrics)Sets the metric group for this RecordWriter.-
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.runtime.io.AvailabilityProvider
isApproximatelyAvailable, isAvailable
-
-
-
-
Field Detail
-
DEFAULT_OUTPUT_FLUSH_THREAD_NAME
@VisibleForTesting public static final String DEFAULT_OUTPUT_FLUSH_THREAD_NAME
Default name for the output flush thread, if no name with a task reference is given.- See Also:
- Constant Field Values
-
targetPartition
protected final ResultPartitionWriter targetPartition
-
numberOfChannels
protected final int numberOfChannels
-
serializer
protected final org.apache.flink.core.memory.DataOutputSerializer serializer
-
rng
protected final Random rng
-
flushAlways
protected final boolean flushAlways
-
-
Method Detail
-
emit
protected void emit(T record, int targetSubpartition) throws IOException
- Throws:
IOException
-
broadcastEvent
public void broadcastEvent(AbstractEvent event) throws IOException
- Throws:
IOException
-
broadcastEvent
public void broadcastEvent(AbstractEvent event, boolean isPriorityEvent) throws IOException
- Throws:
IOException
-
alignedBarrierTimeout
public void alignedBarrierTimeout(long checkpointId) throws IOException- Throws:
IOException
-
abortCheckpoint
public void abortCheckpoint(long checkpointId, CheckpointException cause)
-
serializeRecord
@VisibleForTesting public static ByteBuffer serializeRecord(org.apache.flink.core.memory.DataOutputSerializer serializer, org.apache.flink.core.io.IOReadableWritable record) throws IOException
- Throws:
IOException
-
flushAll
public void flushAll()
-
setMetricGroup
public void setMetricGroup(TaskIOMetricGroup metrics)
Sets the metric group for this RecordWriter.
-
getAvailableFuture
public CompletableFuture<?> getAvailableFuture()
- Specified by:
getAvailableFuturein interfaceAvailabilityProvider- Returns:
- a future that is completed if the respective provider is available.
-
emit
public abstract void emit(T record) throws IOException
This is used to send regular records.- Throws:
IOException
-
randomEmit
public void randomEmit(T record) throws IOException
This is used to send LatencyMarks to a random target channel.- Throws:
IOException
-
broadcastEmit
public abstract void broadcastEmit(T record) throws IOException
This is used to broadcast streaming Watermarks in-band with records.- Throws:
IOException
-
close
public void close()
Closes the writer. This stops the flushing thread (if there is one).
-
checkErroneous
protected void checkErroneous() throws IOException- Throws:
IOException
-
setMaxOverdraftBuffersPerGate
public void setMaxOverdraftBuffersPerGate(int maxOverdraftBuffersPerGate)
Sets the max overdraft buffer size of per gate.
-
-