R - The type of request (e.g. ReadRequest or WriteRequest issued by this access to
the I/O threads.C - The type of collection used to collect the segments from completed requests. Those segments are for
example for write requests the written and reusable segments, and for read requests the now full
and usable segments. The collection type may for example be a synchronized queue or an unsynchronized
list.public abstract class BlockChannelAccess<R extends org.apache.flink.runtime.io.disk.iomanager.IORequest,C extends Collection<MemorySegment>> extends ChannelAccess<MemorySegment,R>
The asynchrony of the access makes it possible to implement read-ahead or write-behind types of I/O accesses.
| Modifier and Type | Field and Description |
|---|---|
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 AtomicInteger |
requestsNotReturned
An atomic integer that counts the number of buffers we still wait for to return.
|
protected C |
returnBuffers
The collection gathering the processed buffers that are ready to be (re)used.
|
exception, fileChannel, id, requestQueue| Modifier | Constructor and Description |
|---|---|
protected |
BlockChannelAccess(Channel.ID channelID,
RequestQueue<R> requestQueue,
C returnQueue,
boolean writeEnabled)
Creates a new channel access to the path indicated by the given ID.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the reader and waits until all pending asynchronous requests are
handled.
|
void |
closeAndDelete()
This method waits for all pending asynchronous requests to return.
|
C |
getReturnQueue()
Gets the queue (or list) to which the asynchronous reader adds its elements.
|
boolean |
isClosed()
Checks, whether this channel has been closed;
|
protected void |
returnBuffer(MemorySegment buffer)
This method is invoked by the asynchronous I/O thread to return a buffer after the I/O request
completed.
|
checkErroneous, deleteChannel, getChannelIDprotected final Object closeLock
protected final AtomicInteger requestsNotReturned
protected final C extends Collection<MemorySegment> returnBuffers
protected volatile boolean closed
protected BlockChannelAccess(Channel.ID channelID, RequestQueue<R> requestQueue, C returnQueue, 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.returnQueue - The queue to which the segments are added after their buffer was written.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 C getReturnQueue()
public boolean isClosed()
ChannelAccessisClosed in class ChannelAccess<MemorySegment,R extends org.apache.flink.runtime.io.disk.iomanager.IORequest>public void close()
throws IOException
IOException - Thrown, if an I/O exception occurred while waiting for the buffers, or if
the closing was interrupted.public void closeAndDelete()
throws IOException
IOException - Thrown, if an I/O exception occurred while waiting for the buffers, or if
the closing was interrupted.protected void returnBuffer(MemorySegment buffer)
ChannelAccessreturnBuffer in class ChannelAccess<MemorySegment,R extends org.apache.flink.runtime.io.disk.iomanager.IORequest>buffer - The buffer to be returned.Copyright © 2014 The Apache Software Foundation. All rights reserved.