/** * Issues a read request, which will asynchronously fill the given segment with the next block in the * underlying file channel. Once the read request is fulfilled, the segment will be added to this reader's * return queue. * * @param segment The segment to read the block into. * @throws IOException Thrown, when the reader encounters an I/O error. Due to the asynchronous nature of the * reader, the exception thrown here may have been caused by an earlier read request. */ @Override public void readBlock(MemorySegment segment) throws IOException { addRequest(new SegmentReadRequest(this, segment)); }
/** * Gets the next memory segment that has been filled with data by the reader. This method blocks until * such a segment is available, or until an error occurs in the reader, or the reader is closed. * <p> * WARNING: If this method is invoked without any segment ever returning (for example, because the * {@link #readBlock(MemorySegment)} method has not been invoked appropriately), the method may block * forever. * * @return The next memory segment from the reader's return queue. * @throws IOException Thrown, if an I/O error occurs in the reader while waiting for the request to return. */ @Override public MemorySegment getNextReturnedBlock() throws IOException { try { while (true) { final MemorySegment next = this.returnSegments.poll(1000, TimeUnit.MILLISECONDS); if (next != null) { return next; } else { if (this.closed) { throw new IOException("The reader has been asynchronously closed."); } checkErroneous(); } } } catch (InterruptedException iex) { throw new IOException("Reader was interrupted while waiting for the next returning segment."); } }
/** * Creates a block channel reader that reads blocks from the given channel. The reader reads asynchronously, * such that a read request is accepted, carried out at some (close) point in time, and the full segment * is pushed to the given queue. * * @param channelID The descriptor for the channel to write to. * @param returnQueue The queue to put the full buffers into. * @return A block channel reader that reads from the given channel. * @throws IOException Thrown, if the channel for the reader could not be opened. */ @Override public BlockChannelReader<MemorySegment> createBlockChannelReader(FileIOChannel.ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) throws IOException { checkState(!isShutdown.get(), "I/O-Manger is shut down."); return new AsynchronousBlockReader(channelID, this.readers[channelID.getThreadNum()].requestQueue, returnQueue); }
/** * Creates a block channel reader that reads blocks from the given channel. The reader reads asynchronously, * such that a read request is accepted, carried out at some (close) point in time, and the full segment * is pushed to the given queue. * * @param channelID The descriptor for the channel to write to. * @param returnQueue The queue to put the full buffers into. * @return A block channel reader that reads from the given channel. * @throws IOException Thrown, if the channel for the reader could not be opened. */ @Override public BlockChannelReader<MemorySegment> createBlockChannelReader(FileIOChannel.ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) throws IOException { checkState(!isShutdown.get(), "I/O-Manger is shut down."); return new AsynchronousBlockReader(channelID, this.readers[channelID.getThreadNum()].requestQueue, returnQueue); }
/** * Issues a read request, which will asynchronously fill the given segment with the next block in the * underlying file channel. Once the read request is fulfilled, the segment will be added to this reader's * return queue. * * @param segment The segment to read the block into. * @throws IOException Thrown, when the reader encounters an I/O error. Due to the asynchronous nature of the * reader, the exception thrown here may have been caused by an earlier read request. */ @Override public void readBlock(MemorySegment segment) throws IOException { addRequest(new SegmentReadRequest(this, segment)); }
/** * Creates a block channel reader that reads blocks from the given channel. The reader reads asynchronously, * such that a read request is accepted, carried out at some (close) point in time, and the full segment * is pushed to the given queue. * * @param channelID The descriptor for the channel to write to. * @param returnQueue The queue to put the full buffers into. * @return A block channel reader that reads from the given channel. * @throws IOException Thrown, if the channel for the reader could not be opened. */ @Override public BlockChannelReader<MemorySegment> createBlockChannelReader(FileIOChannel.ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) throws IOException { checkState(!isShutdown.get(), "I/O-Manger is shut down."); return new AsynchronousBlockReader(channelID, this.readers[channelID.getThreadNum()].requestQueue, returnQueue, bufferedReadSize); }
/** * Gets the next memory segment that has been filled with data by the reader. This method blocks until * such a segment is available, or until an error occurs in the reader, or the reader is closed. * <p> * WARNING: If this method is invoked without any segment ever returning (for example, because the * {@link #readBlock(MemorySegment)} method has not been invoked appropriately), the method may block * forever. * * @return The next memory segment from the reader's return queue. * @throws IOException Thrown, if an I/O error occurs in the reader while waiting for the request to return. */ @Override public MemorySegment getNextReturnedBlock() throws IOException { try { while (true) { final MemorySegment next = this.returnSegments.poll(1000, TimeUnit.MILLISECONDS); if (next != null) { return next; } else { if (this.closed) { throw new IOException("The reader has been asynchronously closed."); } checkErroneous(); } } } catch (InterruptedException iex) { throw new IOException("Reader was interrupted while waiting for the next returning segment."); } }
/** * Issues a read request, which will asynchronously fill the given segment with the next block in the * underlying file channel. Once the read request is fulfilled, the segment will be added to this reader's * return queue. * * @param segment The segment to read the block into. * @throws IOException Thrown, when the reader encounters an I/O error. Due to the asynchronous nature of the * reader, the exception thrown here may have been caused by an earlier read request. */ @Override public void readBlock(MemorySegment segment) throws IOException { addRequest(new SegmentReadRequest(this, segment)); }
/** * Creates a block channel reader that reads blocks from the given channel. The reader reads asynchronously, * such that a read request is accepted, carried out at some (close) point in time, and the full segment * is pushed to the given queue. * * @param channelID The descriptor for the channel to write to. * @param returnQueue The queue to put the full buffers into. * @return A block channel reader that reads from the given channel. * @throws IOException Thrown, if the channel for the reader could not be opened. */ @Override public BlockChannelReader<MemorySegment> createBlockChannelReader(FileIOChannel.ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) throws IOException { checkState(!isShutdown.get(), "I/O-Manger is shut down."); return new AsynchronousBlockReader(channelID, this.readers[channelID.getThreadNum()].requestQueue, returnQueue); }
/** * Gets the next memory segment that has been filled with data by the reader. This method blocks until * such a segment is available, or until an error occurs in the reader, or the reader is closed. * <p> * WARNING: If this method is invoked without any segment ever returning (for example, because the * {@link #readBlock(MemorySegment)} method has not been invoked appropriately), the method may block * forever. * * @return The next memory segment from the reader's return queue. * @throws IOException Thrown, if an I/O error occurs in the reader while waiting for the request to return. */ @Override public MemorySegment getNextReturnedBlock() throws IOException { try { while (true) { final MemorySegment next = this.returnSegments.poll(1000, TimeUnit.MILLISECONDS); if (next != null) { return next; } else { if (this.closed) { throw new IOException("The reader has been asynchronously closed."); } checkErroneous(); } } } catch (InterruptedException iex) { throw new IOException("Reader was interrupted while waiting for the next returning segment."); } }
/** * Issues a read request, which will asynchronously fill the given segment with the next block in the * underlying file channel. Once the read request is fulfilled, the segment will be added to this reader's * return queue. * * @param segment The segment to read the block into. * @throws IOException Thrown, when the reader encounters an I/O error. Due to the asynchronous nature of the * reader, the exception thrown here may have been caused by an earlier read request. */ @Override public void readBlock(MemorySegment segment) throws IOException { addRequest(new SegmentReadRequest(this, segment, bufferSize)); }
/** * Gets the next memory segment that has been filled with data by the reader. This method blocks until * such a segment is available, or until an error occurs in the reader, or the reader is closed. * <p> * WARNING: If this method is invoked without any segment ever returning (for example, because the * {@link #readBlock(MemorySegment)} method has not been invoked appropriately), the method may block * forever. * * @return The next memory segment from the reader's return queue. * @throws IOException Thrown, if an I/O error occurs in the reader while waiting for the request to return. */ @Override public MemorySegment getNextReturnedBlock() throws IOException { try { while (true) { final MemorySegment next = this.returnSegments.poll(1000, TimeUnit.MILLISECONDS); if (next != null) { return next; } else { if (this.closed) { throw new IOException("The reader has been asynchronously closed."); } checkErroneous(); } } } catch (InterruptedException iex) { throw new IOException("Reader was interrupted while waiting for the next returning segment."); } }