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 ResultPartitionWriter and takes care of
subpartition 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
FieldsModifier and TypeFieldDescriptionstatic final StringDefault name for the output flush thread, if no name with a task reference is given.protected final booleanprotected final intprotected final Randomprotected final org.apache.flink.core.memory.DataOutputSerializerprotected final ResultPartitionWriterFields inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AVAILABLE -
Method Summary
Modifier and TypeMethodDescriptionvoidabortCheckpoint(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 voidvoidclose()Closes the writer.protected voidemit(ByteBuffer record, int targetSubpartition) abstract voidThis is used to send regular records.voidvoidflushAll()intbooleanWhether the subpartition where an element comes from can be derived from the existing information.voidrandomEmit(T record) This is used to send LatencyMarks to a random target subpartition.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, waitMethods inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
isApproximatelyAvailable, isAvailable
-
Field Details
-
DEFAULT_OUTPUT_FLUSH_THREAD_NAME
Default name for the output flush thread, if no name with a task reference is given.- See Also:
-
targetPartition
-
numberOfSubpartitions
protected final int numberOfSubpartitions -
serializer
protected final org.apache.flink.core.memory.DataOutputSerializer serializer -
rng
-
flushAlways
protected final boolean flushAlways
-
-
Method Details
-
emit
- Throws:
IOException
-
emit
- Throws:
IOException
-
broadcastEvent
- Throws:
IOException
-
broadcastEvent
- Throws:
IOException
-
alignedBarrierTimeout
- Throws:
IOException
-
abortCheckpoint
-
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
Sets the metric group for this RecordWriter. -
getNumberOfSubpartitions
public int getNumberOfSubpartitions() -
isSubpartitionDerivable
public boolean isSubpartitionDerivable()Whether the subpartition where an element comes from can be derived from the existing information. If false, the caller of this writer should attach the subpartition information onto an element before writing it to a subpartition, if the element needs this information afterward. -
getAvailableFuture
- Specified by:
getAvailableFuturein interfaceAvailabilityProvider- Returns:
- a future that is completed if the respective provider is available.
-
emit
This is used to send regular records.- Throws:
IOException
-
randomEmit
This is used to send LatencyMarks to a random target subpartition.- Throws:
IOException
-
broadcastEmit
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
- Throws:
IOException
-
setMaxOverdraftBuffersPerGate
public void setMaxOverdraftBuffersPerGate(int maxOverdraftBuffersPerGate) Sets the max overdraft buffer size of per gate.
-