Class AbstractFileIOChannel

java.lang.Object
org.apache.flink.runtime.io.disk.iomanager.AbstractFileIOChannel
All Implemented Interfaces:
FileIOChannel
Direct Known Subclasses:
AsynchronousFileIOChannel, SynchronousFileIOChannel

public abstract class AbstractFileIOChannel extends Object implements FileIOChannel
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
      Logger object for channel and its subclasses
    • id

      protected final FileIOChannel.ID id
      The ID of the underlying channel.
    • fileChannel

      protected final FileChannel fileChannel
      A file channel for NIO access to the file.
  • Constructor Details

    • AbstractFileIOChannel

      protected AbstractFileIOChannel(FileIOChannel.ID channelID, boolean writeEnabled) throws IOException
      Creates a new channel to the path indicated by the given ID. The channel hands IO requests to the given request queue to be processed.
      Parameters:
      channelID - The id describing the path of the file that the channel accessed.
      writeEnabled - Flag describing whether the channel should be opened in read/write mode, rather than in read-only mode.
      Throws:
      IOException - Thrown, if the channel could no be opened.
  • Method Details

    • getChannelID

      public final FileIOChannel.ID getChannelID()
      Description copied from interface: FileIOChannel
      Gets the channel ID of this I/O channel.
      Specified by:
      getChannelID in interface FileIOChannel
      Returns:
      The channel ID.
    • getSize

      public long getSize() throws IOException
      Description copied from interface: FileIOChannel
      Gets the size (in bytes) of the file underlying the channel.
      Specified by:
      getSize in interface FileIOChannel
      Throws:
      IOException
    • isClosed

      public abstract boolean isClosed()
      Description copied from interface: FileIOChannel
      Checks whether the channel has been closed.
      Specified by:
      isClosed in interface FileIOChannel
      Returns:
      True if the channel has been closed, false otherwise.
    • close

      public abstract void close() throws IOException
      Description copied from interface: FileIOChannel
      Closes the channel. For asynchronous implementations, this method waits until all pending requests are handled. Even if an exception interrupts the closing, the underlying FileChannel is closed.
      Specified by:
      close in interface FileIOChannel
      Throws:
      IOException - Thrown, if an error occurred while waiting for pending requests.
    • deleteChannel

      public void deleteChannel()
      Description copied from interface: FileIOChannel
      Deletes the file underlying this I/O channel.
      Specified by:
      deleteChannel in interface FileIOChannel
    • closeAndDelete

      public void closeAndDelete() throws IOException
      Description copied from interface: FileIOChannel
      Closes the channel and deletes the underlying file. For asynchronous implementations, this method waits until all pending requests are handled.
      Specified by:
      closeAndDelete in interface FileIOChannel
      Throws:
      IOException - Thrown, if an error occurred while waiting for pending requests.
    • getNioFileChannel

      public FileChannel getNioFileChannel()
      Specified by:
      getNioFileChannel in interface FileIOChannel