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 FileChannelfileChannelA file channel for NIO access to the file.protected FileIOChannel.IDidThe ID of the underlying channel.protected static org.slf4j.LoggerLOGLogger object for channel and its subclasses
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractFileIOChannel(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 voidclose()Closes the channel.voidcloseAndDelete()Closes the channel and deletes the underlying file.voiddeleteChannel()Deletes the file underlying this I/O channel.FileIOChannel.IDgetChannelID()Gets the channel ID of this I/O channel.FileChannelgetNioFileChannel()longgetSize()Gets the size (in bytes) of the file underlying the channel.abstract booleanisClosed()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:FileIOChannelGets the channel ID of this I/O channel.- Specified by:
getChannelIDin interfaceFileIOChannel- Returns:
- The channel ID.
-
getSize
public long getSize() throws IOExceptionDescription copied from interface:FileIOChannelGets the size (in bytes) of the file underlying the channel.- Specified by:
getSizein interfaceFileIOChannel- Throws:
IOException
-
isClosed
public abstract boolean isClosed()
Description copied from interface:FileIOChannelChecks whether the channel has been closed.- Specified by:
isClosedin interfaceFileIOChannel- Returns:
- True if the channel has been closed, false otherwise.
-
close
public abstract void close() throws IOExceptionDescription copied from interface:FileIOChannelCloses 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:
closein interfaceFileIOChannel- Throws:
IOException- Thrown, if an error occurred while waiting for pending requests.
-
deleteChannel
public void deleteChannel()
Description copied from interface:FileIOChannelDeletes the file underlying this I/O channel.- Specified by:
deleteChannelin interfaceFileIOChannel
-
closeAndDelete
public void closeAndDelete() throws IOExceptionDescription copied from interface:FileIOChannelCloses the channel and deletes the underlying file. For asynchronous implementations, this method waits until all pending requests are handled.- Specified by:
closeAndDeletein interfaceFileIOChannel- Throws:
IOException- Thrown, if an error occurred while waiting for pending requests.
-
getNioFileChannel
public FileChannel getNioFileChannel()
- Specified by:
getNioFileChannelin interfaceFileIOChannel
-
-