R - The type of request (e.g. ReadRequest or WriteRequest issued by this
access to the I/O threads.public abstract class AsynchronousFileIOChannel<T,R extends org.apache.flink.runtime.io.disk.iomanager.IORequest> extends AbstractFileIOChannel
The asynchrony of the access makes it possible to implement read-ahead or write-behind types of I/O accesses.
FileIOChannel.Enumerator, FileIOChannel.ID| 限定符和类型 | 字段和说明 |
|---|---|
protected boolean |
closed
Flag marking this channel as closed
|
protected Object |
closeLock
The lock that is used during closing to synchronize the thread that waits for all requests to
be handled with the asynchronous I/O thread.
|
protected IOException |
exception
An exception that was encountered by the asynchronous request handling thread.
|
protected RequestQueue<R> |
requestQueue
A request queue for submitting asynchronous requests to the corresponding IO worker thread.
|
protected AtomicInteger |
requestsNotReturned
An atomic integer that counts the number of requests that we still wait for to return.
|
protected RequestDoneCallback<T> |
resultHandler
Handler for completed requests
|
fileChannel, id, LOG| 限定符 | 构造器和说明 |
|---|---|
protected |
AsynchronousFileIOChannel(FileIOChannel.ID channelID,
RequestQueue<R> requestQueue,
RequestDoneCallback<T> callback,
boolean writeEnabled)
Creates a new channel access to the path indicated by the given ID.
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
addRequest(R request) |
void |
checkErroneous()
Checks the exception state of this channel.
|
void |
close()
Closes the channel and waits until all pending asynchronous requests are processed.
|
void |
closeAndDelete()
This method waits for all pending asynchronous requests to return.
|
protected void |
handleProcessedBuffer(T buffer,
IOException ex)
Handles a processed Buffer.
|
boolean |
isClosed()
Checks whether the channel has been closed.
|
protected boolean |
registerAllRequestsProcessedListener(NotificationListener listener)
Registers a listener to be notified when all outstanding requests have been processed.
|
deleteChannel, getChannelID, getNioFileChannel, getSizeprotected final Object closeLock
protected final RequestQueue<R extends org.apache.flink.runtime.io.disk.iomanager.IORequest> requestQueue
protected final AtomicInteger requestsNotReturned
protected final RequestDoneCallback<T> resultHandler
protected volatile IOException exception
protected volatile boolean closed
protected AsynchronousFileIOChannel(FileIOChannel.ID channelID, RequestQueue<R> requestQueue, RequestDoneCallback<T> callback, boolean writeEnabled) throws IOException
channelID - The id describing the path of the file that the channel accessed.requestQueue - The queue that this channel hands its IO requests to.callback - The callback to be invoked when a request is done.writeEnabled - Flag describing whether the channel should be opened in read/write mode,
rather than in read-only mode.IOException - Thrown, if the channel could no be opened.public boolean isClosed()
FileIOChannelisClosed 在接口中 FileIOChannelisClosed 在类中 AbstractFileIOChannelpublic void close()
throws IOException
FileChannel is closed even if an exception interrupts the closing.
Important: the isClosed() method returns true
immediately after this method has been called even when there are outstanding requests.
close 在接口中 FileIOChannelclose 在类中 AbstractFileIOChannelIOException - Thrown, if an I/O exception occurred while waiting for the buffers, or if
the closing was interrupted.public void closeAndDelete()
throws IOException
Even if an exception interrupts the closing, such that not all request are handled, the underlying FileChannel is closed and deleted.
closeAndDelete 在接口中 FileIOChannelcloseAndDelete 在类中 AbstractFileIOChannelIOException - Thrown, if an I/O exception occurred while waiting for the buffers, or if
the closing was interrupted.public final void checkErroneous()
throws IOException
IOException - Thrown, if the channel is erroneous. The thrown exception contains the
original exception that defined the erroneous state as its cause.protected final void handleProcessedBuffer(T buffer, IOException ex)
buffer - The buffer to be processed.ex - The exception that occurred in the I/O threads when processing the buffer's
request.protected final void addRequest(R request) throws IOException
IOExceptionprotected boolean registerAllRequestsProcessedListener(NotificationListener listener) throws IOException
New requests can arrive right after the listener got notified. Therefore, it is not safe to assume that the number of outstanding requests is still zero after a notification unless there was a close right before the listener got called.
Returns true, if the registration was successful. A registration can fail, if
there are no outstanding requests when trying to register a listener.
IOExceptionCopyright © 2014–2022 The Apache Software Foundation. All rights reserved.