Class AsynchronousBlockWriter

java.lang.Object
org.apache.flink.runtime.io.disk.iomanager.AbstractFileIOChannel
org.apache.flink.runtime.io.disk.iomanager.AsynchronousFileIOChannel<org.apache.flink.core.memory.MemorySegment,org.apache.flink.runtime.io.disk.iomanager.WriteRequest>
org.apache.flink.runtime.io.disk.iomanager.AsynchronousBlockWriterWithCallback
org.apache.flink.runtime.io.disk.iomanager.AsynchronousBlockWriter
All Implemented Interfaces:
BlockChannelWriter<org.apache.flink.core.memory.MemorySegment>, BlockChannelWriterWithCallback<org.apache.flink.core.memory.MemorySegment>, FileIOChannel

public class AsynchronousBlockWriter extends AsynchronousBlockWriterWithCallback implements BlockChannelWriter<org.apache.flink.core.memory.MemorySegment>
  • Constructor Details

    • AsynchronousBlockWriter

      protected AsynchronousBlockWriter(FileIOChannel.ID channelID, RequestQueue<org.apache.flink.runtime.io.disk.iomanager.WriteRequest> requestQueue, LinkedBlockingQueue<org.apache.flink.core.memory.MemorySegment> returnSegments) throws IOException
      Creates a new block channel writer for the given channel.
      Parameters:
      channelID - The ID of the channel to write to.
      requestQueue - The request queue of the asynchronous writer thread, to which the I/O requests are added.
      returnSegments - The return queue, to which the processed Memory Segments are added.
      Throws:
      IOException - Thrown, if the underlying file channel could not be opened exclusively.
  • Method Details

    • getNextReturnedBlock

      public org.apache.flink.core.memory.MemorySegment getNextReturnedBlock() throws IOException
      Gets the next memory segment that has been written and is available again. This method blocks until such a segment is available, or until an error occurs in the writer, or the writer is closed.

      NOTE: If this method is invoked without any segment ever returning (for example, because the AsynchronousBlockWriterWithCallback.writeBlock(MemorySegment) method has not been invoked accordingly), the method may block forever.

      Specified by:
      getNextReturnedBlock in interface BlockChannelWriter<org.apache.flink.core.memory.MemorySegment>
      Returns:
      The next memory segment from the writers's return queue.
      Throws:
      IOException - Thrown, if an I/O error occurs in the writer while waiting for the request to return.
    • getReturnQueue

      public LinkedBlockingQueue<org.apache.flink.core.memory.MemorySegment> getReturnQueue()
      Gets the queue in which the memory segments are queued after the asynchronous write is completed.
      Specified by:
      getReturnQueue in interface BlockChannelWriter<org.apache.flink.core.memory.MemorySegment>
      Returns:
      The queue with the written memory segments.