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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.runtime.io.disk.iomanager.FileIOChannel
FileIOChannel.Enumerator, FileIOChannel.ID
-
-
Field Summary
Fields Modifier and Type Field Description protected FileChannel
fileChannel
A file channel for NIO access to the file.protected FileIOChannel.ID
id
The ID of the underlying channel.protected static org.slf4j.Logger
LOG
Logger object for channel and its subclasses
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractFileIOChannel(FileIOChannel.ID channelID, boolean writeEnabled)
Creates a new channel to the path indicated by the given ID.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
close()
Closes the channel.void
closeAndDelete()
Closes the channel and deletes the underlying file.void
deleteChannel()
Deletes the file underlying this I/O channel.FileIOChannel.ID
getChannelID()
Gets the channel ID of this I/O channel.FileChannel
getNioFileChannel()
long
getSize()
Gets the size (in bytes) of the file underlying the channel.abstract boolean
isClosed()
Checks whether the channel has been closed.
-
-
-
Field Detail
-
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 Detail
-
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 Detail
-
getChannelID
public final FileIOChannel.ID getChannelID()
Description copied from interface:FileIOChannel
Gets the channel ID of this I/O channel.- Specified by:
getChannelID
in interfaceFileIOChannel
- 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 interfaceFileIOChannel
- Throws:
IOException
-
isClosed
public abstract boolean isClosed()
Description copied from interface:FileIOChannel
Checks whether the channel has been closed.- Specified by:
isClosed
in interfaceFileIOChannel
- 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 interfaceFileIOChannel
- 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 interfaceFileIOChannel
-
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 interfaceFileIOChannel
- Throws:
IOException
- Thrown, if an error occurred while waiting for pending requests.
-
getNioFileChannel
public FileChannel getNioFileChannel()
- Specified by:
getNioFileChannel
in interfaceFileIOChannel
-
-